Fixes when loading next toots.

This commit is contained in:
tom79 2017-09-24 18:44:42 +02:00
parent 56190e49df
commit 9bc6e4795e
3 changed files with 19 additions and 12 deletions

View File

@ -196,8 +196,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
}
max_id = apiResponse.getMax_id();
List<Notification> notifications = apiResponse.getNotifications();
//The initial call comes from a classic tab refresh
flag_loading = (max_id == null );
if( !swiped && firstLoad && (notifications == null || notifications.size() == 0))
textviewNoAction.setVisibility(View.VISIBLE);
else
@ -215,16 +214,20 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
MainActivity.countNewNotifications++;
this.notifications.add(tmpNotification);
}
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + this.userId, notifications.get(0).getId());
editor.apply();
lastReadNotifications = notifications.get(0).getId();
if( firstLoad) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + this.userId, notifications.get(0).getId());
editor.apply();
lastReadNotifications = notifications.get(0).getId();
}
notificationsListAdapter.notifyDataSetChanged();
}
if( firstLoad )
((MainActivity)context).updateNotifCounter();
swipeRefreshLayout.setRefreshing(false);
firstLoad = false;
//The initial call comes from a classic tab refresh
flag_loading = (max_id == null );
}
@Override

View File

@ -77,6 +77,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
private String lastReadStatus;
private String userId;
public static ArrayList<Status> tempStatuses = new ArrayList<>();
private int lastTotalItemCount = 0;
public DisplayStatusFragment(){
}
@ -311,12 +312,16 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
}
this.statuses.add(tmpStatus);
}
lastReadStatus = statuses.get(0).getId();
SharedPreferences.Editor editor = sharedpreferences.edit();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, statuses.get(0).getId());
editor.apply();
if( firstLoad && type == RetrieveFeedsAsyncTask.Type.HOME) {
SharedPreferences.Editor editor = sharedpreferences.edit();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, statuses.get(0).getId());
editor.apply();
lastReadStatus = statuses.get(0).getId();
}
statusListAdapter.notifyDataSetChanged();
if( firstLoad && type == RetrieveFeedsAsyncTask.Type.HOME)
//Display new value in counter
try {
((MainActivity) context).updateHomeCounter();

View File

@ -29,7 +29,6 @@
android:layout_height="match_parent">
<ListView
android:id="@+id/lv_status"
android:transcriptMode="normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"