@@ -49,6 +49,7 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie | |||||
mDataList = dataList; | mDataList = dataList; | ||||
} | } | ||||
@Override | @Override | ||||
public FileShowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | public FileShowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||||
View view =mLayoutInflater.inflate(R.layout.item_file_picker_show, parent, false); | 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 | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
int position=holder.getAdapterPosition(); | int position=holder.getAdapterPosition(); | ||||
File file= mDataList.get(position).getFile(); | File file= mDataList.get(position).getFile(); | ||||
if (file.exists() && file.isFile()) | if (file.exists() && file.isFile()) | ||||
{ | { | ||||
@@ -95,6 +94,9 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie | |||||
mDataList.remove(position); | mDataList.remove(position); | ||||
} | } | ||||
notifyDataSetChanged(); | notifyDataSetChanged(); | ||||
if(callBack!=null){ | |||||
callBack.delete(); | |||||
} | |||||
} | } | ||||
}); | }); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
@@ -121,4 +123,12 @@ public class FilePickerShowAdapter extends RecyclerView.Adapter<RecyclerView.Vie | |||||
image_open=itemView.findViewById(R.id.image_open); | image_open=itemView.findViewById(R.id.image_open); | ||||
} | } | ||||
} | } | ||||
private CallBack callBack; | |||||
public void setCallBack(CallBack callBack){ | |||||
this.callBack= callBack; | |||||
} | |||||
public interface CallBack{ | |||||
void delete(); | |||||
} | |||||
} | } |
@@ -78,7 +78,7 @@ public class LocalCacheUtils { | |||||
// .thumbnail(0.1f) // 加载原始图片的10%作为缩略图 | // .thumbnail(0.1f) // 加载原始图片的10%作为缩略图 | ||||
.fitCenter() // 缩放图片以适应ImageView的尺寸 | .fitCenter() // 缩放图片以适应ImageView的尺寸 | ||||
// .override(150, 75) // 设置目标图片的宽度和高度 | // .override(150, 75) // 设置目标图片的宽度和高度 | ||||
.placeholder(R.mipmap.loading2) | |||||
.placeholder(R.mipmap.loading3) | |||||
// .error(R.mipmap.loadingerror) | // .error(R.mipmap.loadingerror) | ||||
.skipMemoryCache(true) // 禁用内存缓存 | .skipMemoryCache(true) // 禁用内存缓存 | ||||
.diskCacheStrategy(DiskCacheStrategy.NONE) | .diskCacheStrategy(DiskCacheStrategy.NONE) | ||||
@@ -78,7 +78,7 @@ public class ImageSourceActivity extends BaseActivity { | |||||
}); | }); | ||||
String cacheSize = getCacheSize(); | String cacheSize = getCacheSize(); | ||||
if(!cacheSize.isEmpty()){ | 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(); | rl_yx_file.getAdapter().notifyDataSetChanged(); | ||||
} | } | ||||
} | } | ||||
delete_all.setText("删除所有缓存图片"); | |||||
break; | break; | ||||
case R.id.baocunbendi://保存按钮 | case R.id.baocunbendi://保存按钮 | ||||
for (FileEntity item : PickerManager.getInstance().files) { | for (FileEntity item : PickerManager.getInstance().files) { | ||||
@@ -149,6 +150,7 @@ public class ImageSourceActivity extends BaseActivity { | |||||
} | } | ||||
rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); | rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); | ||||
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files); | FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files); | ||||
adapter.setCallBack(callBack); | |||||
rl_yx_file.setAdapter(adapter); | rl_yx_file.setAdapter(adapter); | ||||
adapter.setOnItemClickListener(new OnFileItemClickListener() { | adapter.setOnItemClickListener(new OnFileItemClickListener() { | ||||
@Override | @Override | ||||
@@ -166,8 +168,16 @@ public class ImageSourceActivity extends BaseActivity { | |||||
// startActivity(intent); | // 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) { | private static boolean checkExits(String path) { | ||||
for (FileEntity entity : PickerManager.getInstance().files) { | for (FileEntity entity : PickerManager.getInstance().files) { | ||||
if (entity.getPath().equals(path)) { | if (entity.getPath().equals(path)) { | ||||