Clear images in StatusListFragment when it becomes invisible

This commit is contained in:
Grishka 2022-01-17 23:09:47 +03:00
parent 13665a11ca
commit ba75aa6d91
2 changed files with 28 additions and 0 deletions

View File

@ -43,4 +43,10 @@ public class HomeFragment extends AppKitFragment{
return content;
}
@Override
public void onHiddenChanged(boolean hidden){
super.onHiddenChanged(hidden);
homeTimelineFragment.onHiddenChanged(hidden);
}
}

View File

@ -12,6 +12,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import me.grishka.appkit.fragments.BaseRecyclerFragment;
import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter;
import me.grishka.appkit.imageloader.ImageLoaderViewHolder;
import me.grishka.appkit.imageloader.requests.ImageLoaderRequest;
import me.grishka.appkit.utils.BindableViewHolder;
import me.grishka.appkit.views.UsableRecyclerView;
@ -54,6 +55,27 @@ public abstract class StatusListFragment extends BaseRecyclerFragment<Status>{
adapter.notifyItemRangeInserted(0, offset);
}
@Override
protected void onHidden(){
super.onHidden();
imgLoader.deactivate();
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){
for(int j=0;j<list.getImageCountForItem(holder.getAbsoluteAdapterPosition());j++){
((ImageLoaderViewHolder) holder).clearImage(j);
}
}
}
}
@Override
protected void onShown(){
super.onShown();
imgLoader.activate();
}
protected class DisplayItemsAdapter extends UsableRecyclerView.Adapter<BindableViewHolder<StatusDisplayItem>> implements ImageLoaderRecyclerAdapter{
public DisplayItemsAdapter(){