Commit 21941c07 authored by HashikD's avatar HashikD
Browse files

Handled failure case and changed messages

parent fed179a6
......@@ -204,6 +204,8 @@ public class MainActivity extends AppCompatActivity implements MainFragmentCallb
runOnUiThread(() -> {
settingsButton.setEnabled(true);
settingsButton.setClickable(true);
Fragment mainFragment = getSupportFragmentManager().findFragmentByTag(Integer.toString(FragmentConstants.MAIN_FRAGMENT));
((MainFragment) mainFragment).relayFailed(message);
});
}
......
......@@ -148,4 +148,12 @@ public class MainFragment extends Fragment {
colorAnimation.addUpdateListener(animator -> snowflakeLogo.setColorFilter((int) animator.getAnimatedValue(), PorterDuff.Mode.SRC_ATOP));
colorAnimation.start();
}
public void relayFailed(String message) {
startButton.setEnabled(true);
startButton.setClickable(true);
startButton.setChecked(false);
setSnowflakeStatus(false);
noteTV.setText(message);
}
}
\ No newline at end of file
......@@ -164,7 +164,7 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
try {
req = new Request.Builder().url(GlobalApplication.getWebSocketUrl()).build();
} catch (IllegalArgumentException e) {
presenter.relayFailure("Malformed URL");
presenter.relayFailure("Error: Malformed/Invalid Relay URL");
return;
}
......@@ -175,7 +175,7 @@ public class MainActivityModel implements MainActivityMVPContract.Model {
public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, @org.jetbrains.annotations.Nullable Response response) {
Log.d(TAG, "WebSocketListener: onFailure: ");
webSocket.close(1000, "Normal Closure"); //TODO: Change Failure code.
presenter.relayFailure("Web socket connection failed");
presenter.relayFailure("Error: WebSocket Connection Failed. Try again later.");
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment