You can navigate to who favourited/reblogged you from clicking the notification now. Closes #11
This commit is contained in:
parent
4ff00ed62c
commit
9478cd4ea1
|
@ -43,13 +43,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
|||
|
||||
private List<Notification> notifications;
|
||||
private StatusActionListener statusListener;
|
||||
private FollowListener followListener;
|
||||
private NotificationActionListener notificationActionListener;
|
||||
|
||||
NotificationsAdapter(StatusActionListener statusListener, FollowListener followListener) {
|
||||
NotificationsAdapter(StatusActionListener statusListener,
|
||||
NotificationActionListener notificationActionListener) {
|
||||
super();
|
||||
notifications = new ArrayList<>();
|
||||
this.statusListener = statusListener;
|
||||
this.followListener = followListener;
|
||||
this.notificationActionListener = notificationActionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,13 +97,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
|||
StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder;
|
||||
holder.setMessage(type, notification.account.getDisplayName(),
|
||||
notification.status);
|
||||
holder.setupButtons(notificationActionListener, notification.account.id);
|
||||
break;
|
||||
}
|
||||
case FOLLOW: {
|
||||
FollowViewHolder holder = (FollowViewHolder) viewHolder;
|
||||
holder.setMessage(notification.account.getDisplayName(), notification.account.username,
|
||||
notification.account.avatar);
|
||||
holder.setupButtons(followListener, notification.account.id);
|
||||
holder.setupButtons(notificationActionListener, notification.account.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +177,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
|||
notifyItemChanged(position);
|
||||
}
|
||||
|
||||
interface FollowListener {
|
||||
interface NotificationActionListener {
|
||||
void onViewAccount(String id);
|
||||
}
|
||||
|
||||
|
@ -213,7 +215,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
|||
.into(avatar);
|
||||
}
|
||||
|
||||
void setupButtons(final FollowListener listener, final String accountId) {
|
||||
void setupButtons(final NotificationActionListener listener, final String accountId) {
|
||||
avatar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -227,12 +229,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
|||
private TextView message;
|
||||
private ImageView icon;
|
||||
private TextView statusContent;
|
||||
private ViewGroup container;
|
||||
|
||||
StatusNotificationViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
message = (TextView) itemView.findViewById(R.id.notification_text);
|
||||
icon = (ImageView) itemView.findViewById(R.id.notification_icon);
|
||||
statusContent = (TextView) itemView.findViewById(R.id.notification_content);
|
||||
container = (ViewGroup) itemView.findViewById(R.id.notification_container);
|
||||
}
|
||||
|
||||
void setMessage(Notification.Type type, String displayName, Status status) {
|
||||
|
@ -262,5 +266,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
|||
message.setText(str);
|
||||
statusContent.setText(status.content);
|
||||
}
|
||||
|
||||
void setupButtons(final NotificationActionListener listener, final String accountId) {
|
||||
container.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
listener.onViewAccount(accountId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import retrofit2.Response;
|
|||
|
||||
public class NotificationsFragment extends SFragment implements
|
||||
SwipeRefreshLayout.OnRefreshListener, StatusActionListener,
|
||||
NotificationsAdapter.FollowListener {
|
||||
NotificationsAdapter.NotificationActionListener {
|
||||
private static final String TAG = "Notifications"; // logging tag
|
||||
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
|
|
@ -85,13 +85,13 @@ public class ViewMediaFragment extends DialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
/* An upward swipe motion also closes the viewer. This is especially useful when the photo
|
||||
/* A vertical swipe motion also closes the viewer. This is especially useful when the photo
|
||||
* mostly fills the screen so clicking outside is difficult. */
|
||||
attacher.setOnSingleFlingListener(new PhotoViewAttacher.OnSingleFlingListener() {
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
||||
float velocityY) {
|
||||
if (velocityY < 0.0 && Math.abs(velocityY) > Math.abs(velocityX)) {
|
||||
if (Math.abs(velocityY) > Math.abs(velocityX)) {
|
||||
dismiss();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
<!--This applies only to favourite and reblog notifications.-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/notification_container"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:layout_height="wrap_content">
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue