Skip to content

Commit

Permalink
Minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Exenifix committed Mar 25, 2022
1 parent af6339e commit b4c2e24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/src/main/java/com/exenifix/weatherapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (!serverURL.endsWith("/")) {
serverURL += "/";
}
currentServerText.setText("Current server: " + serverURL);
currentServerText.setText(getString(R.string.current_server, serverURL));

findViewById(R.id.inputButton).setOnClickListener(this::onSearchButtonClick);
findViewById(R.id.update_server_button).setOnClickListener(this::onSetServerButtonClick);
Expand All @@ -78,7 +78,13 @@ private void onSetServerButtonClick(View v) {
Toast.makeText(this, "Server field must not be empty!", Toast.LENGTH_SHORT).show();
return;
}
if (newUrl.endsWith("/")) {
newUrl += "/";
}
serverURL = newUrl;
currentServerText.setText(getString(R.string.current_server, newUrl));
sharedPrefsEditor.putString("baseURL", newUrl);
sharedPrefsEditor.commit();
Toast.makeText(this, "Updated the server successfully!", Toast.LENGTH_SHORT).show();
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<string name="button_text">Искать</string>
<string name="default_server">http://147.182.254.173:5001/</string>
<string name="update_button_text">Установить сервер</string>
<string name="current_server">Current server: %s</string>
</resources>

0 comments on commit b4c2e24

Please # to comment.