From c86402dd7509f1e9e46c5e3a52afabceda887323 Mon Sep 17 00:00:00 2001 From: fyf Date: Mon, 10 Jul 2023 14:57:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=BA=9322?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../from/fragment/systeminternetfragment.java | 53 +++++++++++++ .../res/layout/fragment_system_internet.xml | 75 +++++++++++++++++-- 2 files changed, 121 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java index 6fde8f0b..e192df3c 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/systeminternetfragment.java @@ -11,6 +11,7 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; +import android.os.Environment; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; @@ -24,19 +25,23 @@ import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET; import com.bonait.bnframework.common.filepicker.PickerManager; import com.bonait.bnframework.common.filepicker.adapter.FilePickerShowAdapter; +import com.bonait.bnframework.common.filepicker.adapter.OnDeleteListener; import com.bonait.bnframework.common.filepicker.adapter.OnFileItemClickListener; import com.bonait.bnframework.common.filepicker.model.FileEntity; +import com.bonait.bnframework.common.filepicker.model.FileType; import com.bonait.bnframework.common.filepicker.util.OpenFile; import com.bonait.bnframework.common.image.utils.LocalCacheUtils; import com.bonait.bnframework.common.image.utils.MD5Encoder; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.view.MyLayoutManager; import com.bonait.bnframework.modules.home.fragment.from.FileActivity; +import com.bonait.bnframework.modules.home.fragment.mode.image_sp; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.arch.QMUIFragment; import java.io.File; import java.io.FileInputStream; +import java.util.ArrayList; import java.util.List; import butterknife.BindView; @@ -50,6 +55,8 @@ import pub.devrel.easypermissions.EasyPermissions; public class systeminternetfragment extends BaseFragment{ @BindView(R.id.rl_file) RecyclerView mRecyclerView; + @BindView(R.id.rl_yx_file) + RecyclerView rl_yx_file; @BindView(R.id.baocunbendi) Button baocunbendi; private Context context; @@ -65,6 +72,7 @@ public class systeminternetfragment extends BaseFragment{ super.onViewCreated(view, savedInstanceState); Logger.d("我的fragment创建"); context = getContext(); + FlushedImage(); } @OnClick({R.id.xuanzhewenjian,R.id.baocunbendi}) @@ -90,6 +98,51 @@ public class systeminternetfragment extends BaseFragment{ break; } } + ArrayList yx_files=new ArrayList<>(); + private static final String CACHE_PATH= Environment.getExternalStorageDirectory().getAbsolutePath()+"/hblxiaochaodb/WebImage"; + public void FlushedImage() + { + File path = new File(CACHE_PATH);// 获得路径 + File[] files = path.listFiles();// 读取文件 + yx_files.clear(); + for (File f : files) { + String absolutePath = f.getAbsolutePath(); + FileEntity e; + if (checkExits(absolutePath)) { + e = new FileEntity(absolutePath, f, true); + } else { + e = new FileEntity(absolutePath, f, false); + } + if(f.isFile()) + { + String[] imgs = {"png","jpg","jpeg","gif"}; + e.setFileType(new FileType("IMG",imgs,0)); + yx_files.add(e); + } + } + rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); + FilePickerShowAdapter adapter = new FilePickerShowAdapter(context,yx_files); + rl_yx_file.setAdapter(adapter); + adapter.setOnDeleteListener(new OnDeleteListener() { + @Override + public void delete(int position) { + File file= yx_files.get(position).getFile(); + if (file.exists() && file.isFile()) + { + file.delete(); + } + } + }); + } + + private static boolean checkExits(String path) { + for (FileEntity entity : PickerManager.getInstance().files) { + if (entity.getPath().equals(path)) { + return true; + } + } + return false; + } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { diff --git a/app/src/main/res/layout/fragment_system_internet.xml b/app/src/main/res/layout/fragment_system_internet.xml index 33b75b79..9771d61e 100644 --- a/app/src/main/res/layout/fragment_system_internet.xml +++ b/app/src/main/res/layout/fragment_system_internet.xml @@ -11,16 +11,77 @@ android:orientation="vertical" android:background="@color/main_background"> - + + + + + + + + + + + + + + android:orientation="vertical" + android:paddingLeft="@dimen/dp_10" + android:paddingRight="@dimen/dp_10"> + + + + + + + + + +