diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 574d7c94d..df59a4059 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -230,6 +230,29 @@ public abstract class BaseStatusListFragment exten } } }); + ((UsableRecyclerView)list).setSelectorBoundsProvider(new UsableRecyclerView.SelectorBoundsProvider(){ + @Override + public void getSelectorBounds(View view, Rect outRect){ + outRect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); + RecyclerView.ViewHolder holder=list.getChildViewHolder(view); + if(holder instanceof StatusDisplayItem.Holder){ + String id=((StatusDisplayItem.Holder) holder).getItemID(); + for(int i=0;i) holder).getItemID(); + if(otherID.equals(id)){ + outRect.left=Math.min(outRect.left, child.getLeft()); + outRect.top=Math.min(outRect.top, child.getTop()); + outRect.right=Math.max(outRect.right, child.getRight()); + outRect.bottom=Math.max(outRect.bottom, child.getBottom()); + } + } + } + } + } + }); } @Override @@ -259,6 +282,10 @@ public abstract class BaseStatusListFragment exten return 0; } + public void onItemClick(String id){ + + } + protected class DisplayItemsAdapter extends UsableRecyclerView.Adapter> implements ImageLoaderRecyclerAdapter{ public DisplayItemsAdapter(){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index d70be7bb3..d8b06b6e4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -119,6 +119,7 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis private CustomEmojiPopupKeyboard emojiKeyboard; private Status replyTo; private String initialReplyMentions; + private String uuid; @Override public void onAttach(Activity activity){ @@ -283,6 +284,7 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis } private void updatePublishButtonState(){ + uuid=null; publishButton.setEnabled((trimmedCharCount>0 || !attachments.isEmpty()) && charCount<=charLimit && uploadingAttachment==null && failedAttachments.isEmpty() && queuedAttachments.isEmpty()); } @@ -308,7 +310,8 @@ public class ComposeFragment extends ToolbarFragment implements OnBackPressedLis if(replyTo!=null){ req.inReplyToId=replyTo.id; } - String uuid=UUID.randomUUID().toString(); + if(uuid==null) + uuid=UUID.randomUUID().toString(); ProgressDialog progress=new ProgressDialog(getActivity()); progress.setMessage(getString(R.string.publishing)); progress.setCancelable(false); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index c9fa14652..fd33810e9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -39,7 +39,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ return Type.FOOTER; } - public static class Holder extends BindableViewHolder{ + public static class Holder extends StatusDisplayItem.Holder{ private final TextView reply, boost, favorite; private final ImageView share; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index e6e51dca8..741fdb369 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -59,7 +59,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ return avaRequest; } - public static class Holder extends BindableViewHolder implements ImageLoaderViewHolder{ + public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ private final TextView name, username, timestamp; private final ImageView avatar, more; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java index d4c986ef2..84914b6c6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PhotoStatusDisplayItem.java @@ -49,7 +49,7 @@ public class PhotoStatusDisplayItem extends StatusDisplayItem{ return request; } - public static class Holder extends BindableViewHolder implements ImageLoaderViewHolder{ + public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ public final ImageView photo; public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_photo, parent); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java index 582bcf3f8..34346fd14 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java @@ -24,7 +24,7 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ return Type.REBLOG_OR_REPLY_LINE; } - public static class Holder extends BindableViewHolder{ + public static class Holder extends StatusDisplayItem.Holder{ private final TextView text; public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_reblog_or_reply_line, parent); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index 0b9dfa768..bc296d1b9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -2,7 +2,9 @@ package org.joinmastodon.android.ui.displayitems; import android.app.Activity; import android.app.Fragment; +import android.content.Context; import android.text.TextUtils; +import android.view.View; import android.view.ViewGroup; import org.joinmastodon.android.R; @@ -16,6 +18,7 @@ import java.util.ArrayList; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.utils.BindableViewHolder; +import me.grishka.appkit.views.UsableRecyclerView; public abstract class StatusDisplayItem{ public final String parentID; @@ -88,4 +91,23 @@ public abstract class StatusDisplayItem{ CARD, FOOTER, } + + public static abstract class Holder extends BindableViewHolder implements UsableRecyclerView.Clickable{ + public Holder(View itemView){ + super(itemView); + } + + public Holder(Context context, int layout, ViewGroup parent){ + super(context, layout, parent); + } + + public String getItemID(){ + return item.parentID; + } + + @Override + public void onClick(){ + item.parentFragment.onItemClick(item.parentID); + } + } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index 7606a1f0b..73e85ef81 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -69,7 +69,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem implements LinkSpan } } - public static class Holder extends BindableViewHolder implements ImageLoaderViewHolder{ + public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ private final LinkedTextView text; private CustomEmojiSpan[] emojiSpans;