Refresh the notifications list when it's opened
This commit is contained in:
@@ -51,6 +51,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
private View endMark;
|
private View endMark;
|
||||||
private String unreadMarker, realUnreadMarker;
|
private String unreadMarker, realUnreadMarker;
|
||||||
private MenuItem markAllReadItem;
|
private MenuItem markAllReadItem;
|
||||||
|
private boolean reloadingFromCache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -110,10 +111,11 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
|
if(!refreshing && !reloadingFromCache)
|
||||||
endMark.setVisibility(View.GONE);
|
endMark.setVisibility(View.GONE);
|
||||||
AccountSessionManager.getInstance()
|
AccountSessionManager.getInstance()
|
||||||
.getAccount(accountID).getCacheController()
|
.getAccount(accountID).getCacheController()
|
||||||
.getNotifications(offset>0 ? maxID : null, count, onlyMentions, refreshing, new SimpleCallback<>(this){
|
.getNotifications(offset>0 ? maxID : null, count, onlyMentions, refreshing && !reloadingFromCache, new SimpleCallback<>(this){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(PaginatedResponse<List<Notification>> result){
|
public void onSuccess(PaginatedResponse<List<Notification>> result){
|
||||||
if(getActivity()==null)
|
if(getActivity()==null)
|
||||||
@@ -121,6 +123,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
onDataLoaded(result.items.stream().filter(n->n.type!=null).collect(Collectors.toList()), !result.items.isEmpty());
|
onDataLoaded(result.items.stream().filter(n->n.type!=null).collect(Collectors.toList()), !result.items.isEmpty());
|
||||||
maxID=result.maxID;
|
maxID=result.maxID;
|
||||||
endMark.setVisibility(result.items.isEmpty() ? View.VISIBLE : View.GONE);
|
endMark.setVisibility(result.items.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
|
reloadingFromCache=false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -129,6 +132,14 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
protected void onShown(){
|
protected void onShown(){
|
||||||
super.onShown();
|
super.onShown();
|
||||||
unreadMarker=realUnreadMarker=AccountSessionManager.get(accountID).getLastKnownNotificationsMarker();
|
unreadMarker=realUnreadMarker=AccountSessionManager.get(accountID).getLastKnownNotificationsMarker();
|
||||||
|
if(!dataLoading){
|
||||||
|
if(onlyMentions){
|
||||||
|
refresh();
|
||||||
|
}else{
|
||||||
|
reloadingFromCache=true;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user