Open status from notifications
This commit is contained in:
parent
305d28a5c1
commit
92fb55cb3a
2 changed files with 54 additions and 16 deletions
|
@ -123,9 +123,11 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder;
|
StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder;
|
||||||
holder.setMessage(type, concreteNotificaton.getAccount().getDisplayName(),
|
holder.setMessage(type, concreteNotificaton.getAccount().getDisplayName(),
|
||||||
concreteNotificaton.getStatusViewData());
|
concreteNotificaton.getStatusViewData());
|
||||||
holder.setupButtons(notificationActionListener, concreteNotificaton.getAccount().id);
|
holder.setupButtons(notificationActionListener,
|
||||||
|
concreteNotificaton.getAccount().id,
|
||||||
|
concreteNotificaton.getId());
|
||||||
holder.setAvatars(concreteNotificaton.getStatusViewData().getAvatar(),
|
holder.setAvatars(concreteNotificaton.getStatusViewData().getAvatar(),
|
||||||
concreteNotificaton.getAccount().avatar);
|
concreteNotificaton.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FOLLOW: {
|
case FOLLOW: {
|
||||||
|
@ -211,6 +213,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
|
|
||||||
public interface NotificationActionListener {
|
public interface NotificationActionListener {
|
||||||
void onViewAccount(String id);
|
void onViewAccount(String id);
|
||||||
|
|
||||||
|
void onViewStatusForNotificationId(String notificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FollowViewHolder extends RecyclerView.ViewHolder {
|
private static class FollowViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@ -258,13 +262,19 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StatusNotificationViewHolder extends RecyclerView.ViewHolder {
|
private static class StatusNotificationViewHolder extends RecyclerView.ViewHolder
|
||||||
private TextView message;
|
implements View.OnClickListener {
|
||||||
private ImageView icon;
|
private final TextView message;
|
||||||
private TextView statusContent;
|
private final ImageView icon;
|
||||||
private ViewGroup container;
|
private final TextView statusContent;
|
||||||
private ImageView statusAvatar;
|
private final ViewGroup container;
|
||||||
private ImageView notificationAvatar;
|
private final ImageView statusAvatar;
|
||||||
|
private final ImageView notificationAvatar;
|
||||||
|
private final ViewGroup topBar;
|
||||||
|
|
||||||
|
private String accountId;
|
||||||
|
private String notificationId;
|
||||||
|
private NotificationActionListener listener;
|
||||||
|
|
||||||
StatusNotificationViewHolder(View itemView) {
|
StatusNotificationViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -274,9 +284,14 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
container = itemView.findViewById(R.id.notification_container);
|
container = itemView.findViewById(R.id.notification_container);
|
||||||
statusAvatar = itemView.findViewById(R.id.notification_status_avatar);
|
statusAvatar = itemView.findViewById(R.id.notification_status_avatar);
|
||||||
notificationAvatar = itemView.findViewById(R.id.notification_notification_avatar);
|
notificationAvatar = itemView.findViewById(R.id.notification_notification_avatar);
|
||||||
|
topBar = itemView.findViewById(R.id.notification_top_bar);
|
||||||
|
|
||||||
int darkerFilter = Color.rgb(123, 123, 123);
|
int darkerFilter = Color.rgb(123, 123, 123);
|
||||||
statusAvatar.setColorFilter(darkerFilter, PorterDuff.Mode.MULTIPLY);
|
statusAvatar.setColorFilter(darkerFilter, PorterDuff.Mode.MULTIPLY);
|
||||||
notificationAvatar.setColorFilter(darkerFilter, PorterDuff.Mode.MULTIPLY);
|
notificationAvatar.setColorFilter(darkerFilter, PorterDuff.Mode.MULTIPLY);
|
||||||
|
|
||||||
|
container.setOnClickListener(this);
|
||||||
|
topBar.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMessage(Notification.Type type, String displayName,
|
void setMessage(Notification.Type type, String displayName,
|
||||||
|
@ -308,13 +323,11 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
statusContent.setText(status.getContent());
|
statusContent.setText(status.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupButtons(final NotificationActionListener listener, final String accountId) {
|
void setupButtons(final NotificationActionListener listener, final String accountId,
|
||||||
container.setOnClickListener(new View.OnClickListener() {
|
final String notificationId) {
|
||||||
@Override
|
this.listener = listener;
|
||||||
public void onClick(View v) {
|
this.accountId = accountId;
|
||||||
listener.onViewAccount(accountId);
|
this.notificationId = notificationId;
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAvatars(@Nullable String statusAvatarUrl, @Nullable String notificationAvatarUrl) {
|
void setAvatars(@Nullable String statusAvatarUrl, @Nullable String notificationAvatarUrl) {
|
||||||
|
@ -341,5 +354,18 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
.into(notificationAvatar);
|
.into(notificationAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (listener == null) return;
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.notification_container:
|
||||||
|
listener.onViewStatusForNotificationId(notificationId);
|
||||||
|
break;
|
||||||
|
case R.id.notification_top_bar:
|
||||||
|
listener.onViewAccount(accountId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,6 +394,18 @@ public class NotificationsFragment extends SFragment implements
|
||||||
super.viewAccount(id);
|
super.viewAccount(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewStatusForNotificationId(String notificationId) {
|
||||||
|
for (Either<Placeholder, Notification> either : notifications) {
|
||||||
|
Notification notification = either.getAsRightOrNull();
|
||||||
|
if (notification != null && notification.id.equals(notificationId)) {
|
||||||
|
super.viewThread(notification.status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.w(TAG, "Didn't find a notification for ID: " + notificationId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|
Loading…
Reference in a new issue