Use pattern-matching instanceof
This commit is contained in:
parent
94b6189f36
commit
b57df8e175
|
@ -150,9 +150,9 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
UsableRecyclerView list=(UsableRecyclerView) this.list;
|
UsableRecyclerView list=(UsableRecyclerView) this.list;
|
||||||
for(int i=0; i<list.getChildCount(); i++){
|
for(int i=0; i<list.getChildCount(); i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof ImageLoaderViewHolder){
|
if(holder instanceof ImageLoaderViewHolder ivh){
|
||||||
for(int j=0; j<list.getImageCountForItem(holder.getAbsoluteAdapterPosition()); j++){
|
for(int j=0; j<list.getImageCountForItem(holder.getAbsoluteAdapterPosition()); j++){
|
||||||
((ImageLoaderViewHolder) holder).clearImage(j);
|
ivh.clearImage(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,18 +169,18 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
public void openPhotoViewer(String parentID, Status _status, int attachmentIndex){
|
public void openPhotoViewer(String parentID, Status _status, int attachmentIndex){
|
||||||
final Status status=_status.reblog!=null ? _status.reblog : _status;
|
final Status status=_status.reblog!=null ? _status.reblog : _status;
|
||||||
currentPhotoViewer=new PhotoViewer(getActivity(), status.mediaAttachments, attachmentIndex, new PhotoViewer.Listener(){
|
currentPhotoViewer=new PhotoViewer(getActivity(), status.mediaAttachments, attachmentIndex, new PhotoViewer.Listener(){
|
||||||
private ImageStatusDisplayItem.Holder transitioningHolder;
|
private ImageStatusDisplayItem.Holder<?> transitioningHolder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPhotoViewVisibility(int index, boolean visible){
|
public void setPhotoViewVisibility(int index, boolean visible){
|
||||||
ImageStatusDisplayItem.Holder holder=findPhotoViewHolder(index);
|
ImageStatusDisplayItem.Holder<?> holder=findPhotoViewHolder(index);
|
||||||
if(holder!=null)
|
if(holder!=null)
|
||||||
holder.photo.setAlpha(visible ? 1f : 0f);
|
holder.photo.setAlpha(visible ? 1f : 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startPhotoViewTransition(int index, @NonNull Rect outRect, @NonNull int[] outCornerRadius){
|
public boolean startPhotoViewTransition(int index, @NonNull Rect outRect, @NonNull int[] outCornerRadius){
|
||||||
ImageStatusDisplayItem.Holder holder=findPhotoViewHolder(index);
|
ImageStatusDisplayItem.Holder<?> holder=findPhotoViewHolder(index);
|
||||||
if(holder!=null){
|
if(holder!=null){
|
||||||
transitioningHolder=holder;
|
transitioningHolder=holder;
|
||||||
View view=transitioningHolder.photo;
|
View view=transitioningHolder.photo;
|
||||||
|
@ -223,7 +223,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getPhotoViewCurrentDrawable(int index){
|
public Drawable getPhotoViewCurrentDrawable(int index){
|
||||||
ImageStatusDisplayItem.Holder holder=findPhotoViewHolder(index);
|
ImageStatusDisplayItem.Holder<?> holder=findPhotoViewHolder(index);
|
||||||
if(holder!=null)
|
if(holder!=null)
|
||||||
return holder.photo.getDrawable();
|
return holder.photo.getDrawable();
|
||||||
return null;
|
return null;
|
||||||
|
@ -234,14 +234,14 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
currentPhotoViewer=null;
|
currentPhotoViewer=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageStatusDisplayItem.Holder findPhotoViewHolder(int index){
|
private ImageStatusDisplayItem.Holder<?> findPhotoViewHolder(int index){
|
||||||
int offset=0;
|
int offset=0;
|
||||||
for(StatusDisplayItem item:displayItems){
|
for(StatusDisplayItem item:displayItems){
|
||||||
if(item.parentID.equals(parentID)){
|
if(item.parentID.equals(parentID)){
|
||||||
if(item instanceof ImageStatusDisplayItem){
|
if(item instanceof ImageStatusDisplayItem){
|
||||||
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(getMainAdapterOffset()+offset+index);
|
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(getMainAdapterOffset()+offset+index);
|
||||||
if(holder instanceof ImageStatusDisplayItem.Holder){
|
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
|
||||||
return (ImageStatusDisplayItem.Holder) holder;
|
return imgHolder;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -303,9 +303,9 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
position-=getMainAdapterOffset();
|
position-=getMainAdapterOffset();
|
||||||
if(position>=0 && position<displayItems.size()){
|
if(position>=0 && position<displayItems.size()){
|
||||||
StatusDisplayItem item=displayItems.get(position);
|
StatusDisplayItem item=displayItems.get(position);
|
||||||
if(item instanceof ImageStatusDisplayItem){
|
if(item instanceof ImageStatusDisplayItem imgItem){
|
||||||
PhotoLayoutHelper.TiledLayoutResult layout=((ImageStatusDisplayItem) item).tiledLayout;
|
PhotoLayoutHelper.TiledLayoutResult layout=imgItem.tiledLayout;
|
||||||
PhotoLayoutHelper.TiledLayoutResult.Tile tile=((ImageStatusDisplayItem) item).thisTile;
|
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgItem.thisTile;
|
||||||
int spans=0;
|
int spans=0;
|
||||||
for(int i=0;i<tile.colSpan;i++){
|
for(int i=0;i<tile.colSpan;i++){
|
||||||
spans+=layout.columnSizes[tile.startCol+i];
|
spans+=layout.columnSizes[tile.startCol+i];
|
||||||
|
@ -390,8 +390,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
}
|
}
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder vh=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder vh=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(vh instanceof PollFooterStatusDisplayItem.Holder){
|
if(vh instanceof PollFooterStatusDisplayItem.Holder footer){
|
||||||
PollFooterStatusDisplayItem.Holder footer=(PollFooterStatusDisplayItem.Holder) vh;
|
|
||||||
if(footer.getItemID().equals(holder.getItemID())){
|
if(footer.getItemID().equals(holder.getItemID())){
|
||||||
footer.rebind();
|
footer.rebind();
|
||||||
break;
|
break;
|
||||||
|
@ -513,7 +512,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
protected <I extends StatusDisplayItem, H extends StatusDisplayItem.Holder<I>> H findHolderOfType(String id, Class<H> type){
|
protected <I extends StatusDisplayItem, H extends StatusDisplayItem.Holder<I>> H findHolderOfType(String id, Class<H> type){
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof StatusDisplayItem.Holder && ((StatusDisplayItem.Holder<?>) holder).getItemID().equals(id) && type.isInstance(holder))
|
if(holder instanceof StatusDisplayItem.Holder<?> itemHolder && itemHolder.getItemID().equals(id) && type.isInstance(holder))
|
||||||
return type.cast(holder);
|
return type.cast(holder);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -523,7 +522,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
ArrayList<H> holders=new ArrayList<>();
|
ArrayList<H> holders=new ArrayList<>();
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof StatusDisplayItem.Holder && ((StatusDisplayItem.Holder<?>) holder).getItemID().equals(id) && type.isInstance(holder))
|
if(holder instanceof StatusDisplayItem.Holder<?> itemHolder && itemHolder.getItemID().equals(id) && type.isInstance(holder))
|
||||||
holders.add(type.cast(holder));
|
holders.add(type.cast(holder));
|
||||||
}
|
}
|
||||||
return holders;
|
return holders;
|
||||||
|
@ -642,8 +641,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
for(int i=0;i<parent.getChildCount();i++){
|
for(int i=0;i<parent.getChildCount();i++){
|
||||||
View child=parent.getChildAt(i);
|
View child=parent.getChildAt(i);
|
||||||
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
||||||
if(holder instanceof ImageStatusDisplayItem.Holder){
|
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
|
||||||
ImageStatusDisplayItem.Holder<?> imgHolder=(ImageStatusDisplayItem.Holder<?>) holder;
|
|
||||||
if(!imgHolder.getItem().status.spoilerRevealed && TextUtils.isEmpty(imgHolder.getItem().status.spoilerText)){
|
if(!imgHolder.getItem().status.spoilerRevealed && TextUtils.isEmpty(imgHolder.getItem().status.spoilerText)){
|
||||||
hiddenMediaPaint.setColor(0x80000000);
|
hiddenMediaPaint.setColor(0x80000000);
|
||||||
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
|
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
|
||||||
|
@ -656,8 +654,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
for(int i=0;i<parent.getChildCount();i++){
|
for(int i=0;i<parent.getChildCount();i++){
|
||||||
View child=parent.getChildAt(i);
|
View child=parent.getChildAt(i);
|
||||||
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
||||||
if(holder instanceof ImageStatusDisplayItem.Holder){
|
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
|
||||||
ImageStatusDisplayItem.Holder<?> imgHolder=(ImageStatusDisplayItem.Holder<?>) holder;
|
|
||||||
if(!imgHolder.getItem().status.spoilerRevealed){
|
if(!imgHolder.getItem().status.spoilerRevealed){
|
||||||
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
|
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
|
||||||
if(tile.startCol==0 && tile.startRow==0 && TextUtils.isEmpty(imgHolder.getItem().status.spoilerText)){
|
if(tile.startCol==0 && tile.startRow==0 && TextUtils.isEmpty(imgHolder.getItem().status.spoilerText)){
|
||||||
|
@ -729,6 +726,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rebuildMediaHiddenLayouts(int width){
|
private void rebuildMediaHiddenLayouts(int width){
|
||||||
|
currentMediaHiddenLayoutsWidth=width;
|
||||||
String title=getString(R.string.sensitive_content);
|
String title=getString(R.string.sensitive_content);
|
||||||
TextPaint titlePaint=new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
TextPaint titlePaint=new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||||
titlePaint.setColor(getResources().getColor(R.color.gray_50));
|
titlePaint.setColor(getResources().getColor(R.color.gray_50));
|
||||||
|
|
|
@ -212,8 +212,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
||||||
private void onTabSelected(@IdRes int tab){
|
private void onTabSelected(@IdRes int tab){
|
||||||
Fragment newFragment=fragmentForTab(tab);
|
Fragment newFragment=fragmentForTab(tab);
|
||||||
if(tab==currentTab){
|
if(tab==currentTab){
|
||||||
if(newFragment instanceof ScrollableToTop)
|
if(newFragment instanceof ScrollableToTop scrollable)
|
||||||
((ScrollableToTop) newFragment).scrollToTop();
|
scrollable.scrollToTop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getChildFragmentManager().beginTransaction().hide(fragmentForTab(currentTab)).show(newFragment).commit();
|
getChildFragmentManager().beginTransaction().hide(fragmentForTab(currentTab)).show(newFragment).commit();
|
||||||
|
@ -223,8 +223,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeTriggerLoading(Fragment newFragment){
|
private void maybeTriggerLoading(Fragment newFragment){
|
||||||
if(newFragment instanceof LoaderFragment){
|
if(newFragment instanceof LoaderFragment lf){
|
||||||
LoaderFragment lf=(LoaderFragment) newFragment;
|
|
||||||
if(!lf.loaded && !lf.dataLoading)
|
if(!lf.loaded && !lf.dataLoading)
|
||||||
lf.loadData();
|
lf.loadData();
|
||||||
}else if(newFragment instanceof DiscoverFragment){
|
}else if(newFragment instanceof DiscoverFragment){
|
||||||
|
|
|
@ -81,8 +81,7 @@ public class NotificationsFragment extends ToolbarFragment implements Scrollable
|
||||||
if(position==0)
|
if(position==0)
|
||||||
return;
|
return;
|
||||||
Fragment _page=getFragmentForPage(position);
|
Fragment _page=getFragmentForPage(position);
|
||||||
if(_page instanceof BaseRecyclerFragment){
|
if(_page instanceof BaseRecyclerFragment<?> page){
|
||||||
BaseRecyclerFragment page=(BaseRecyclerFragment) _page;
|
|
||||||
if(!page.loaded && !page.isDataLoading())
|
if(!page.loaded && !page.isDataLoading())
|
||||||
page.loadData();
|
page.loadData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
ArrayList<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, titleItem!=null, titleItem==null);
|
ArrayList<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, titleItem!=null, titleItem==null);
|
||||||
if(titleItem!=null){
|
if(titleItem!=null){
|
||||||
for(StatusDisplayItem item:items){
|
for(StatusDisplayItem item:items){
|
||||||
if(item instanceof ImageStatusDisplayItem){
|
if(item instanceof ImageStatusDisplayItem imgItem){
|
||||||
((ImageStatusDisplayItem) item).horizontalInset=V.dp(32);
|
imgItem.horizontalInset=V.dp(32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
return;
|
return;
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof AccountCardStatusDisplayItem.Holder)
|
if(holder instanceof AccountCardStatusDisplayItem.Holder accountHolder)
|
||||||
((AccountCardStatusDisplayItem.Holder) holder).rebind();
|
accountHolder.rebind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
View child=parent.getChildAt(i);
|
View child=parent.getChildAt(i);
|
||||||
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
||||||
pos=holder.getAbsoluteAdapterPosition();
|
pos=holder.getAbsoluteAdapterPosition();
|
||||||
boolean inset=(holder instanceof StatusDisplayItem.Holder) && ((StatusDisplayItem.Holder<?>) holder).getItem().inset;
|
boolean inset=(holder instanceof StatusDisplayItem.Holder<?> sdi) && sdi.getItem().inset;
|
||||||
if(inset){
|
if(inset){
|
||||||
if(rect.isEmpty()){
|
if(rect.isEmpty()){
|
||||||
rect.set(child.getX(), i==0 && pos>0 && displayItems.get(pos-1).inset ? V.dp(-10) : child.getY(), child.getX()+child.getWidth(), child.getY()+child.getHeight());
|
rect.set(child.getX(), i==0 && pos>0 && displayItems.get(pos-1).inset ? V.dp(-10) : child.getY(), child.getX()+child.getWidth(), child.getY()+child.getHeight());
|
||||||
|
@ -210,8 +210,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
@Override
|
@Override
|
||||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state){
|
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state){
|
||||||
RecyclerView.ViewHolder holder=parent.getChildViewHolder(view);
|
RecyclerView.ViewHolder holder=parent.getChildViewHolder(view);
|
||||||
if(holder instanceof StatusDisplayItem.Holder){
|
if(holder instanceof StatusDisplayItem.Holder<?> sdi){
|
||||||
boolean inset=((StatusDisplayItem.Holder<?>) holder).getItem().inset;
|
boolean inset=sdi.getItem().inset;
|
||||||
int pos=holder.getAbsoluteAdapterPosition();
|
int pos=holder.getAbsoluteAdapterPosition();
|
||||||
if(inset){
|
if(inset){
|
||||||
boolean topSiblingInset=pos>0 && displayItems.get(pos-1).inset;
|
boolean topSiblingInset=pos>0 && displayItems.get(pos-1).inset;
|
||||||
|
@ -222,9 +222,9 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
else
|
else
|
||||||
pad=V.dp(12);
|
pad=V.dp(12);
|
||||||
boolean insetLeft=true, insetRight=true;
|
boolean insetLeft=true, insetRight=true;
|
||||||
if(holder instanceof ImageStatusDisplayItem.Holder){
|
if(holder instanceof ImageStatusDisplayItem.Holder<?> img){
|
||||||
PhotoLayoutHelper.TiledLayoutResult layout=((ImageStatusDisplayItem.Holder<?>) holder).getItem().tiledLayout;
|
PhotoLayoutHelper.TiledLayoutResult layout=img.getItem().tiledLayout;
|
||||||
PhotoLayoutHelper.TiledLayoutResult.Tile tile=((ImageStatusDisplayItem.Holder<?>) holder).getItem().thisTile;
|
PhotoLayoutHelper.TiledLayoutResult.Tile tile=img.getItem().thisTile;
|
||||||
// only inset those items that are on the edges of the layout
|
// only inset those items that are on the edges of the layout
|
||||||
insetLeft=tile.startCol==0;
|
insetLeft=tile.startCol==0;
|
||||||
insetRight=tile.startCol+tile.colSpan==layout.columnSizes.length;
|
insetRight=tile.startCol+tile.colSpan==layout.columnSizes.length;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package org.joinmastodon.android.fragments;
|
package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Outline;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.ShapeDrawable;
|
import android.graphics.drawable.ShapeDrawable;
|
||||||
|
@ -13,8 +11,6 @@ import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewOutlineProvider;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -22,7 +18,6 @@ import android.widget.TextView;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.model.AccountField;
|
import org.joinmastodon.android.model.AccountField;
|
||||||
import org.joinmastodon.android.ui.BetterItemAnimator;
|
import org.joinmastodon.android.ui.BetterItemAnimator;
|
||||||
import org.joinmastodon.android.ui.OutlineProviders;
|
|
||||||
import org.joinmastodon.android.ui.text.CustomEmojiSpan;
|
import org.joinmastodon.android.ui.text.CustomEmojiSpan;
|
||||||
import org.joinmastodon.android.ui.utils.SimpleTextWatcher;
|
import org.joinmastodon.android.ui.utils.SimpleTextWatcher;
|
||||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
|
|
|
@ -330,8 +330,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
||||||
if(position==0)
|
if(position==0)
|
||||||
return;
|
return;
|
||||||
Fragment _page=getFragmentForPage(position);
|
Fragment _page=getFragmentForPage(position);
|
||||||
if(_page instanceof BaseRecyclerFragment){
|
if(_page instanceof BaseRecyclerFragment<?> page){
|
||||||
BaseRecyclerFragment page=(BaseRecyclerFragment) _page;
|
|
||||||
if(!page.loaded && !page.isDataLoading())
|
if(!page.loaded && !page.isDataLoading())
|
||||||
page.loadData();
|
page.loadData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@ package org.joinmastodon.android.fragments;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
@ -240,8 +238,7 @@ public class SettingsFragment extends ToolbarFragment{
|
||||||
}
|
}
|
||||||
if((prevPolicy==PushSubscription.Policy.NONE)!=(policy==PushSubscription.Policy.NONE)){
|
if((prevPolicy==PushSubscription.Policy.NONE)!=(policy==PushSubscription.Policy.NONE)){
|
||||||
index++;
|
index++;
|
||||||
while(items.get(index) instanceof SwitchItem){
|
while(items.get(index) instanceof SwitchItem si){
|
||||||
SwitchItem si=(SwitchItem) items.get(index);
|
|
||||||
si.enabled=si.checked=policy!=PushSubscription.Policy.NONE;
|
si.enabled=si.checked=policy!=PushSubscription.Policy.NONE;
|
||||||
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(index);
|
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(index);
|
||||||
if(holder!=null)
|
if(holder!=null)
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.joinmastodon.android.events.PollUpdatedEvent;
|
||||||
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
|
||||||
import org.joinmastodon.android.events.StatusCreatedEvent;
|
import org.joinmastodon.android.events.StatusCreatedEvent;
|
||||||
import org.joinmastodon.android.events.StatusDeletedEvent;
|
import org.joinmastodon.android.events.StatusDeletedEvent;
|
||||||
import org.joinmastodon.android.model.Poll;
|
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.ui.displayitems.FooterStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.FooterStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
||||||
|
@ -89,8 +88,8 @@ public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
|
||||||
s.update(ev);
|
s.update(ev);
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof FooterStatusDisplayItem.Holder && ((FooterStatusDisplayItem.Holder) holder).getItem().status==s.getContentStatus()){
|
if(holder instanceof FooterStatusDisplayItem.Holder footer && footer.getItem().status==s.getContentStatus()){
|
||||||
((FooterStatusDisplayItem.Holder) holder).rebind();
|
footer.rebind();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ public class ThreadFragment extends StatusListFragment{
|
||||||
List<StatusDisplayItem> items=super.buildDisplayItems(s);
|
List<StatusDisplayItem> items=super.buildDisplayItems(s);
|
||||||
if(s==mainStatus){
|
if(s==mainStatus){
|
||||||
for(StatusDisplayItem item:items){
|
for(StatusDisplayItem item:items){
|
||||||
if(item instanceof TextStatusDisplayItem)
|
if(item instanceof TextStatusDisplayItem text)
|
||||||
((TextStatusDisplayItem) item).textSelectable=true;
|
text.textSelectable=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
|
|
|
@ -111,8 +111,8 @@ public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccou
|
||||||
return;
|
return;
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof AccountViewHolder)
|
if(holder instanceof AccountViewHolder avh)
|
||||||
((AccountViewHolder) holder).rebind();
|
avh.rebind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccou
|
||||||
name.invalidate();
|
name.invalidate();
|
||||||
bio.invalidate();
|
bio.invalidate();
|
||||||
}
|
}
|
||||||
if(image instanceof Animatable && !((Animatable) image).isRunning())
|
if(image instanceof Animatable a && !a.isRunning())
|
||||||
((Animatable) image).start();
|
a.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -97,8 +97,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
|
||||||
if(position==0)
|
if(position==0)
|
||||||
return;
|
return;
|
||||||
Fragment _page=getFragmentForPage(position);
|
Fragment _page=getFragmentForPage(position);
|
||||||
if(_page instanceof BaseRecyclerFragment){
|
if(_page instanceof BaseRecyclerFragment<?> page){
|
||||||
BaseRecyclerFragment page=(BaseRecyclerFragment) _page;
|
|
||||||
if(!page.loaded && !page.isDataLoading())
|
if(!page.loaded && !page.isDataLoading())
|
||||||
page.loadData();
|
page.loadData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
|
@ -13,7 +12,6 @@ import org.joinmastodon.android.api.requests.search.GetSearchResults;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.fragments.StatusListFragment;
|
|
||||||
import org.joinmastodon.android.fragments.ThreadFragment;
|
import org.joinmastodon.android.fragments.ThreadFragment;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Hashtag;
|
import org.joinmastodon.android.model.Hashtag;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.joinmastodon.android.fragments.discover;
|
package org.joinmastodon.android.fragments.discover;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -22,7 +20,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import me.grishka.appkit.api.SimpleCallback;
|
import me.grishka.appkit.api.SimpleCallback;
|
||||||
import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
import me.grishka.appkit.fragments.BaseRecyclerFragment;
|
||||||
import me.grishka.appkit.utils.BindableViewHolder;
|
import me.grishka.appkit.utils.BindableViewHolder;
|
||||||
import me.grishka.appkit.utils.V;
|
|
||||||
import me.grishka.appkit.views.UsableRecyclerView;
|
import me.grishka.appkit.views.UsableRecyclerView;
|
||||||
|
|
||||||
public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop{
|
public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop{
|
||||||
|
|
|
@ -545,8 +545,8 @@ public class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInstanc
|
||||||
int idx=filteredData.indexOf(chosenInstance);
|
int idx=filteredData.indexOf(chosenInstance);
|
||||||
if(idx!=-1){
|
if(idx!=-1){
|
||||||
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(mergeAdapter.getPositionForAdapter(adapter)+idx);
|
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(mergeAdapter.getPositionForAdapter(adapter)+idx);
|
||||||
if(holder instanceof InstanceViewHolder){
|
if(holder instanceof InstanceViewHolder ivh){
|
||||||
((InstanceViewHolder)holder).radioButton.setChecked(false);
|
ivh.radioButton.setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.joinmastodon.android.fragments.onboarding;
|
package org.joinmastodon.android.fragments.onboarding;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
|
@ -42,7 +42,6 @@ import java.io.InputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -216,8 +215,8 @@ public class SignupFragment extends AppKitFragment{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(ErrorResponse error){
|
public void onError(ErrorResponse error){
|
||||||
if(error instanceof MastodonDetailedErrorResponse){
|
if(error instanceof MastodonDetailedErrorResponse derr){
|
||||||
Map<String, List<MastodonDetailedErrorResponse.FieldError>> fieldErrors=((MastodonDetailedErrorResponse) error).detailedErrors;
|
Map<String, List<MastodonDetailedErrorResponse.FieldError>> fieldErrors=derr.detailedErrors;
|
||||||
boolean first=true;
|
boolean first=true;
|
||||||
boolean anyFieldsSkipped=false;
|
boolean anyFieldsSkipped=false;
|
||||||
for(String fieldName:fieldErrors.keySet()){
|
for(String fieldName:fieldErrors.keySet()){
|
||||||
|
|
|
@ -179,8 +179,8 @@ public abstract class BaseReportChoiceFragment extends ToolbarFragment{
|
||||||
String prev=selectedIDs.remove(0);
|
String prev=selectedIDs.remove(0);
|
||||||
for(int i=0;i<list.getChildCount();i++){
|
for(int i=0;i<list.getChildCount();i++){
|
||||||
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
|
||||||
if(holder instanceof ItemViewHolder && ((ItemViewHolder) holder).getItem().id.equals(prev)){
|
if(holder instanceof ItemViewHolder ivh && ivh.getItem().id.equals(prev)){
|
||||||
((ItemViewHolder) holder).rebind();
|
ivh.rebind();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -123,8 +122,7 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
|
||||||
if(holder.getAbsoluteAdapterPosition()==0)
|
if(holder.getAbsoluteAdapterPosition()==0)
|
||||||
return;
|
return;
|
||||||
outRect.left=V.dp(40);
|
outRect.left=V.dp(40);
|
||||||
if(holder instanceof ImageStatusDisplayItem.Holder){
|
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
|
||||||
ImageStatusDisplayItem.Holder<?> imgHolder=(ImageStatusDisplayItem.Holder<?>) holder;
|
|
||||||
PhotoLayoutHelper.TiledLayoutResult layout=imgHolder.getItem().tiledLayout;
|
PhotoLayoutHelper.TiledLayoutResult layout=imgHolder.getItem().tiledLayout;
|
||||||
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
|
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
|
||||||
String siblingID;
|
String siblingID;
|
||||||
|
@ -154,12 +152,11 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
|
||||||
for(int i=0;i<parent.getChildCount();i++){
|
for(int i=0;i<parent.getChildCount();i++){
|
||||||
View child=parent.getChildAt(i);
|
View child=parent.getChildAt(i);
|
||||||
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
||||||
if(holder instanceof StatusDisplayItem.Holder){
|
if(holder instanceof StatusDisplayItem.Holder sdiHolder){
|
||||||
parent.getDecoratedBoundsWithMargins(child, tmpRect);
|
parent.getDecoratedBoundsWithMargins(child, tmpRect);
|
||||||
String id=((StatusDisplayItem.Holder<?>) holder).getItemID();
|
String id=sdiHolder.getItemID();
|
||||||
int height=tmpRect.height();
|
int height=tmpRect.height();
|
||||||
if(holder instanceof ImageStatusDisplayItem.Holder){
|
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
|
||||||
ImageStatusDisplayItem.Holder<ImageStatusDisplayItem> imgHolder=(ImageStatusDisplayItem.Holder<ImageStatusDisplayItem>) holder;
|
|
||||||
if(imgHolder.getItem().thisTile.startCol+imgHolder.getItem().thisTile.colSpan<imgHolder.getItem().tiledLayout.columnSizes.length)
|
if(imgHolder.getItem().thisTile.startCol+imgHolder.getItem().thisTile.colSpan<imgHolder.getItem().tiledLayout.columnSizes.length)
|
||||||
height=0;
|
height=0;
|
||||||
}
|
}
|
||||||
|
@ -173,8 +170,8 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
|
||||||
for(int i=0;i<parent.getChildCount();i++){
|
for(int i=0;i<parent.getChildCount();i++){
|
||||||
View child=parent.getChildAt(i);
|
View child=parent.getChildAt(i);
|
||||||
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
|
||||||
if(holder instanceof StatusDisplayItem.Holder){
|
if(holder instanceof StatusDisplayItem.Holder<?> sdiHolder){
|
||||||
String postID=((StatusDisplayItem.Holder<?>) holder).getItemID();
|
String postID=sdiHolder.getItemID();
|
||||||
if(!postID.equals(lastPostID)){
|
if(!postID.equals(lastPostID)){
|
||||||
lastPostID=postID;
|
lastPostID=postID;
|
||||||
if(!postsWithKnownNonHeaderHeights.contains(postID))
|
if(!postsWithKnownNonHeaderHeights.contains(postID))
|
||||||
|
@ -233,8 +230,8 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
protected List<StatusDisplayItem> buildDisplayItems(Status s){
|
||||||
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false);
|
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false);
|
||||||
for(StatusDisplayItem item:items){
|
for(StatusDisplayItem item:items){
|
||||||
if(item instanceof ImageStatusDisplayItem){
|
if(item instanceof ImageStatusDisplayItem isdi){
|
||||||
((ImageStatusDisplayItem) item).horizontalInset=V.dp(40+32);
|
isdi.horizontalInset=V.dp(40+32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class Instance extends BaseModel{
|
||||||
/**
|
/**
|
||||||
* A shorter description defined by the admin.
|
* A shorter description defined by the admin.
|
||||||
*/
|
*/
|
||||||
@RequiredField
|
// @RequiredField
|
||||||
public String shortDescription;
|
public String shortDescription;
|
||||||
/**
|
/**
|
||||||
* An email that may be contacted for any inquiries.
|
* An email that may be contacted for any inquiries.
|
||||||
|
@ -89,6 +89,8 @@ public class Instance extends BaseModel{
|
||||||
contactAccount.postprocess();
|
contactAccount.postprocess();
|
||||||
if(rules==null)
|
if(rules==null)
|
||||||
rules=Collections.emptyList();
|
rules=Collections.emptyList();
|
||||||
|
if(shortDescription==null)
|
||||||
|
shortDescription="";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -277,16 +277,16 @@ public class PhotoViewer implements ZoomPanView.Listener{
|
||||||
@Override
|
@Override
|
||||||
public void onViewDetachedFromWindow(@NonNull BaseHolder holder){
|
public void onViewDetachedFromWindow(@NonNull BaseHolder holder){
|
||||||
super.onViewDetachedFromWindow(holder);
|
super.onViewDetachedFromWindow(holder);
|
||||||
if(holder instanceof GifVViewHolder){
|
if(holder instanceof GifVViewHolder gifHolder){
|
||||||
((GifVViewHolder) holder).reset();
|
gifHolder.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewAttachedToWindow(@NonNull BaseHolder holder){
|
public void onViewAttachedToWindow(@NonNull BaseHolder holder){
|
||||||
super.onViewAttachedToWindow(holder);
|
super.onViewAttachedToWindow(holder);
|
||||||
if(holder instanceof GifVViewHolder){
|
if(holder instanceof GifVViewHolder gifHolder){
|
||||||
((GifVViewHolder) holder).prepareAndStartPlayer();
|
gifHolder.prepareAndStartPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package org.joinmastodon.android.ui.photoviewer;
|
package org.joinmastodon.android.ui.photoviewer;
|
||||||
|
|
||||||
import android.animation.ValueAnimator;
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
Loading…
Reference in New Issue