summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
diff options
context:
space:
mode:
authorstom79 <tschneider.ac@gmail.com>2017-12-25 09:54:19 +0100
committerstom79 <tschneider.ac@gmail.com>2017-12-25 09:54:19 +0100
commit74c4e22abb00bb33c441627939a41a52ed7e3c0d (patch)
tree0955f86375117199f092e8358ab7e21b60829ad6 /app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
parentfe0a3c8868f7841416680ddd975d0a92f8a4d39e (diff)
Change button behavior for spoiler in notifications
Diffstat (limited to 'app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java')
-rw-r--r--app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java62
1 files changed, 37 insertions, 25 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
index 897871f2b..776b04872 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
@@ -333,38 +333,39 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
imgReply = ContextCompat.getDrawable(context, R.drawable.ic_reply);
if( status.getReblog() == null) {
- if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
- holder.notification_status_container.setVisibility(View.GONE);
+ if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 ) {
holder.status_spoiler_container.setVisibility(View.VISIBLE);
- holder.status_spoiler_button.setVisibility(View.VISIBLE);
- holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
- holder.status_spoiler.setVisibility(View.VISIBLE);
+ if( !status.isSpoilerShown()) {
+ holder.notification_status_container.setVisibility(View.GONE);
+ holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
+ holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler));
+ }else {
+ holder.notification_status_container.setVisibility(View.VISIBLE);
+ holder.status_spoiler_mention_container.setVisibility(View.GONE);
+ holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler_less));
+ }
} else {
- holder.status_spoiler_button.setVisibility(View.GONE);
- holder.notification_status_container.setVisibility(View.VISIBLE);
+ holder.status_spoiler_container.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
- if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0)
- holder.status_spoiler_container.setVisibility(View.VISIBLE);
- else
- holder.status_spoiler_container.setVisibility(View.GONE);
-
+ holder.notification_status_container.setVisibility(View.VISIBLE);
}
+
}else {
- if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
- holder.notification_status_container.setVisibility(View.GONE);
+ if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0) {
holder.status_spoiler_container.setVisibility(View.VISIBLE);
- holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
- holder.status_spoiler_button.setVisibility(View.VISIBLE);
- holder.status_spoiler.setVisibility(View.VISIBLE);
+ if( !status.isSpoilerShown()) {
+ holder.notification_status_container.setVisibility(View.GONE);
+ holder.status_spoiler_mention_container.setVisibility(View.VISIBLE);
+ holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler));
+ }else {
+ holder.notification_status_container.setVisibility(View.VISIBLE);
+ holder.status_spoiler_mention_container.setVisibility(View.GONE);
+ holder.status_spoiler_button.setText(context.getString(R.string.load_attachment_spoiler_less));
+ }
} else {
- holder.status_spoiler_button.setVisibility(View.GONE);
+ holder.status_spoiler_container.setVisibility(View.GONE);
holder.status_spoiler_mention_container.setVisibility(View.GONE);
holder.notification_status_container.setVisibility(View.VISIBLE);
- if (status.getReblog().getSpoiler_text() != null && status.getReblog().getSpoiler_text().trim().length() > 0)
- holder.status_spoiler_container.setVisibility(View.VISIBLE);
- else
- holder.status_spoiler_container.setVisibility(View.GONE);
-
}
}
@@ -442,8 +443,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.status_spoiler_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- status.setSpoilerShown(true);
- notificationsListAdapter.notifyDataSetChanged();
+ notification.getStatus().setSpoilerShown(!status.isSpoilerShown());
+ notifyNotificationChanged(notification);
}
});
@@ -764,6 +765,17 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
+ private void notifyNotificationChanged(Notification notification){
+ for (int i = 0; i < notificationsListAdapter.getItemCount(); i++) {
+ if (notificationsListAdapter.getItemAt(i) != null && notificationsListAdapter.getItemAt(i).getId().equals(notification.getId())) {
+ try {
+ notificationsListAdapter.notifyItemChanged(i);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+
@Override
public long getItemId(int position) {
return position;