Hide unknown notifications (#1151)
* hide unknown notifications * hide unknown notifications
This commit is contained in:
parent
c3df44eaef
commit
2e52457b32
2 changed files with 32 additions and 17 deletions
|
@ -45,6 +45,7 @@ import com.keylesspalace.tusky.util.LinkHelper;
|
|||
import com.keylesspalace.tusky.util.SmartLengthInputFilter;
|
||||
import com.keylesspalace.tusky.viewdata.NotificationViewData;
|
||||
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
||||
import com.mikepenz.iconics.utils.Utils;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -71,6 +72,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
private static final int VIEW_TYPE_STATUS_NOTIFICATION = 1;
|
||||
private static final int VIEW_TYPE_FOLLOW = 2;
|
||||
private static final int VIEW_TYPE_PLACEHOLDER = 3;
|
||||
private static final int VIEW_TYPE_UNKNOWN = 4;
|
||||
|
||||
private static final InputFilter[] COLLAPSE_INPUT_FILTER = new InputFilter[]{SmartLengthInputFilter.INSTANCE};
|
||||
private static final InputFilter[] NO_INPUT_FILTER = new InputFilter[0];
|
||||
|
@ -98,7 +100,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
switch (viewType) {
|
||||
default:
|
||||
case VIEW_TYPE_MENTION: {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_status, parent, false);
|
||||
|
@ -119,6 +120,17 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
.inflate(R.layout.item_status_placeholder, parent, false);
|
||||
return new PlaceholderViewHolder(view);
|
||||
}
|
||||
default:
|
||||
case VIEW_TYPE_UNKNOWN: {
|
||||
View view = new View(parent.getContext());
|
||||
view.setLayoutParams(
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
Utils.convertDpToPx(parent.getContext(), 24)
|
||||
)
|
||||
);
|
||||
return new RecyclerView.ViewHolder(view) {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +160,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
(NotificationViewData.Concrete) notification;
|
||||
Notification.Type type = concreteNotificaton.getType();
|
||||
switch (type) {
|
||||
default:
|
||||
case MENTION: {
|
||||
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
||||
StatusViewData.Concrete status = concreteNotificaton.getStatusViewData();
|
||||
|
@ -178,8 +189,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
holder.setupButtons(notificationActionListener,
|
||||
concreteNotificaton.getAccount().getId(),
|
||||
concreteNotificaton.getId());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (payloadForHolder instanceof List)
|
||||
for (Object item : payloads) {
|
||||
if (StatusBaseViewHolder.Key.KEY_CREATED.equals(item)) {
|
||||
|
@ -197,10 +207,12 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataSource.getItemCount();
|
||||
|
@ -212,7 +224,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
if (notification instanceof NotificationViewData.Concrete) {
|
||||
NotificationViewData.Concrete concrete = ((NotificationViewData.Concrete) notification);
|
||||
switch (concrete.getType()) {
|
||||
default:
|
||||
case MENTION: {
|
||||
return VIEW_TYPE_MENTION;
|
||||
}
|
||||
|
@ -223,6 +234,9 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
|||
case FOLLOW: {
|
||||
return VIEW_TYPE_FOLLOW;
|
||||
}
|
||||
default: {
|
||||
return VIEW_TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
} else if (notification instanceof NotificationViewData.Placeholder) {
|
||||
return VIEW_TYPE_PLACEHOLDER;
|
||||
|
|
|
@ -476,7 +476,6 @@ public class NotificationHelper {
|
|||
}
|
||||
|
||||
switch (notification.getType()) {
|
||||
default:
|
||||
case MENTION:
|
||||
return account.getNotificationsMentioned();
|
||||
case FOLLOW:
|
||||
|
@ -485,6 +484,8 @@ public class NotificationHelper {
|
|||
return account.getNotificationsReblogged();
|
||||
case FAVOURITE:
|
||||
return account.getNotificationsFavorited();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue