Commit b7b8b12d authored by Varun Patil's avatar Varun Patil

Animate updates to notifications (and other) lists

parent 7a5c9e12
...@@ -38,6 +38,7 @@ public abstract class CardAdapter<T extends CardInterface> extends RecyclerView. ...@@ -38,6 +38,7 @@ public abstract class CardAdapter<T extends CardInterface> extends RecyclerView.
public CardAdapter(List<T> tList, Fragment fragment) { public CardAdapter(List<T> tList, Fragment fragment) {
this.tList = tList; this.tList = tList;
mFragment = fragment; mFragment = fragment;
this.setHasStableIds(true);
} }
@Override @Override
...@@ -114,6 +115,11 @@ public abstract class CardAdapter<T extends CardInterface> extends RecyclerView. ...@@ -114,6 +115,11 @@ public abstract class CardAdapter<T extends CardInterface> extends RecyclerView.
else return 2; else return 2;
} }
@Override
public long getItemId(int position) {
return tList.get(position).getId();
}
@Override @Override
public int getItemCount() { public int getItemCount() {
return tList.size(); return tList.size();
......
...@@ -184,6 +184,10 @@ public class Body implements CardInterface { ...@@ -184,6 +184,10 @@ public class Body implements CardInterface {
this.bodyRoles = bodyRoles; this.bodyRoles = bodyRoles;
} }
public long getId() {
return getBodyID().hashCode();
}
public String getTitle() { public String getTitle() {
return getBodyName(); return getBodyName();
} }
......
...@@ -243,6 +243,10 @@ public class Event implements CardInterface { ...@@ -243,6 +243,10 @@ public class Event implements CardInterface {
return Objects.hash(eventID); return Objects.hash(eventID);
} }
public long getId() {
return hashCode();
}
public String getTitle() { public String getTitle() {
return getEventName(); return getEventName();
} }
......
...@@ -79,6 +79,10 @@ public class Notification implements CardInterface { ...@@ -79,6 +79,10 @@ public class Notification implements CardInterface {
this.notificationActor = notificationActor; this.notificationActor = notificationActor;
} }
public long getId() {
return getNotificationId().hashCode();
}
public String getTitle() { public String getTitle() {
if (isEvent()) { if (isEvent()) {
return getEvent().getEventName(); return getEvent().getEventName();
......
...@@ -121,6 +121,10 @@ public class Role implements CardInterface { ...@@ -121,6 +121,10 @@ public class Role implements CardInterface {
this.roleUsersDetail = roleUsersDetail; this.roleUsersDetail = roleUsersDetail;
} }
public long getId() {
return getRoleID().hashCode();
}
public String getTitle() { public String getTitle() {
return getRoleBodyDetails().getBodyName(); return getRoleBodyDetails().getBodyName();
} }
......
...@@ -238,6 +238,10 @@ public class User implements CardInterface { ...@@ -238,6 +238,10 @@ public class User implements CardInterface {
return new Gson().toJson(this); return new Gson().toJson(this);
} }
public long getId() {
return getUserID().hashCode();
}
public String getTitle() { public String getTitle() {
return getUserName(); return getUserName();
} }
......
package app.insti.interfaces; package app.insti.interfaces;
public interface CardInterface { public interface CardInterface {
long getId();
String getTitle(); String getTitle();
String getSubtitle(); String getSubtitle();
String getAvatarUrl(); String getAvatarUrl();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment