Browse Source

删除fileUtils

Pq 3 years ago
parent
commit
a67038cd31

+ 58 - 31
BaseLibrary/src/main/java/com/cooleshow/base/utils/MyFileUtils.java

@@ -46,14 +46,15 @@ import java.util.Map;
 import okhttp3.ResponseBody;
 
 /**
- * 创建日期:2022/6/7 15:36
- *
- * @author Ryan
- * 类说明:
+ * Description:
+ * Copyright  : Copyright (c) 2019
+ * Company    : 大雅乐盟
+ * Author     : r
+ * Date       : 2019/9/6 15:07
  */
 public class MyFileUtils {
     private static final String TAG = "FileUtil";
-    private static final String filesDirectory =getCacheDir(Utils.getApp())+ File.separator+"cooleshow";
+    private static final String filesDirectory = getCacheDir(Utils.getApp())+ File.separator+"cooleshow";
     public static final String examDownloadDirectory = "examDownload";
 
     public static String getCacheDir(Context context) {
@@ -101,6 +102,28 @@ public class MyFileUtils {
         }
     }
 
+    public static String getPublicDirectory(String path) {
+        String fileDir = null;
+        try {
+            File file = new File(filesDirectory);
+            if (!file.exists()) {
+                file.mkdirs();
+            }
+            fileDir = file.getAbsolutePath();
+            if (!TextUtils.isEmpty(path)) {
+                File filePath = new File(file.getPath() + File.separator + path);
+                if (!filePath.exists()) {
+                    filePath.mkdirs();
+                }
+                fileDir = filePath.getAbsolutePath();
+            }
+            return fileDir;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
     public static String getPublicDirectoryDownload() {
         try {
             File file = Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS);
@@ -130,6 +153,30 @@ public class MyFileUtils {
         return s;
     }
 
+    /**
+     * 根据文件后缀名判断是否是图片(不一定准确)
+     *
+     * @param path
+     * @return
+     */
+    public static boolean isImg(String path) {
+        try {
+            File file = new File(path);
+            if (!file.exists()) {
+                return false;
+            }
+            int lastDot = file.getName().lastIndexOf(".");
+            if (lastDot < 0) {
+                return false;
+            }
+            String fileType = getFileType(file.getName(), lastDot);
+            return TextUtils.equals("file_image", fileType);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
     public static String getBase64Type(String str) {
         if (TextUtils.isEmpty(str)) {
             return "";
@@ -467,30 +514,6 @@ public class MyFileUtils {
     }
 
     /**
-     * 根据文件后缀名判断是否是图片(不一定准确)
-     *
-     * @param path
-     * @return
-     */
-    public static boolean isImg(String path) {
-        try {
-            File file = new File(path);
-            if (!file.exists()) {
-                return false;
-            }
-            int lastDot = file.getName().lastIndexOf(".");
-            if (lastDot < 0) {
-                return false;
-            }
-            String fileType = getFileType(file.getName(), lastDot);
-            return TextUtils.equals("file_image", fileType);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return false;
-    }
-
-    /**
      * 根据后缀得到文件类型
      *
      * @param fileName
@@ -1096,7 +1119,11 @@ public class MyFileUtils {
             return false;
         }
         try {
-            File futureStudioIconFile = new File(filePath + File.separator + fileName);
+            File parentFile = new File(filePath);
+            if (!parentFile.exists()) {
+                parentFile.mkdirs();
+            }
+            File futureStudioIconFile = new File(parentFile, fileName);
             InputStream inputStream = null;
             OutputStream outputStream = null;
             try {
@@ -1329,7 +1356,7 @@ public class MyFileUtils {
         File file = new File(Path);
         Intent intent = new Intent();
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.setAction(android.content.Intent.ACTION_VIEW);
+        intent.setAction(Intent.ACTION_VIEW);
         intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
         return intent;
     }

+ 9 - 22
student/src/main/java/com/cooleshow/student/ui/main/MallFragment.java

@@ -18,7 +18,6 @@ import android.os.Message;
 import android.text.TextUtils;
 import android.util.Base64;
 import android.util.Log;
-import android.view.KeyEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.webkit.GeolocationPermissions;
@@ -37,7 +36,6 @@ import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
 import androidx.constraintlayout.widget.ConstraintLayout;
 
 import com.alipay.sdk.app.PayTask;
@@ -48,14 +46,10 @@ import com.cooleshow.base.constanst.Constants;
 import com.cooleshow.base.data.net.RetrofitClientNoToken;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
 import com.cooleshow.base.utils.AppUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
-import com.cooleshow.base.utils.UriUtils;
-import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
-import com.cooleshow.base.utils.helper.upload.UploadHelper;
 import com.cooleshow.base.widgets.DialogUtil;
-import com.cooleshow.student.App;
 import com.cooleshow.student.R;
 import com.cooleshow.student.api.APIService;
 import com.cooleshow.student.bean.alipay.AuthResult;
@@ -63,20 +57,14 @@ import com.cooleshow.student.bean.alipay.PayResult;
 import com.cooleshow.student.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.student.databinding.FragmentMallBinding;
 import com.cooleshow.student.presenter.main.ShopMallPresenter;
-import com.cooleshow.student.ui.web.HtmlActivity;
-import com.cooleshow.student.widgets.FileUtils;
 import com.cooleshow.student.widgets.LollipopFixedWebView;
 import com.cooleshow.student.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
-import com.daya.live_teaching.model.UserInfo;
 import com.daya.live_teaching.utils.GlideEngine;
 import com.google.gson.Gson;
-import com.gyf.immersionbar.ImmersionBar;
 import com.luck.picture.lib.PictureSelector;
 import com.luck.picture.lib.config.PictureConfig;
 import com.luck.picture.lib.config.PictureMimeType;
-import com.luck.picture.lib.entity.LocalMedia;
-import com.luck.picture.lib.tools.PictureFileUtils;
 import com.tbruyelle.rxpermissions3.RxPermissions;
 import com.tencent.mm.opensdk.modelpay.PayReq;
 import com.tencent.mm.opensdk.openapi.IWXAPI;
@@ -103,7 +91,6 @@ import java.lang.ref.WeakReference;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -327,16 +314,16 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = FileUtils.getBase64Type(url.split(",")[0]);
+                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
                                     ToastUtil.getInstance().showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -351,14 +338,14 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -385,7 +372,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
                         .setShareboardclickCallback(new ShareBoardlistener() {
                             @Override
                             public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
-                                UMImage image = new UMImage(mContext, FileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
+                                UMImage image = new UMImage(mContext, MyFileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
                                 image.setThumb(image);
                                 image.compressStyle = UMImage.CompressStyle.SCALE;
                                 new ShareAction(getActivity()).withMedia(image)
@@ -680,7 +667,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -701,7 +688,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = FileUtils.startIntent(getContext(), filePath + File.separator + fileName);
+                                            Intent intent = MyFileUtils.startIntent(getContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {

+ 0 - 1
student/src/main/java/com/cooleshow/student/ui/mine/PersonalSettingActivity.java

@@ -30,7 +30,6 @@ import com.cooleshow.base.utils.GlideUtils;
 import com.cooleshow.base.utils.PopupUtil;
 import com.cooleshow.base.utils.ToastUtil;
 
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.student.R;
 import com.cooleshow.student.bean.StudentUserInfo;
 import com.cooleshow.student.bean.TeachableInstrumentBean;

+ 3 - 6
student/src/main/java/com/cooleshow/student/ui/web/AccompanyActivity.java

@@ -18,14 +18,13 @@ import com.alibaba.android.arouter.facade.annotation.Route;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.service.PlayMusicService;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.helper.WebParamsHelper;
 import com.cooleshow.base.utils.helper.upload.UploadHelper;
 import com.cooleshow.student.R;
 import com.cooleshow.student.databinding.ActivityAccompanyBinding;
 import com.cooleshow.student.presenter.web.AccompanyPresenter;
-import com.cooleshow.student.widgets.FileUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.gyf.immersionbar.ImmersionBar;
 import com.wonderkiln.camerakit.CameraKit;
@@ -46,8 +45,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
 
-import io.rong.imkit.utils.StatusBarUtil;
-
 /**
  * 创建日期:2022/6/8 14:19
  *
@@ -180,7 +177,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             @Override
             public void startCapture() {
                 if (cameraView != null) {
-                    recordVideFilePath = FileUtils.getPublicDirectory(videoDerectoryName) + File.separator
+                    recordVideFilePath = MyFileUtils.getPublicDirectory(videoDerectoryName) + File.separator
                             + "VID_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".mp4";
                     cameraView.captureVideo(new File(recordVideFilePath));//开始录像
                 }
@@ -194,7 +191,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
 
                 if (!file.exists()) {
                     ToastUtil.getInstance().showShort("未找到该视频,请重试");
-                    FileUtils.deleteFile(recordVideFilePath);
+                    MyFileUtils.deleteFile(recordVideFilePath);
                 }
                 String bucket = WebParamsHelper.getParams(jsonObject, "bucket");
                 UploadHelper uploadHelper = new UploadHelper(AccompanyActivity.this,bucket);

+ 8 - 17
student/src/main/java/com/cooleshow/student/ui/web/AccompanyFragment.java

@@ -11,19 +11,15 @@ import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.Configuration;
 import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
 import android.media.AudioDeviceInfo;
 import android.media.AudioManager;
 import android.media.SoundPool;
-import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
 import android.os.SystemClock;
-import android.provider.MediaStore;
 import android.text.TextUtils;
-import android.util.Base64;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.View;
@@ -54,9 +50,9 @@ import com.cooleshow.base.utils.AppUtils;
 import com.cooleshow.base.utils.HeadsetPlugListener;
 import com.cooleshow.base.utils.HeadsetPlugReceiver;
 import com.cooleshow.base.utils.LogUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.websocket.JWebSocketClient;
 import com.cooleshow.base.widgets.BaseDialog;
@@ -72,7 +68,6 @@ import com.cooleshow.student.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.student.databinding.FragmentAccompanyBinding;
 import com.cooleshow.student.helper.ShareHelper;
 import com.cooleshow.student.presenter.web.AccompanyPresenter;
-import com.cooleshow.student.widgets.FileUtils;
 import com.cooleshow.student.widgets.LollipopFixedWebView;
 import com.cooleshow.student.widgets.helper.JsInterfaceAccomPanyUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
@@ -102,7 +97,6 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.lang.ref.WeakReference;
 import java.net.URI;
 import java.security.MessageDigest;
@@ -110,7 +104,6 @@ import java.security.NoSuchAlgorithmException;
 import java.util.HashMap;
 import java.util.Map;
 
-import androidx.annotation.Nullable;
 import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
 import io.reactivex.rxjava3.annotations.NonNull;
 import io.reactivex.rxjava3.core.Observable;
@@ -119,8 +112,6 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
 import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
-import io.rong.imkit.utils.helper.OpenChatHelper;
-import io.rong.imlib.model.Conversation;
 import okhttp3.ResponseBody;
 
 /**
@@ -578,7 +569,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         }
         if (wavRecorder != null) {
             wavRecorder.stopRecording();
-            FileUtils.deleteFile(getVoicePath());
+            MyFileUtils.deleteFile(getVoicePath());
             wavRecorder.startRecording(getContext());
         } else {
             Observable.create((ObservableOnSubscribe<String>) emitter -> {
@@ -751,7 +742,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
         if (wavRecorder != null) {
             wavRecorder.stopRecording();
-            FileUtils.deleteFile(getVoicePath());
+            MyFileUtils.deleteFile(getVoicePath());
             wavRecorder.startRecording(getContext());
         } else {
             Observable.create((ObservableOnSubscribe<String>) emitter -> {
@@ -862,7 +853,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
     // 录音文件存储名称
     private String getVoicePath() {
-        return FileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
+        return MyFileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
     }
 
     /**
@@ -916,7 +907,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
             return;
         }
         wavRecorder.stopRecording();
-        FileUtils.deleteFile(getVoicePath());
+        MyFileUtils.deleteFile(getVoicePath());
     }
 
     /**
@@ -1391,7 +1382,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
                                         ToastUtil.getInstance().show(Utils.getApp(), "应用未安装,分享失败");
                                         return;
                                     }
-                                    UMImage image = new UMImage(mContext, FileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
+                                    UMImage image = new UMImage(mContext, MyFileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
                                     image.setThumb(image);
                                     image.compressStyle = UMImage.CompressStyle.SCALE;
                                     new ShareAction(getActivity()).withMedia(image)
@@ -1556,7 +1547,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = hashKeyForDisk(midiFile) + "." + type;
                                 File file = new File(path + "/" + name);
                                 if (file.exists() && file.length() > 0) {
@@ -1582,7 +1573,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
                                                 @Override
                                                 public void onNext(ResponseBody response) {
-                                                    if (FileUtils.writeFileToSDCard(response, path, name)) {
+                                                    if (MyFileUtils.writeFileToSDCard(response, path, name)) {
                                                         runOnUiThread(() -> {
                                                             midiFilePath = path + File.separator + name;
                                                             MidiPlayerUtils.getInstance().init(getActivity().getApplication(), midiFilePath);

+ 9 - 13
student/src/main/java/com/cooleshow/student/ui/web/HtmlActivity.java

@@ -45,7 +45,6 @@ import com.alibaba.android.arouter.launcher.ARouter;
 import com.alipay.sdk.app.PayTask;
 import com.cooleshow.base.BuildConfig;
 import com.cooleshow.base.bean.WxPayResult;
-import com.cooleshow.base.common.BaseApplication;
 import com.cooleshow.base.common.WebConstants;
 import com.cooleshow.base.constanst.Constants;
 import com.cooleshow.base.data.net.RetrofitClientNoToken;
@@ -53,9 +52,9 @@ import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseActivity;
 import com.cooleshow.base.utils.AppUtils;
 import com.cooleshow.base.utils.LogUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.UriUtils;
 import com.cooleshow.base.utils.helper.DialogHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
@@ -70,11 +69,9 @@ import com.cooleshow.student.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.student.databinding.ActivityHtml1Binding;
 import com.cooleshow.student.helper.ShareHelper;
 import com.cooleshow.student.ui.live.LiveRoomActivity;
-import com.cooleshow.student.widgets.FileUtils;
 import com.cooleshow.student.widgets.LollipopFixedWebView;
 import com.cooleshow.student.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
-import com.cooleshow.usercenter.utils.SavePicUtil;
 import com.daya.live_teaching.utils.GlideEngine;
 import com.google.gson.Gson;
 import com.gyf.immersionbar.ImmersionBar;
@@ -118,7 +115,6 @@ import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 import io.rong.imkit.utils.helper.OpenChatHelper;
-import io.rong.imlib.model.Conversation;
 import okhttp3.ResponseBody;
 
 @Route(path = RouterPath.WebCenter.ACTIVITY_HTML)
@@ -394,16 +390,16 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = FileUtils.getBase64Type(url.split(",")[0]);
+                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
                                     ToastUtil.getInstance().showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -418,14 +414,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -463,7 +459,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                                         ToastUtil.getInstance().show(getApplicationContext(), "应用未安装,分享失败");
                                         return;
                                     }
-                                    UMImage image = new UMImage(HtmlActivity.this, FileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
+                                    UMImage image = new UMImage(HtmlActivity.this, MyFileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
                                     image.setThumb(image);
                                     image.compressStyle = UMImage.CompressStyle.SCALE;
                                     new ShareAction(HtmlActivity.this).withMedia(image)
@@ -824,7 +820,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -845,7 +841,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = FileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
+                                            Intent intent = MyFileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {

+ 9 - 11
student/src/main/java/com/cooleshow/student/ui/web/HtmlHorizontalScreenActivity.java

@@ -50,9 +50,9 @@ import com.cooleshow.base.data.net.RetrofitClientNoToken;
 import com.cooleshow.base.router.RouterPath;
 import com.cooleshow.base.ui.activity.BaseActivity;
 import com.cooleshow.base.utils.AppUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.UriUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.utils.helper.DialogHelper;
@@ -67,7 +67,6 @@ import com.cooleshow.student.bean.alipay.PayResult;
 import com.cooleshow.student.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.student.databinding.ActivityHtml1Binding;
 import com.cooleshow.student.helper.ShareHelper;
-import com.cooleshow.student.widgets.FileUtils;
 import com.cooleshow.student.widgets.LollipopFixedWebView;
 import com.cooleshow.student.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
@@ -84,7 +83,6 @@ import com.tencent.mm.opensdk.modelpay.PayReq;
 import com.tencent.mm.opensdk.openapi.IWXAPI;
 import com.tencent.mm.opensdk.openapi.WXAPIFactory;
 import com.umeng.socialize.ShareAction;
-import com.umeng.socialize.ShareContent;
 import com.umeng.socialize.UMShareAPI;
 import com.umeng.socialize.UMShareListener;
 import com.umeng.socialize.bean.SHARE_MEDIA;
@@ -384,16 +382,16 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = FileUtils.getBase64Type(url.split(",")[0]);
+                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
                                     ToastUtil.getInstance().showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -408,14 +406,14 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -444,7 +442,7 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
                                     ToastUtil.getInstance().show(Utils.getApp(), "应用未安装,分享失败");
                                     return;
                                 }
-                                UMImage image = new UMImage(HtmlHorizontalScreenActivity.this, FileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
+                                UMImage image = new UMImage(HtmlHorizontalScreenActivity.this, MyFileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
                                 image.setThumb(image);
                                 image.compressStyle = UMImage.CompressStyle.SCALE;
                                 new ShareAction(HtmlHorizontalScreenActivity.this).withMedia(image)
@@ -780,7 +778,7 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -801,7 +799,7 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = FileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
+                                            Intent intent = MyFileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {

+ 0 - 1633
student/src/main/java/com/cooleshow/student/widgets/FileUtils.java

@@ -1,1633 +0,0 @@
-package com.cooleshow.student.widgets;
-
-import static android.os.Environment.DIRECTORY_DOWNLOADS;
-
-import android.annotation.SuppressLint;
-import android.content.ContentUris;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Environment;
-import android.provider.DocumentsContract;
-import android.provider.MediaStore;
-import android.provider.OpenableColumns;
-import android.text.TextUtils;
-import android.util.Base64;
-import android.util.Log;
-
-import com.cooleshow.base.utils.Utils;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.FileProvider;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.LineNumberReader;
-import java.io.OutputStream;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import okhttp3.ResponseBody;
-
-/**
- * Description:
- * Copyright  : Copyright (c) 2019
- * Company    : 大雅乐盟
- * Author     : r
- * Date       : 2019/9/6 15:07
- */
-public class FileUtils {
-    private static final String TAG = "FileUtil";
-    private static final String filesDirectory = getCacheDir(Utils.getApp()) + File.separator + "cooleshow";
-    public static final String examDownloadDirectory = "examDownload";
-
-    public static String getCacheDir(Context context) {
-        String cacheDir = context.getExternalCacheDir().getAbsolutePath();
-        return cacheDir;
-    }
-
-    public static String getCacheDir(Context context, String directory) {
-        String fileDir;
-        try {
-            File file = new File(context.getExternalCacheDir() + File.separator + directory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            fileDir = file.getAbsolutePath();
-            return fileDir;
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    public static String getFilesDir(Context context) {
-        try {
-            File file = context.getExternalFilesDir(filesDirectory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            String fileDir = file.getAbsolutePath();
-            return fileDir;
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    public static String getFilesDir(Context context, String directory) {
-        try {
-            File file = context.getExternalFilesDir(filesDirectory + File.separator + directory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            String fileDir = file.getAbsolutePath();
-            return fileDir;
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    public static String getPublicDirectory(String path) {
-        String fileDir = null;
-        try {
-            File file = new File(filesDirectory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            fileDir = file.getAbsolutePath();
-            if (!TextUtils.isEmpty(path)) {
-                File filePath = new File(file.getPath() + File.separator + path);
-                if (!filePath.exists()) {
-                    filePath.mkdirs();
-                }
-                fileDir = filePath.getAbsolutePath();
-            }
-            return fileDir;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return "";
-        }
-    }
-
-    public static String getPublicDirectoryDownload() {
-        try {
-            File file = Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS);
-            return file.getAbsolutePath();
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    /**
-     * 获取该路径下全部的文件名
-     *
-     * @param path
-     * @return
-     */
-    public static List<String> getFilesAllName(String path) {
-        File file = new File(path);
-        File[] files = file.listFiles();
-        if (files == null) {
-            Log.e("error", "空目录");
-            return null;
-        }
-        List<String> s = new ArrayList<>();
-        for (int i = 0; i < files.length; i++) {
-            s.add(files[i].getAbsolutePath());
-        }
-        return s;
-    }
-
-    public static String getBase64Type(String str) {
-        if (TextUtils.isEmpty(str)) {
-            return "";
-        }
-        String type = "";
-        switch (str) {
-            case "data:application/msword;base64":
-                type = "doc";
-            case "data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64":
-                type = "docx";
-            case "data:application/vnd.ms-excel;base64":
-                type = "xls";
-            case "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64":
-                type = "xlsx";
-            case "data:application/pdf;base64":
-                type = "pdf";
-            case "data:application/vnd.ms-powerpoint;base64":
-                type = "ppt";
-            case "data:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64":
-                type = "pptx";
-            case "data:text/plain;base64":
-                type = "txt";
-            case "data:image/png;base64":
-                type = "png";
-            case "data:image/jpeg;base64":
-                type = "jpg";
-        }
-        return type;
-    }
-
-    /**
-     * 从sd卡取文件
-     *
-     * @param filename
-     * @return
-     */
-    public String getFileFromSdcard(String filename) {
-        ByteArrayOutputStream outputStream = null;
-        FileInputStream fis = null;
-        try {
-            outputStream = new ByteArrayOutputStream();
-            File file = new File(Environment.getExternalStorageDirectory(), filename);
-            if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
-                fis = new FileInputStream(file);
-                int len = 0;
-                byte[] data = new byte[1024];
-                while ((len = fis.read(data)) != -1) {
-                    outputStream.write(data, 0, len);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                outputStream.close();
-                fis.close();
-            } catch (IOException e) {
-            }
-        }
-        return new String(outputStream.toByteArray());
-    }
-
-    /**
-     * 保存文件到sd
-     *
-     * @param filename
-     * @param content
-     * @return
-     */
-    public static boolean saveContentToSdcard(String filename, String content) {
-        boolean flag;
-        FileOutputStream fos = null;
-        content += "\r\n";
-        try {
-            File file = new File(filename);
-            if (file.exists()) {
-                file.mkdirs();
-            }
-            fos = new FileOutputStream(file, true);
-            fos.write(content.getBytes());
-            flag = true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            flag = false;
-        } finally {
-            try {
-                if (fos != null) {
-                    fos.close();
-                }
-            } catch (IOException e) {
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 保存文件到sd
-     *
-     * @param
-     * @param
-     * @return
-     */
-    public static boolean saveFileToSdcard(String mPath, InputStream inputStream) {
-        byte[] mData = null;
-        try {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            int len = 0;
-            byte[] bytes = new byte[1024];
-            while ((len = inputStream.read(bytes)) != -1) {
-                baos.write(bytes, 0, len);
-            }
-            mData = baos.toByteArray();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        try {
-            FileOutputStream fos = new FileOutputStream(new File(mPath));
-            fos.write(mData, 0, mData.length);
-            return true;
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return false;
-    }
-
-    /**
-     * 取得文件大小
-     *
-     * @param f
-     * @return
-     */
-    public static long getFileSizes(File f) {
-        long size = 0;
-        try {
-            if (f.exists()) {
-                FileInputStream fis = null;
-                fis = new FileInputStream(f);
-                size = fis.available();
-            } else {
-                f.createNewFile();
-            }
-        } catch (Exception e) {
-        }
-
-        return size;
-    }
-
-    /**
-     * 递归取得文件夹大小
-     *
-     * @param dir
-     * @return
-     * @throws Exception
-     */
-    public static long getFileSize(File dir) throws Exception {
-        long size = 0;
-        File flist[] = dir.listFiles();
-        for (int i = 0; i < flist.length; i++) {
-            if (flist[i].isDirectory()) {
-                size = size + getFileSize(flist[i]);
-            } else {
-                size = size + flist[i].length();
-            }
-        }
-        return size;
-    }
-
-    /**
-     * 转换文件大小
-     *
-     * @param fileS
-     * @return
-     */
-    public static String FormetFileSize(long fileS) {
-        DecimalFormat df = new DecimalFormat("#.00");
-        String fileSizeString = "";
-        if (fileS < 1024) {
-            fileSizeString = df.format((double) fileS) + "B";
-        } else if (fileS < 1048576) {
-            fileSizeString = df.format((double) fileS / 1024) + "K";
-        } else if (fileS < 1073741824) {
-            fileSizeString = df.format((double) fileS / 1048576) + "M";
-        } else {
-            fileSizeString = df.format((double) fileS / 1073741824) + "G";
-        }
-        return fileSizeString;
-    }
-
-    /**
-     * 递归求取目录文件个数
-     *
-     * @param f
-     * @return
-     */
-    public static long getlist(File f) {
-        long size = 0;
-        File flist[] = f.listFiles();
-        size = flist.length;
-        for (int i = 0; i < flist.length; i++) {
-            if (flist[i].isDirectory()) {
-                size = size + getlist(flist[i]);
-                size--;
-            }
-        }
-        return size;
-    }
-
-    /**
-     * 在根目录下搜索文件
-     *
-     * @param keyword
-     * @return
-     */
-    public static String searchFile(String keyword) {
-        String result = "";
-        File[] files = new File("/").listFiles();
-        for (File file : files) {
-            if (file.getName().indexOf(keyword) >= 0) {
-                result += file.getPath() + "\n";
-            }
-        }
-        if (result.equals("")) {
-            result = "找不到文件!!";
-        }
-        return result;
-    }
-
-    /**
-     *
-     */
-    public static List<String> search(File file, String[] ext) {
-        List<String> list = new ArrayList<String>();
-        if (file != null) {
-            if (file.isDirectory()) {
-                File[] listFile = file.listFiles();
-                if (listFile != null) {
-                    for (int i = 0; i < listFile.length; i++) {
-                        search(listFile[i], ext);
-                    }
-                }
-            } else {
-                String filename = file.getAbsolutePath();
-                for (int i = 0; i < ext.length; i++) {
-                    if (filename.endsWith(ext[i])) {
-                        list.add(filename);
-                        break;
-                    }
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * 查询文件
-     *
-     * @param file
-     * @param keyword
-     * @return
-     */
-    public static List<File> FindFile(File file, String keyword) {
-        List<File> list = new ArrayList<File>();
-        if (file.isDirectory()) {
-            File[] files = file.listFiles();
-            if (files != null) {
-                for (File tempf : files) {
-                    if (tempf.isDirectory()) {
-                        if (tempf.getName().toLowerCase().lastIndexOf(keyword) > -1) {
-                            list.add(tempf);
-                        }
-                        list.addAll(FindFile(tempf, keyword));
-                    } else {
-                        if (tempf.getName().toLowerCase().lastIndexOf(keyword) > -1) {
-                            list.add(tempf);
-                        }
-                    }
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * searchFile 查找文件并加入到ArrayList 当中去
-     *
-     * @param context
-     * @param keyword
-     * @param filepath
-     * @return
-     */
-    public static List<Map<String, Object>> searchFile(Context context, String keyword, File filepath) {
-        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
-        Map<String, Object> rowItem = null;
-        int index = 0;
-        // 判断SD卡是否存在
-        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-            File[] files = filepath.listFiles();
-            if (files.length > 0) {
-                for (File file : files) {
-                    if (file.isDirectory()) {
-                        if (file.getName().toLowerCase().lastIndexOf(keyword) > -1) {
-                            rowItem = new HashMap<String, Object>();
-                            rowItem.put("number", index); // 加入序列号
-                            rowItem.put("fileName", file.getName());// 加入名称
-                            rowItem.put("path", file.getPath()); // 加入路径
-                            rowItem.put("size", file.length() + ""); // 加入文件大小
-                            list.add(rowItem);
-                        }
-                        // 如果目录可读就执行(一定要加,不然会挂掉)
-                        if (file.canRead()) {
-                            list.addAll(searchFile(context, keyword, file)); // 如果是目录,递归查找
-                        }
-                    } else {
-                        // 判断是文件,则进行文件名判断
-                        try {
-                            if (file.getName().indexOf(keyword) > -1 || file.getName().indexOf(keyword.toUpperCase()) > -1) {
-                                rowItem = new HashMap<String, Object>();
-                                rowItem.put("number", index); // 加入序列号
-                                rowItem.put("fileName", file.getName());// 加入名称
-                                rowItem.put("path", file.getPath()); // 加入路径
-                                rowItem.put("size", file.length() + ""); // 加入文件大小
-                                list.add(rowItem);
-                                index++;
-                            }
-                        } catch (Exception e) {
-                        }
-                    }
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * 根据后缀得到文件类型
-     *
-     * @param fileName
-     * @param pointIndex
-     * @return
-     */
-    public static String getFileType(String fileName, int pointIndex) {
-        String type = fileName.substring(pointIndex + 1).toLowerCase();
-        if ("m4a".equalsIgnoreCase(type) || "xmf".equalsIgnoreCase(type) || "ogg".equalsIgnoreCase(type) || "wav".equalsIgnoreCase(type)
-                || "m4a".equalsIgnoreCase(type) || "aiff".equalsIgnoreCase(type) || "midi".equalsIgnoreCase(type)
-                || "vqf".equalsIgnoreCase(type) || "aac".equalsIgnoreCase(type) || "flac".equalsIgnoreCase(type)
-                || "tak".equalsIgnoreCase(type) || "wv".equalsIgnoreCase(type)) {
-            type = "file_audio";
-        } else if ("mp3".equalsIgnoreCase(type) || "mid".equalsIgnoreCase(type)) {
-            type = "file_mp3";
-        } else if ("avi".equalsIgnoreCase(type) || "mp4".equalsIgnoreCase(type) || "dvd".equalsIgnoreCase(type)
-                || "mid".equalsIgnoreCase(type) || "mov".equalsIgnoreCase(type) || "mkv".equalsIgnoreCase(type)
-                || "mp2v".equalsIgnoreCase(type) || "mpe".equalsIgnoreCase(type) || "mpeg".equalsIgnoreCase(type)
-                || "mpg".equalsIgnoreCase(type) || "asx".equalsIgnoreCase(type) || "asf".equalsIgnoreCase(type)
-                || "flv".equalsIgnoreCase(type) || "navi".equalsIgnoreCase(type) || "divx".equalsIgnoreCase(type)
-                || "rm".equalsIgnoreCase(type) || "rmvb".equalsIgnoreCase(type) || "dat".equalsIgnoreCase(type)
-                || "mpa".equalsIgnoreCase(type) || "vob".equalsIgnoreCase(type) || "3gp".equalsIgnoreCase(type)
-                || "swf".equalsIgnoreCase(type) || "wmv".equalsIgnoreCase(type)) {
-            type = "file_video";
-        } else if ("bmp".equalsIgnoreCase(type) || "pcx".equalsIgnoreCase(type) || "tiff".equalsIgnoreCase(type)
-                || "gif".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type) || "tga".equalsIgnoreCase(type)
-                || "exif".equalsIgnoreCase(type) || "fpx".equalsIgnoreCase(type) || "psd".equalsIgnoreCase(type)
-                || "cdr".equalsIgnoreCase(type) || "raw".equalsIgnoreCase(type) || "eps".equalsIgnoreCase(type)
-                || "gif".equalsIgnoreCase(type) || "jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)
-                || "png".equalsIgnoreCase(type) || "hdri".equalsIgnoreCase(type) || "ai".equalsIgnoreCase(type)) {
-            type = "file_image";
-        } else if ("ppt".equalsIgnoreCase(type) || "doc".equalsIgnoreCase(type) || "xls".equalsIgnoreCase(type)
-                || "pps".equalsIgnoreCase(type) || "xlsx".equalsIgnoreCase(type) || "xlsm".equalsIgnoreCase(type)
-                || "pptx".equalsIgnoreCase(type) || "pptm".equalsIgnoreCase(type) || "ppsx".equalsIgnoreCase(type)
-                || "maw".equalsIgnoreCase(type) || "mdb".equalsIgnoreCase(type) || "pot".equalsIgnoreCase(type)
-                || "msg".equalsIgnoreCase(type) || "oft".equalsIgnoreCase(type) || "xlw".equalsIgnoreCase(type)
-                || "wps".equalsIgnoreCase(type) || "rtf".equalsIgnoreCase(type) || "ppsm".equalsIgnoreCase(type)
-                || "potx".equalsIgnoreCase(type) || "potm".equalsIgnoreCase(type) || "ppam".equalsIgnoreCase(type)) {
-            type = "ic_file_office";
-        } else if ("txt".equalsIgnoreCase(type) || "text".equalsIgnoreCase(type) || "chm".equalsIgnoreCase(type)
-                || "hlp".equalsIgnoreCase(type) || "pdf".equalsIgnoreCase(type) || "doc".equalsIgnoreCase(type)
-                || "docx".equalsIgnoreCase(type) || "docm".equalsIgnoreCase(type) || "dotx".equalsIgnoreCase(type)) {
-            type = "file_text";
-        } else if ("ini".equalsIgnoreCase(type) || "sys".equalsIgnoreCase(type) || "dll".equalsIgnoreCase(type)
-                || "adt".equalsIgnoreCase(type)) {
-            type = "file_system";
-        } else if ("rar".equalsIgnoreCase(type) || "zip".equalsIgnoreCase(type) || "arj".equalsIgnoreCase(type)
-                || "gz".equalsIgnoreCase(type) || "z".equalsIgnoreCase(type) || "7Z".equalsIgnoreCase(type) || "GZ".equalsIgnoreCase(type)
-                || "BZ".equalsIgnoreCase(type) || "ZPAQ".equalsIgnoreCase(type)) {
-            type = "ic_file_rar";
-        } else if ("html".equalsIgnoreCase(type) || "htm".equalsIgnoreCase(type) || "java".equalsIgnoreCase(type)
-                || "php".equalsIgnoreCase(type) || "asp".equalsIgnoreCase(type) || "aspx".equalsIgnoreCase(type)
-                || "jsp".equalsIgnoreCase(type) || "shtml".equalsIgnoreCase(type) || "xml".equalsIgnoreCase(type)) {
-            type = "file_web";
-        } else if ("exe".equalsIgnoreCase(type) || "com".equalsIgnoreCase(type) || "bat".equalsIgnoreCase(type)
-                || "iso".equalsIgnoreCase(type) || "msi".equalsIgnoreCase(type)) {
-            type = "file_exe";
-        } else if ("apk".equalsIgnoreCase(type)) {
-            type = "ic_file_apk";
-        } else {
-            type = "ic_file_normal";
-        }
-        return type;
-    }
-
-    /**
-     * 改变文件大小显示的内容
-     *
-     * @param size
-     * @return
-     */
-    public static String changeFileSize(String size) {
-        if (Integer.parseInt(size) > 1024) {
-            size = Integer.parseInt(size) / 1024 + "K";
-        } else if (Integer.parseInt(size) > (1024 * 1024)) {
-            size = Integer.parseInt(size) / (1024 * 1024) + "M";
-        } else if (Integer.parseInt(size) > (1024 * 1024 * 1024)) {
-            size = Integer.parseInt(size) / (1024 * 1024 * 1024) + "G";
-        } else {
-            size += "B";
-        }
-        return size;
-    }
-
-    /**
-     * 得到所有文件
-     *
-     * @param dir
-     * @return
-     */
-    public static ArrayList<File> getAllFiles(File dir) {
-        ArrayList<File> allFiles = new ArrayList<File>();
-        // 递归取得目录下的所有文件及文件夹
-        File[] files = dir.listFiles();
-        for (int i = 0; i < files.length; i++) {
-            File file = files[i];
-            allFiles.add(file);
-            if (file.isDirectory()) {
-                getAllFiles(file);
-            }
-        }
-        return allFiles;
-    }
-
-    /**
-     * 判断文件MimeType 类型
-     *
-     * @param f
-     * @return
-     */
-    public static String getMIMEType(File f) {
-        String type = "";
-        String fName = f.getName();
-        /* 取得扩展名 */
-        String end = fName.substring(fName.lastIndexOf(".") + 1, fName.length()).toLowerCase();
-        /* 依扩展名的类型决定MimeType */
-        if (end.equalsIgnoreCase("m4a") || end.equalsIgnoreCase("mp3") || end.equalsIgnoreCase("mid") || end.equalsIgnoreCase("xmf")
-                || end.equalsIgnoreCase("ogg") || end.equalsIgnoreCase("wav")) {
-            type = "audio";
-        } else if (end.equalsIgnoreCase("3gp") || end.equalsIgnoreCase("mp4")) {
-            type = "video";
-        } else if (end.equalsIgnoreCase("jpg") || end.equalsIgnoreCase("gif") || end.equalsIgnoreCase("png")
-                || end.equalsIgnoreCase("jpeg") || end.equalsIgnoreCase("bmp")) {
-            type = "image";
-        } else if (end.equalsIgnoreCase("apk")) {
-            /* android.permission.INSTALL_PACKAGES */
-            type = "application/vnd.android.package-archive";
-        } else if (end.equalsIgnoreCase("txt") || end.equalsIgnoreCase("java")) {
-            /* android.permission.INSTALL_PACKAGES */
-            type = "text";
-        } else {
-            type = "*";
-        }
-        /* 如果无法直接打开,就跳出软件列表给用户选择 */
-        if (end.equalsIgnoreCase("apk")) {
-        } else {
-            type += "/*";
-        }
-        return type;
-    }
-
-    /**
-     * 拷贝文件
-     *
-     * @param fromFile
-     * @param toFile
-     * @throws IOException
-     */
-    public static void copyFile(File fromFile, String toFile) throws IOException {
-        FileInputStream from = null;
-        FileOutputStream to = null;
-        try {
-            from = new FileInputStream(fromFile);
-            to = new FileOutputStream(toFile);
-            byte[] buffer = new byte[1024];
-            int bytesRead;
-            while ((bytesRead = from.read(buffer)) != -1)
-                to.write(buffer, 0, bytesRead); // write
-        } finally {
-            if (from != null)
-                try {
-                    from.close();
-                } catch (IOException e) {
-                    Log.e(TAG, "", e);
-                }
-            if (to != null)
-                try {
-                    to.close();
-                } catch (IOException e) {
-                    Log.e(TAG, "", e);
-                }
-        }
-    }
-
-    /**
-     * 创建文件
-     *
-     * @param file
-     * @return
-     */
-    public static File createNewFile(File file) {
-        try {
-            if (file.exists()) {
-                return file;
-            }
-            File dir = file.getParentFile();
-            if (!dir.exists()) {
-                dir.mkdirs();
-            }
-            if (!file.exists()) {
-                file.createNewFile();
-            }
-        } catch (IOException e) {
-            Log.e(TAG, "", e);
-            return null;
-        }
-        return file;
-    }
-
-    /**
-     * 创建文件
-     *
-     * @param path
-     */
-    public static File createNewFile(String path) {
-        File file = new File(path);
-        return createNewFile(file);
-    }// end method createText()
-
-    /**
-     * 删除文件
-     *
-     * @param path
-     */
-    public static void deleteFile(String path) {
-        if (TextUtils.isEmpty(path)) {
-            return;
-        }
-        File file = new File(path);
-        deleteFile(file);
-    }
-
-    /**
-     * 删除文件
-     *
-     * @param file
-     */
-    public static void deleteFile(File file) {
-        try {
-            if (!file.exists()) {
-                return;
-            }
-            if (file.isFile()) {
-                file.delete();
-            } else if (file.isDirectory()) {
-                File files[] = file.listFiles();
-                for (int i = 0; i < files.length; i++) {
-                    deleteFile(files[i]);
-                }
-            }
-            file.delete();
-        } catch (Exception e) {
-        }
-
-    }
-
-    /**
-     * 向Text文件中写入内容
-     *
-     * @param content
-     * @return
-     */
-    public static boolean write(String path, String content) {
-        return write(path, content, false);
-    }
-
-    public static boolean write(String path, String content, boolean append) {
-        return write(new File(path), content, append);
-    }
-
-    public static boolean write(File file, String content) {
-        return write(file, content, false);
-    }
-
-    /**
-     * 写入文件
-     *
-     * @param file
-     * @param content
-     * @param append
-     * @return
-     */
-    public static boolean write(File file, String content, boolean append) {
-        if (file == null || TextUtils.isEmpty(content)) {
-            return false;
-        }
-        if (!file.exists()) {
-            file = createNewFile(file);
-        }
-        FileOutputStream fos = null;
-        try {
-            fos = new FileOutputStream(file, append);
-            fos.write(content.getBytes());
-        } catch (Exception e) {
-            Log.e(TAG, "", e);
-            return false;
-        } finally {
-            try {
-                fos.close();
-            } catch (IOException e) {
-                Log.e(TAG, "", e);
-            }
-            fos = null;
-        }
-        return true;
-    }
-
-    /**
-     * 获得文件名
-     *
-     * @param path
-     * @return
-     */
-    public static String getFileName(String path) {
-        if (TextUtils.isEmpty(path)) {
-            return null;
-        }
-        File f = new File(path);
-        String name = f.getName();
-        f = null;
-        return name;
-    }
-
-    /**
-     * 读取文件内容,从第startLine行开始,读取lineCount行
-     *
-     * @param file
-     * @param startLine
-     * @param lineCount
-     * @return 读到文字的list, 如果list.size<lineCount则说明读到文件末尾了
-     */
-    public static List<String> readFile(File file, int startLine, int lineCount) {
-        if (file == null || startLine < 1 || lineCount < 1) {
-            return null;
-        }
-        if (!file.exists()) {
-            return null;
-        }
-        FileReader fileReader = null;
-        List<String> list = null;
-        try {
-            list = new ArrayList<String>();
-            fileReader = new FileReader(file);
-            LineNumberReader lineReader = new LineNumberReader(fileReader);
-            boolean end = false;
-            for (int i = 1; i < startLine; i++) {
-                if (lineReader.readLine() == null) {
-                    end = true;
-                    break;
-                }
-            }
-            if (end == false) {
-                for (int i = startLine; i < startLine + lineCount; i++) {
-                    String line = lineReader.readLine();
-                    if (line == null) {
-                        break;
-                    }
-                    list.add(line);
-                }
-            }
-        } catch (Exception e) {
-            Log.e(TAG, "read log error!", e);
-        } finally {
-            if (fileReader != null) {
-                try {
-                    fileReader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * 创建文件夹
-     *
-     * @param dir
-     * @return
-     */
-    public static boolean createDir(File dir) {
-        try {
-            if (!dir.exists()) {
-                dir.mkdirs();
-            }
-            return true;
-        } catch (Exception e) {
-            Log.e(TAG, "create dir error", e);
-            return false;
-        }
-    }
-
-    /**
-     * 在SD卡上创建目录
-     *
-     * @param dirName
-     */
-    public static File creatSDDir(String dirName) {
-        File dir = new File(dirName);
-        dir.mkdir();
-        return dir;
-    }
-
-    /**
-     * 判断SD卡上的文件是否存在
-     */
-    public static boolean isFileExist(String fileName) {
-        File file = new File(fileName);
-
-        return file == null ? false : file.exists();
-    }
-
-    /**
-     * 将一个InputStream里面的数据写入到SD卡中
-     */
-    public static File write2SDFromInput(String path, String fileName, InputStream input) {
-        File file = null;
-        OutputStream output = null;
-        try {
-            creatSDDir(path);
-            file = createNewFile(path + "/" + fileName);
-            output = new FileOutputStream(file);
-            byte buffer[] = new byte[1024];
-            int len = -1;
-            while ((len = input.read(buffer)) != -1) {
-                output.write(buffer, 0, len);
-            }
-            output.flush();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                output.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return file;
-    }
-
-    /**
-     * 读取文件内容 从文件中一行一行的读取文件
-     *
-     * @param file
-     * @return
-     */
-    public static String readFile(File file) {
-        FileReader read = null;
-        String content = "";
-        String result = "";
-        BufferedReader br = null;
-        try {
-            read = new FileReader(file);
-            br = new BufferedReader(read);
-            while ((content = br.readLine().toString().trim()) != null) {
-                result += content + "\r\n";
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                read.close();
-                br.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * 将图片保存到本地时进行压缩, 即将图片从Bitmap形式变为File形式时进行压缩,
-     * 特点是: File形式的图片确实被压缩了, 但是当你重新读取压缩后的file为 Bitmap是,它占用的内存并没有改变
-     *
-     * @param bmp
-     * @param file
-     */
-    public static void compressBmpToFile(Bitmap bmp, File file) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        int options = 100;// 个人喜欢从80开始,
-        bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
-        while (baos.toByteArray().length / 1024 > 100) {
-            baos.reset();
-            options -= 10;
-            bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
-        }
-        try {
-            FileOutputStream fos = new FileOutputStream(file);
-            fos.write(baos.toByteArray());
-            fos.flush();
-            fos.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * 将图片从本地读到内存时,进行压缩 ,即图片从File形式变为Bitmap形式
-     * 特点: 通过设置采样率, 减少图片的像素, 达到对内存中的Bitmap进行压缩
-     *
-     * @param srcPath
-     * @return
-     */
-    public static Bitmap compressImageFromFile(String srcPath, float pixWidth, float pixHeight) {
-        BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inJustDecodeBounds = true;// 只读边,不读内容
-        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, options);
-        options.inJustDecodeBounds = false;
-        int w = options.outWidth;
-        int h = options.outHeight;
-        //float pixWidth = 800f;//
-        //float pixHeight = 480f;//
-        int scale = 1;
-        if (w > h && w > pixWidth) {
-            scale = (int) (options.outWidth / pixWidth);
-        } else if (w < h && h > pixHeight) {
-            scale = (int) (options.outHeight / pixHeight);
-        }
-        if (scale <= 0)
-            scale = 1;
-        options.inSampleSize = scale;// 设置采样率
-        options.inPreferredConfig = Bitmap.Config.ARGB_8888;// 该模式是默认的,可不设
-        options.inPurgeable = true;// 同时设置才会有效
-        options.inInputShareable = true;// 。当系统内存不够时候图片自动被回收
-        bitmap = BitmapFactory.decodeFile(srcPath, options);
-        // return compressBmpFromBmp(bitmap);//原来的方法调用了这个方法企图进行二次压缩
-        // 其实是无效的,大家尽管尝试
-        return bitmap;
-    }
-
-    /**
-     * 指定分辨率和清晰度的图片压缩
-     */
-    public void transImage(String fromFile, String toFile, int width, int height, int quality) {
-        try {
-            Bitmap bitmap = BitmapFactory.decodeFile(fromFile);
-            int bitmapWidth = bitmap.getWidth();
-            int bitmapHeight = bitmap.getHeight();
-            // 缩放图片的尺寸
-            float scaleWidth = (float) width / bitmapWidth;
-            float scaleHeight = (float) height / bitmapHeight;
-            Matrix matrix = new Matrix();
-            matrix.postScale(scaleWidth, scaleHeight);
-            // 产生缩放后的Bitmap对象
-            Bitmap resizeBitmap = (Bitmap) Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, false);
-            // save file
-            File myCaptureFile = new File(toFile);
-            FileOutputStream out = new FileOutputStream(myCaptureFile);
-            if (resizeBitmap.compress(Bitmap.CompressFormat.JPEG, quality, out)) {
-                out.flush();
-                out.close();
-            }
-            if (!bitmap.isRecycled()) {
-                bitmap.recycle();//记得释放资源,否则会内存溢出
-            }
-            if (!resizeBitmap.isRecycled()) {
-                resizeBitmap.recycle();
-            }
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    public static String getFilePath(Bitmap bitmap) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        bitmap.compress(Bitmap.CompressFormat.PNG, 80, baos);
-        String path = Environment.getExternalStorageDirectory() + "/dayaWhiteBroad";
-        File dir = new File(path);
-        if (!dir.exists()) {
-            dir.mkdirs();
-        }
-        File file = new File(path + "/" + System.currentTimeMillis() + ".png");
-        try {
-            file.createNewFile();
-            FileOutputStream fos = new FileOutputStream(file);
-            InputStream is = new ByteArrayInputStream(baos.toByteArray());
-            int x = 0;
-            byte[] b = new byte[1024 * 100];
-            while ((x = is.read(b)) != -1) {
-                fos.write(b, 0, x);
-            }
-            fos.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return file.getPath();
-    }
-
-    /**
-     * 保存图片到图库
-     *
-     * @param bmp
-     */
-    public static void saveImageToGallery(Bitmap bmp, String path) {
-        // 首先保存图片
-        File file = new File(path);
-        try {
-            FileOutputStream fos = new FileOutputStream(file);
-            bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
-            fos.flush();
-            fos.close();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static boolean writeFileToSDCard(ResponseBody body, String filePath, String fileName) {
-        if (null == body) {
-            return false;
-        }
-        try {
-            File parentFile = new File(filePath);
-            if (!parentFile.exists()) {
-                parentFile.mkdirs();
-            }
-            File futureStudioIconFile = new File(parentFile, fileName);
-            InputStream inputStream = null;
-            OutputStream outputStream = null;
-            try {
-                byte[] fileReader = new byte[4096];
-                long fileSize = body.contentLength();
-                long fileSizeDownloaded = 0;
-                inputStream = body.byteStream();
-                outputStream = new FileOutputStream(futureStudioIconFile);
-                while (true) {
-                    int read = inputStream.read(fileReader);
-                    if (read == -1) {
-                        break;
-                    }
-                    outputStream.write(fileReader, 0, read);
-                    fileSizeDownloaded += read;
-                }
-                outputStream.flush();
-                return true;
-            } catch (IOException e) {
-                return false;
-            } finally {
-                if (inputStream != null) {
-                    inputStream.close();
-                }
-                if (outputStream != null) {
-                    outputStream.close();
-                }
-            }
-        } catch (IOException e) {
-            return false;
-        }
-    }
-
-    public static String uriToFile(Context context, Uri uri, String filePath) {
-        File privateFile = new File(filePath);
-        File fileParent = privateFile.getParentFile();
-        if (!fileParent.exists()) {
-            fileParent.mkdirs();
-        }
-        if (privateFile.exists()) return privateFile.getAbsolutePath();
-        InputStream ist = null;
-        OutputStream ost = null;
-        try {
-            privateFile.createNewFile();
-            ist = context.getContentResolver().openInputStream(uri);
-            ost = new FileOutputStream(privateFile);
-            byte[] buffer = new byte[4096];
-            int byteCount = 0;
-            while ((byteCount = ist.read(buffer)) != -1) {  // 循环从输入流读取 buffer字节
-                ost.write(buffer, 0, byteCount);        // 将读取的输入流写入到输出流
-            }
-        } catch (IOException e) {
-            return "";
-        } finally {
-            try {
-                if (ist != null) {
-                    ist.close();
-                }
-                if (ost != null) {
-                    ost.close();
-                }
-            } catch (IOException e) {
-                return "";
-            }
-        }
-        return privateFile.getAbsolutePath();
-    }
-
-    public static Intent startIntent(Context context, String path) {
-        if (TextUtils.isEmpty(path)) {
-            return null;
-        }
-        Intent intent = null;
-        switch (path.substring(path.lastIndexOf(".") + 1)) {
-            case "pdf":
-                intent = getPdfFileIntent(context, path);
-                break;
-            case "text":
-                intent = getTextFileIntent(context, path);
-                break;
-            case "html":
-                intent = getHtmlFileIntent(path);
-                break;
-            case "doc":
-            case "docx":
-                intent = getWordFileIntent(context, path);
-                break;
-            case "xls":
-            case "xlsx":
-                intent = getHtmlFileIntent(path);
-                break;
-        }
-        return intent;
-    }
-
-    //android获取一个用于打开HTML文件的intent
-    public static Intent getHtmlFileIntent(String Path) {
-        File file = new File(Path);
-        Uri uri = Uri.parse(file.toString()).buildUpon().encodedAuthority("com.android.htmlfileprovider").scheme("content").encodedPath(file.toString()).build();
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.setDataAndType(uri, "text/html");
-        return intent;
-    }
-
-    //android获取一个用于打开图片文件的intent
-    public static Intent getImageFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "image/*");
-        return intent;
-    }
-
-    //android获取一个用于打开PDF文件的intent
-    public static Intent getPdfFileIntent(Context context, String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = null;
-        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
-        if (isN) {
-            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
-        } else {
-            uri = Uri.fromFile(file);
-        }
-        intent.setDataAndType(uri, "application/pdf");
-        return intent;
-    }
-
-    //android获取一个用于打开文本文件的intent
-    public static Intent getTextFileIntent(Context context, String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = null;
-        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
-        if (isN) {
-            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
-        } else {
-            uri = Uri.fromFile(file);
-
-        }
-        intent.setDataAndType(uri, "text/plain");
-        return intent;
-    }
-
-    //android获取一个用于打开音频文件的intent
-    public static Intent getAudioFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        intent.putExtra("oneshot", 0);
-        intent.putExtra("configchange", 0);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "audio/*");
-        return intent;
-    }
-
-    //android获取一个用于打开视频文件的intent
-    public static Intent getVideoFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        intent.putExtra("oneshot", 0);
-        intent.putExtra("configchange", 0);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "video/*");
-        return intent;
-    }
-
-
-    //android获取一个用于打开CHM文件的intent
-    public static Intent getChmFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "application/x-chm");
-        return intent;
-    }
-
-
-    //android获取一个用于打开Word文件的intent
-    public static Intent getWordFileIntent(Context context, String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = null;
-        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
-        if (isN) {
-            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
-        } else {
-            uri = Uri.fromFile(file);
-
-        }
-        intent.setDataAndType(uri, "application/msword");
-        return intent;
-    }
-
-    //android获取一个用于打开Excel文件的intent
-    public static Intent getExcelFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "application/vnd.ms-excel");
-        return intent;
-    }
-
-    //android获取一个用于打开PPT文件的intent
-    public static Intent getPPTFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
-        return intent;
-    }
-
-    //android获取一个用于打开apk文件的intent
-    public static Intent getApkFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent();
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.setAction(Intent.ACTION_VIEW);
-        intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
-        return intent;
-    }
-
-
-    public static final String DOCUMENTS_DIR = "documents";
-
-    @SuppressLint("NewApi")
-    public static String getPath(final Context context, final Uri uri) {
-
-        final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
-
-        // DocumentProvider
-        if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
-            // ExternalStorageProvider
-            if (isExternalStorageDocument(uri)) {
-                final String docId = DocumentsContract.getDocumentId(uri);
-                final String[] split = docId.split(":");
-                final String type = split[0];
-
-                if ("primary".equalsIgnoreCase(type)) {
-                    return Environment.getExternalStorageDirectory() + "/" + split[1];
-                }
-            }
-            // DownloadsProvider
-            else if (isDownloadsDocument(uri)) {
-
-                final String id = DocumentsContract.getDocumentId(uri);
-
-                if (id != null && id.startsWith("raw:")) {
-                    return id.substring(4);
-                }
-
-                String[] contentUriPrefixesToTry = new String[]{
-                        "content://downloads/public_downloads",
-                        "content://downloads/my_downloads"
-                };
-
-                for (String contentUriPrefix : contentUriPrefixesToTry) {
-                    Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
-                    try {
-                        String path = getDataColumn(context, contentUri, null, null);
-                        if (path != null && !path.equals("")) {
-                            return path;
-                        }
-                    } catch (Exception e) {
-                    }
-                }
-
-                // path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
-                String fileName = getFileName(context, uri);
-                File cacheDir = getDocumentCacheDir(context);
-                File file = generateFileName(fileName, cacheDir);
-                String destinationPath = null;
-                if (file != null) {
-                    destinationPath = file.getAbsolutePath();
-                    saveFileFromUri(context, uri, destinationPath);
-                }
-
-                return destinationPath;
-            }
-            // MediaProvider
-            else if (isMediaDocument(uri)) {
-                final String docId = DocumentsContract.getDocumentId(uri);
-                final String[] split = docId.split(":");
-                final String type = split[0];
-
-                Uri contentUri = null;
-                if ("image".equals(type)) {
-                    contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
-                } else if ("video".equals(type)) {
-                    contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
-                } else if ("audio".equals(type)) {
-                    contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
-                }
-
-                final String selection = "_id=?";
-                final String[] selectionArgs = new String[]{split[1]};
-
-                return getDataColumn(context, contentUri, selection, selectionArgs);
-            }
-        }
-        // MediaStore (and general)
-        else if ("content".equalsIgnoreCase(uri.getScheme())) {
-            String path = getDataColumn(context, uri, null, null);
-            if (path != null && !path.equals("")) return path;
-
-            // path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
-            String fileName = getFileName(context, uri);
-            File cacheDir = getDocumentCacheDir(context);
-            File file = generateFileName(fileName, cacheDir);
-            String destinationPath = null;
-            if (file != null) {
-                destinationPath = file.getAbsolutePath();
-                saveFileFromUri(context, uri, destinationPath);
-            }
-            return destinationPath;
-        }
-        // File
-        else if ("file".equalsIgnoreCase(uri.getScheme())) {
-            return uri.getPath();
-        }
-        return null;
-    }
-
-    /**
-     * @param uri The Uri to check.
-     * @return Whether the Uri authority is ExternalStorageProvider.
-     */
-    public static boolean isExternalStorageDocument(Uri uri) {
-        return "com.android.externalstorage.documents".equals(uri.getAuthority());
-    }
-
-    /**
-     * @param uri The Uri to check.
-     * @return Whether the Uri authority is DownloadsProvider.
-     */
-    public static boolean isDownloadsDocument(Uri uri) {
-        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
-    }
-
-    /**
-     * @param uri The Uri to check.
-     * @return Whether the Uri authority is MediaProvider.
-     */
-    public static boolean isMediaDocument(Uri uri) {
-        return "com.android.providers.media.documents".equals(uri.getAuthority());
-    }
-
-    public static String getDataColumn(Context context, Uri uri, String selection,
-                                       String[] selectionArgs) {
-
-        Cursor cursor = null;
-        final String column = "_data";
-        final String[] projection = {column};
-        String path = "";
-        try {
-            cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
-                    null);
-            if (cursor != null && cursor.moveToFirst()) {
-                final int column_index = cursor.getColumnIndexOrThrow(column);
-                path = cursor.getString(column_index);
-                return path;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (cursor != null)
-                cursor.close();
-        }
-        return path;
-    }
-
-    public static String getFileName(@NonNull Context context, Uri uri) {
-        String mimeType = context.getContentResolver().getType(uri);
-        String filename = null;
-
-        if (mimeType == null && context != null) {
-            String path = getPath(context, uri);
-            if (path == null) {
-                filename = getName(uri.toString());
-            } else {
-                File file = new File(path);
-                filename = file.getName();
-            }
-        } else {
-            Cursor returnCursor = context.getContentResolver().query(uri, null,
-                    null, null, null);
-            if (returnCursor != null) {
-                int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
-                returnCursor.moveToFirst();
-                filename = returnCursor.getString(nameIndex);
-                returnCursor.close();
-            }
-        }
-
-        return filename;
-    }
-
-    public static String getName(String filename) {
-        if (filename == null) {
-            return null;
-        }
-        int index = filename.lastIndexOf('/');
-        return filename.substring(index + 1);
-    }
-
-    public static File getDocumentCacheDir(@NonNull Context context) {
-        File dir = new File(context.getCacheDir(), DOCUMENTS_DIR);
-        if (!dir.exists()) {
-            dir.mkdirs();
-        }
-
-        return dir;
-    }
-
-    @Nullable
-    public static File generateFileName(@Nullable String name, File directory) {
-        if (name == null) {
-            return null;
-        }
-
-        File file = new File(directory, name);
-
-        if (file.exists()) {
-            String fileName = name;
-            String extension = "";
-            int dotIndex = name.lastIndexOf('.');
-            if (dotIndex > 0) {
-                fileName = name.substring(0, dotIndex);
-                extension = name.substring(dotIndex);
-            }
-
-            int index = 0;
-
-            while (file.exists()) {
-                index++;
-                name = fileName + '(' + index + ')' + extension;
-                file = new File(directory, name);
-            }
-        }
-
-        try {
-            if (!file.createNewFile()) {
-                return null;
-            }
-        } catch (IOException e) {
-            return null;
-        }
-
-        return file;
-    }
-
-
-    private static void saveFileFromUri(Context context, Uri uri, String destinationPath) {
-        InputStream is = null;
-        BufferedOutputStream bos = null;
-        try {
-            is = context.getContentResolver().openInputStream(uri);
-            bos = new BufferedOutputStream(new FileOutputStream(destinationPath, false));
-            byte[] buf = new byte[1024];
-            is.read(buf);
-            do {
-                bos.write(buf);
-            } while (is.read(buf) != -1);
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (is != null) is.close();
-                if (bos != null) bos.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-
-    //bitmap转为base64
-    public static String bitmapToBase64(Bitmap bitmap) {
-
-        String result = null;
-        ByteArrayOutputStream baos = null;
-        try {
-            if (bitmap != null) {
-                baos = new ByteArrayOutputStream();
-                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
-
-                baos.flush();
-                baos.close();
-
-                byte[] bitmapBytes = baos.toByteArray();
-                result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (baos != null) {
-                    baos.flush();
-                    baos.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return result;
-    }
-
-    //base64转为bitmap
-    public static Bitmap base64ToBitmap(String base64Data) {
-        byte[] bytes = Base64.decode(base64Data, Base64.NO_WRAP);
-        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
-    }
-}
-

+ 9 - 14
teacher/src/main/java/com/cooleshow/teacher/ui/main/MallFragment.java

@@ -48,10 +48,7 @@ import com.cooleshow.base.ui.fragment.BaseMVPFragment;
 import com.cooleshow.base.utils.AppUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
-import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
 import com.cooleshow.base.widgets.DialogUtil;
-import com.cooleshow.teacher.App;
 import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.api.APIService;
 import com.cooleshow.teacher.bean.alipay.AuthResult;
@@ -59,9 +56,7 @@ import com.cooleshow.teacher.bean.alipay.PayResult;
 import com.cooleshow.teacher.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.teacher.databinding.FragmentMallBinding;
 import com.cooleshow.teacher.presenter.main.ShopMallPresenter;
-import com.cooleshow.teacher.ui.main.MainActivity;
-import com.cooleshow.teacher.ui.web.HtmlActivity;
-import com.cooleshow.teacher.widgets.FileUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.teacher.widgets.LollipopFixedWebView;
 import com.cooleshow.teacher.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
@@ -323,16 +318,16 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = FileUtils.getBase64Type(url.split(",")[0]);
+                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
                                     ToastUtil.getInstance().showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -347,14 +342,14 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -381,7 +376,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
                         .setShareboardclickCallback(new ShareBoardlistener() {
                             @Override
                             public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
-                                UMImage image = new UMImage(mContext, FileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
+                                UMImage image = new UMImage(mContext, MyFileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
                                 image.setThumb(image);
                                 image.compressStyle = UMImage.CompressStyle.SCALE;
                                 new ShareAction(getActivity()).withMedia(image)
@@ -678,7 +673,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -699,7 +694,7 @@ public class MallFragment extends BaseMVPFragment<FragmentMallBinding, ShopMallP
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = FileUtils.startIntent(getContext(), filePath + File.separator + fileName);
+                                            Intent intent = MyFileUtils.startIntent(getContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {

+ 0 - 2
teacher/src/main/java/com/cooleshow/teacher/ui/mine/PersonalSettingActivity.java

@@ -17,7 +17,6 @@ import androidx.core.content.FileProvider;
 import com.alibaba.android.arouter.facade.annotation.Route;
 import com.alibaba.android.arouter.launcher.ARouter;
 import com.cooleshow.base.router.RouterPath;
-import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.teacher.bean.TeacherUserInfo;
 import com.cooleshow.usercenter.helper.UserHelper;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
@@ -26,7 +25,6 @@ import com.cooleshow.base.utils.FileUtils;
 import com.cooleshow.base.utils.GlideUtils;
 import com.cooleshow.base.utils.PopupUtil;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.contract.PersonalSettingContract;
 import com.cooleshow.teacher.databinding.ActivityPersonalSettingBinding;

+ 3 - 12
teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyActivity.java

@@ -11,28 +11,21 @@ import android.view.View;
 import android.view.WindowManager;
 import android.widget.FrameLayout;
 
-import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.alibaba.android.arouter.facade.annotation.Route;
 import com.cooleshow.base.common.WebConstants;
-import com.cooleshow.base.constanst.Constants;
 import com.cooleshow.base.router.RouterPath;
-import com.cooleshow.base.rx.BaseObserver;
 import com.cooleshow.base.service.PlayMusicService;
 import com.cooleshow.base.ui.activity.BaseMVPActivity;
-import com.cooleshow.base.utils.RequestBodyUtil;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.helper.WebParamsHelper;
 import com.cooleshow.base.utils.helper.upload.UploadHelper;
 import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.databinding.ActivityAccompanyBinding;
-import com.cooleshow.teacher.presenter.splash.GuidePresenter;
 import com.cooleshow.teacher.presenter.web.AccompanyPresenter;
-import com.cooleshow.teacher.widgets.FileUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
-import com.daya.live_teaching.model.FileUploadBean;
 import com.gyf.immersionbar.ImmersionBar;
 import com.wonderkiln.camerakit.CameraKit;
 import com.wonderkiln.camerakit.CameraView;
@@ -52,8 +45,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
 
-import io.rong.imkit.utils.StatusBarUtil;
-
 /**
  * 创建日期:2022/6/8 14:19
  *
@@ -194,7 +185,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
             @Override
             public void startCapture() {
                 if (cameraView != null) {
-                    recordVideFilePath = FileUtils.getPublicDirectory(videoDerectoryName) + File.separator
+                    recordVideFilePath = MyFileUtils.getPublicDirectory(videoDerectoryName) + File.separator
                             + "VID_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".mp4";
                     cameraView.captureVideo(new File(recordVideFilePath));//开始录像
                 }
@@ -208,7 +199,7 @@ public class AccompanyActivity extends BaseMVPActivity<ActivityAccompanyBinding,
 
                 if (!file.exists()) {
                     ToastUtil.getInstance().showShort("未找到该视频,请重试");
-                    FileUtils.deleteFile(recordVideFilePath);
+                    MyFileUtils.deleteFile(recordVideFilePath);
                 }
                 String bucket = WebParamsHelper.getParams(jsonObject, "bucket");
                 UploadHelper uploadHelper = new UploadHelper(AccompanyActivity.this, bucket);

+ 8 - 14
teacher/src/main/java/com/cooleshow/teacher/ui/web/AccompanyFragment.java

@@ -45,7 +45,6 @@ import com.cooleshow.base.recorder.MsRecorder;
 import com.cooleshow.base.recorder.PullTransport;
 import com.cooleshow.base.recorder.Recorder;
 import com.cooleshow.base.router.RouterPath;
-import com.cooleshow.base.ui.fragment.BaseFragment;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
 import com.cooleshow.base.utils.AppUtils;
 import com.cooleshow.base.utils.HeadsetPlugListener;
@@ -53,7 +52,6 @@ import com.cooleshow.base.utils.HeadsetPlugReceiver;
 import com.cooleshow.base.utils.LogUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.websocket.JWebSocketClient;
 import com.cooleshow.base.widgets.BaseDialog;
@@ -67,11 +65,9 @@ import com.cooleshow.teacher.bean.alipay.AuthResult;
 import com.cooleshow.teacher.bean.alipay.PayResult;
 import com.cooleshow.teacher.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.teacher.databinding.FragmentAccompanyBinding;
-import com.cooleshow.teacher.databinding.FragmentMineLayoutBinding;
 import com.cooleshow.teacher.helper.ShareHelper;
-import com.cooleshow.teacher.presenter.main.MinePresenter;
 import com.cooleshow.teacher.presenter.web.AccompanyPresenter;
-import com.cooleshow.teacher.widgets.FileUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.teacher.widgets.LollipopFixedWebView;
 import com.cooleshow.teacher.widgets.helper.JsInterfaceAccomPanyUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
@@ -116,8 +112,6 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
 import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
-import io.rong.imkit.utils.helper.OpenChatHelper;
-import io.rong.imlib.model.Conversation;
 import okhttp3.ResponseBody;
 
 /**
@@ -576,7 +570,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
         }
         if (wavRecorder != null) {
             wavRecorder.stopRecording();
-            FileUtils.deleteFile(getVoicePath());
+            MyFileUtils.deleteFile(getVoicePath());
             wavRecorder.startRecording(getContext());
         } else {
             Observable.create((ObservableOnSubscribe<String>) emitter -> {
@@ -749,7 +743,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
         if (wavRecorder != null) {
             wavRecorder.stopRecording();
-            FileUtils.deleteFile(getVoicePath());
+            MyFileUtils.deleteFile(getVoicePath());
             wavRecorder.startRecording(getContext());
         } else {
             Observable.create((ObservableOnSubscribe<String>) emitter -> {
@@ -860,7 +854,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
     // 录音文件存储名称
     private String getVoicePath() {
-        return FileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
+        return MyFileUtils.getCacheDir(getContext()) + File.separator + "wav-accompany" + ".wav";
     }
 
     /**
@@ -914,7 +908,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
             return;
         }
         wavRecorder.stopRecording();
-        FileUtils.deleteFile(getVoicePath());
+        MyFileUtils.deleteFile(getVoicePath());
     }
 
     /**
@@ -1388,7 +1382,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
                                         ToastUtil.getInstance().show(Utils.getApp(), "应用未安装,分享失败");
                                         return;
                                     }
-                                    UMImage image = new UMImage(mContext, FileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
+                                    UMImage image = new UMImage(mContext, MyFileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
                                     image.setThumb(image);
                                     image.compressStyle = UMImage.CompressStyle.SCALE;
                                     new ShareAction(getActivity()).withMedia(image)
@@ -1552,7 +1546,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = hashKeyForDisk(midiFile) + "." + type;
                                 File file = new File(path + "/" + name);
                                 if (file.exists() && file.length() > 0) {
@@ -1578,7 +1572,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
 
                                                 @Override
                                                 public void onNext(ResponseBody response) {
-                                                    if (FileUtils.writeFileToSDCard(response, path, name)) {
+                                                    if (MyFileUtils.writeFileToSDCard(response, path, name)) {
                                                         runOnUiThread(() -> {
                                                             midiFilePath = path + File.separator + name;
                                                             MidiPlayerUtils.getInstance().init(getActivity().getApplication(), midiFilePath);

+ 9 - 13
teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlActivity.java

@@ -1,7 +1,6 @@
 package com.cooleshow.teacher.ui.web;
 
 import static com.cooleshow.base.common.WebConstants.WEB_URL;
-import static com.umeng.commonsdk.stateless.UMSLEnvelopeBuild.mContext;
 
 import android.Manifest;
 import android.annotation.SuppressLint;
@@ -55,7 +54,6 @@ import com.cooleshow.base.utils.AppUtils;
 import com.cooleshow.base.utils.LogUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.UriUtils;
 import com.cooleshow.base.utils.helper.DialogHelper;
 import com.cooleshow.base.utils.helper.QMUIStatusBarHelper;
@@ -70,7 +68,7 @@ import com.cooleshow.teacher.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.teacher.databinding.ActivityHtml1Binding;
 import com.cooleshow.teacher.helper.ShareHelper;
 import com.cooleshow.teacher.ui.live.TeacherLiveRoomActivity;
-import com.cooleshow.teacher.widgets.FileUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.teacher.widgets.LollipopFixedWebView;
 import com.cooleshow.teacher.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
@@ -92,7 +90,6 @@ import com.umeng.socialize.UMShareListener;
 import com.umeng.socialize.bean.SHARE_MEDIA;
 import com.umeng.socialize.media.UMImage;
 import com.umeng.socialize.media.UMWeb;
-import com.umeng.socialize.shareboard.ShareBoardConfig;
 import com.umeng.socialize.shareboard.SnsPlatform;
 import com.umeng.socialize.utils.ShareBoardlistener;
 
@@ -118,7 +115,6 @@ import io.reactivex.rxjava3.core.Observer;
 import io.reactivex.rxjava3.disposables.Disposable;
 import io.reactivex.rxjava3.schedulers.Schedulers;
 import io.rong.imkit.utils.helper.OpenChatHelper;
-import io.rong.imlib.model.Conversation;
 import okhttp3.ResponseBody;
 
 @Route(path = RouterPath.WebCenter.ACTIVITY_HTML)
@@ -396,16 +392,16 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = FileUtils.getBase64Type(url.split(",")[0]);
+                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
                                     ToastUtil.getInstance().showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -420,14 +416,14 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -465,7 +461,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                                         ToastUtil.getInstance().show(getApplicationContext(), "应用未安装,分享失败");
                                         return;
                                     }
-                                    UMImage image = new UMImage(HtmlActivity.this, FileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
+                                    UMImage image = new UMImage(HtmlActivity.this, MyFileUtils.base64ToBitmap(mImageBase64.split(",")[1]));//bitmap文件
                                     image.setThumb(image);
                                     image.compressStyle = UMImage.CompressStyle.SCALE;
                                     new ShareAction(HtmlActivity.this).withMedia(image)
@@ -832,7 +828,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -853,7 +849,7 @@ public class HtmlActivity extends BaseActivity<ActivityHtml1Binding> implements
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = FileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
+                                            Intent intent = MyFileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {

+ 9 - 11
teacher/src/main/java/com/cooleshow/teacher/ui/web/HtmlHorizontalScreenActivity.java

@@ -1,7 +1,6 @@
 package com.cooleshow.teacher.ui.web;
 
 import static com.cooleshow.base.common.WebConstants.WEB_URL;
-import static com.umeng.commonsdk.stateless.UMSLEnvelopeBuild.mContext;
 
 import android.Manifest;
 import android.annotation.SuppressLint;
@@ -53,7 +52,6 @@ import com.cooleshow.base.ui.activity.BaseActivity;
 import com.cooleshow.base.utils.AppUtils;
 import com.cooleshow.base.utils.PermissionUtils;
 import com.cooleshow.base.utils.ToastUtil;
-import com.cooleshow.base.utils.ToastUtils;
 import com.cooleshow.base.utils.UriUtils;
 import com.cooleshow.base.utils.Utils;
 import com.cooleshow.base.utils.helper.DialogHelper;
@@ -68,7 +66,7 @@ import com.cooleshow.teacher.bean.alipay.PayResult;
 import com.cooleshow.teacher.bean.weixinpay.WeixinPayInfo;
 import com.cooleshow.teacher.databinding.ActivityHtml1Binding;
 import com.cooleshow.teacher.helper.ShareHelper;
-import com.cooleshow.teacher.widgets.FileUtils;
+import com.cooleshow.base.utils.MyFileUtils;
 import com.cooleshow.teacher.widgets.LollipopFixedWebView;
 import com.cooleshow.teacher.widgets.helper.JsInterfaceUtils;
 import com.cooleshow.usercenter.helper.UserHelper;
@@ -382,16 +380,16 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
                                     ToastUtil.getInstance().showShort("文件异常");
                                     return;
                                 }
-                                String path = FileUtils.getPublicDirectory("file");
+                                String path = MyFileUtils.getPublicDirectory("file");
                                 String name = "FILE_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + "." + type;
                                 upDateNewsVideoFile(path, name, url, type);
                             } else {
-                                String type = FileUtils.getBase64Type(url.split(",")[0]);
+                                String type = MyFileUtils.getBase64Type(url.split(",")[0]);
                                 if (TextUtils.isEmpty(type)) {
                                     ToastUtil.getInstance().showShort("暂不支持该文件保存");
                                     return;
                                 }
-                                decoderBase64File(url, FileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
+                                decoderBase64File(url, MyFileUtils.getPublicDirectory(("png".equals(type) || "jpg".equals(type) ? "img" : "file")), type);
                             }
 
                         } catch (Exception e) {
@@ -406,14 +404,14 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
 
     @Override
     public void createRightNavToShareButton(String base64Code, String url) {
-        String type = FileUtils.getBase64Type(base64Code.split(",")[0]);
+        String type = MyFileUtils.getBase64Type(base64Code.split(",")[0]);
         if (TextUtils.isEmpty(type)) {
             return;
         }
         try {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("api", "shareDisplay");
-            ivAction.setImageBitmap(FileUtils.base64ToBitmap(base64Code.split(",")[1]));
+            ivAction.setImageBitmap(MyFileUtils.base64ToBitmap(base64Code.split(",")[1]));
             ivAction.setVisibility(View.VISIBLE);
             ivAction.setOnClickListener(v ->
                     onSendMessage(jsonObject.toString())
@@ -442,7 +440,7 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
                                     ToastUtil.getInstance().show(Utils.getApp(), "应用未安装,分享失败");
                                     return;
                                 }
-                                UMImage image = new UMImage(HtmlHorizontalScreenActivity.this, FileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
+                                UMImage image = new UMImage(HtmlHorizontalScreenActivity.this, MyFileUtils.base64ToBitmap(imageBase64.split(",")[1]));//bitmap文件
                                 image.setThumb(image);
                                 image.compressStyle = UMImage.CompressStyle.SCALE;
                                 new ShareAction(HtmlHorizontalScreenActivity.this).withMedia(image)
@@ -777,7 +775,7 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
 
                     @Override
                     public void onNext(ResponseBody response) {
-                        if (FileUtils.writeFileToSDCard(response, filePath, fileName)) {
+                        if (MyFileUtils.writeFileToSDCard(response, filePath, fileName)) {
 
                             runOnUiThread(() -> {
                                 hideLoading();
@@ -798,7 +796,7 @@ public class HtmlHorizontalScreenActivity extends BaseActivity<ActivityHtml1Bind
                                     @Override
                                     public void onCommit(View v) {
                                         try {
-                                            Intent intent = FileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
+                                            Intent intent = MyFileUtils.startIntent(getApplicationContext(), filePath + File.separator + fileName);
                                             if (intent != null) {
                                                 startActivity(intent);
                                             } else {

+ 0 - 1633
teacher/src/main/java/com/cooleshow/teacher/widgets/FileUtils.java

@@ -1,1633 +0,0 @@
-package com.cooleshow.teacher.widgets;
-
-import static android.os.Environment.DIRECTORY_DOWNLOADS;
-
-import android.annotation.SuppressLint;
-import android.content.ContentUris;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Environment;
-import android.provider.DocumentsContract;
-import android.provider.MediaStore;
-import android.provider.OpenableColumns;
-import android.text.TextUtils;
-import android.util.Base64;
-import android.util.Log;
-
-import com.cooleshow.base.utils.Utils;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.content.FileProvider;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.LineNumberReader;
-import java.io.OutputStream;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import okhttp3.ResponseBody;
-
-/**
- * Description:
- * Copyright  : Copyright (c) 2019
- * Company    : 大雅乐盟
- * Author     : r
- * Date       : 2019/9/6 15:07
- */
-public class FileUtils {
-    private static final String TAG = "FileUtil";
-    private static final String filesDirectory = getCacheDir(Utils.getApp())+ File.separator+"cooleshow";
-    public static final String examDownloadDirectory = "examDownload";
-
-    public static String getCacheDir(Context context) {
-        String cacheDir = context.getExternalCacheDir().getAbsolutePath();
-        return cacheDir;
-    }
-
-    public static String getCacheDir(Context context, String directory) {
-        String fileDir;
-        try {
-            File file = new File(context.getExternalCacheDir() + File.separator + directory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            fileDir = file.getAbsolutePath();
-            return fileDir;
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    public static String getFilesDir(Context context) {
-        try {
-            File file = context.getExternalFilesDir(filesDirectory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            String fileDir = file.getAbsolutePath();
-            return fileDir;
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    public static String getFilesDir(Context context, String directory) {
-        try {
-            File file = context.getExternalFilesDir(filesDirectory + File.separator + directory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            String fileDir = file.getAbsolutePath();
-            return fileDir;
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    public static String getPublicDirectory(String path) {
-        String fileDir = null;
-        try {
-            File file = new File(filesDirectory);
-            if (!file.exists()) {
-                file.mkdirs();
-            }
-            fileDir = file.getAbsolutePath();
-            if (!TextUtils.isEmpty(path)) {
-                File filePath = new File(file.getPath() + File.separator + path);
-                if (!filePath.exists()) {
-                    filePath.mkdirs();
-                }
-                fileDir = filePath.getAbsolutePath();
-            }
-            return fileDir;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return "";
-        }
-    }
-
-    public static String getPublicDirectoryDownload() {
-        try {
-            File file = Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS);
-            return file.getAbsolutePath();
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    /**
-     * 获取该路径下全部的文件名
-     *
-     * @param path
-     * @return
-     */
-    public static List<String> getFilesAllName(String path) {
-        File file = new File(path);
-        File[] files = file.listFiles();
-        if (files == null) {
-            Log.e("error", "空目录");
-            return null;
-        }
-        List<String> s = new ArrayList<>();
-        for (int i = 0; i < files.length; i++) {
-            s.add(files[i].getAbsolutePath());
-        }
-        return s;
-    }
-
-    public static String getBase64Type(String str) {
-        if (TextUtils.isEmpty(str)) {
-            return "";
-        }
-        String type = "";
-        switch (str) {
-            case "data:application/msword;base64":
-                type = "doc";
-            case "data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64":
-                type = "docx";
-            case "data:application/vnd.ms-excel;base64":
-                type = "xls";
-            case "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64":
-                type = "xlsx";
-            case "data:application/pdf;base64":
-                type = "pdf";
-            case "data:application/vnd.ms-powerpoint;base64":
-                type = "ppt";
-            case "data:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64":
-                type = "pptx";
-            case "data:text/plain;base64":
-                type = "txt";
-            case "data:image/png;base64":
-                type = "png";
-            case "data:image/jpeg;base64":
-                type = "jpg";
-        }
-        return type;
-    }
-
-    /**
-     * 从sd卡取文件
-     *
-     * @param filename
-     * @return
-     */
-    public String getFileFromSdcard(String filename) {
-        ByteArrayOutputStream outputStream = null;
-        FileInputStream fis = null;
-        try {
-            outputStream = new ByteArrayOutputStream();
-            File file = new File(Environment.getExternalStorageDirectory(), filename);
-            if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
-                fis = new FileInputStream(file);
-                int len = 0;
-                byte[] data = new byte[1024];
-                while ((len = fis.read(data)) != -1) {
-                    outputStream.write(data, 0, len);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                outputStream.close();
-                fis.close();
-            } catch (IOException e) {
-            }
-        }
-        return new String(outputStream.toByteArray());
-    }
-
-    /**
-     * 保存文件到sd
-     *
-     * @param filename
-     * @param content
-     * @return
-     */
-    public static boolean saveContentToSdcard(String filename, String content) {
-        boolean flag;
-        FileOutputStream fos = null;
-        content += "\r\n";
-        try {
-            File file = new File(filename);
-            if (file.exists()) {
-                file.mkdirs();
-            }
-            fos = new FileOutputStream(file, true);
-            fos.write(content.getBytes());
-            flag = true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            flag = false;
-        } finally {
-            try {
-                if (fos != null) {
-                    fos.close();
-                }
-            } catch (IOException e) {
-            }
-        }
-        return flag;
-    }
-
-    /**
-     * 保存文件到sd
-     *
-     * @param
-     * @param
-     * @return
-     */
-    public static boolean saveFileToSdcard(String mPath, InputStream inputStream) {
-        byte[] mData = null;
-        try {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            int len = 0;
-            byte[] bytes = new byte[1024];
-            while ((len = inputStream.read(bytes)) != -1) {
-                baos.write(bytes, 0, len);
-            }
-            mData = baos.toByteArray();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        try {
-            FileOutputStream fos = new FileOutputStream(new File(mPath));
-            fos.write(mData, 0, mData.length);
-            return true;
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return false;
-    }
-
-    /**
-     * 取得文件大小
-     *
-     * @param f
-     * @return
-     */
-    public static long getFileSizes(File f) {
-        long size = 0;
-        try {
-            if (f.exists()) {
-                FileInputStream fis = null;
-                fis = new FileInputStream(f);
-                size = fis.available();
-            } else {
-                f.createNewFile();
-            }
-        } catch (Exception e) {
-        }
-
-        return size;
-    }
-
-    /**
-     * 递归取得文件夹大小
-     *
-     * @param dir
-     * @return
-     * @throws Exception
-     */
-    public static long getFileSize(File dir) throws Exception {
-        long size = 0;
-        File flist[] = dir.listFiles();
-        for (int i = 0; i < flist.length; i++) {
-            if (flist[i].isDirectory()) {
-                size = size + getFileSize(flist[i]);
-            } else {
-                size = size + flist[i].length();
-            }
-        }
-        return size;
-    }
-
-    /**
-     * 转换文件大小
-     *
-     * @param fileS
-     * @return
-     */
-    public static String FormetFileSize(long fileS) {
-        DecimalFormat df = new DecimalFormat("#.00");
-        String fileSizeString = "";
-        if (fileS < 1024) {
-            fileSizeString = df.format((double) fileS) + "B";
-        } else if (fileS < 1048576) {
-            fileSizeString = df.format((double) fileS / 1024) + "K";
-        } else if (fileS < 1073741824) {
-            fileSizeString = df.format((double) fileS / 1048576) + "M";
-        } else {
-            fileSizeString = df.format((double) fileS / 1073741824) + "G";
-        }
-        return fileSizeString;
-    }
-
-    /**
-     * 递归求取目录文件个数
-     *
-     * @param f
-     * @return
-     */
-    public static long getlist(File f) {
-        long size = 0;
-        File flist[] = f.listFiles();
-        size = flist.length;
-        for (int i = 0; i < flist.length; i++) {
-            if (flist[i].isDirectory()) {
-                size = size + getlist(flist[i]);
-                size--;
-            }
-        }
-        return size;
-    }
-
-    /**
-     * 在根目录下搜索文件
-     *
-     * @param keyword
-     * @return
-     */
-    public static String searchFile(String keyword) {
-        String result = "";
-        File[] files = new File("/").listFiles();
-        for (File file : files) {
-            if (file.getName().indexOf(keyword) >= 0) {
-                result += file.getPath() + "\n";
-            }
-        }
-        if (result.equals("")) {
-            result = "找不到文件!!";
-        }
-        return result;
-    }
-
-    /**
-     *
-     */
-    public static List<String> search(File file, String[] ext) {
-        List<String> list = new ArrayList<String>();
-        if (file != null) {
-            if (file.isDirectory()) {
-                File[] listFile = file.listFiles();
-                if (listFile != null) {
-                    for (int i = 0; i < listFile.length; i++) {
-                        search(listFile[i], ext);
-                    }
-                }
-            } else {
-                String filename = file.getAbsolutePath();
-                for (int i = 0; i < ext.length; i++) {
-                    if (filename.endsWith(ext[i])) {
-                        list.add(filename);
-                        break;
-                    }
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * 查询文件
-     *
-     * @param file
-     * @param keyword
-     * @return
-     */
-    public static List<File> FindFile(File file, String keyword) {
-        List<File> list = new ArrayList<File>();
-        if (file.isDirectory()) {
-            File[] files = file.listFiles();
-            if (files != null) {
-                for (File tempf : files) {
-                    if (tempf.isDirectory()) {
-                        if (tempf.getName().toLowerCase().lastIndexOf(keyword) > -1) {
-                            list.add(tempf);
-                        }
-                        list.addAll(FindFile(tempf, keyword));
-                    } else {
-                        if (tempf.getName().toLowerCase().lastIndexOf(keyword) > -1) {
-                            list.add(tempf);
-                        }
-                    }
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * searchFile 查找文件并加入到ArrayList 当中去
-     *
-     * @param context
-     * @param keyword
-     * @param filepath
-     * @return
-     */
-    public static List<Map<String, Object>> searchFile(Context context, String keyword, File filepath) {
-        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
-        Map<String, Object> rowItem = null;
-        int index = 0;
-        // 判断SD卡是否存在
-        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-            File[] files = filepath.listFiles();
-            if (files.length > 0) {
-                for (File file : files) {
-                    if (file.isDirectory()) {
-                        if (file.getName().toLowerCase().lastIndexOf(keyword) > -1) {
-                            rowItem = new HashMap<String, Object>();
-                            rowItem.put("number", index); // 加入序列号
-                            rowItem.put("fileName", file.getName());// 加入名称
-                            rowItem.put("path", file.getPath()); // 加入路径
-                            rowItem.put("size", file.length() + ""); // 加入文件大小
-                            list.add(rowItem);
-                        }
-                        // 如果目录可读就执行(一定要加,不然会挂掉)
-                        if (file.canRead()) {
-                            list.addAll(searchFile(context, keyword, file)); // 如果是目录,递归查找
-                        }
-                    } else {
-                        // 判断是文件,则进行文件名判断
-                        try {
-                            if (file.getName().indexOf(keyword) > -1 || file.getName().indexOf(keyword.toUpperCase()) > -1) {
-                                rowItem = new HashMap<String, Object>();
-                                rowItem.put("number", index); // 加入序列号
-                                rowItem.put("fileName", file.getName());// 加入名称
-                                rowItem.put("path", file.getPath()); // 加入路径
-                                rowItem.put("size", file.length() + ""); // 加入文件大小
-                                list.add(rowItem);
-                                index++;
-                            }
-                        } catch (Exception e) {
-                        }
-                    }
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * 根据后缀得到文件类型
-     *
-     * @param fileName
-     * @param pointIndex
-     * @return
-     */
-    public static String getFileType(String fileName, int pointIndex) {
-        String type = fileName.substring(pointIndex + 1).toLowerCase();
-        if ("m4a".equalsIgnoreCase(type) || "xmf".equalsIgnoreCase(type) || "ogg".equalsIgnoreCase(type) || "wav".equalsIgnoreCase(type)
-                || "m4a".equalsIgnoreCase(type) || "aiff".equalsIgnoreCase(type) || "midi".equalsIgnoreCase(type)
-                || "vqf".equalsIgnoreCase(type) || "aac".equalsIgnoreCase(type) || "flac".equalsIgnoreCase(type)
-                || "tak".equalsIgnoreCase(type) || "wv".equalsIgnoreCase(type)) {
-            type = "file_audio";
-        } else if ("mp3".equalsIgnoreCase(type) || "mid".equalsIgnoreCase(type)) {
-            type = "file_mp3";
-        } else if ("avi".equalsIgnoreCase(type) || "mp4".equalsIgnoreCase(type) || "dvd".equalsIgnoreCase(type)
-                || "mid".equalsIgnoreCase(type) || "mov".equalsIgnoreCase(type) || "mkv".equalsIgnoreCase(type)
-                || "mp2v".equalsIgnoreCase(type) || "mpe".equalsIgnoreCase(type) || "mpeg".equalsIgnoreCase(type)
-                || "mpg".equalsIgnoreCase(type) || "asx".equalsIgnoreCase(type) || "asf".equalsIgnoreCase(type)
-                || "flv".equalsIgnoreCase(type) || "navi".equalsIgnoreCase(type) || "divx".equalsIgnoreCase(type)
-                || "rm".equalsIgnoreCase(type) || "rmvb".equalsIgnoreCase(type) || "dat".equalsIgnoreCase(type)
-                || "mpa".equalsIgnoreCase(type) || "vob".equalsIgnoreCase(type) || "3gp".equalsIgnoreCase(type)
-                || "swf".equalsIgnoreCase(type) || "wmv".equalsIgnoreCase(type)) {
-            type = "file_video";
-        } else if ("bmp".equalsIgnoreCase(type) || "pcx".equalsIgnoreCase(type) || "tiff".equalsIgnoreCase(type)
-                || "gif".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type) || "tga".equalsIgnoreCase(type)
-                || "exif".equalsIgnoreCase(type) || "fpx".equalsIgnoreCase(type) || "psd".equalsIgnoreCase(type)
-                || "cdr".equalsIgnoreCase(type) || "raw".equalsIgnoreCase(type) || "eps".equalsIgnoreCase(type)
-                || "gif".equalsIgnoreCase(type) || "jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)
-                || "png".equalsIgnoreCase(type) || "hdri".equalsIgnoreCase(type) || "ai".equalsIgnoreCase(type)) {
-            type = "file_image";
-        } else if ("ppt".equalsIgnoreCase(type) || "doc".equalsIgnoreCase(type) || "xls".equalsIgnoreCase(type)
-                || "pps".equalsIgnoreCase(type) || "xlsx".equalsIgnoreCase(type) || "xlsm".equalsIgnoreCase(type)
-                || "pptx".equalsIgnoreCase(type) || "pptm".equalsIgnoreCase(type) || "ppsx".equalsIgnoreCase(type)
-                || "maw".equalsIgnoreCase(type) || "mdb".equalsIgnoreCase(type) || "pot".equalsIgnoreCase(type)
-                || "msg".equalsIgnoreCase(type) || "oft".equalsIgnoreCase(type) || "xlw".equalsIgnoreCase(type)
-                || "wps".equalsIgnoreCase(type) || "rtf".equalsIgnoreCase(type) || "ppsm".equalsIgnoreCase(type)
-                || "potx".equalsIgnoreCase(type) || "potm".equalsIgnoreCase(type) || "ppam".equalsIgnoreCase(type)) {
-            type = "ic_file_office";
-        } else if ("txt".equalsIgnoreCase(type) || "text".equalsIgnoreCase(type) || "chm".equalsIgnoreCase(type)
-                || "hlp".equalsIgnoreCase(type) || "pdf".equalsIgnoreCase(type) || "doc".equalsIgnoreCase(type)
-                || "docx".equalsIgnoreCase(type) || "docm".equalsIgnoreCase(type) || "dotx".equalsIgnoreCase(type)) {
-            type = "file_text";
-        } else if ("ini".equalsIgnoreCase(type) || "sys".equalsIgnoreCase(type) || "dll".equalsIgnoreCase(type)
-                || "adt".equalsIgnoreCase(type)) {
-            type = "file_system";
-        } else if ("rar".equalsIgnoreCase(type) || "zip".equalsIgnoreCase(type) || "arj".equalsIgnoreCase(type)
-                || "gz".equalsIgnoreCase(type) || "z".equalsIgnoreCase(type) || "7Z".equalsIgnoreCase(type) || "GZ".equalsIgnoreCase(type)
-                || "BZ".equalsIgnoreCase(type) || "ZPAQ".equalsIgnoreCase(type)) {
-            type = "ic_file_rar";
-        } else if ("html".equalsIgnoreCase(type) || "htm".equalsIgnoreCase(type) || "java".equalsIgnoreCase(type)
-                || "php".equalsIgnoreCase(type) || "asp".equalsIgnoreCase(type) || "aspx".equalsIgnoreCase(type)
-                || "jsp".equalsIgnoreCase(type) || "shtml".equalsIgnoreCase(type) || "xml".equalsIgnoreCase(type)) {
-            type = "file_web";
-        } else if ("exe".equalsIgnoreCase(type) || "com".equalsIgnoreCase(type) || "bat".equalsIgnoreCase(type)
-                || "iso".equalsIgnoreCase(type) || "msi".equalsIgnoreCase(type)) {
-            type = "file_exe";
-        } else if ("apk".equalsIgnoreCase(type)) {
-            type = "ic_file_apk";
-        } else {
-            type = "ic_file_normal";
-        }
-        return type;
-    }
-
-    /**
-     * 改变文件大小显示的内容
-     *
-     * @param size
-     * @return
-     */
-    public static String changeFileSize(String size) {
-        if (Integer.parseInt(size) > 1024) {
-            size = Integer.parseInt(size) / 1024 + "K";
-        } else if (Integer.parseInt(size) > (1024 * 1024)) {
-            size = Integer.parseInt(size) / (1024 * 1024) + "M";
-        } else if (Integer.parseInt(size) > (1024 * 1024 * 1024)) {
-            size = Integer.parseInt(size) / (1024 * 1024 * 1024) + "G";
-        } else {
-            size += "B";
-        }
-        return size;
-    }
-
-    /**
-     * 得到所有文件
-     *
-     * @param dir
-     * @return
-     */
-    public static ArrayList<File> getAllFiles(File dir) {
-        ArrayList<File> allFiles = new ArrayList<File>();
-        // 递归取得目录下的所有文件及文件夹
-        File[] files = dir.listFiles();
-        for (int i = 0; i < files.length; i++) {
-            File file = files[i];
-            allFiles.add(file);
-            if (file.isDirectory()) {
-                getAllFiles(file);
-            }
-        }
-        return allFiles;
-    }
-
-    /**
-     * 判断文件MimeType 类型
-     *
-     * @param f
-     * @return
-     */
-    public static String getMIMEType(File f) {
-        String type = "";
-        String fName = f.getName();
-        /* 取得扩展名 */
-        String end = fName.substring(fName.lastIndexOf(".") + 1, fName.length()).toLowerCase();
-        /* 依扩展名的类型决定MimeType */
-        if (end.equalsIgnoreCase("m4a") || end.equalsIgnoreCase("mp3") || end.equalsIgnoreCase("mid") || end.equalsIgnoreCase("xmf")
-                || end.equalsIgnoreCase("ogg") || end.equalsIgnoreCase("wav")) {
-            type = "audio";
-        } else if (end.equalsIgnoreCase("3gp") || end.equalsIgnoreCase("mp4")) {
-            type = "video";
-        } else if (end.equalsIgnoreCase("jpg") || end.equalsIgnoreCase("gif") || end.equalsIgnoreCase("png")
-                || end.equalsIgnoreCase("jpeg") || end.equalsIgnoreCase("bmp")) {
-            type = "image";
-        } else if (end.equalsIgnoreCase("apk")) {
-            /* android.permission.INSTALL_PACKAGES */
-            type = "application/vnd.android.package-archive";
-        } else if (end.equalsIgnoreCase("txt") || end.equalsIgnoreCase("java")) {
-            /* android.permission.INSTALL_PACKAGES */
-            type = "text";
-        } else {
-            type = "*";
-        }
-        /* 如果无法直接打开,就跳出软件列表给用户选择 */
-        if (end.equalsIgnoreCase("apk")) {
-        } else {
-            type += "/*";
-        }
-        return type;
-    }
-
-    /**
-     * 拷贝文件
-     *
-     * @param fromFile
-     * @param toFile
-     * @throws IOException
-     */
-    public static void copyFile(File fromFile, String toFile) throws IOException {
-        FileInputStream from = null;
-        FileOutputStream to = null;
-        try {
-            from = new FileInputStream(fromFile);
-            to = new FileOutputStream(toFile);
-            byte[] buffer = new byte[1024];
-            int bytesRead;
-            while ((bytesRead = from.read(buffer)) != -1)
-                to.write(buffer, 0, bytesRead); // write
-        } finally {
-            if (from != null)
-                try {
-                    from.close();
-                } catch (IOException e) {
-                    Log.e(TAG, "", e);
-                }
-            if (to != null)
-                try {
-                    to.close();
-                } catch (IOException e) {
-                    Log.e(TAG, "", e);
-                }
-        }
-    }
-
-    /**
-     * 创建文件
-     *
-     * @param file
-     * @return
-     */
-    public static File createNewFile(File file) {
-        try {
-            if (file.exists()) {
-                return file;
-            }
-            File dir = file.getParentFile();
-            if (!dir.exists()) {
-                dir.mkdirs();
-            }
-            if (!file.exists()) {
-                file.createNewFile();
-            }
-        } catch (IOException e) {
-            Log.e(TAG, "", e);
-            return null;
-        }
-        return file;
-    }
-
-    /**
-     * 创建文件
-     *
-     * @param path
-     */
-    public static File createNewFile(String path) {
-        File file = new File(path);
-        return createNewFile(file);
-    }// end method createText()
-
-    /**
-     * 删除文件
-     *
-     * @param path
-     */
-    public static void deleteFile(String path) {
-        if (TextUtils.isEmpty(path)) {
-            return;
-        }
-        File file = new File(path);
-        deleteFile(file);
-    }
-
-    /**
-     * 删除文件
-     *
-     * @param file
-     */
-    public static void deleteFile(File file) {
-        try {
-            if (!file.exists()) {
-                return;
-            }
-            if (file.isFile()) {
-                file.delete();
-            } else if (file.isDirectory()) {
-                File files[] = file.listFiles();
-                for (int i = 0; i < files.length; i++) {
-                    deleteFile(files[i]);
-                }
-            }
-            file.delete();
-        } catch (Exception e) {
-        }
-
-    }
-
-    /**
-     * 向Text文件中写入内容
-     *
-     * @param content
-     * @return
-     */
-    public static boolean write(String path, String content) {
-        return write(path, content, false);
-    }
-
-    public static boolean write(String path, String content, boolean append) {
-        return write(new File(path), content, append);
-    }
-
-    public static boolean write(File file, String content) {
-        return write(file, content, false);
-    }
-
-    /**
-     * 写入文件
-     *
-     * @param file
-     * @param content
-     * @param append
-     * @return
-     */
-    public static boolean write(File file, String content, boolean append) {
-        if (file == null || TextUtils.isEmpty(content)) {
-            return false;
-        }
-        if (!file.exists()) {
-            file = createNewFile(file);
-        }
-        FileOutputStream fos = null;
-        try {
-            fos = new FileOutputStream(file, append);
-            fos.write(content.getBytes());
-        } catch (Exception e) {
-            Log.e(TAG, "", e);
-            return false;
-        } finally {
-            try {
-                fos.close();
-            } catch (IOException e) {
-                Log.e(TAG, "", e);
-            }
-            fos = null;
-        }
-        return true;
-    }
-
-    /**
-     * 获得文件名
-     *
-     * @param path
-     * @return
-     */
-    public static String getFileName(String path) {
-        if (TextUtils.isEmpty(path)) {
-            return null;
-        }
-        File f = new File(path);
-        String name = f.getName();
-        f = null;
-        return name;
-    }
-
-    /**
-     * 读取文件内容,从第startLine行开始,读取lineCount行
-     *
-     * @param file
-     * @param startLine
-     * @param lineCount
-     * @return 读到文字的list, 如果list.size<lineCount则说明读到文件末尾了
-     */
-    public static List<String> readFile(File file, int startLine, int lineCount) {
-        if (file == null || startLine < 1 || lineCount < 1) {
-            return null;
-        }
-        if (!file.exists()) {
-            return null;
-        }
-        FileReader fileReader = null;
-        List<String> list = null;
-        try {
-            list = new ArrayList<String>();
-            fileReader = new FileReader(file);
-            LineNumberReader lineReader = new LineNumberReader(fileReader);
-            boolean end = false;
-            for (int i = 1; i < startLine; i++) {
-                if (lineReader.readLine() == null) {
-                    end = true;
-                    break;
-                }
-            }
-            if (end == false) {
-                for (int i = startLine; i < startLine + lineCount; i++) {
-                    String line = lineReader.readLine();
-                    if (line == null) {
-                        break;
-                    }
-                    list.add(line);
-                }
-            }
-        } catch (Exception e) {
-            Log.e(TAG, "read log error!", e);
-        } finally {
-            if (fileReader != null) {
-                try {
-                    fileReader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * 创建文件夹
-     *
-     * @param dir
-     * @return
-     */
-    public static boolean createDir(File dir) {
-        try {
-            if (!dir.exists()) {
-                dir.mkdirs();
-            }
-            return true;
-        } catch (Exception e) {
-            Log.e(TAG, "create dir error", e);
-            return false;
-        }
-    }
-
-    /**
-     * 在SD卡上创建目录
-     *
-     * @param dirName
-     */
-    public static File creatSDDir(String dirName) {
-        File dir = new File(dirName);
-        dir.mkdir();
-        return dir;
-    }
-
-    /**
-     * 判断SD卡上的文件是否存在
-     */
-    public static boolean isFileExist(String fileName) {
-        File file = new File(fileName);
-
-        return file == null ? false : file.exists();
-    }
-
-    /**
-     * 将一个InputStream里面的数据写入到SD卡中
-     */
-    public static File write2SDFromInput(String path, String fileName, InputStream input) {
-        File file = null;
-        OutputStream output = null;
-        try {
-            creatSDDir(path);
-            file = createNewFile(path + "/" + fileName);
-            output = new FileOutputStream(file);
-            byte buffer[] = new byte[1024];
-            int len = -1;
-            while ((len = input.read(buffer)) != -1) {
-                output.write(buffer, 0, len);
-            }
-            output.flush();
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                output.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return file;
-    }
-
-    /**
-     * 读取文件内容 从文件中一行一行的读取文件
-     *
-     * @param file
-     * @return
-     */
-    public static String readFile(File file) {
-        FileReader read = null;
-        String content = "";
-        String result = "";
-        BufferedReader br = null;
-        try {
-            read = new FileReader(file);
-            br = new BufferedReader(read);
-            while ((content = br.readLine().toString().trim()) != null) {
-                result += content + "\r\n";
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                read.close();
-                br.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * 将图片保存到本地时进行压缩, 即将图片从Bitmap形式变为File形式时进行压缩,
-     * 特点是: File形式的图片确实被压缩了, 但是当你重新读取压缩后的file为 Bitmap是,它占用的内存并没有改变
-     *
-     * @param bmp
-     * @param file
-     */
-    public static void compressBmpToFile(Bitmap bmp, File file) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        int options = 100;// 个人喜欢从80开始,
-        bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
-        while (baos.toByteArray().length / 1024 > 100) {
-            baos.reset();
-            options -= 10;
-            bmp.compress(Bitmap.CompressFormat.JPEG, options, baos);
-        }
-        try {
-            FileOutputStream fos = new FileOutputStream(file);
-            fos.write(baos.toByteArray());
-            fos.flush();
-            fos.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * 将图片从本地读到内存时,进行压缩 ,即图片从File形式变为Bitmap形式
-     * 特点: 通过设置采样率, 减少图片的像素, 达到对内存中的Bitmap进行压缩
-     *
-     * @param srcPath
-     * @return
-     */
-    public static Bitmap compressImageFromFile(String srcPath, float pixWidth, float pixHeight) {
-        BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inJustDecodeBounds = true;// 只读边,不读内容
-        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, options);
-        options.inJustDecodeBounds = false;
-        int w = options.outWidth;
-        int h = options.outHeight;
-        //float pixWidth = 800f;//
-        //float pixHeight = 480f;//
-        int scale = 1;
-        if (w > h && w > pixWidth) {
-            scale = (int) (options.outWidth / pixWidth);
-        } else if (w < h && h > pixHeight) {
-            scale = (int) (options.outHeight / pixHeight);
-        }
-        if (scale <= 0)
-            scale = 1;
-        options.inSampleSize = scale;// 设置采样率
-        options.inPreferredConfig = Bitmap.Config.ARGB_8888;// 该模式是默认的,可不设
-        options.inPurgeable = true;// 同时设置才会有效
-        options.inInputShareable = true;// 。当系统内存不够时候图片自动被回收
-        bitmap = BitmapFactory.decodeFile(srcPath, options);
-        // return compressBmpFromBmp(bitmap);//原来的方法调用了这个方法企图进行二次压缩
-        // 其实是无效的,大家尽管尝试
-        return bitmap;
-    }
-
-    /**
-     * 指定分辨率和清晰度的图片压缩
-     */
-    public void transImage(String fromFile, String toFile, int width, int height, int quality) {
-        try {
-            Bitmap bitmap = BitmapFactory.decodeFile(fromFile);
-            int bitmapWidth = bitmap.getWidth();
-            int bitmapHeight = bitmap.getHeight();
-            // 缩放图片的尺寸
-            float scaleWidth = (float) width / bitmapWidth;
-            float scaleHeight = (float) height / bitmapHeight;
-            Matrix matrix = new Matrix();
-            matrix.postScale(scaleWidth, scaleHeight);
-            // 产生缩放后的Bitmap对象
-            Bitmap resizeBitmap = (Bitmap) Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, false);
-            // save file
-            File myCaptureFile = new File(toFile);
-            FileOutputStream out = new FileOutputStream(myCaptureFile);
-            if (resizeBitmap.compress(Bitmap.CompressFormat.JPEG, quality, out)) {
-                out.flush();
-                out.close();
-            }
-            if (!bitmap.isRecycled()) {
-                bitmap.recycle();//记得释放资源,否则会内存溢出
-            }
-            if (!resizeBitmap.isRecycled()) {
-                resizeBitmap.recycle();
-            }
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    public static String getFilePath(Bitmap bitmap) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        bitmap.compress(Bitmap.CompressFormat.PNG, 80, baos);
-        String path = Environment.getExternalStorageDirectory() + "/dayaWhiteBroad";
-        File dir = new File(path);
-        if (!dir.exists()) {
-            dir.mkdirs();
-        }
-        File file = new File(path + "/" + System.currentTimeMillis() + ".png");
-        try {
-            file.createNewFile();
-            FileOutputStream fos = new FileOutputStream(file);
-            InputStream is = new ByteArrayInputStream(baos.toByteArray());
-            int x = 0;
-            byte[] b = new byte[1024 * 100];
-            while ((x = is.read(b)) != -1) {
-                fos.write(b, 0, x);
-            }
-            fos.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return file.getPath();
-    }
-
-    /**
-     * 保存图片到图库
-     *
-     * @param bmp
-     */
-    public static void saveImageToGallery(Bitmap bmp, String path) {
-        // 首先保存图片
-        File file = new File(path);
-        try {
-            FileOutputStream fos = new FileOutputStream(file);
-            bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
-            fos.flush();
-            fos.close();
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static boolean writeFileToSDCard(ResponseBody body, String filePath, String fileName) {
-        if (null == body) {
-            return false;
-        }
-        try {
-            File parentFile = new File(filePath);
-            if (!parentFile.exists()) {
-                parentFile.mkdirs();
-            }
-            File futureStudioIconFile = new File(parentFile, fileName);
-            InputStream inputStream = null;
-            OutputStream outputStream = null;
-            try {
-                byte[] fileReader = new byte[4096];
-                long fileSize = body.contentLength();
-                long fileSizeDownloaded = 0;
-                inputStream = body.byteStream();
-                outputStream = new FileOutputStream(futureStudioIconFile);
-                while (true) {
-                    int read = inputStream.read(fileReader);
-                    if (read == -1) {
-                        break;
-                    }
-                    outputStream.write(fileReader, 0, read);
-                    fileSizeDownloaded += read;
-                }
-                outputStream.flush();
-                return true;
-            } catch (IOException e) {
-                return false;
-            } finally {
-                if (inputStream != null) {
-                    inputStream.close();
-                }
-                if (outputStream != null) {
-                    outputStream.close();
-                }
-            }
-        } catch (IOException e) {
-            return false;
-        }
-    }
-
-    public static String uriToFile(Context context, Uri uri, String filePath) {
-        File privateFile = new File(filePath);
-        File fileParent = privateFile.getParentFile();
-        if (!fileParent.exists()) {
-            fileParent.mkdirs();
-        }
-        if (privateFile.exists()) return privateFile.getAbsolutePath();
-        InputStream ist = null;
-        OutputStream ost = null;
-        try {
-            privateFile.createNewFile();
-            ist = context.getContentResolver().openInputStream(uri);
-            ost = new FileOutputStream(privateFile);
-            byte[] buffer = new byte[4096];
-            int byteCount = 0;
-            while ((byteCount = ist.read(buffer)) != -1) {  // 循环从输入流读取 buffer字节
-                ost.write(buffer, 0, byteCount);        // 将读取的输入流写入到输出流
-            }
-        } catch (IOException e) {
-            return "";
-        } finally {
-            try {
-                if (ist != null) {
-                    ist.close();
-                }
-                if (ost != null) {
-                    ost.close();
-                }
-            } catch (IOException e) {
-                return "";
-            }
-        }
-        return privateFile.getAbsolutePath();
-    }
-
-    public static Intent startIntent(Context context, String path) {
-        if (TextUtils.isEmpty(path)) {
-            return null;
-        }
-        Intent intent = null;
-        switch (path.substring(path.lastIndexOf(".") + 1)) {
-            case "pdf":
-                intent = getPdfFileIntent(context, path);
-                break;
-            case "text":
-                intent = getTextFileIntent(context, path);
-                break;
-            case "html":
-                intent = getHtmlFileIntent(path);
-                break;
-            case "doc":
-            case "docx":
-                intent = getWordFileIntent(context, path);
-                break;
-            case "xls":
-            case "xlsx":
-                intent = getHtmlFileIntent(path);
-                break;
-        }
-        return intent;
-    }
-
-    //android获取一个用于打开HTML文件的intent
-    public static Intent getHtmlFileIntent(String Path) {
-        File file = new File(Path);
-        Uri uri = Uri.parse(file.toString()).buildUpon().encodedAuthority("com.android.htmlfileprovider").scheme("content").encodedPath(file.toString()).build();
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.setDataAndType(uri, "text/html");
-        return intent;
-    }
-
-    //android获取一个用于打开图片文件的intent
-    public static Intent getImageFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "image/*");
-        return intent;
-    }
-
-    //android获取一个用于打开PDF文件的intent
-    public static Intent getPdfFileIntent(Context context, String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = null;
-        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
-        if (isN) {
-            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
-        } else {
-            uri = Uri.fromFile(file);
-        }
-        intent.setDataAndType(uri, "application/pdf");
-        return intent;
-    }
-
-    //android获取一个用于打开文本文件的intent
-    public static Intent getTextFileIntent(Context context, String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = null;
-        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
-        if (isN) {
-            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
-        } else {
-            uri = Uri.fromFile(file);
-
-        }
-        intent.setDataAndType(uri, "text/plain");
-        return intent;
-    }
-
-    //android获取一个用于打开音频文件的intent
-    public static Intent getAudioFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        intent.putExtra("oneshot", 0);
-        intent.putExtra("configchange", 0);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "audio/*");
-        return intent;
-    }
-
-    //android获取一个用于打开视频文件的intent
-    public static Intent getVideoFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        intent.putExtra("oneshot", 0);
-        intent.putExtra("configchange", 0);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "video/*");
-        return intent;
-    }
-
-
-    //android获取一个用于打开CHM文件的intent
-    public static Intent getChmFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "application/x-chm");
-        return intent;
-    }
-
-
-    //android获取一个用于打开Word文件的intent
-    public static Intent getWordFileIntent(Context context, String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = null;
-        final boolean isN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
-        if (isN) {
-            uri = FileProvider.getUriForFile(context, context.getPackageName() + ".FileProvider", file);
-        } else {
-            uri = Uri.fromFile(file);
-
-        }
-        intent.setDataAndType(uri, "application/msword");
-        return intent;
-    }
-
-    //android获取一个用于打开Excel文件的intent
-    public static Intent getExcelFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "application/vnd.ms-excel");
-        return intent;
-    }
-
-    //android获取一个用于打开PPT文件的intent
-    public static Intent getPPTFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent("android.intent.action.VIEW");
-        intent.addCategory("android.intent.category.DEFAULT");
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        Uri uri = Uri.fromFile(file);
-        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
-        return intent;
-    }
-
-    //android获取一个用于打开apk文件的intent
-    public static Intent getApkFileIntent(String Path) {
-        File file = new File(Path);
-        Intent intent = new Intent();
-        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.setAction(Intent.ACTION_VIEW);
-        intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
-        return intent;
-    }
-
-
-    public static final String DOCUMENTS_DIR = "documents";
-
-    @SuppressLint("NewApi")
-    public static String getPath(final Context context, final Uri uri) {
-
-        final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
-
-        // DocumentProvider
-        if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
-            // ExternalStorageProvider
-            if (isExternalStorageDocument(uri)) {
-                final String docId = DocumentsContract.getDocumentId(uri);
-                final String[] split = docId.split(":");
-                final String type = split[0];
-
-                if ("primary".equalsIgnoreCase(type)) {
-                    return Environment.getExternalStorageDirectory() + "/" + split[1];
-                }
-            }
-            // DownloadsProvider
-            else if (isDownloadsDocument(uri)) {
-
-                final String id = DocumentsContract.getDocumentId(uri);
-
-                if (id != null && id.startsWith("raw:")) {
-                    return id.substring(4);
-                }
-
-                String[] contentUriPrefixesToTry = new String[]{
-                        "content://downloads/public_downloads",
-                        "content://downloads/my_downloads"
-                };
-
-                for (String contentUriPrefix : contentUriPrefixesToTry) {
-                    Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.valueOf(id));
-                    try {
-                        String path = getDataColumn(context, contentUri, null, null);
-                        if (path != null && !path.equals("")) {
-                            return path;
-                        }
-                    } catch (Exception e) {
-                    }
-                }
-
-                // path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
-                String fileName = getFileName(context, uri);
-                File cacheDir = getDocumentCacheDir(context);
-                File file = generateFileName(fileName, cacheDir);
-                String destinationPath = null;
-                if (file != null) {
-                    destinationPath = file.getAbsolutePath();
-                    saveFileFromUri(context, uri, destinationPath);
-                }
-
-                return destinationPath;
-            }
-            // MediaProvider
-            else if (isMediaDocument(uri)) {
-                final String docId = DocumentsContract.getDocumentId(uri);
-                final String[] split = docId.split(":");
-                final String type = split[0];
-
-                Uri contentUri = null;
-                if ("image".equals(type)) {
-                    contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
-                } else if ("video".equals(type)) {
-                    contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
-                } else if ("audio".equals(type)) {
-                    contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
-                }
-
-                final String selection = "_id=?";
-                final String[] selectionArgs = new String[]{split[1]};
-
-                return getDataColumn(context, contentUri, selection, selectionArgs);
-            }
-        }
-        // MediaStore (and general)
-        else if ("content".equalsIgnoreCase(uri.getScheme())) {
-            String path = getDataColumn(context, uri, null, null);
-            if (path != null && !path.equals("")) return path;
-
-            // path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams
-            String fileName = getFileName(context, uri);
-            File cacheDir = getDocumentCacheDir(context);
-            File file = generateFileName(fileName, cacheDir);
-            String destinationPath = null;
-            if (file != null) {
-                destinationPath = file.getAbsolutePath();
-                saveFileFromUri(context, uri, destinationPath);
-            }
-            return destinationPath;
-        }
-        // File
-        else if ("file".equalsIgnoreCase(uri.getScheme())) {
-            return uri.getPath();
-        }
-        return null;
-    }
-
-    /**
-     * @param uri The Uri to check.
-     * @return Whether the Uri authority is ExternalStorageProvider.
-     */
-    public static boolean isExternalStorageDocument(Uri uri) {
-        return "com.android.externalstorage.documents".equals(uri.getAuthority());
-    }
-
-    /**
-     * @param uri The Uri to check.
-     * @return Whether the Uri authority is DownloadsProvider.
-     */
-    public static boolean isDownloadsDocument(Uri uri) {
-        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
-    }
-
-    /**
-     * @param uri The Uri to check.
-     * @return Whether the Uri authority is MediaProvider.
-     */
-    public static boolean isMediaDocument(Uri uri) {
-        return "com.android.providers.media.documents".equals(uri.getAuthority());
-    }
-
-    public static String getDataColumn(Context context, Uri uri, String selection,
-                                       String[] selectionArgs) {
-
-        Cursor cursor = null;
-        final String column = "_data";
-        final String[] projection = {column};
-        String path = "";
-        try {
-            cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
-                    null);
-            if (cursor != null && cursor.moveToFirst()) {
-                final int column_index = cursor.getColumnIndexOrThrow(column);
-                path = cursor.getString(column_index);
-                return path;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (cursor != null)
-                cursor.close();
-        }
-        return path;
-    }
-
-    public static String getFileName(@NonNull Context context, Uri uri) {
-        String mimeType = context.getContentResolver().getType(uri);
-        String filename = null;
-
-        if (mimeType == null && context != null) {
-            String path = getPath(context, uri);
-            if (path == null) {
-                filename = getName(uri.toString());
-            } else {
-                File file = new File(path);
-                filename = file.getName();
-            }
-        } else {
-            Cursor returnCursor = context.getContentResolver().query(uri, null,
-                    null, null, null);
-            if (returnCursor != null) {
-                int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
-                returnCursor.moveToFirst();
-                filename = returnCursor.getString(nameIndex);
-                returnCursor.close();
-            }
-        }
-
-        return filename;
-    }
-
-    public static String getName(String filename) {
-        if (filename == null) {
-            return null;
-        }
-        int index = filename.lastIndexOf('/');
-        return filename.substring(index + 1);
-    }
-
-    public static File getDocumentCacheDir(@NonNull Context context) {
-        File dir = new File(context.getCacheDir(), DOCUMENTS_DIR);
-        if (!dir.exists()) {
-            dir.mkdirs();
-        }
-
-        return dir;
-    }
-
-    @Nullable
-    public static File generateFileName(@Nullable String name, File directory) {
-        if (name == null) {
-            return null;
-        }
-
-        File file = new File(directory, name);
-
-        if (file.exists()) {
-            String fileName = name;
-            String extension = "";
-            int dotIndex = name.lastIndexOf('.');
-            if (dotIndex > 0) {
-                fileName = name.substring(0, dotIndex);
-                extension = name.substring(dotIndex);
-            }
-
-            int index = 0;
-
-            while (file.exists()) {
-                index++;
-                name = fileName + '(' + index + ')' + extension;
-                file = new File(directory, name);
-            }
-        }
-
-        try {
-            if (!file.createNewFile()) {
-                return null;
-            }
-        } catch (IOException e) {
-            return null;
-        }
-
-        return file;
-    }
-
-
-    private static void saveFileFromUri(Context context, Uri uri, String destinationPath) {
-        InputStream is = null;
-        BufferedOutputStream bos = null;
-        try {
-            is = context.getContentResolver().openInputStream(uri);
-            bos = new BufferedOutputStream(new FileOutputStream(destinationPath, false));
-            byte[] buf = new byte[1024];
-            is.read(buf);
-            do {
-                bos.write(buf);
-            } while (is.read(buf) != -1);
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (is != null) is.close();
-                if (bos != null) bos.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-
-    //bitmap转为base64
-    public static String bitmapToBase64(Bitmap bitmap) {
-
-        String result = null;
-        ByteArrayOutputStream baos = null;
-        try {
-            if (bitmap != null) {
-                baos = new ByteArrayOutputStream();
-                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
-
-                baos.flush();
-                baos.close();
-
-                byte[] bitmapBytes = baos.toByteArray();
-                result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (baos != null) {
-                    baos.flush();
-                    baos.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return result;
-    }
-
-    //base64转为bitmap
-    public static Bitmap base64ToBitmap(String base64Data) {
-        byte[] bytes = Base64.decode(base64Data, Base64.NO_WRAP);
-        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
-    }
-}
-