mirror of
https://github.com/gitnex-org/gitnex.git
synced 2026-05-08 13:04:19 -05:00
Fix notifications pagination
This commit is contained in:
@@ -36,7 +36,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private List<NotificationThread> notificationThreads;
|
||||
private final OnMoreClickedListener onMoreClickedListener;
|
||||
private final OnNotificationClickedListener onNotificationClickedListener;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final TinyDB tinyDb;
|
||||
|
||||
@@ -62,9 +61,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading) {
|
||||
isLoading = true;
|
||||
loadMoreListener.run();
|
||||
}
|
||||
|
||||
if(getItemViewType(position) == TYPE_LOAD) {
|
||||
@@ -212,10 +210,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
public void updateList(List<NotificationThread> list) {
|
||||
notificationThreads = list;
|
||||
notifyDataChanged();
|
||||
|
||||
@@ -4,8 +4,6 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -91,15 +89,16 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||
viewBinding.notifications.setAdapter(notificationsAdapter);
|
||||
viewBinding.notifications.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
notificationsAdapter.setLoadMoreListener(() -> {
|
||||
pageCurrentIndex++;
|
||||
loadNotifications(true);
|
||||
});
|
||||
|
||||
viewBinding.notifications.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
|
||||
if(!recyclerView.canScrollVertically(1) && dy != 0) {
|
||||
pageCurrentIndex++;
|
||||
loadNotifications(true);
|
||||
}
|
||||
|
||||
if(currentFilterMode.equalsIgnoreCase("unread")) {
|
||||
if(dy > 0 && viewBinding.markAllAsRead.isShown()) {
|
||||
viewBinding.markAllAsRead.setVisibility(View.GONE);
|
||||
|
||||
Reference in New Issue
Block a user