小编jef*_*don的帖子

通用图像加载器 - 手动清除缓存

我正在使用Universal Image Loader在listviews中显示我的应用程序中的图像.我正在使用,UnlimitedDiscCache因为根据文档,这是最快的缓存机制.

但是,我想清除我的应用程序关闭时的光盘缓存(例如,在onStop()),但只应删除超过给定限制的最旧的缓存文件(如同TotalSizeLimitedDiscCache).

我知道,ImageLoader.clearDiscCache()但在我的情况下,这清除了完整的缓存,因为我UnlimitedDiscCache以前使用...

因此,当用户加载和滚动列表视图时,我希望拥有最快的缓存机制,并在用户不再与应用程序交互时清除慢速缓存.

我有什么想法可以达到这个目的吗?

java android universal-image-loader

8
推荐指数
1
解决办法
3127
查看次数

ItemDecoration覆盖getItemOffsets()和动画

我申请的利润率等于我对RecyclerView使用GridLayoutManager通过重写getItemOffsets()方法(见下面我的代码)。

但是,当从适配器中删除对象时,将在没有偏移的情况下调用删除动画。因此,酰胺化在与要去除的物体不同的位置开始。

我试图通过来获取位置,getSpanIndex(position)但是位置(parent.getChildAdapterPosition(view))返回,NO_POSITION因为调用时已将对象从适配器中移除getItemOffsets()

有什么办法可以抵消我的情况吗?

@Override
public void getItemOffsets(Rect outRect, View view, 
                     RecyclerView parent, RecyclerView.State state) {

    GridLayoutManager mgr = parent.getLayoutManager();
    int position = parent.getChildAdapterPosition(view);

    if (position == RecyclerView.NO_POSITION) {
       // here I need to access the position of the current element
       // and call outRect.set(left, top , right, bottom);
       // which is not possible because it is no longer in the adapter
        return;
    } 

    int spanCount …
Run Code Online (Sandbox Code Playgroud)

android android-animation recycler-adapter android-recyclerview

6
推荐指数
2
解决办法
3999
查看次数