Use pattern-matching instanceof

This commit is contained in:
Grishka 2022-04-19 07:32:33 +03:00
parent 94b6189f36
commit b57df8e175
21 changed files with 64 additions and 89 deletions

View File

@ -150,9 +150,9 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
UsableRecyclerView list=(UsableRecyclerView) this.list;
for(int i=0; i<list.getChildCount(); 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++){
((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){
final Status status=_status.reblog!=null ? _status.reblog : _status;
currentPhotoViewer=new PhotoViewer(getActivity(), status.mediaAttachments, attachmentIndex, new PhotoViewer.Listener(){
private ImageStatusDisplayItem.Holder transitioningHolder;
private ImageStatusDisplayItem.Holder<?> transitioningHolder;
@Override
public void setPhotoViewVisibility(int index, boolean visible){
ImageStatusDisplayItem.Holder holder=findPhotoViewHolder(index);
ImageStatusDisplayItem.Holder<?> holder=findPhotoViewHolder(index);
if(holder!=null)
holder.photo.setAlpha(visible ? 1f : 0f);
}
@Override
public boolean startPhotoViewTransition(int index, @NonNull Rect outRect, @NonNull int[] outCornerRadius){
ImageStatusDisplayItem.Holder holder=findPhotoViewHolder(index);
ImageStatusDisplayItem.Holder<?> holder=findPhotoViewHolder(index);
if(holder!=null){
transitioningHolder=holder;
View view=transitioningHolder.photo;
@ -223,7 +223,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
@Override
public Drawable getPhotoViewCurrentDrawable(int index){
ImageStatusDisplayItem.Holder holder=findPhotoViewHolder(index);
ImageStatusDisplayItem.Holder<?> holder=findPhotoViewHolder(index);
if(holder!=null)
return holder.photo.getDrawable();
return null;
@ -234,14 +234,14 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
currentPhotoViewer=null;
}
private ImageStatusDisplayItem.Holder findPhotoViewHolder(int index){
private ImageStatusDisplayItem.Holder<?> findPhotoViewHolder(int index){
int offset=0;
for(StatusDisplayItem item:displayItems){
if(item.parentID.equals(parentID)){
if(item instanceof ImageStatusDisplayItem){
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(getMainAdapterOffset()+offset+index);
if(holder instanceof ImageStatusDisplayItem.Holder){
return (ImageStatusDisplayItem.Holder) holder;
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
return imgHolder;
}
return null;
}
@ -303,9 +303,9 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
position-=getMainAdapterOffset();
if(position>=0 && position<displayItems.size()){
StatusDisplayItem item=displayItems.get(position);
if(item instanceof ImageStatusDisplayItem){
PhotoLayoutHelper.TiledLayoutResult layout=((ImageStatusDisplayItem) item).tiledLayout;
PhotoLayoutHelper.TiledLayoutResult.Tile tile=((ImageStatusDisplayItem) item).thisTile;
if(item instanceof ImageStatusDisplayItem imgItem){
PhotoLayoutHelper.TiledLayoutResult layout=imgItem.tiledLayout;
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgItem.thisTile;
int spans=0;
for(int i=0;i<tile.colSpan;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++){
RecyclerView.ViewHolder vh=list.getChildViewHolder(list.getChildAt(i));
if(vh instanceof PollFooterStatusDisplayItem.Holder){
PollFooterStatusDisplayItem.Holder footer=(PollFooterStatusDisplayItem.Holder) vh;
if(vh instanceof PollFooterStatusDisplayItem.Holder footer){
if(footer.getItemID().equals(holder.getItemID())){
footer.rebind();
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){
for(int i=0;i<list.getChildCount();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 null;
@ -523,7 +522,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
ArrayList<H> holders=new ArrayList<>();
for(int i=0;i<list.getChildCount();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));
}
return holders;
@ -642,8 +641,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
for(int i=0;i<parent.getChildCount();i++){
View child=parent.getChildAt(i);
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
if(holder instanceof ImageStatusDisplayItem.Holder){
ImageStatusDisplayItem.Holder<?> imgHolder=(ImageStatusDisplayItem.Holder<?>) holder;
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
if(!imgHolder.getItem().status.spoilerRevealed && TextUtils.isEmpty(imgHolder.getItem().status.spoilerText)){
hiddenMediaPaint.setColor(0x80000000);
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++){
View child=parent.getChildAt(i);
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
if(holder instanceof ImageStatusDisplayItem.Holder){
ImageStatusDisplayItem.Holder<?> imgHolder=(ImageStatusDisplayItem.Holder<?>) holder;
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
if(!imgHolder.getItem().status.spoilerRevealed){
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
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){
currentMediaHiddenLayoutsWidth=width;
String title=getString(R.string.sensitive_content);
TextPaint titlePaint=new TextPaint(Paint.ANTI_ALIAS_FLAG);
titlePaint.setColor(getResources().getColor(R.color.gray_50));

View File

@ -212,8 +212,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
private void onTabSelected(@IdRes int tab){
Fragment newFragment=fragmentForTab(tab);
if(tab==currentTab){
if(newFragment instanceof ScrollableToTop)
((ScrollableToTop) newFragment).scrollToTop();
if(newFragment instanceof ScrollableToTop scrollable)
scrollable.scrollToTop();
return;
}
getChildFragmentManager().beginTransaction().hide(fragmentForTab(currentTab)).show(newFragment).commit();
@ -223,8 +223,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
}
private void maybeTriggerLoading(Fragment newFragment){
if(newFragment instanceof LoaderFragment){
LoaderFragment lf=(LoaderFragment) newFragment;
if(newFragment instanceof LoaderFragment lf){
if(!lf.loaded && !lf.dataLoading)
lf.loadData();
}else if(newFragment instanceof DiscoverFragment){

View File

@ -81,8 +81,7 @@ public class NotificationsFragment extends ToolbarFragment implements Scrollable
if(position==0)
return;
Fragment _page=getFragmentForPage(position);
if(_page instanceof BaseRecyclerFragment){
BaseRecyclerFragment page=(BaseRecyclerFragment) _page;
if(_page instanceof BaseRecyclerFragment<?> page){
if(!page.loaded && !page.isDataLoading())
page.loadData();
}

View File

@ -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);
if(titleItem!=null){
for(StatusDisplayItem item:items){
if(item instanceof ImageStatusDisplayItem){
((ImageStatusDisplayItem) item).horizontalInset=V.dp(32);
if(item instanceof ImageStatusDisplayItem imgItem){
imgItem.horizontalInset=V.dp(32);
}
}
}
@ -126,8 +126,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
return;
for(int i=0;i<list.getChildCount();i++){
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
if(holder instanceof AccountCardStatusDisplayItem.Holder)
((AccountCardStatusDisplayItem.Holder) holder).rebind();
if(holder instanceof AccountCardStatusDisplayItem.Holder accountHolder)
accountHolder.rebind();
}
}
@ -173,7 +173,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
View child=parent.getChildAt(i);
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
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(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());
@ -210,8 +210,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state){
RecyclerView.ViewHolder holder=parent.getChildViewHolder(view);
if(holder instanceof StatusDisplayItem.Holder){
boolean inset=((StatusDisplayItem.Holder<?>) holder).getItem().inset;
if(holder instanceof StatusDisplayItem.Holder<?> sdi){
boolean inset=sdi.getItem().inset;
int pos=holder.getAbsoluteAdapterPosition();
if(inset){
boolean topSiblingInset=pos>0 && displayItems.get(pos-1).inset;
@ -222,9 +222,9 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
else
pad=V.dp(12);
boolean insetLeft=true, insetRight=true;
if(holder instanceof ImageStatusDisplayItem.Holder){
PhotoLayoutHelper.TiledLayoutResult layout=((ImageStatusDisplayItem.Holder<?>) holder).getItem().tiledLayout;
PhotoLayoutHelper.TiledLayoutResult.Tile tile=((ImageStatusDisplayItem.Holder<?>) holder).getItem().thisTile;
if(holder instanceof ImageStatusDisplayItem.Holder<?> img){
PhotoLayoutHelper.TiledLayoutResult layout=img.getItem().tiledLayout;
PhotoLayoutHelper.TiledLayoutResult.Tile tile=img.getItem().thisTile;
// only inset those items that are on the edges of the layout
insetLeft=tile.startCol==0;
insetRight=tile.startCol+tile.colSpan==layout.columnSizes.length;

View File

@ -1,9 +1,7 @@
package org.joinmastodon.android.fragments;
import android.app.Fragment;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
@ -13,8 +11,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.widget.EditText;
import android.widget.TextView;
@ -22,7 +18,6 @@ import android.widget.TextView;
import org.joinmastodon.android.R;
import org.joinmastodon.android.model.AccountField;
import org.joinmastodon.android.ui.BetterItemAnimator;
import org.joinmastodon.android.ui.OutlineProviders;
import org.joinmastodon.android.ui.text.CustomEmojiSpan;
import org.joinmastodon.android.ui.utils.SimpleTextWatcher;
import org.joinmastodon.android.ui.utils.UiUtils;

View File

@ -330,8 +330,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(position==0)
return;
Fragment _page=getFragmentForPage(position);
if(_page instanceof BaseRecyclerFragment){
BaseRecyclerFragment page=(BaseRecyclerFragment) _page;
if(_page instanceof BaseRecyclerFragment<?> page){
if(!page.loaded && !page.isDataLoading())
page.loadData();
}

View File

@ -2,9 +2,7 @@ package org.joinmastodon.android.fragments;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
@ -240,8 +238,7 @@ public class SettingsFragment extends ToolbarFragment{
}
if((prevPolicy==PushSubscription.Policy.NONE)!=(policy==PushSubscription.Policy.NONE)){
index++;
while(items.get(index) instanceof SwitchItem){
SwitchItem si=(SwitchItem) items.get(index);
while(items.get(index) instanceof SwitchItem si){
si.enabled=si.checked=policy!=PushSubscription.Policy.NONE;
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(index);
if(holder!=null)

View File

@ -9,7 +9,6 @@ import org.joinmastodon.android.events.PollUpdatedEvent;
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
import org.joinmastodon.android.events.StatusCreatedEvent;
import org.joinmastodon.android.events.StatusDeletedEvent;
import org.joinmastodon.android.model.Poll;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.ui.displayitems.FooterStatusDisplayItem;
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
@ -89,8 +88,8 @@ public abstract class StatusListFragment extends BaseStatusListFragment<Status>{
s.update(ev);
for(int i=0;i<list.getChildCount();i++){
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
if(holder instanceof FooterStatusDisplayItem.Holder && ((FooterStatusDisplayItem.Holder) holder).getItem().status==s.getContentStatus()){
((FooterStatusDisplayItem.Holder) holder).rebind();
if(holder instanceof FooterStatusDisplayItem.Holder footer && footer.getItem().status==s.getContentStatus()){
footer.rebind();
return;
}
}

View File

@ -43,8 +43,8 @@ public class ThreadFragment extends StatusListFragment{
List<StatusDisplayItem> items=super.buildDisplayItems(s);
if(s==mainStatus){
for(StatusDisplayItem item:items){
if(item instanceof TextStatusDisplayItem)
((TextStatusDisplayItem) item).textSelectable=true;
if(item instanceof TextStatusDisplayItem text)
text.textSelectable=true;
}
}
return items;

View File

@ -111,8 +111,8 @@ public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccou
return;
for(int i=0;i<list.getChildCount();i++){
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
if(holder instanceof AccountViewHolder)
((AccountViewHolder) holder).rebind();
if(holder instanceof AccountViewHolder avh)
avh.rebind();
}
}
@ -243,8 +243,8 @@ public class DiscoverAccountsFragment extends BaseRecyclerFragment<DiscoverAccou
name.invalidate();
bio.invalidate();
}
if(image instanceof Animatable && !((Animatable) image).isRunning())
((Animatable) image).start();
if(image instanceof Animatable a && !a.isRunning())
a.start();
}
@Override

View File

@ -97,8 +97,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
if(position==0)
return;
Fragment _page=getFragmentForPage(position);
if(_page instanceof BaseRecyclerFragment){
BaseRecyclerFragment page=(BaseRecyclerFragment) _page;
if(_page instanceof BaseRecyclerFragment<?> page){
if(!page.loaded && !page.isDataLoading())
page.loadData();
}

View File

@ -5,7 +5,6 @@ import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
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.fragments.BaseStatusListFragment;
import org.joinmastodon.android.fragments.ProfileFragment;
import org.joinmastodon.android.fragments.StatusListFragment;
import org.joinmastodon.android.fragments.ThreadFragment;
import org.joinmastodon.android.model.Account;
import org.joinmastodon.android.model.Hashtag;

View File

@ -1,7 +1,5 @@
package org.joinmastodon.android.fragments.discover;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
@ -22,7 +20,6 @@ import androidx.recyclerview.widget.RecyclerView;
import me.grishka.appkit.api.SimpleCallback;
import me.grishka.appkit.fragments.BaseRecyclerFragment;
import me.grishka.appkit.utils.BindableViewHolder;
import me.grishka.appkit.utils.V;
import me.grishka.appkit.views.UsableRecyclerView;
public class TrendingHashtagsFragment extends BaseRecyclerFragment<Hashtag> implements ScrollableToTop{

View File

@ -545,8 +545,8 @@ public class InstanceCatalogFragment extends BaseRecyclerFragment<CatalogInstanc
int idx=filteredData.indexOf(chosenInstance);
if(idx!=-1){
RecyclerView.ViewHolder holder=list.findViewHolderForAdapterPosition(mergeAdapter.getPositionForAdapter(adapter)+idx);
if(holder instanceof InstanceViewHolder){
((InstanceViewHolder)holder).radioButton.setChecked(false);
if(holder instanceof InstanceViewHolder ivh){
ivh.radioButton.setChecked(false);
}
}
}

View File

@ -1,7 +1,6 @@
package org.joinmastodon.android.fragments.onboarding;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;

View File

@ -42,7 +42,6 @@ import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import androidx.annotation.Nullable;
@ -216,8 +215,8 @@ public class SignupFragment extends AppKitFragment{
@Override
public void onError(ErrorResponse error){
if(error instanceof MastodonDetailedErrorResponse){
Map<String, List<MastodonDetailedErrorResponse.FieldError>> fieldErrors=((MastodonDetailedErrorResponse) error).detailedErrors;
if(error instanceof MastodonDetailedErrorResponse derr){
Map<String, List<MastodonDetailedErrorResponse.FieldError>> fieldErrors=derr.detailedErrors;
boolean first=true;
boolean anyFieldsSkipped=false;
for(String fieldName:fieldErrors.keySet()){

View File

@ -179,8 +179,8 @@ public abstract class BaseReportChoiceFragment extends ToolbarFragment{
String prev=selectedIDs.remove(0);
for(int i=0;i<list.getChildCount();i++){
RecyclerView.ViewHolder holder=list.getChildViewHolder(list.getChildAt(i));
if(holder instanceof ItemViewHolder && ((ItemViewHolder) holder).getItem().id.equals(prev)){
((ItemViewHolder) holder).rebind();
if(holder instanceof ItemViewHolder ivh && ivh.getItem().id.equals(prev)){
ivh.rebind();
break;
}
}

View File

@ -32,7 +32,6 @@ import org.joinmastodon.android.ui.utils.UiUtils;
import org.parceler.Parcels;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@ -123,8 +122,7 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
if(holder.getAbsoluteAdapterPosition()==0)
return;
outRect.left=V.dp(40);
if(holder instanceof ImageStatusDisplayItem.Holder){
ImageStatusDisplayItem.Holder<?> imgHolder=(ImageStatusDisplayItem.Holder<?>) holder;
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
PhotoLayoutHelper.TiledLayoutResult layout=imgHolder.getItem().tiledLayout;
PhotoLayoutHelper.TiledLayoutResult.Tile tile=imgHolder.getItem().thisTile;
String siblingID;
@ -154,12 +152,11 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
for(int i=0;i<parent.getChildCount();i++){
View child=parent.getChildAt(i);
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
if(holder instanceof StatusDisplayItem.Holder){
if(holder instanceof StatusDisplayItem.Holder sdiHolder){
parent.getDecoratedBoundsWithMargins(child, tmpRect);
String id=((StatusDisplayItem.Holder<?>) holder).getItemID();
String id=sdiHolder.getItemID();
int height=tmpRect.height();
if(holder instanceof ImageStatusDisplayItem.Holder){
ImageStatusDisplayItem.Holder<ImageStatusDisplayItem> imgHolder=(ImageStatusDisplayItem.Holder<ImageStatusDisplayItem>) holder;
if(holder instanceof ImageStatusDisplayItem.Holder<?> imgHolder){
if(imgHolder.getItem().thisTile.startCol+imgHolder.getItem().thisTile.colSpan<imgHolder.getItem().tiledLayout.columnSizes.length)
height=0;
}
@ -173,8 +170,8 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
for(int i=0;i<parent.getChildCount();i++){
View child=parent.getChildAt(i);
RecyclerView.ViewHolder holder=parent.getChildViewHolder(child);
if(holder instanceof StatusDisplayItem.Holder){
String postID=((StatusDisplayItem.Holder<?>) holder).getItemID();
if(holder instanceof StatusDisplayItem.Holder<?> sdiHolder){
String postID=sdiHolder.getItemID();
if(!postID.equals(lastPostID)){
lastPostID=postID;
if(!postsWithKnownNonHeaderHeights.contains(postID))
@ -233,8 +230,8 @@ public class ReportAddPostsChoiceFragment extends StatusListFragment{
protected List<StatusDisplayItem> buildDisplayItems(Status s){
List<StatusDisplayItem> items=StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, true, false);
for(StatusDisplayItem item:items){
if(item instanceof ImageStatusDisplayItem){
((ImageStatusDisplayItem) item).horizontalInset=V.dp(40+32);
if(item instanceof ImageStatusDisplayItem isdi){
isdi.horizontalInset=V.dp(40+32);
}
}
return items;

View File

@ -32,7 +32,7 @@ public class Instance extends BaseModel{
/**
* A shorter description defined by the admin.
*/
@RequiredField
// @RequiredField
public String shortDescription;
/**
* An email that may be contacted for any inquiries.
@ -89,6 +89,8 @@ public class Instance extends BaseModel{
contactAccount.postprocess();
if(rules==null)
rules=Collections.emptyList();
if(shortDescription==null)
shortDescription="";
}
@Override

View File

@ -277,16 +277,16 @@ public class PhotoViewer implements ZoomPanView.Listener{
@Override
public void onViewDetachedFromWindow(@NonNull BaseHolder holder){
super.onViewDetachedFromWindow(holder);
if(holder instanceof GifVViewHolder){
((GifVViewHolder) holder).reset();
if(holder instanceof GifVViewHolder gifHolder){
gifHolder.reset();
}
}
@Override
public void onViewAttachedToWindow(@NonNull BaseHolder holder){
super.onViewAttachedToWindow(holder);
if(holder instanceof GifVViewHolder){
((GifVViewHolder) holder).prepareAndStartPlayer();
if(holder instanceof GifVViewHolder gifHolder){
gifHolder.prepareAndStartPlayer();
}
}
}

View File

@ -1,11 +1,9 @@
package org.joinmastodon.android.ui.photoviewer;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;