fix notification tab loading (#777)
* fix progressbars of footer and fragment overlapping * add progressbar to bottom of notification list again * fix bottom loading getting stuck sometimes
This commit is contained in:
parent
4d16514851
commit
4653b1e37b
4 changed files with 49 additions and 70 deletions
|
|
@ -64,7 +64,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
private List<NotificationViewData> notifications;
|
||||
private StatusActionListener statusListener;
|
||||
private NotificationActionListener notificationActionListener;
|
||||
private FooterViewHolder.State footerState;
|
||||
private boolean mediaPreviewEnabled;
|
||||
private BidiFormatter bidiFormatter;
|
||||
|
||||
|
|
@ -74,7 +73,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
notifications = new ArrayList<>();
|
||||
this.statusListener = statusListener;
|
||||
this.notificationActionListener = notificationActionListener;
|
||||
footerState = FooterViewHolder.State.END;
|
||||
mediaPreviewEnabled = true;
|
||||
bidiFormatter = BidiFormatter.getInstance();
|
||||
}
|
||||
|
|
@ -119,7 +117,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
if (notification instanceof NotificationViewData.Placeholder) {
|
||||
NotificationViewData.Placeholder placeholder = ((NotificationViewData.Placeholder) notification);
|
||||
PlaceholderViewHolder holder = (PlaceholderViewHolder) viewHolder;
|
||||
holder.setup(!placeholder.isLoading(), statusListener);
|
||||
holder.setup(statusListener, placeholder.isLoading());
|
||||
return;
|
||||
}
|
||||
NotificationViewData.Concrete concreteNotificaton =
|
||||
|
|
@ -164,15 +162,12 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FooterViewHolder holder = (FooterViewHolder) viewHolder;
|
||||
holder.setState(footerState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return notifications.size() + 1;
|
||||
return notifications.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -224,19 +219,16 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
notifyItemRangeInserted(notifications.size(), newNotifications.size());
|
||||
}
|
||||
|
||||
public void removeItemAndNotify(int position) {
|
||||
notifications.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
notifications.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setFooterState(FooterViewHolder.State newFooterState) {
|
||||
FooterViewHolder.State oldValue = footerState;
|
||||
footerState = newFooterState;
|
||||
if (footerState != oldValue) {
|
||||
notifyItemChanged(notifications.size());
|
||||
}
|
||||
}
|
||||
|
||||
public void setMediaPreviewEnabled(boolean enabled) {
|
||||
mediaPreviewEnabled = enabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,21 +34,16 @@ public final class PlaceholderViewHolder extends RecyclerView.ViewHolder {
|
|||
progressBar = itemView.findViewById(R.id.progress_bar);
|
||||
}
|
||||
|
||||
public void setup(boolean enabled, final StatusActionListener listener) {
|
||||
this.setup(enabled, listener, false);
|
||||
}
|
||||
|
||||
public void setup(boolean enabled, final StatusActionListener listener, boolean progress) {
|
||||
public void setup(final StatusActionListener listener, boolean progress) {
|
||||
loadMoreButton.setVisibility(progress ? View.GONE : View.VISIBLE);
|
||||
progressBar.setVisibility(progress ? View.VISIBLE : View.GONE);
|
||||
|
||||
loadMoreButton.setEnabled(enabled);
|
||||
if (enabled) {
|
||||
loadMoreButton.setOnClickListener(v -> {
|
||||
loadMoreButton.setEnabled(false);
|
||||
listener.onLoadMore(getAdapterPosition());
|
||||
});
|
||||
}
|
||||
loadMoreButton.setEnabled(true);
|
||||
loadMoreButton.setOnClickListener(v -> {
|
||||
loadMoreButton.setEnabled(false);
|
||||
listener.onLoadMore(getAdapterPosition());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -71,8 +71,7 @@ public final class TimelineAdapter extends RecyclerView.Adapter {
|
|||
StatusViewData status = dataSource.getItemAt(position);
|
||||
if (status instanceof StatusViewData.Placeholder) {
|
||||
PlaceholderViewHolder holder = (PlaceholderViewHolder) viewHolder;
|
||||
holder.setup(!((StatusViewData.Placeholder) status).isLoading(),
|
||||
statusListener, ((StatusViewData.Placeholder) status).isLoading());
|
||||
holder.setup(statusListener, ((StatusViewData.Placeholder) status).isLoading());
|
||||
} else {
|
||||
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
||||
holder.setupWithStatus((StatusViewData.Concrete) status,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue