Non-Informative Message & Expressive Message (NIM-EM)

ECn Categories > Non-Informative Message & Expressive Message (NIM-EM)

The app shows at the same time multiple messages when performing an action, some of them are inexpressive messages while the rest are expressive messages.

Amount of Issues App List
2 (A44) Materialistic

Examples

Materialistic

Category:
News & Magazines
v 3.1
Scenario: Like a news without internet

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 issue is generated, we need to review all the event flow. First, as it can be seen in the following snippet there two important actions that are being executed. Specifically, at lines 143-146 there is a validation of connection and due to connectionless state of the test a Snackbar is generated with the text of the “R.string.offline_notice”. Before that, at line 139 the “load” method is called.

app/src/main/java/io/github/hidroh/materialistic/UserActivity.java

     if (mUser == null) {
139.     load();
     } else {
         bind();
     }
     if (!AppUtils.hasConnection(this)) {
144.     Snackbar.make(findViewById(R.id.content_frame),
145.         R.string.offline_notice, Snackbar.LENGTH_LONG)
             .show();
     }

Now, when reviewing the code in “load” method it can be found that between lines 207-209 the information of the user that published the news is being retrieved using a “UserResponseListener” element.

app/src/main/java/io/github/hidroh/materialistic/UserActivity.java

     private void load() {
208.     mUserManager.getUser(mUsername, new UserResponseListener(this));
     }

Finally, when the event flow gets in “UserResponseListener” the retrieve is performed and due to connectionless state an error is thrown. Therefore, between lines 264-268 the error is managed and at line 266 a message is displayed to the user saying that the app was unable to load de user data. However, this message is shown to the user at the same time with the message of the first snippet. Because of this, the user sees both a generic message and a expressive message about the action just performed.

app/src/main/java/io/github/hidroh/materialistic/UserActivity.java

    static class UserResponseListener implements ResponseListener<UserManager.User> {
        private final WeakReference<UserActivity> mUserActivity;

        @Synthetic
        UserResponseListener(UserActivity userActivity) {
            mUserActivity = new WeakReference<>(userActivity);
        }

        @Override
        public void onResponse(@Nullable UserManager.User response) {
            if (mUserActivity.get() != null && !mUserActivity.get().isActivityDestroyed()) {
                mUserActivity.get().onUserLoaded(response);
            }
        }

        @Override
264.    public void onError(String errorMessage) {
            if (mUserActivity.get() != null && !mUserActivity.get().isActivityDestroyed()) {
266.            Toast.makeText(mUserActivity.get(), R.string.user_failed, Toast.LENGTH_SHORT).show();
            }
        }
    }