You can navigate to who favourited/reblogged you from clicking the notification now. Closes #11

This commit is contained in:
Vavassor 2017-03-20 16:34:23 -04:00
parent 4ff00ed62c
commit 9478cd4ea1
4 changed files with 26 additions and 12 deletions

View File

@ -43,13 +43,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
private List<Notification> notifications; private List<Notification> notifications;
private StatusActionListener statusListener; private StatusActionListener statusListener;
private FollowListener followListener; private NotificationActionListener notificationActionListener;
NotificationsAdapter(StatusActionListener statusListener, FollowListener followListener) { NotificationsAdapter(StatusActionListener statusListener,
NotificationActionListener notificationActionListener) {
super(); super();
notifications = new ArrayList<>(); notifications = new ArrayList<>();
this.statusListener = statusListener; this.statusListener = statusListener;
this.followListener = followListener; this.notificationActionListener = notificationActionListener;
} }
@Override @Override
@ -96,13 +97,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder; StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder;
holder.setMessage(type, notification.account.getDisplayName(), holder.setMessage(type, notification.account.getDisplayName(),
notification.status); notification.status);
holder.setupButtons(notificationActionListener, notification.account.id);
break; break;
} }
case FOLLOW: { case FOLLOW: {
FollowViewHolder holder = (FollowViewHolder) viewHolder; FollowViewHolder holder = (FollowViewHolder) viewHolder;
holder.setMessage(notification.account.getDisplayName(), notification.account.username, holder.setMessage(notification.account.getDisplayName(), notification.account.username,
notification.account.avatar); notification.account.avatar);
holder.setupButtons(followListener, notification.account.id); holder.setupButtons(notificationActionListener, notification.account.id);
break; break;
} }
} }
@ -175,7 +177,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
notifyItemChanged(position); notifyItemChanged(position);
} }
interface FollowListener { interface NotificationActionListener {
void onViewAccount(String id); void onViewAccount(String id);
} }
@ -213,7 +215,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
.into(avatar); .into(avatar);
} }
void setupButtons(final FollowListener listener, final String accountId) { void setupButtons(final NotificationActionListener listener, final String accountId) {
avatar.setOnClickListener(new View.OnClickListener() { avatar.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -227,12 +229,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
private TextView message; private TextView message;
private ImageView icon; private ImageView icon;
private TextView statusContent; private TextView statusContent;
private ViewGroup container;
StatusNotificationViewHolder(View itemView) { StatusNotificationViewHolder(View itemView) {
super(itemView); super(itemView);
message = (TextView) itemView.findViewById(R.id.notification_text); message = (TextView) itemView.findViewById(R.id.notification_text);
icon = (ImageView) itemView.findViewById(R.id.notification_icon); icon = (ImageView) itemView.findViewById(R.id.notification_icon);
statusContent = (TextView) itemView.findViewById(R.id.notification_content); 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) { void setMessage(Notification.Type type, String displayName, Status status) {
@ -262,5 +266,14 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
message.setText(str); message.setText(str);
statusContent.setText(status.content); 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);
}
});
}
} }
} }

View File

@ -40,7 +40,7 @@ import retrofit2.Response;
public class NotificationsFragment extends SFragment implements public class NotificationsFragment extends SFragment implements
SwipeRefreshLayout.OnRefreshListener, StatusActionListener, SwipeRefreshLayout.OnRefreshListener, StatusActionListener,
NotificationsAdapter.FollowListener { NotificationsAdapter.NotificationActionListener {
private static final String TAG = "Notifications"; // logging tag private static final String TAG = "Notifications"; // logging tag
private SwipeRefreshLayout swipeRefreshLayout; private SwipeRefreshLayout swipeRefreshLayout;

View File

@ -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. */ * mostly fills the screen so clicking outside is difficult. */
attacher.setOnSingleFlingListener(new PhotoViewAttacher.OnSingleFlingListener() { attacher.setOnSingleFlingListener(new PhotoViewAttacher.OnSingleFlingListener() {
@Override @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) { float velocityY) {
if (velocityY < 0.0 && Math.abs(velocityY) > Math.abs(velocityX)) { if (Math.abs(velocityY) > Math.abs(velocityX)) {
dismiss(); dismiss();
return true; return true;
} }

View File

@ -2,11 +2,12 @@
<!--This applies only to favourite and reblog notifications.--> <!--This applies only to favourite and reblog notifications.-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/notification_container"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp" android:paddingRight="16dp">
android:layout_height="wrap_content">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"