fix notification sorting
This commit is contained in:
parent
e8a0bca5ea
commit
f83a043664
2 changed files with 4 additions and 3 deletions
|
@ -48,6 +48,7 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
||||||
public NotificationListAdapter(List<LbryNotification> notifications, Context context) {
|
public NotificationListAdapter(List<LbryNotification> notifications, Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.items = new ArrayList<>(notifications);
|
this.items = new ArrayList<>(notifications);
|
||||||
|
Collections.sort(items, Collections.reverseOrder(new LbryNotification()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
|
@ -29,11 +29,11 @@ public class LbryNotification implements Comparator<LbryNotification> {
|
||||||
public int compare(LbryNotification a, LbryNotification b) {
|
public int compare(LbryNotification a, LbryNotification b) {
|
||||||
long t1 = a.getTimestamp() != null ? a.getTimestamp().getTime() : 0;
|
long t1 = a.getTimestamp() != null ? a.getTimestamp().getTime() : 0;
|
||||||
long t2 = b.getTimestamp() != null ? b.getTimestamp().getTime() : 0;
|
long t2 = b.getTimestamp() != null ? b.getTimestamp().getTime() : 0;
|
||||||
if (t2 > t1) {
|
if (t1 < t2) {
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (t1 > t2) {
|
if (t1 > t2) {
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue