Browse Source

缓存提示

调味吧台
liup 7 months ago
parent
commit
7b8a55d815
3 changed files with 24 additions and 4 deletions
  1. +12
    -2
      app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java
  2. +1
    -1
      app/src/main/java/com/bonait/bnframework/common/image/utils/LocalCacheUtils.java
  3. +11
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java

+ 12
- 2
app/src/main/java/com/bonait/bnframework/common/filepicker/adapter/FilePickerShowAdapter.java View File

@@ -49,6 +49,7 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
mDataList = dataList;
}


@Override
public FileShowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view =mLayoutInflater.inflate(R.layout.item_file_picker_show, parent, false);
@@ -86,8 +87,6 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
@Override
public void onClick(View v) {
int position=holder.getAdapterPosition();


File file= mDataList.get(position).getFile();
if (file.exists() && file.isFile())
{
@@ -95,6 +94,9 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
mDataList.remove(position);
}
notifyDataSetChanged();
if(callBack!=null){
callBack.delete();
}
}
});
} catch (Exception e) {
@@ -121,4 +123,12 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie
image_open=itemView.findViewById(R.id.image_open);
}
}

private CallBack callBack;
public void setCallBack(CallBack callBack){
this.callBack= callBack;
}
public interface CallBack{
void delete();
}
}

+ 1
- 1
app/src/main/java/com/bonait/bnframework/common/image/utils/LocalCacheUtils.java View File

@@ -78,7 +78,7 @@ public class LocalCacheUtils {
// .thumbnail(0.1f) // 加载原始图片的10%作为缩略图
.fitCenter() // 缩放图片以适应ImageView的尺寸
// .override(150, 75) // 设置目标图片的宽度和高度
.placeholder(R.mipmap.loading2)
.placeholder(R.mipmap.loading3)
// .error(R.mipmap.loadingerror)
.skipMemoryCache(true) // 禁用内存缓存
.diskCacheStrategy(DiskCacheStrategy.NONE)


+ 11
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java View File

@@ -78,7 +78,7 @@ public class ImageSourceActivity extends BaseActivity {
});
String cacheSize = getCacheSize();
if(!cacheSize.isEmpty()){
delete_all.setText("已缓存:"+getCacheSize()+"\n删除所有缓存图片");
delete_all.setText("已缓存:"+cacheSize+"\n删除所有缓存图片");
}
}
/**
@@ -110,6 +110,7 @@ public class ImageSourceActivity extends BaseActivity {
rl_yx_file.getAdapter().notifyDataSetChanged();
}
}
delete_all.setText("删除所有缓存图片");
break;
case R.id.baocunbendi://保存按钮
for (FileEntity item : PickerManager.getInstance().files) {
@@ -149,6 +150,7 @@ public class ImageSourceActivity extends BaseActivity {
}
rl_yx_file.setLayoutManager(new LinearLayoutManager(context));
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files);
adapter.setCallBack(callBack);
rl_yx_file.setAdapter(adapter);
adapter.setOnItemClickListener(new OnFileItemClickListener() {
@Override
@@ -166,8 +168,16 @@ public class ImageSourceActivity extends BaseActivity {
// startActivity(intent);
}
});
delete_all.setText("已缓存:"+getCacheSize()+"\n删除所有缓存图片");
}

private FilePickerShowAdapter.CallBack callBack = new FilePickerShowAdapter.CallBack() {
@Override
public void delete() {
delete_all.setText("已缓存:"+getCacheSize()+"\n删除所有缓存图片");
}
};

private static boolean checkExits(String path) {
for (FileEntity entity : PickerManager.getInstance().files) {
if (entity.getPath().equals(path)) {


Loading…
Cancel
Save