Fix issue #712 - Empty notifications

maths
Thomas 2 years ago
parent 580024e1b9
commit 1edd554fde

@ -47,6 +47,7 @@ import app.fedilab.android.client.entities.api.Notification;
import app.fedilab.android.client.entities.app.Timeline; import app.fedilab.android.client.entities.app.Timeline;
import app.fedilab.android.databinding.DrawerFollowBinding; import app.fedilab.android.databinding.DrawerFollowBinding;
import app.fedilab.android.databinding.DrawerStatusFilteredBinding; import app.fedilab.android.databinding.DrawerStatusFilteredBinding;
import app.fedilab.android.databinding.DrawerStatusFilteredHideBinding;
import app.fedilab.android.databinding.DrawerStatusNotificationBinding; import app.fedilab.android.databinding.DrawerStatusNotificationBinding;
import app.fedilab.android.databinding.NotificationsRelatedAccountsBinding; import app.fedilab.android.databinding.NotificationsRelatedAccountsBinding;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
@ -70,6 +71,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private final int TYPE_FILERED = 10; private final int TYPE_FILERED = 10;
private final int TYPE_ADMIN_SIGNUP = 11; private final int TYPE_ADMIN_SIGNUP = 11;
private final int TYPE_ADMIN_REPORT = 12; private final int TYPE_ADMIN_REPORT = 12;
private final int TYPE_HIDDEN = 13;
public FetchMoreCallBack fetchMoreCallBack; public FetchMoreCallBack fetchMoreCallBack;
private Context context; private Context context;
private RecyclerView mRecyclerView; private RecyclerView mRecyclerView;
@ -144,17 +146,41 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
case "follow_request": case "follow_request":
return TYPE_FOLLOW_REQUEST; return TYPE_FOLLOW_REQUEST;
case "mention": case "mention":
if (notificationList.get(position).status != null) {
return TYPE_MENTION; return TYPE_MENTION;
} else {
return TYPE_HIDDEN;
}
case "reblog": case "reblog":
if (notificationList.get(position).status != null) {
return TYPE_REBLOG; return TYPE_REBLOG;
} else {
return TYPE_HIDDEN;
}
case "update": case "update":
if (notificationList.get(position).status != null) {
return TYPE_UPDATE; return TYPE_UPDATE;
} else {
return TYPE_HIDDEN;
}
case "favourite": case "favourite":
if (notificationList.get(position).status != null) {
return TYPE_FAVOURITE; return TYPE_FAVOURITE;
} else {
return TYPE_HIDDEN;
}
case "poll": case "poll":
if (notificationList.get(position).status != null) {
return TYPE_POLL; return TYPE_POLL;
} else {
return TYPE_HIDDEN;
}
case "status": case "status":
if (notificationList.get(position).status != null) {
return TYPE_STATUS; return TYPE_STATUS;
} else {
return TYPE_HIDDEN;
}
case "admin.sign_up": case "admin.sign_up":
return TYPE_ADMIN_SIGNUP; return TYPE_ADMIN_SIGNUP;
case "admin.report": case "admin.report":
@ -167,7 +193,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} }
@Override @Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) { public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView); super.onAttachedToRecyclerView(recyclerView);
mRecyclerView = recyclerView; mRecyclerView = recyclerView;
@ -183,6 +209,9 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} else if (viewType == TYPE_FILERED) { } else if (viewType == TYPE_FILERED) {
DrawerStatusFilteredBinding itemBinding = DrawerStatusFilteredBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); DrawerStatusFilteredBinding itemBinding = DrawerStatusFilteredBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusAdapter.StatusViewHolder(itemBinding); return new StatusAdapter.StatusViewHolder(itemBinding);
} else if (viewType == TYPE_HIDDEN) {
DrawerStatusFilteredHideBinding itemBinding = DrawerStatusFilteredHideBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusAdapter.StatusViewHolder(itemBinding);
} else { } else {
DrawerStatusNotificationBinding itemBinding = DrawerStatusNotificationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); DrawerStatusNotificationBinding itemBinding = DrawerStatusNotificationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StatusAdapter.StatusViewHolder(itemBinding); return new StatusAdapter.StatusViewHolder(itemBinding);
@ -284,6 +313,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
notification.filteredByApp = null; notification.filteredByApp = null;
notifyItemChanged(position); notifyItemChanged(position);
}); });
} else if (getItemViewType(position) == TYPE_HIDDEN) {
} else { } else {
StatusAdapter.StatusViewHolder holderStatus = (StatusAdapter.StatusViewHolder) viewHolder; StatusAdapter.StatusViewHolder holderStatus = (StatusAdapter.StatusViewHolder) viewHolder;
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);

Loading…
Cancel
Save