Lost Functionality after Connection Recovery (LFACR)

ECn Categories > Lost Content (LC) > Lost Functionality (LF) > Lost Functionality after Connection Recovery (LFACR)

One or more functionalities of a view in an application are not responding after connection recovery.

Amount of Issues App List
1 (A39) Habitica

Examples

Habitica

Category: Productivity
v 1.1.6
Scenario: To turn on the internet connection and to signing up again after signing up without internet connection
This video shows an example of a unavailable functionality after connection recovery. At 4th second after the user has restablished the connection tries to register to the app, a space is generated between the form and the buttons and disapear after 1 second. This behaviour repeat every time the user tries to register but never pass from the same view.

The following code snippets show the classes and files that are involved in the generation of the previuos issue.

In order to see how this error is generated, we need to review all the flow event. First, as it can be seen in the following snippet the click event of the “Register” button is managed in the “mLoginNormalClick”. To start the process the method make visible a progress bar at line 255 that is the space that appears between the form and the register button when it is clicked.

Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/LoginActivity.java

    private View.OnClickListener mLoginNormalClick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
255.        mProgressBar.setVisibility(View.VISIBLE);

Now, as it is known the current process is registering so the if clause at line 256 is true. However, as iit can be seen in the video, there is no error message displayed to the user, so all fields are correctly filled. Therefore the behaviour must be generated at lines 266 or 267. But in the line 266 the app makes arequest to create the user via “registerUser” method from apiClient that returns an Observable object from the ReactiveX library.

    if (isRegistering) {
        String username, email, password, cpassword;
        username = String.valueOf(mUsernameET.getText()).trim();
        email = String.valueOf(mEmail.getText()).trim();
        password = String.valueOf(mPasswordET.getText());
        cpassword = String.valueOf(mConfirmPassword.getText());
        if (username.length() == 0 || password.length() == 0 || email.length() == 0 || cpassword.length() == 0) {
            showValidationError(R.string.login_validation_error_fieldsmissing);
            return;
        }
266.    apiClient.registerUser(username, email, password, cpassword)

Finally, there is in the line 267 that the subscribe method is called in order to manage the different events generated by the observable. The subscribe method can be called in several ways, but for the current implementation and as it can be seen in the documentation it receive two parameters, the first one in case the observable emits an object, the second one manages if there is an error, it receives an exception or a throwable that indicates what happen and execute and action, in this specific case as we can see the action is to call the “hideProgress” method.

267. .subscribe(LoginActivity.this, throwable -> hideProgress());

So, when the “hideProgress” method is called at line 425 the progress bar that was visible is hidden.

```java private void hideProgress() { runOnUiThread(() -> { if (mProgressBar != null) {

  1. mProgressBar.setVisibility(View.GONE); } }); }