scroll to added emoji; improve loading animation

This commit is contained in:
sk 2023-08-24 13:26:42 +02:00
parent 0f72809342
commit 71f4f089b6
1 changed files with 9 additions and 5 deletions

View File

@ -65,6 +65,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
private final boolean hideAdd, forAnnouncement; private final boolean hideAdd, forAnnouncement;
private final String accountID; private final String accountID;
private boolean hidden; private boolean hidden;
private static final float ALPHA_DISABLED=0.55f;
public EmojiReactionsStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Status status, String accountID, boolean hideAdd, boolean forAnnouncement) { public EmojiReactionsStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Status status, String accountID, boolean hideAdd, boolean forAnnouncement) {
super(parentID, parentFragment); super(parentID, parentFragment);
@ -104,9 +105,8 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
private void setActionProgressVisible(Holder.EmojiReactionViewHolder vh, boolean visible){ private void setActionProgressVisible(Holder.EmojiReactionViewHolder vh, boolean visible){
if(vh==null) return; if(vh==null) return;
vh.progress.setVisibility(visible ? View.VISIBLE : View.GONE); vh.progress.setVisibility(visible ? View.VISIBLE : View.GONE);
if(visible)
vh.progress.setIndeterminateTintList(vh.btn.getTextColors());
vh.btn.setClickable(!visible); vh.btn.setClickable(!visible);
vh.btn.setAlpha(visible ? ALPHA_DISABLED : 1);
} }
private MastodonAPIRequest<?> createRequest(String name, int count, boolean delete, Holder.EmojiReactionViewHolder vh, Runnable cb, Runnable err){ private MastodonAPIRequest<?> createRequest(String name, int count, boolean delete, Holder.EmojiReactionViewHolder vh, Runnable cb, Runnable err){
@ -231,7 +231,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
progress.setVisibility(View.VISIBLE); progress.setVisibility(View.VISIBLE);
addButton.setClickable(false); addButton.setClickable(false);
addButton.setAlpha(0.55f); addButton.setAlpha(ALPHA_DISABLED);
Runnable resetBtn=()->{ Runnable resetBtn=()->{
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
@ -251,8 +251,12 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem {
item.createRequest(emoji, existing==null ? 1 : existing.count, false, null, ()->{ item.createRequest(emoji, existing==null ? 1 : existing.count, false, null, ()->{
resetBtn.run(); resetBtn.run();
if(finalExisting==null){ if(finalExisting==null){
item.status.reactions.add(0, info!=null ? EmojiReaction.of(info, me) : EmojiReaction.of(emoji, me)); int pos=item.status.reactions.size();
adapter.notifyItemRangeInserted(0, 1); item.status.reactions.add(pos, info!=null ? EmojiReaction.of(info, me) : EmojiReaction.of(emoji, me));
adapter.notifyItemRangeInserted(pos, 1);
RecyclerView.SmoothScroller scroller=new LinearSmoothScroller(list.getContext());
scroller.setTargetPosition(pos);
list.getLayoutManager().startSmoothScroll(scroller);
}else{ }else{
finalExisting.add(me); finalExisting.add(me);
adapter.notifyItemChanged(item.status.reactions.indexOf(finalExisting)); adapter.notifyItemChanged(item.status.reactions.indexOf(finalExisting));