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

View File

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

View File

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