Commit a3a7ee80e099ede550cea21efdd523762ab9f8ab

Authored by 韩亚云
1 parent c57fee4c

增加回收站,删除,排序,新建文件夹,重命名功能以及相关的ui展示

Showing 100 changed files with 2574 additions and 1 deletions

Too many changes to show.

To preserve performance only 100 of 164 files are displayed.

.idea/vcs.xml
... ... @@ -2,5 +2,6 @@
2 2 <project version="4">
3 3 <component name="VcsDirectoryMappings">
4 4 <mapping directory="" vcs="Git" />
  5 + <mapping directory="$PROJECT_DIR$/Updown" vcs="Git" />
5 6 </component>
6 7 </project>
7 8 \ No newline at end of file
... ...
app/build.gradle
... ... @@ -34,4 +34,9 @@ dependencies {
34 34 androidTestImplementation 'com.android.support.test:runner:1.0.2'
35 35 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
36 36 api project(':updownfile')
  37 +
  38 + implementation "com.android.support:recyclerview-v7:28.0.0"
  39 + implementation "com.github.bumptech.glide:glide:4.5.0"
  40 + implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.40'
  41 + implementation 'com.lcodecorex:tkrefreshlayout:1.0.7'
37 42 }
... ...
app/src/main/java/com/cnlive/updown/MainActivity.java
... ... @@ -4,7 +4,8 @@ import android.content.Intent;
4 4 import android.support.v7.app.AppCompatActivity;
5 5 import android.os.Bundle;
6 6  
7   -import com.cnlive.updownfile.InitViewActivity;
  7 +import com.cnlive.updownfile.xiaoRay.InitViewActivity;
  8 +
8 9  
9 10 public class MainActivity extends AppCompatActivity {
10 11  
... ...
filespicker/.gitignore 0 → 100644
  1 +/build
... ...
filespicker/build.gradle 0 → 100644
  1 +apply plugin: 'com.android.library'
  2 +
  3 +android {
  4 + compileSdkVersion 28
  5 +
  6 +
  7 +
  8 + defaultConfig {
  9 + minSdkVersion 16
  10 + targetSdkVersion 28
  11 + versionCode 1
  12 + versionName "1.0"
  13 +
  14 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  15 + }
  16 +
  17 + dependencies {
  18 + implementation fileTree(dir: 'libs', include: ['*.jar'])
  19 +
  20 + implementation "com.android.support:appcompat-v7:28.0.0"
  21 + implementation "com.android.support:recyclerview-v7:28.0.0"
  22 + implementation "com.android.support.constraint:constraint-layout:1.1.3"
  23 +
  24 + implementation 'com.cnlive.libs:mediapicker:1.2.2'
  25 + implementation 'com.cnlive.libs:base:1.0.7'
  26 + }
  27 +
  28 +}
0 29 \ No newline at end of file
... ...
filespicker/proguard-rules.pro 0 → 100644
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
... ...
filespicker/src/main/AndroidManifest.xml 0 → 100644
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + package="com.cnlive.filespicker">
  3 +
  4 + <application android:largeHeap="true">
  5 + <activity
  6 + android:name=".ui.FilePickerActivity"
  7 + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  8 + android:screenOrientation="portrait" />
  9 + </application>
  10 +</manifest>
... ...
filespicker/src/main/java/com/cnlive/filespicker/ExFilePicker.java 0 → 100644
  1 +package com.cnlive.filespicker;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +import android.os.Build;
  7 +import android.support.annotation.NonNull;
  8 +import android.support.annotation.Nullable;
  9 +import android.support.annotation.RequiresApi;
  10 +
  11 +import com.cnlive.filespicker.ui.FilePickerActivity;
  12 +
  13 +public class ExFilePicker {
  14 +
  15 + @Nullable
  16 + private String mStartDirectory;
  17 + private int mMaxFileCount;
  18 + private int maxVideoSize;
  19 + private int maxFileSize;
  20 + private int maxImageSize;
  21 +
  22 + public void setMaxVideoSize(int maxVideoSize) {
  23 + this.maxVideoSize = maxVideoSize;
  24 + }
  25 +
  26 + public void setMaxFileSize(int maxFileSize) {
  27 + this.maxFileSize = maxFileSize;
  28 + }
  29 +
  30 + public void setMaxImageSize(int maxImageSize) {
  31 + this.maxImageSize = maxImageSize;
  32 + }
  33 +
  34 + public void setStartDirectory(@Nullable String startDirectory) {
  35 + mStartDirectory = startDirectory;
  36 + }
  37 +
  38 + public void setMaxFileCount(int maxFileCount) {
  39 + this.mMaxFileCount = maxFileCount;
  40 + }
  41 +
  42 + public void start(@NonNull Activity activity, int requestCode) {
  43 + activity.startActivityForResult(createIntent(activity), requestCode);
  44 + }
  45 +
  46 + public void start(@NonNull android.support.v4.app.Fragment fragment, int requestCode) {
  47 + fragment.startActivityForResult(createIntent(fragment.getContext()), requestCode);
  48 + }
  49 +
  50 + @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
  51 + public void start(@NonNull android.app.Fragment fragment, int requestCode) {
  52 + Context context;
  53 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  54 + context = fragment.getContext();
  55 + } else {
  56 + context = fragment.getActivity();
  57 + }
  58 + fragment.startActivityForResult(createIntent(context), requestCode);
  59 + }
  60 +
  61 + @NonNull
  62 + private Intent createIntent(@NonNull Context context) {
  63 + Intent intent = new Intent(context, FilePickerActivity.class);
  64 + intent.putExtra(FilePickerActivity.EXTRA_START_DIRECTORY, mStartDirectory);
  65 + intent.putExtra(FilePickerActivity.SELECT_MAX_FILE_COUNT, mMaxFileCount);
  66 + intent.putExtra(FilePickerActivity.EXTRA_MAX_IMAGE_SIZE, maxImageSize);
  67 + intent.putExtra(FilePickerActivity.EXTRA_MAX_VIDEO_SIZE, maxVideoSize);
  68 + intent.putExtra(FilePickerActivity.EXTRA_MAX_FILE_SIZE, maxFileSize);
  69 + return intent;
  70 + }
  71 +
  72 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/ui/FilePickerActivity.java 0 → 100644
  1 +package com.cnlive.filespicker.ui;
  2 +
  3 +import android.Manifest;
  4 +import android.animation.ValueAnimator;
  5 +import android.app.Activity;
  6 +import android.content.Intent;
  7 +import android.os.Bundle;
  8 +import android.os.Environment;
  9 +import android.support.annotation.NonNull;
  10 +import android.support.annotation.Nullable;
  11 +import android.support.v7.app.AppCompatActivity;
  12 +import android.support.v7.widget.LinearLayoutManager;
  13 +import android.support.v7.widget.RecyclerView;
  14 +import android.view.Gravity;
  15 +import android.view.View;
  16 +import android.view.ViewGroup;
  17 +import android.view.WindowManager;
  18 +import android.widget.ImageView;
  19 +import android.widget.PopupWindow;
  20 +import android.widget.TextView;
  21 +
  22 +import com.cnlive.filespicker.R;
  23 +import com.cnlive.filespicker.ui.adapter.FileListAdapter;
  24 +import com.cnlive.filespicker.ui.adapter.SelectListAdapter;
  25 +import com.cnlive.filespicker.ui.model.FilePickerResult;
  26 +import com.cnlive.filespicker.utils.FilePickerUtils;
  27 +import com.cnlive.filespicker.utils.FilesListComparator;
  28 +import com.cnlive.filespicker.utils.ListUtils;
  29 +import com.cnlive.filespicker.utils.ScreenUtil;
  30 +import com.cnlive.filespicker.utils.StatusBarUtil2;
  31 +import com.cnlive.libs.base.util.AlertUtil;
  32 +import com.cnlive.media.picker.utils.PermissionChecker;
  33 +
  34 +import java.io.File;
  35 +import java.util.ArrayList;
  36 +import java.util.Collections;
  37 +import java.util.List;
  38 +
  39 +public class FilePickerActivity extends AppCompatActivity implements FileListAdapter.OnFileItemSelectListener, View.OnClickListener {
  40 + public static final int REQUEST_CODE_WRITE_STORAGE = 0x1001;
  41 +
  42 + public static final String EXTRA_START_DIRECTORY = "START_DIRECTORY";
  43 + public static final String SELECT_MAX_FILE_COUNT = "MAX_FILE_COUNT";
  44 + public static final String EXTRA_MAX_FILE_SIZE = "MAX_FILE_SIZE";
  45 + public static final String EXTRA_MAX_VIDEO_SIZE = "MAX_VIDEO_SIZE";
  46 + public static final String EXTRA_MAX_IMAGE_SIZE = "MAX_IMAGE_SIZE";
  47 +
  48 + private static final int DEFAULT_MAX_FILE_SIZE = 20 * 1024 * 1024;
  49 +
  50 + public static final String app_path = "网++文件";
  51 + public static final String ext_path = "手机存储";
  52 +
  53 + private int maxCount;
  54 + private int maxImageSize;
  55 + private int maxVideoSize;
  56 + private int maxFileSize;
  57 + private File mCurrentDirectory;
  58 +
  59 + private TextView titleView, pathView, sendView, selectFolder, totalSizeView;
  60 + private ImageView closeView;
  61 + private RecyclerView recyclerView;
  62 + private View emptyView, selectView;
  63 +
  64 + private FileListAdapter mAdapter;
  65 +
  66 + private PopupWindow popupWindow;
  67 + private RecyclerView popupWindowContentView;
  68 + private List<String> lists = new ArrayList<String>();
  69 +
  70 + private String topDirectory;
  71 + private List<File> selectFileList;
  72 + //是否默认展示网++文件夹
  73 + private boolean isDefaultShowWang = true;
  74 +
  75 + @Override
  76 + protected void onCreate(@Nullable Bundle savedInstanceState) {
  77 + super.onCreate(savedInstanceState);
  78 + setContentView(R.layout.activity_file_picker);
  79 + StatusBarUtil2.setColor(this, getResources().getColor(R.color.top_bar_color), 0);
  80 + if (initPermission()) {
  81 + showData();
  82 + }
  83 + }
  84 +
  85 + private void showData() {
  86 + handleIntent();
  87 + initView();
  88 + createFolderView();
  89 + }
  90 +
  91 + private boolean initPermission() {
  92 + return PermissionChecker.checkPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CODE_WRITE_STORAGE, R.string.permission_write_storage_checker, true);
  93 + }
  94 +
  95 + @Override
  96 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  97 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  98 + if (requestCode == REQUEST_CODE_WRITE_STORAGE) {
  99 + boolean hasPermission = PermissionChecker.onRequestPermissionsResult(this,requestCode,permissions, grantResults, true, R.string.permission_write_storage_checker)[0];
  100 + boolean isNeverAsk = PermissionChecker.onRequestPermissionsResult(this,requestCode,permissions, grantResults, true, R.string.permission_write_storage_checker)[1];
  101 + if (!hasPermission && !isNeverAsk) {
  102 + finish();
  103 + } else if (hasPermission) {
  104 + showData();
  105 + }
  106 + }
  107 + }
  108 +
  109 + private void handleIntent() {
  110 + Intent intent = getIntent();
  111 + maxCount = intent.getIntExtra(SELECT_MAX_FILE_COUNT, -1);
  112 + mCurrentDirectory = getStartDirectory(intent);
  113 + topDirectory = mCurrentDirectory.getPath();
  114 + maxFileSize = intent.getIntExtra(EXTRA_MAX_FILE_SIZE, DEFAULT_MAX_FILE_SIZE);
  115 + maxVideoSize = intent.getIntExtra(EXTRA_MAX_VIDEO_SIZE, DEFAULT_MAX_FILE_SIZE);
  116 + maxImageSize = intent.getIntExtra(EXTRA_MAX_IMAGE_SIZE, DEFAULT_MAX_FILE_SIZE);
  117 + }
  118 +
  119 + private void initView() {
  120 + titleView = findViewById(R.id.title);
  121 + pathView = findViewById(R.id.path);
  122 + sendView = findViewById(R.id.send);
  123 + selectFolder = findViewById(R.id.selectFolder);
  124 + closeView = findViewById(R.id.close);
  125 + selectView = findViewById(R.id.selectView);
  126 + recyclerView = findViewById(R.id.recyclerView);
  127 + emptyView = findViewById(R.id.emptyView);
  128 + totalSizeView = findViewById(R.id.totalSize);
  129 +
  130 + mAdapter = new FileListAdapter(this);
  131 + mAdapter.setListener(this);
  132 + mAdapter.setMaxCount(maxCount);
  133 + mAdapter.setMaxFileSize(maxFileSize);
  134 + mAdapter.setMaxImageSize(maxImageSize);
  135 + mAdapter.setMaxVideoSize(maxVideoSize);
  136 + recyclerView.setLayoutManager(new LinearLayoutManager(this));
  137 + recyclerView.setAdapter(mAdapter);
  138 + sendView.setClickable(false);
  139 + sendView.setOnClickListener(this);
  140 + selectView.setOnClickListener(this);
  141 + closeView.setOnClickListener(this);
  142 + pathView.setVisibility(View.GONE);
  143 + readDirectory(mCurrentDirectory);
  144 + }
  145 +
  146 + private void createFolderView() {
  147 + if (lists != null)
  148 + lists.clear();
  149 + lists.add(app_path);
  150 + lists.add(ext_path);
  151 + selectFolder.setText(isDefaultShowWang ? app_path : ext_path);
  152 + titleView.setText(selectFolder.getText().toString());
  153 + SelectListAdapter selectListAdapter = new SelectListAdapter(this);
  154 + selectListAdapter.updateItems(lists);
  155 + selectListAdapter.setOnItemSelectListener(new SelectListAdapter.OnItemSelectListener() {
  156 + @Override
  157 + public void onItemSelect(int position) {
  158 + if (popupWindow != null) popupWindow.dismiss();
  159 + switch (position) {
  160 + case 0:
  161 + mCurrentDirectory = getAppPathDirectory(getIntent());
  162 + selectFolder.setText(app_path);
  163 + break;
  164 + case 1:
  165 + mCurrentDirectory = Environment.getExternalStorageDirectory();
  166 + selectFolder.setText(ext_path);
  167 + break;
  168 + }
  169 + topDirectory = mCurrentDirectory.getPath();
  170 + readDirectory(mCurrentDirectory);
  171 + titleView.setText(selectFolder.getText().toString());
  172 + }
  173 + });
  174 + popupWindowContentView = new RecyclerView(this);
  175 + popupWindowContentView.setLayoutManager(new LinearLayoutManager(this));
  176 + popupWindowContentView.setBackgroundColor(getResources().getColor(android.R.color.white));
  177 + popupWindowContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  178 + popupWindowContentView.setAdapter(selectListAdapter);
  179 + if (popupWindow == null)
  180 + popupWindow = new PopupWindow(popupWindowContentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
  181 + popupWindow.setOutsideTouchable(true);
  182 + popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
  183 + @Override
  184 + public void onDismiss() {
  185 + bgAlpha(0.6f, 1f);
  186 + }
  187 + });
  188 + }
  189 +
  190 + @NonNull
  191 + private File getStartDirectory(@NonNull Intent intent) {
  192 + File path = getAppPathDirectory(intent);
  193 + if (path == null || path.listFiles() == null || path.listFiles().length <= 0) {
  194 + if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
  195 + path = Environment.getExternalStorageDirectory();
  196 + isDefaultShowWang = false;
  197 + }
  198 + }
  199 + return path;
  200 + }
  201 +
  202 + @NonNull
  203 + private File getAppPathDirectory(@NonNull Intent intent) {
  204 + File path = null;
  205 + String startPath = intent.getStringExtra(EXTRA_START_DIRECTORY);
  206 + if (startPath != null && startPath.length() > 0) {
  207 + File tmp = new File(startPath);
  208 + if (tmp.exists() && tmp.isDirectory()) {
  209 + path = tmp;
  210 + }
  211 + }
  212 + return path;
  213 + }
  214 +
  215 + private void readUpDirectory() {
  216 + mCurrentDirectory = mCurrentDirectory.getParentFile();
  217 + readDirectory(mCurrentDirectory);
  218 + }
  219 +
  220 + private void readDirectory(@NonNull File directory) {
  221 + mCurrentDirectory = directory;
  222 + setDesc(directory);
  223 + File[] files = directory.listFiles();
  224 + List<File> fileList = new ArrayList<>();
  225 + if (files == null || files.length == 0) {
  226 + emptyView.setVisibility(View.VISIBLE);
  227 + recyclerView.setVisibility(View.GONE);
  228 + } else {
  229 + ListUtils.copyListWithCondition(files, fileList, new ListUtils.ConditionChecker<File>() {
  230 + @Override
  231 + public boolean check(@NonNull File item) {
  232 + return !item.isHidden();
  233 + }
  234 + });
  235 + if (fileList != null && fileList.size() > 0) {
  236 + emptyView.setVisibility(View.GONE);
  237 + recyclerView.setVisibility(View.VISIBLE);
  238 + try {
  239 + Collections.sort(fileList, new FilesListComparator());
  240 + } catch (Exception e) {
  241 + }
  242 + } else {
  243 + emptyView.setVisibility(View.VISIBLE);
  244 + recyclerView.setVisibility(View.GONE);
  245 + }
  246 + mAdapter.updateItems(fileList);
  247 + }
  248 + }
  249 +
  250 + private void setDesc(@NonNull File directory) {
  251 + if (isTopDirectory(directory)) {
  252 + pathView.setVisibility(View.GONE);
  253 + pathView.setText("");
  254 + } else {
  255 + String path = directory.getAbsolutePath();
  256 + String desc = path.startsWith(topDirectory + "/") ? path.replace(topDirectory + "/", "") : path;
  257 + pathView.setVisibility(View.VISIBLE);
  258 + pathView.setText(desc);
  259 + }
  260 + }
  261 +
  262 + private boolean isTopDirectory(@Nullable File directory) {
  263 + return directory != null && topDirectory.equals(directory.getAbsolutePath());
  264 + }
  265 +
  266 + @Override
  267 + public void onBackPressed() {
  268 + if (mCurrentDirectory == null || isTopDirectory(mCurrentDirectory)) {
  269 + super.onBackPressed();
  270 + } else {
  271 + readUpDirectory();
  272 + }
  273 + }
  274 +
  275 + @Override
  276 + protected void onDestroy() {
  277 + if (popupWindow != null) {
  278 + popupWindow.dismiss();
  279 + popupWindow = null;
  280 + }
  281 + super.onDestroy();
  282 + }
  283 +
  284 + @Override
  285 + public void onItemCheckedChanged(List<File> selectFileList) {
  286 + this.selectFileList = selectFileList;
  287 + setSendText(selectFileList == null ? 0 : selectFileList.size());
  288 + }
  289 +
  290 + @Override
  291 + public void onDirectoryItemClick(File file) {
  292 + readDirectory(file);
  293 + }
  294 +
  295 + private void setSendText(int curCount) {
  296 + sendView.setText("发送" + (curCount > 0 ? ("(" + curCount + "/" + maxCount + ")") : ""));
  297 + sendView.setClickable(curCount > 0);
  298 + setTotalFileSizeText(curCount);
  299 + }
  300 +
  301 + @Override
  302 + public void onClick(View v) {
  303 + if (v.getId() == R.id.send) {
  304 + if (selectFileList == null || selectFileList.size() <= 0) {
  305 + AlertUtil.showDeftToast(this, getString(R.string.select_no_file));
  306 + return;
  307 + }
  308 + Intent intent = getIntent();
  309 + intent.putExtra(FilePickerResult.RESULT, new FilePickerResult(selectFileList));
  310 + setResult(Activity.RESULT_OK, intent);
  311 + finish();
  312 + } else if (v.getId() == R.id.selectView) {
  313 + if (popupWindow == null) return;
  314 + if (popupWindow.isShowing()) {
  315 + popupWindow.dismiss();
  316 + } else {
  317 + if (popupWindowContentView == null) return;
  318 + int windowPos[] = ScreenUtil.calculatePopWindowPos(findViewById(R.id.bottomLayout), popupWindowContentView);
  319 + popupWindow.showAtLocation(findViewById(R.id.bottomLayout), Gravity.NO_GRAVITY, windowPos[0], windowPos[1]);
  320 + bgAlpha(1f, 0.6f);
  321 + }
  322 + } else if (v.getId() == R.id.close) {
  323 + finish();
  324 + }
  325 + }
  326 +
  327 + private void bgAlpha(float fromBgAlpha, float toBgAlpha) {
  328 + ValueAnimator animator = ValueAnimator.ofFloat(fromBgAlpha, toBgAlpha).setDuration(200);
  329 + animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
  330 + @Override
  331 + public void onAnimationUpdate(ValueAnimator animation) {
  332 + WindowManager.LayoutParams lp = getWindow().getAttributes();
  333 + lp.alpha = (float) animation.getAnimatedValue(); //0.0-1.0
  334 + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
  335 + getWindow().setAttributes(lp);
  336 + }
  337 + });
  338 + animator.start();
  339 + }
  340 +
  341 + public void setTotalFileSizeText(int curCount) {
  342 + totalSizeView.setVisibility(curCount > 0 ? View.VISIBLE : View.GONE);
  343 + if (curCount <= 0) return;
  344 + long totalSize = 0;
  345 + for (File file : selectFileList) {
  346 + totalSize += file.length();
  347 + }
  348 + totalSizeView.setText("已选:" + FilePickerUtils.getDataSize(totalSize));
  349 + }
  350 +
  351 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/ui/adapter/BaseRecyclerAdapter.java 0 → 100644
  1 +package com.cnlive.filespicker.ui.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.support.v7.widget.RecyclerView;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.Collections;
  8 +import java.util.List;
  9 +
  10 +public abstract class BaseRecyclerAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
  11 +
  12 + protected List<T> mItems;
  13 + protected Context mContext;
  14 +
  15 + public BaseRecyclerAdapter(Context context) {
  16 + this.mContext = context;
  17 + mItems = new ArrayList<>();
  18 + }
  19 +
  20 + public List<T> getList() {
  21 + return mItems;
  22 + }
  23 +
  24 + public void addItem(T item) {
  25 + addItem(mItems.size(), item);
  26 + }
  27 +
  28 + public void addItem(int index, T item) {
  29 + if (item == null) return;
  30 + mItems.add(index, item);
  31 + try {
  32 + notifyItemInserted(index);
  33 + } catch (Exception e) {
  34 + }
  35 + }
  36 +
  37 + public void addItems(List<T> items) {
  38 + if (items == null) return;
  39 + int position = mItems.size() - 1;
  40 + this.mItems.addAll(items);
  41 + notifyDataSetChanged();
  42 + }
  43 +
  44 + public void addItems(int indext, List<T> items) {
  45 + if (items == null) return;
  46 + this.mItems.addAll(indext, items);
  47 + notifyItemRangeInserted(indext, items.size());
  48 + }
  49 +
  50 + public boolean containsAll(List<T> items) {
  51 + return mItems.containsAll(items);
  52 + }
  53 +
  54 + public void updateItem(T tasks, int position) {
  55 + if (tasks == null) return;
  56 + mItems.set(position, tasks);
  57 + try {
  58 + notifyItemChanged(position);
  59 + } catch (Exception e) {
  60 + }
  61 + }
  62 +
  63 + public void updateItems(List<T> items) {
  64 + if (items == null) return;
  65 + this.mItems.clear();
  66 + this.mItems.addAll(items);
  67 + notifyDataSetChanged();
  68 + }
  69 +
  70 + public int indexOf(T item) {
  71 + if (item == null || mItems == null || mItems.size() <= 0) return -1;
  72 + return mItems.indexOf(item);
  73 + }
  74 +
  75 + public void removeItem(int index) {
  76 + mItems.remove(index);
  77 + notifyItemRemoved(index);
  78 + }
  79 +
  80 + public void removeAllItems() {
  81 + mItems.clear();
  82 + notifyDataSetChanged();
  83 + }
  84 +
  85 + public void moveItem(T item, int fromPosition, int toPosition) {
  86 + if (fromPosition > toPosition) {
  87 + Collections.rotate(mItems.subList(toPosition, fromPosition + 1), 1);
  88 + } else {
  89 + Collections.rotate(mItems.subList(fromPosition, toPosition + 1), -1);
  90 + }
  91 + notifyItemMoved(fromPosition, toPosition);
  92 + mItems.set(toPosition, item);
  93 + notifyItemChanged(toPosition);
  94 + }
  95 +
  96 + public void getView(int position, RecyclerView.ViewHolder viewHolder, int type, T item) {
  97 + }
  98 +
  99 + public T getItem(int location) {
  100 + return mItems.get(location);
  101 + }
  102 +
  103 + @Override
  104 + public int getItemCount() {
  105 + return mItems == null ? 0 : mItems.size();
  106 + }
  107 +
  108 +
  109 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/ui/adapter/FileListAdapter.java 0 → 100644
  1 +package com.cnlive.filespicker.ui.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.support.annotation.NonNull;
  5 +import android.support.v7.widget.RecyclerView;
  6 +import android.view.LayoutInflater;
  7 +import android.view.View;
  8 +import android.view.ViewGroup;
  9 +import android.widget.CheckBox;
  10 +import android.widget.ImageView;
  11 +import android.widget.TextView;
  12 +
  13 +import com.cnlive.filespicker.R;
  14 +import com.cnlive.filespicker.utils.FilePickerUtils;
  15 +import com.cnlive.libs.base.util.AlertUtil;
  16 +
  17 +import java.io.File;
  18 +import java.util.ArrayList;
  19 +import java.util.List;
  20 +
  21 +public class FileListAdapter extends BaseRecyclerAdapter<File> {
  22 +
  23 + public static final int TYPE_FILE = 0X1001;
  24 + public static final int TYPE_DIRECTORY = 0X1002;
  25 +
  26 + private int maxCount;
  27 + private int maxImageSize;
  28 + private int maxVideoSize;
  29 + private int maxFileSize;
  30 +
  31 + private List<File> selectFileList;
  32 +
  33 + private OnFileItemSelectListener listener;
  34 +
  35 + public FileListAdapter(Context context) {
  36 + super(context);
  37 + selectFileList = new ArrayList<>();
  38 + }
  39 +
  40 + public void setListener(OnFileItemSelectListener listener) {
  41 + this.listener = listener;
  42 + }
  43 +
  44 + public void setMaxCount(int maxCount) {
  45 + this.maxCount = maxCount;
  46 + }
  47 +
  48 + public void setMaxFileSize(int maxFileSize) {
  49 + this.maxFileSize = maxFileSize;
  50 + }
  51 +
  52 + public void setMaxImageSize(int maxImageSize) {
  53 + this.maxImageSize = maxImageSize;
  54 + }
  55 +
  56 + public void setMaxVideoSize(int maxVideoSize) {
  57 + this.maxVideoSize = maxVideoSize;
  58 + }
  59 +
  60 + @NonNull
  61 + @Override
  62 + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  63 + return new FileListHolder(LayoutInflater.from(mContext).inflate(R.layout.list_item_file, parent, false));
  64 + }
  65 +
  66 + @Override
  67 + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
  68 + FileListHolder fileListHolder = (FileListHolder) holder;
  69 + fileListHolder.show(getItem(position));
  70 + }
  71 +
  72 + @Override
  73 + public int getItemViewType(int position) {
  74 + return getItem(position).isFile() ? TYPE_FILE : TYPE_DIRECTORY;
  75 + }
  76 +
  77 + public class FileListHolder extends RecyclerView.ViewHolder {
  78 + private TextView titleView, descView;
  79 + private View checkLayout;
  80 + private ImageView iconView;
  81 + private CheckBox checkBox;
  82 + private View rootLayout;
  83 +
  84 + private Context mContext;
  85 +
  86 + public FileListHolder(View itemView) {
  87 + super(itemView);
  88 + mContext = itemView.getContext();
  89 + titleView = itemView.findViewById(R.id.title);
  90 + descView = itemView.findViewById(R.id.desc);
  91 + checkLayout = itemView.findViewById(R.id.checkLayout);
  92 + iconView = itemView.findViewById(R.id.icon);
  93 + checkBox = itemView.findViewById(R.id.checkbox);
  94 + rootLayout = itemView.findViewById(R.id.rootLayout);
  95 + }
  96 +
  97 + public void show(final File file) {
  98 + File[] childFiles = file.listFiles();
  99 + String desc = file.isFile() ? FilePickerUtils.getDataSize(file.length()) + " " + FilePickerUtils.getModifiedTime(file) : ("文件:" + (childFiles == null ? 0 : childFiles.length));
  100 + descView.setText(desc);
  101 + checkLayout.setVisibility(file.isFile() ? View.VISIBLE : View.GONE);
  102 + titleView.setText(file.getName());
  103 + iconView.setImageDrawable(FilePickerUtils.matchImage(mContext, file.isDirectory(), file.getName()));
  104 + if (file.isFile())
  105 + checkBox.setChecked(containsFile(file));
  106 +
  107 + rootLayout.setOnClickListener(new View.OnClickListener() {
  108 + @Override
  109 + public void onClick(View v) {
  110 + if (file.isDirectory()) {
  111 + if (listener != null)
  112 + listener.onDirectoryItemClick(file);
  113 + } else {
  114 + fileItemClick(file);
  115 + }
  116 + }
  117 + });
  118 +
  119 + }
  120 +
  121 + private void fileItemClick(File file) {
  122 + if (!checkBox.isChecked() && !containsFile(file)) {
  123 + if (selectFileList.size() < maxCount) {
  124 + if (file.length() <= 0) {
  125 + AlertUtil.showDeftToast(mContext, mContext.getString(R.string.min_file_size));
  126 + return;
  127 + }
  128 + boolean canSelect = canSelect(file);
  129 + if (canSelect) {
  130 + checkBox.setChecked(true);
  131 + selectFileList.add(file);
  132 + if (listener != null)
  133 + listener.onItemCheckedChanged(selectFileList);
  134 + } else {
  135 + AlertUtil.showDeftToast(mContext, mContext.getString(R.string.max_file_size));
  136 + }
  137 + } else {
  138 + AlertUtil.showDeftToast(mContext, mContext.getString(R.string.max_file_count));
  139 + }
  140 + } else if (checkBox.isChecked() && containsFile(file)) {
  141 + checkBox.setChecked(false);
  142 + selectFileList.remove(file);
  143 + if (listener != null)
  144 + listener.onItemCheckedChanged(selectFileList);
  145 + }
  146 + }
  147 +
  148 + private boolean containsFile(File curFile) {
  149 + if (curFile.isDirectory()) return false;
  150 + for (File file : selectFileList) {
  151 + if (file.getAbsolutePath().equals(curFile.getAbsolutePath())) {
  152 + return true;
  153 + }
  154 + }
  155 + return false;
  156 + }
  157 +
  158 + private boolean canSelect(File file) {
  159 + if (FilePickerUtils.isImage(file.getName())) {
  160 + if (file.length() <= maxImageSize)
  161 + return true;
  162 + } else if (FilePickerUtils.isVideo(file.getName())) {
  163 + if (file.length() <= maxVideoSize)
  164 + return true;
  165 + } else {
  166 + if (file.length() <= maxFileSize)
  167 + return true;
  168 + }
  169 + return false;
  170 + }
  171 + }
  172 +
  173 + public interface OnFileItemSelectListener {
  174 + void onItemCheckedChanged(List<File> selectFileList);
  175 +
  176 + void onDirectoryItemClick(File file);
  177 + }
  178 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/ui/adapter/SelectListAdapter.java 0 → 100644
  1 +package com.cnlive.filespicker.ui.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.support.annotation.NonNull;
  5 +import android.support.v7.widget.RecyclerView;
  6 +import android.view.LayoutInflater;
  7 +import android.view.View;
  8 +import android.view.ViewGroup;
  9 +import android.widget.TextView;
  10 +
  11 +import com.cnlive.filespicker.R;
  12 +
  13 +public class SelectListAdapter extends BaseRecyclerAdapter<String> {
  14 +
  15 + private OnItemSelectListener onItemSelectListener;
  16 +
  17 + public SelectListAdapter(Context context) {
  18 + super(context);
  19 + }
  20 +
  21 + public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
  22 + this.onItemSelectListener = onItemSelectListener;
  23 + }
  24 +
  25 + @NonNull
  26 + @Override
  27 + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  28 + return new SelectListHolder(LayoutInflater.from(mContext).inflate(R.layout.list_item_select, parent, false));
  29 + }
  30 +
  31 + @Override
  32 + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
  33 + SelectListHolder selectListHolder = (SelectListHolder) holder;
  34 + selectListHolder.show(getItem(position), position);
  35 + }
  36 +
  37 + public class SelectListHolder extends RecyclerView.ViewHolder {
  38 + private TextView textView;
  39 +
  40 + public SelectListHolder(View itemView) {
  41 + super(itemView);
  42 + textView = itemView.findViewById(R.id.text);
  43 + }
  44 +
  45 + public void show(String content, final int position) {
  46 + textView.setText(content);
  47 + textView.setOnClickListener(new View.OnClickListener() {
  48 + @Override
  49 + public void onClick(View v) {
  50 + if (onItemSelectListener != null)
  51 + onItemSelectListener.onItemSelect(position);
  52 + }
  53 + });
  54 + }
  55 + }
  56 +
  57 + public interface OnItemSelectListener {
  58 + void onItemSelect(int position);
  59 + }
  60 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/ui/model/FilePickerResult.java 0 → 100644
  1 +package com.cnlive.filespicker.ui.model;
  2 +
  3 +import android.content.Intent;
  4 +
  5 +import java.io.File;
  6 +import java.io.Serializable;
  7 +import java.util.List;
  8 +
  9 +public class FilePickerResult implements Serializable {
  10 + public static final String RESULT = "result";
  11 +
  12 + public FilePickerResult(List<File> fileList) {
  13 + this.fileList = fileList;
  14 + }
  15 +
  16 + private List<File> fileList;
  17 +
  18 + public List<File> getFileList() {
  19 + return fileList;
  20 + }
  21 +
  22 + public void setFileList(List<File> fileList) {
  23 + this.fileList = fileList;
  24 + }
  25 +
  26 + public static FilePickerResult getPickerResult(Intent intent) {
  27 + if(intent.getSerializableExtra(RESULT) != null){
  28 + return (FilePickerResult) intent.getSerializableExtra(RESULT);
  29 + }
  30 + return null;
  31 + }
  32 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/utils/FilePickerUtils.java 0 → 100644
  1 +package com.cnlive.filespicker.utils;
  2 +
  3 +import android.content.Context;
  4 +import android.content.res.Resources;
  5 +import android.graphics.drawable.Drawable;
  6 +import android.text.TextUtils;
  7 +
  8 +import com.cnlive.filespicker.R;
  9 +
  10 +import java.io.File;
  11 +import java.math.RoundingMode;
  12 +import java.text.DecimalFormat;
  13 +
  14 +public class FilePickerUtils {
  15 + public static Drawable matchImage(Context context, boolean isDir, String fileName) {
  16 + Resources resources = context.getResources();
  17 + if (isDir)
  18 + return resources.getDrawable(R.drawable.ks_format_forder);
  19 + if (fileName.endsWith(".3gp")) return resources.getDrawable(R.drawable.ks_format_3gp);
  20 + else if (fileName.endsWith(".apk")) return resources.getDrawable(R.drawable.ks_format_apk);
  21 + else if (fileName.endsWith(".asf")) return resources.getDrawable(R.drawable.ks_format_asf);
  22 + else if (fileName.endsWith(".avi")) return resources.getDrawable(R.drawable.ks_format_avi);
  23 + else if (fileName.endsWith(".bin")) return resources.getDrawable(R.drawable.ks_format_bin);
  24 + else if (fileName.endsWith(".bmp")) return resources.getDrawable(R.drawable.ks_format_bmp);
  25 + else if (fileName.endsWith(".c")) return resources.getDrawable(R.drawable.ks_format_c);
  26 + else if (fileName.endsWith(".class"))
  27 + return resources.getDrawable(R.drawable.ks_format_class);
  28 + else if (fileName.endsWith(".conf"))
  29 + return resources.getDrawable(R.drawable.ks_format_conf);
  30 + else if (fileName.endsWith(".cpp")) return resources.getDrawable(R.drawable.ks_format_cpp);
  31 + else if (fileName.endsWith(".doc")) return resources.getDrawable(R.drawable.ks_format_doc);
  32 + else if (fileName.endsWith(".docx"))
  33 + return resources.getDrawable(R.drawable.ks_format_docx);
  34 + else if (fileName.endsWith(".exe"))
  35 + return resources.getDrawable(R.drawable.ks_format_exe);
  36 + else if (fileName.endsWith(".gif"))
  37 + return resources.getDrawable(R.drawable.ks_format_gif);
  38 + else if (fileName.endsWith(".gtar"))
  39 + return resources.getDrawable(R.drawable.ks_format_gtar);
  40 + else if (fileName.endsWith(".gz")) return resources.getDrawable(R.drawable.ks_format_gz);
  41 + else if (fileName.endsWith(".h"))
  42 + return resources.getDrawable(R.drawable.ks_format_h);
  43 + else if (fileName.endsWith(".htm")) return resources.getDrawable(R.drawable.ks_format_htm);
  44 + else if (fileName.endsWith(".html"))
  45 + return resources.getDrawable(R.drawable.ks_format_html);
  46 + else if (fileName.endsWith(".jar")) return resources.getDrawable(R.drawable.ks_format_jar);
  47 + else if (fileName.endsWith(".java"))
  48 + return resources.getDrawable(R.drawable.ks_format_java);
  49 + else if (fileName.endsWith(".jif")) return resources.getDrawable(R.drawable.ks_format_jif);
  50 + else if (fileName.endsWith(".jpeg"))
  51 + return resources.getDrawable(R.drawable.ks_format_jpeg);
  52 + else if (fileName.endsWith(".jpg")) return resources.getDrawable(R.drawable.ks_format_jpg);
  53 + else if (fileName.endsWith(".js")) return resources.getDrawable(R.drawable.ks_format_js);
  54 + else if (fileName.endsWith(".log")) return resources.getDrawable(R.drawable.ks_format_log);
  55 + else if (fileName.endsWith(".m")) return resources.getDrawable(R.drawable.ks_format_m);
  56 + else if (fileName.endsWith(".m3u")) return resources.getDrawable(R.drawable.ks_format_m3u);
  57 + else if (fileName.endsWith(".m4a")) return resources.getDrawable(R.drawable.ks_format_m4a);
  58 + else if (fileName.endsWith(".m4b")) return resources.getDrawable(R.drawable.ks_format_m4b);
  59 + else if (fileName.endsWith(".m4p")) return resources.getDrawable(R.drawable.ks_format_m4p);
  60 + else if (fileName.endsWith(".m4u")) return resources.getDrawable(R.drawable.ks_format_m4u);
  61 + else if (fileName.endsWith(".m4v"))
  62 + return resources.getDrawable(R.drawable.ks_format_m4v);
  63 + else if (fileName.endsWith(".mov")) return resources.getDrawable(R.drawable.ks_format_mov);
  64 + else if (fileName.endsWith(".mp2")) return resources.getDrawable(R.drawable.ks_format_mp2);
  65 + else if (fileName.endsWith(".mp3")) return resources.getDrawable(R.drawable.ks_format_mp3);
  66 + else if (fileName.endsWith(".mp4")) return resources.getDrawable(R.drawable.ks_format_mp4);
  67 + else if (fileName.endsWith(".mpc")) return resources.getDrawable(R.drawable.ks_format_mpc);
  68 + else if (fileName.endsWith(".mpe"))
  69 + return resources.getDrawable(R.drawable.ks_format_mpe);
  70 + else if (fileName.endsWith(".mpeg"))
  71 + return resources.getDrawable(R.drawable.ks_format_mpeg);
  72 + else if (fileName.endsWith(".mpg")) return resources.getDrawable(R.drawable.ks_format_mpg);
  73 + else if (fileName.endsWith(".mpg4"))
  74 + return resources.getDrawable(R.drawable.ks_format_mpg4);
  75 + else if (fileName.endsWith(".mpga"))
  76 + return resources.getDrawable(R.drawable.ks_format_mpga);
  77 + else if (fileName.endsWith(".msg")) return resources.getDrawable(R.drawable.ks_format_msg);
  78 + else if (fileName.endsWith(".ogg")) return resources.getDrawable(R.drawable.ks_format_ogg);
  79 + else if (fileName.endsWith(".pdf"))
  80 + return resources.getDrawable(R.drawable.ks_format_pdf);
  81 + else if (fileName.endsWith(".png")) return resources.getDrawable(R.drawable.ks_format_png);
  82 + else if (fileName.endsWith(".pps")) return resources.getDrawable(R.drawable.ks_format_pps);
  83 + else if (fileName.endsWith(".ppt")) return resources.getDrawable(R.drawable.ks_format_ppt);
  84 + else if (fileName.endsWith(".pptx"))
  85 + return resources.getDrawable(R.drawable.ks_format_pptx);
  86 + else if (fileName.endsWith(".prop"))
  87 + return resources.getDrawable(R.drawable.ks_format_prop);
  88 + else if (fileName.endsWith(".rar")) return resources.getDrawable(R.drawable.ks_format_rar);
  89 + else if (fileName.endsWith(".rc")) return resources.getDrawable(R.drawable.ks_format_rc);
  90 + else if (fileName.endsWith(".rmvb"))
  91 + return resources.getDrawable(R.drawable.ks_format_rmvb);
  92 + else if (fileName.endsWith(".rtf")) return resources.getDrawable(R.drawable.ks_format_rtf);
  93 + else if (fileName.endsWith(".sh")) return resources.getDrawable(R.drawable.ks_format_sh);
  94 + else if (fileName.endsWith(".tar")) return resources.getDrawable(R.drawable.ks_format_tar);
  95 + else if (fileName.endsWith(".tgz")) return resources.getDrawable(R.drawable.ks_format_tgz);
  96 + else if (fileName.endsWith(".tx")) return resources.getDrawable(R.drawable.ks_format_tx);
  97 + else if (fileName.endsWith(".wav")) return resources.getDrawable(R.drawable.ks_format_wav);
  98 + else if (fileName.endsWith(".wma")) return resources.getDrawable(R.drawable.ks_format_wma);
  99 + else if (fileName.endsWith(".wmv")) return resources.getDrawable(R.drawable.ks_format_wmv);
  100 + else if (fileName.endsWith(".wps")) return resources.getDrawable(R.drawable.ks_format_wps);
  101 + else if (fileName.endsWith(".xls")) return resources.getDrawable(R.drawable.ks_format_xls);
  102 + else if (fileName.endsWith(".xlsx"))
  103 + return resources.getDrawable(R.drawable.ks_format_xlsx);
  104 + else if (fileName.endsWith(".xml")) return resources.getDrawable(R.drawable.ks_format_xml);
  105 + else if (fileName.endsWith(".xsl")) return resources.getDrawable(R.drawable.ks_format_xsl);
  106 + else if (fileName.endsWith(".z")) return resources.getDrawable(R.drawable.ks_format_z);
  107 + else if (fileName.endsWith(".zip")) return resources.getDrawable(R.drawable.ks_format_zip);
  108 + else return resources.getDrawable(R.drawable.ks_format_unkown);
  109 + }
  110 +
  111 + public static String getDataSize(long size) {
  112 + if (size < 0) {
  113 + size = 0;
  114 + }
  115 + DecimalFormat formater = new DecimalFormat("####.00");
  116 + formater.setRoundingMode(RoundingMode.UP);
  117 + if (size < 1024) {
  118 + return size + "B";
  119 + } else if (size < 1024 * 1024) {
  120 + float kbsize = size / 1024f;
  121 + return formater.format(kbsize) + "KB";
  122 + } else if (size < 1024 * 1024 * 1024) {
  123 + float mbsize = size / 1024f / 1024f;
  124 + return formater.format(mbsize) + "MB";
  125 + } else if (size < 1024 * 1024 * 1024 * 1024) {
  126 + float gbsize = size / 1024f / 1024f / 1024f;
  127 + return formater.format(gbsize) + "GB";
  128 + } else {
  129 + return "size: error";
  130 + }
  131 +
  132 + }
  133 +
  134 + /**
  135 + * 读取修改时间的方法2
  136 + */
  137 + public static String getModifiedTime(File f) {
  138 + long time = f.lastModified();
  139 + return TimeUtil.getConversationTimeStr(time / 1000);
  140 + }
  141 +
  142 + //建立一个文件类型与文件后缀名的匹配表
  143 + private static final String[][] MIME_MapTable = {
  144 + // --{后缀名, MIME类型} --
  145 + {".3gp", "video/3gpp"},
  146 + {".3gpp", "video/3gpp"},
  147 + {".aac", "audio/x-mpeg"},
  148 + {".amr", "audio/x-mpeg"},
  149 + {".apk", "application/vnd.android.package-archive"},
  150 + {".avi", "video/x-msvideo"},
  151 + {".aab", "application/x-authoware-bin"},
  152 + {".aam", "application/x-authoware-map"},
  153 + {".aas", "application/x-authoware-seg"},
  154 + {".ai", "application/postscript"},
  155 + {".aif", "audio/x-aiff"},
  156 + {".aifc", "audio/x-aiff"},
  157 + {".aiff", "audio/x-aiff"},
  158 + {".als", "audio/x-alpha5"},
  159 + {".amc", "application/x-mpeg"},
  160 + {".ani", "application/octet-stream"},
  161 + {".asc", "text/plain"},
  162 + {".asd", "application/astound"},
  163 + {".asf", "video/x-ms-asf"},
  164 + {".asn", "application/astound"},
  165 + {".asp", "application/x-asap"},
  166 + {".asx", " video/x-ms-asf"},
  167 + {".au", "audio/basic"},
  168 + {".avb", "application/octet-stream"},
  169 + {".awb", "audio/amr-wb"},
  170 + {".bcpio", "application/x-bcpio"},
  171 + {".bld", "application/bld"},
  172 + {".bld2", "application/bld2"},
  173 + {".bpk", "application/octet-stream"},
  174 + {".bz2", "application/x-bzip2"},
  175 + {".bin", "application/octet-stream"},
  176 + {".bmp", "image/bmp"},
  177 + {".c", "text/plain"},
  178 + {".class", "application/octet-stream"},
  179 + {".conf", "text/plain"},
  180 + {".cpp", "text/plain"},
  181 + {".cal", "image/x-cals"},
  182 + {".ccn", "application/x-cnc"},
  183 + {".cco", "application/x-cocoa"},
  184 + {".cdf", "application/x-netcdf"},
  185 + {".cgi", "magnus-internal/cgi"},
  186 + {".chat", "application/x-chat"},
  187 + {".clp", "application/x-msclip"},
  188 + {".cmx", "application/x-cmx"},
  189 + {".co", "application/x-cult3d-object"},
  190 + {".cod", "image/cis-cod"},
  191 + {".cpio", "application/x-cpio"},
  192 + {".cpt", "application/mac-compactpro"},
  193 + {".crd", "application/x-mscardfile"},
  194 + {".csh", "application/x-csh"},
  195 + {".csm", "chemical/x-csml"},
  196 + {".csml", "chemical/x-csml"},
  197 + {".css", "text/css"},
  198 + {".cur", "application/octet-stream"},
  199 + {".doc", "application/msword"},
  200 + {".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
  201 + {".dcm", "x-lml/x-evm"},
  202 + {".dcr", "application/x-director"},
  203 + {".dcx", "image/x-dcx"},
  204 + {".dhtml", "text/html"},
  205 + {".dir", "application/x-director"},
  206 + {".dll", "application/octet-stream"},
  207 + {".dmg", "application/octet-stream"},
  208 + {".dms", "application/octet-stream"},
  209 + {".dot", "application/x-dot"},
  210 + {".dvi", "application/x-dvi"},
  211 + {".dwf", "drawing/x-dwf"},
  212 + {".dwg", "application/x-autocad"},
  213 + {".dxf", "application/x-autocad"},
  214 + {".dxr", "application/x-director"},
  215 + {".ebk", "application/x-expandedbook"},
  216 + {".emb", "chemical/x-embl-dl-nucleotide"},
  217 + {".embl", "chemical/x-embl-dl-nucleotide"},
  218 + {".eps", "application/postscript"},
  219 + {".epub", "application/epub+zip"},
  220 + {".eri", "image/x-eri"},
  221 + {".es", "audio/echospeech"},
  222 + {".esl", "audio/echospeech"},
  223 + {".etc", "application/x-earthtime"},
  224 + {".etx", "text/x-setext"},
  225 + {".evm", "x-lml/x-evm"},
  226 + {".evy", "application/x-envoy"},
  227 + {".exe", "application/octet-stream"},
  228 + {".fh4", "image/x-freehand"},
  229 + {".fh5", "image/x-freehand"},
  230 + {".fhc", "image/x-freehand"},
  231 + {".fif", "image/fif"},
  232 + {".fm", "application/x-maker"},
  233 + {".fpx", "image/x-fpx"},
  234 + {".fvi", "video/isivideo"},
  235 + {".flv", "video/x-msvideo"},
  236 + {".gau", "chemical/x-gaussian-input"},
  237 + {".gca", "application/x-gca-compressed"},
  238 + {".gdb", "x-lml/x-gdb"},
  239 + {".gif", "image/gif"},
  240 + {".gps", "application/x-gps"},
  241 + {".gtar", "application/x-gtar"},
  242 + {".gz", "application/x-gzip"},
  243 + {".gif", "image/gif"},
  244 + {".gtar", "application/x-gtar"},
  245 + {".gz", "application/x-gzip"},
  246 + {".h", "text/plain"},
  247 + {".hdf", "application/x-hdf"},
  248 + {".hdm", "text/x-hdml"},
  249 + {".hdml", "text/x-hdml"},
  250 + {".htm", "text/html"},
  251 + {".html", "text/html"},
  252 + {".hlp", "application/winhlp"},
  253 + {".hqx", "application/mac-binhex40"},
  254 + {".hts", "text/html"},
  255 + {".ice", "x-conference/x-cooltalk"},
  256 + {".ico", "application/octet-stream"},
  257 + {".ief", "image/ief"},
  258 + {".ifm", "image/gif"},
  259 + {".ifs", "image/ifs"},
  260 + {".imy", "audio/melody"},
  261 + {".ins", "application/x-net-install"},
  262 + {".ips", "application/x-ipscript"},
  263 + {".ipx", "application/x-ipix"},
  264 + {".it", "audio/x-mod"},
  265 + {".itz", "audio/x-mod"},
  266 + {".ivr", "i-world/i-vrml"},
  267 + {".j2k", "image/j2k"},
  268 + {".jad", "text/vnd.sun.j2me.app-descriptor"},
  269 + {".jam", "application/x-jam"},
  270 + {".jnlp", "application/x-java-jnlp-file"},
  271 + {".jpe", "image/jpeg"},
  272 + {".jpz", "image/jpeg"},
  273 + {".jwc", "application/jwc"},
  274 + {".jar", "application/java-archive"},
  275 + {".java", "text/plain"},
  276 + {".jpeg", "image/jpeg"},
  277 + {".jpg", "image/jpeg"},
  278 + {".js", "application/x-javascript"},
  279 + {".kjx", "application/x-kjx"},
  280 + {".lak", "x-lml/x-lak"},
  281 + {".latex", "application/x-latex"},
  282 + {".lcc", "application/fastman"},
  283 + {".lcl", "application/x-digitalloca"},
  284 + {".lcr", "application/x-digitalloca"},
  285 + {".lgh", "application/lgh"},
  286 + {".lha", "application/octet-stream"},
  287 + {".lml", "x-lml/x-lml"},
  288 + {".lmlpack", "x-lml/x-lmlpack"},
  289 + {".log", "text/plain"},
  290 + {".lsf", "video/x-ms-asf"},
  291 + {".lsx", "video/x-ms-asf"},
  292 + {".lzh", "application/x-lzh "},
  293 + {".m13", "application/x-msmediaview"},
  294 + {".m14", "application/x-msmediaview"},
  295 + {".m15", "audio/x-mod"},
  296 + {".m3u", "audio/x-mpegurl"},
  297 + {".m3url", "audio/x-mpegurl"},
  298 + {".ma1", "audio/ma1"},
  299 + {".ma2", "audio/ma2"},
  300 + {".ma3", "audio/ma3"},
  301 + {".ma5", "audio/ma5"},
  302 + {".man", "application/x-troff-man"},
  303 + {".map", "magnus-internal/imagemap"},
  304 + {".mbd", "application/mbedlet"},
  305 + {".mct", "application/x-mascot"},
  306 + {".mdb", "application/x-msaccess"},
  307 + {".mdz", "audio/x-mod"},
  308 + {".me", "application/x-troff-me"},
  309 + {".mel", "text/x-vmel"},
  310 + {".mi", "application/x-mif"},
  311 + {".mid", "audio/midi"},
  312 + {".midi", "audio/midi"},
  313 + {".m4a", "audio/mp4a-latm"},
  314 + {".m4b", "audio/mp4a-latm"},
  315 + {".m4p", "audio/mp4a-latm"},
  316 + {".m4u", "video/vnd.mpegurl"},
  317 + {".m4v", "video/x-m4v"},
  318 + {".mov", "video/quicktime"},
  319 + {".mp2", "audio/x-mpeg"},
  320 + {".mp3", "audio/x-mpeg"},
  321 + {".mp4", "video/mp4"},
  322 + {".mpc", "application/vnd.mpohun.certificate"},
  323 + {".mpe", "video/mpeg"},
  324 + {".mpeg", "video/mpeg"},
  325 + {".mpg", "video/mpeg"},
  326 + {".mpg4", "video/mp4"},
  327 + {".mpga", "audio/mpeg"},
  328 + {".msg", "application/vnd.ms-outlook"},
  329 + {".mif", "application/x-mif"},
  330 + {".mil", "image/x-cals"},
  331 + {".mio", "audio/x-mio"},
  332 + {".mmf", "application/x-skt-lbs"},
  333 + {".mng", "video/x-mng"},
  334 + {".mny", "application/x-msmoney"},
  335 + {".moc", "application/x-mocha"},
  336 + {".mocha", "application/x-mocha"},
  337 + {".mod", "audio/x-mod"},
  338 + {".mof", "application/x-yumekara"},
  339 + {".mol", "chemical/x-mdl-molfile"},
  340 + {".mop", "chemical/x-mopac-input"},
  341 + {".movie", "video/x-sgi-movie"},
  342 + {".mpn", "application/vnd.mophun.application"},
  343 + {".mpp", "application/vnd.ms-project"},
  344 + {".mps", "application/x-mapserver"},
  345 + {".mrl", "text/x-mrml"},
  346 + {".mrm", "application/x-mrm"},
  347 + {".ms", "application/x-troff-ms"},
  348 + {".mts", "application/metastream"},
  349 + {".mtx", "application/metastream"},
  350 + {".mtz", "application/metastream"},
  351 + {".mzv", "application/metastream"},
  352 + {".nar", "application/zip"},
  353 + {".nbmp", "image/nbmp"},
  354 + {".nc", "application/x-netcdf"},
  355 + {".ndb", "x-lml/x-ndb"},
  356 + {".ndwn", "application/ndwn"},
  357 + {".nif", "application/x-nif"},
  358 + {".nmz", "application/x-scream"},
  359 + {".nokia-op-logo", "image/vnd.nok-oplogo-color"},
  360 + {".npx", "application/x-netfpx"},
  361 + {".nsnd", "audio/nsnd"},
  362 + {".nva", "application/x-neva1"},
  363 + {".oda", "application/oda"},
  364 + {".oom", "application/x-atlasMate-plugin"},
  365 + {".ogg", "audio/ogg"},
  366 + {".pac", "audio/x-pac"},
  367 + {".pae", "audio/x-epac"},
  368 + {".pan", "application/x-pan"},
  369 + {".pbm", "image/x-portable-bitmap"},
  370 + {".pcx", "image/x-pcx"},
  371 + {".pda", "image/x-pda"},
  372 + {".pdb", "chemical/x-pdb"},
  373 + {".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
  374 + {".pdf", "application/pdf"},
  375 + {".pfr", "application/font-tdpfr"},
  376 + {".pgm", "image/x-portable-graymap"},
  377 + {".pict", "image/x-pict"},
  378 + {".pm", "application/x-perl"},
  379 + {".pmd", "application/x-pmd"},
  380 + {".png", "image/png"},
  381 + {".pnm", "image/x-portable-anymap"},
  382 + {".pnz", "image/png"},
  383 + {".pot", "application/vnd.ms-powerpoint"},
  384 + {".ppm", "image/x-portable-pixmap"},
  385 + {".pps", "application/vnd.ms-powerpoint"},
  386 + {".ppt", "application/vnd.ms-powerpoint"},
  387 + {".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"},
  388 + {".pqf", "application/x-cprplayer"},
  389 + {".pqi", "application/cprplayer"},
  390 + {".prc", "application/x-prc"},
  391 + {".proxy", "application/x-ns-proxy-autoconfig"},
  392 + {".prop", "text/plain"},
  393 + {".ps", "application/postscript"},
  394 + {".ptlk", "application/listenup"},
  395 + {".pub", "application/x-mspublisher"},
  396 + {".pvx", "video/x-pv-pvx"},
  397 + {".qcp", "audio/vnd.qcelp"},
  398 + {".qt", "video/quicktime"},
  399 + {".qti", "image/x-quicktime"},
  400 + {".qtif", "image/x-quicktime"},
  401 + {".r3t", "text/vnd.rn-realtext3d"},
  402 + {".ra", "audio/x-pn-realaudio"},
  403 + {".ram", "audio/x-pn-realaudio"},
  404 + {".ras", "image/x-cmu-raster"},
  405 + {".rdf", "application/rdf+xml"},
  406 + {".rf", "image/vnd.rn-realflash"},
  407 + {".rgb", "image/x-rgb"},
  408 + {".rlf", "application/x-richlink"},
  409 + {".rm", "audio/x-pn-realaudio"},
  410 + {".rmf", "audio/x-rmf"},
  411 + {".rmm", "audio/x-pn-realaudio"},
  412 + {".rnx", "application/vnd.rn-realplayer"},
  413 + {".roff", "application/x-troff"},
  414 + {".rp", "image/vnd.rn-realpix"},
  415 + {".rpm", "audio/x-pn-realaudio-plugin"},
  416 + {".rt", "text/vnd.rn-realtext"},
  417 + {".rte", "x-lml/x-gps"},
  418 + {".rtf", "application/rtf"},
  419 + {".rtg", "application/metastream"},
  420 + {".rtx", "text/richtext"},
  421 + {".rv", "video/vnd.rn-realvideo"},
  422 + {".rwc", "application/x-rogerwilco"},
  423 + {".rar", "application/x-rar-compressed"},
  424 + {".rc", "text/plain"},
  425 + {".rmvb", "audio/x-pn-realaudio"},
  426 + {".s3m", "audio/x-mod"},
  427 + {".s3z", "audio/x-mod"},
  428 + {".sca", "application/x-supercard"},
  429 + {".scd", "application/x-msschedule"},
  430 + {".sdf", "application/e-score"},
  431 + {".sea", "application/x-stuffit"},
  432 + {".sgm", "text/x-sgml"},
  433 + {".sgml", "text/x-sgml"},
  434 + {".shar", "application/x-shar"},
  435 + {".shtml", "magnus-internal/parsed-html"},
  436 + {".shw", "application/presentations"},
  437 + {".si6", "image/si6"},
  438 + {".si7", "image/vnd.stiwap.sis"},
  439 + {".si9", "image/vnd.lgtwap.sis"},
  440 + {".sis", "application/vnd.symbian.install"},
  441 + {".sit", "application/x-stuffit"},
  442 + {".skd", "application/x-koan"},
  443 + {".skm", "application/x-koan"},
  444 + {".skp", "application/x-koan"},
  445 + {".skt", "application/x-koan"},
  446 + {".slc", "application/x-salsa"},
  447 + {".smd", "audio/x-smd"},
  448 + {".smi", "application/smil"},
  449 + {".smil", "application/smil"},
  450 + {".smp", "application/studiom"},
  451 + {".smz", "audio/x-smd"},
  452 + {".sh", "application/x-sh"},
  453 + {".snd", "audio/basic"},
  454 + {".spc", "text/x-speech"},
  455 + {".spl", "application/futuresplash"},
  456 + {".spr", "application/x-sprite"},
  457 + {".sprite", "application/x-sprite"},
  458 + {".sdp", "application/sdp"},
  459 + {".spt", "application/x-spt"},
  460 + {".src", "application/x-wais-source"},
  461 + {".stk", "application/hyperstudio"},
  462 + {".stm", "audio/x-mod"},
  463 + {".sv4cpio", "application/x-sv4cpio"},
  464 + {".sv4crc", "application/x-sv4crc"},
  465 + {".svf", "image/vnd"},
  466 + {".svg", "image/svg-xml"},
  467 + {".svh", "image/svh"},
  468 + {".svr", "x-world/x-svr"},
  469 + {".swf", "application/x-shockwave-flash"},
  470 + {".swfl", "application/x-shockwave-flash"},
  471 + {".t", "application/x-troff"},
  472 + {".tad", "application/octet-stream"},
  473 + {".talk", "text/x-speech"},
  474 + {".tar", "application/x-tar"},
  475 + {".taz", "application/x-tar"},
  476 + {".tbp", "application/x-timbuktu"},
  477 + {".tbt", "application/x-timbuktu"},
  478 + {".tcl", "application/x-tcl"},
  479 + {".tex", "application/x-tex"},
  480 + {".texi", "application/x-texinfo"},
  481 + {".texinfo", "application/x-texinfo"},
  482 + {".tgz", "application/x-tar"},
  483 + {".thm", "application/vnd.eri.thm"},
  484 + {".tif", "image/tiff"},
  485 + {".tiff", "image/tiff"},
  486 + {".tki", "application/x-tkined"},
  487 + {".tkined", "application/x-tkined"},
  488 + {".toc", "application/toc"},
  489 + {".toy", "image/toy"},
  490 + {".tr", "application/x-troff"},
  491 + {".trk", "x-lml/x-gps"},
  492 + {".trm", "application/x-msterminal"},
  493 + {".tsi", "audio/tsplayer"},
  494 + {".tsp", "application/dsptype"},
  495 + {".tsv", "text/tab-separated-values"},
  496 + {".ttf", "application/octet-stream"},
  497 + {".ttz", "application/t-time"},
  498 + {".txt", "text/plain"},
  499 + {".ult", "audio/x-mod"},
  500 + {".ustar", "application/x-ustar"},
  501 + {".uu", "application/x-uuencode"},
  502 + {".uue", "application/x-uuencode"},
  503 + {".vcd", "application/x-cdlink"},
  504 + {".vcf", "text/x-vcard"},
  505 + {".vdo", "video/vdo"},
  506 + {".vib", "audio/vib"},
  507 + {".viv", "video/vivo"},
  508 + {".vivo", "video/vivo"},
  509 + {".vmd", "application/vocaltec-media-desc"},
  510 + {".vmf", "application/vocaltec-media-file"},
  511 + {".vmi", "application/x-dreamcast-vms-info"},
  512 + {".vms", "application/x-dreamcast-vms"},
  513 + {".vox", "audio/voxware"},
  514 + {".vqe", "audio/x-twinvq-plugin"},
  515 + {".vqf", "audio/x-twinvq"},
  516 + {".vql", "audio/x-twinvq"},
  517 + {".vre", "x-world/x-vream"},
  518 + {".vrml", "x-world/x-vrml"},
  519 + {".vrt", "x-world/x-vrt"},
  520 + {".vrw", "x-world/x-vream"},
  521 + {".vts", "workbook/formulaone"},
  522 + {".wax", "audio/x-ms-wax"},
  523 + {".wbmp", "image/vnd.wap.wbmp"},
  524 + {".web", "application/vnd.xara"},
  525 + {".wav", "audio/x-wav"},
  526 + {".wma", "audio/x-ms-wma"},
  527 + {".wmv", "audio/x-ms-wmv"},
  528 + {".wi", "image/wavelet"},
  529 + {".wis", "application/x-InstallShield"},
  530 + {".wm", "video/x-ms-wm"},
  531 + {".wmd", "application/x-ms-wmd"},
  532 + {".wmf", "application/x-msmetafile"},
  533 + {".wml", "text/vnd.wap.wml"},
  534 + {".wmlc", "application/vnd.wap.wmlc"},
  535 + {".wmls", "text/vnd.wap.wmlscript"},
  536 + {".wmlsc", "application/vnd.wap.wmlscriptc"},
  537 + {".wmlscript", "text/vnd.wap.wmlscript"},
  538 + {".wmv", "video/x-ms-wmv"},
  539 + {".wmx", "video/x-ms-wmx"},
  540 + {".wmz", "application/x-ms-wmz"},
  541 + {".wpng", "image/x-up-wpng"},
  542 + {".wps", "application/vnd.ms-works"},
  543 + {".wpt", "x-lml/x-gps"},
  544 + {".wri", "application/x-mswrite"},
  545 + {".wrl", "x-world/x-vrml"},
  546 + {".wrz", "x-world/x-vrml"},
  547 + {".ws", "text/vnd.wap.wmlscript"},
  548 + {".wsc", "application/vnd.wap.wmlscriptc"},
  549 + {".wv", "video/wavelet"},
  550 + {".wvx", "video/x-ms-wvx"},
  551 + {".wxl", "application/x-wxl"},
  552 + {".x-gzip", "application/x-gzip"},
  553 + {".xar", "application/vnd.xara"},
  554 + {".xbm", "image/x-xbitmap"},
  555 + {".xdm", "application/x-xdma"},
  556 + {".xdma", "application/x-xdma"},
  557 + {".xdw", "application/vnd.fujixerox.docuworks"},
  558 + {".xht", "application/xhtml+xml"},
  559 + {".xhtm", "application/xhtml+xml"},
  560 + {".xhtml", "application/xhtml+xml"},
  561 + {".xla", "application/vnd.ms-excel"},
  562 + {".xlc", "application/vnd.ms-excel"},
  563 + {".xll", "application/x-excel"},
  564 + {".xlm", "application/vnd.ms-excel"},
  565 + {".xls", "application/vnd.ms-excel"},
  566 + {".xlt", "application/vnd.ms-excel"},
  567 + {".xlw", "application/vnd.ms-excel"},
  568 + {".xm", "audio/x-mod"},
  569 + {".xml", "text/xml"},
  570 + {".xmz", "audio/x-mod"},
  571 + {".xpi", "application/x-xpinstall"},
  572 + {".xpm", "image/x-xpixmap"},
  573 + {".xsit", "text/xml"},
  574 + {".xsl", "text/xml"},
  575 + {".xul", "text/xul"},
  576 + {".xwd", "image/x-xwindowdump"},
  577 + {".xyz", "chemical/x-pdb"},
  578 + {".yz1", "application/x-yz1"},
  579 + {".z", "application/x-compress"},
  580 + {".zac", "application/x-zaurus-zac"},
  581 + {".zip", "application/zip"},
  582 + {"", "*/*"}
  583 + };
  584 +
  585 + /**
  586 + * --获取文件类型 --
  587 + */
  588 + public static String getMIMEType(String filePath) {
  589 + String type = "*/*";
  590 + String fName = filePath;
  591 +
  592 + int dotIndex = fName.lastIndexOf(".");
  593 + if (dotIndex < 0) {
  594 + return type;
  595 + }
  596 +
  597 + String end = fName.substring(dotIndex, fName.length()).toLowerCase();
  598 + if (TextUtils.isEmpty(end)) {
  599 + return type;
  600 + }
  601 +
  602 + for (int i = 0; i < MIME_MapTable.length; i++) {
  603 + if (end.equals(MIME_MapTable[i][0])) {
  604 + type = MIME_MapTable[i][1];
  605 + }
  606 + }
  607 + return type;
  608 + }
  609 +
  610 + /**
  611 + * 判断文件是否是视频
  612 + *
  613 + * @param filePath
  614 + * @return
  615 + */
  616 + public static boolean isVideo(String filePath) {
  617 + if (getMIMEType(filePath).startsWith("video/"))
  618 + return true;
  619 + return false;
  620 + }
  621 +
  622 + /**
  623 + * 判断文件是否是图片
  624 + *
  625 + * @param filePath
  626 + * @return
  627 + */
  628 + public static boolean isImage(String filePath) {
  629 + if (getMIMEType(filePath).startsWith("image/"))
  630 + return true;
  631 + return false;
  632 + }
  633 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/utils/FilesListComparator.java 0 → 100644
  1 +package com.cnlive.filespicker.utils;
  2 +
  3 +import android.support.annotation.IntRange;
  4 +import android.support.annotation.NonNull;
  5 +
  6 +import java.io.File;
  7 +import java.util.Comparator;
  8 +import java.util.Locale;
  9 +
  10 +public class FilesListComparator implements Comparator<File> {
  11 + @Override
  12 + @IntRange(from = -1, to = 1)
  13 + public int compare(@NonNull File file1, @NonNull File file2) {
  14 + try {
  15 + if (file1 == null || file1.length() == 0 || !file1.exists()) return -1;
  16 + if (file2 == null || file2.length() == 0 || !file2.exists()) return 1;
  17 + if (file1.isDirectory() && !file2.isDirectory()) {
  18 + return -1;
  19 + } else if (!file1.isDirectory() && file2.isDirectory()) {
  20 + return 1;
  21 + } else if (!file1.isDirectory() && !file2.isDirectory()) {
  22 + if (file1.lastModified() == file2.lastModified()) {
  23 + return 0;
  24 + } else if (file1.lastModified() > file2.lastModified()) {
  25 + return -1;
  26 + } else {
  27 + return 1;
  28 + }
  29 + } else {
  30 + return file1.getName().toLowerCase(Locale.getDefault()).compareTo(file2.getName().toLowerCase(Locale.getDefault()));
  31 + }
  32 + } catch (Exception e) {
  33 + return 0;
  34 + }
  35 + }
  36 +}
0 37 \ No newline at end of file
... ...
filespicker/src/main/java/com/cnlive/filespicker/utils/ListUtils.java 0 → 100644
  1 +package com.cnlive.filespicker.utils;
  2 +
  3 +import android.support.annotation.NonNull;
  4 +import android.support.annotation.Nullable;
  5 +
  6 +import java.util.Arrays;
  7 +import java.util.Iterator;
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by BArtWell on 12.03.2017.
  12 + */
  13 +
  14 +public class ListUtils {
  15 +
  16 + public static <T> void copyListWithCondition(@NonNull T[] fromList, @NonNull List<T> toList, @Nullable ConditionChecker<T> checker) {
  17 + copyListWithCondition(Arrays.asList(fromList), toList, checker);
  18 + }
  19 +
  20 + public static <T> void copyListWithCondition(@NonNull List<T> fromList, @NonNull List<T> toList, @Nullable ConditionChecker<T> checker) {
  21 + if (checker == null) {
  22 + toList.addAll(fromList);
  23 + } else {
  24 + for (T item : fromList) {
  25 + if (checker.check(item)) {
  26 + toList.add(item);
  27 + }
  28 + }
  29 + }
  30 + }
  31 +
  32 + public static <T> void filterList(@NonNull List<T> list, @NonNull ConditionChecker<T> checker) {
  33 + Iterator<T> iterator = list.iterator();
  34 + while (iterator.hasNext()) {
  35 + if (checker.check(iterator.next())) {
  36 + iterator.remove();
  37 + }
  38 + }
  39 + }
  40 +
  41 + public interface ConditionChecker<T> {
  42 + boolean check(@NonNull T item);
  43 + }
  44 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/utils/ScreenUtil.java 0 → 100644
  1 +package com.cnlive.filespicker.utils;
  2 +
  3 +import android.content.Context;
  4 +import android.view.View;
  5 +import android.view.WindowManager;
  6 +
  7 +/**
  8 + * Created by gujun on 2017/10/14.
  9 + */
  10 +
  11 +public class ScreenUtil {
  12 +
  13 + /**
  14 + * 获取手机宽度的分辨率
  15 + *
  16 + * @param context
  17 + * @return
  18 + */
  19 + public static int getScreenWidth(Context context) {
  20 + WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  21 + int screenWidth = wm.getDefaultDisplay().getWidth();
  22 + return screenWidth;
  23 + }
  24 +
  25 + /**
  26 + * 获取手机高度的分辨率
  27 + *
  28 + * @param context
  29 + * @return
  30 + */
  31 + public static int getScreenHeight(Context context) {
  32 + WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  33 + int screenHeight = wm.getDefaultDisplay().getHeight();
  34 + return screenHeight;
  35 + }
  36 +
  37 + /**
  38 + * 计算出来的位置,y方向就在anchorView的上面和下面对齐显示,x方向就是与屏幕右边对齐显示
  39 + * 如果anchorView的位置有变化,就可以适当自己额外加入偏移来修正
  40 + *
  41 + * @param anchorView 呼出window的view
  42 + * @param contentView window的内容布局
  43 + * @return window显示的左上角的xOff, yOff坐标
  44 + */
  45 + public static int[] calculatePopWindowPos(final View anchorView, final View contentView) {
  46 + final int windowPos[] = new int[2];
  47 + final int anchorLoc[] = new int[2];
  48 + // 获取锚点View在屏幕上的左上角坐标位置
  49 + anchorView.getLocationOnScreen(anchorLoc);
  50 + final int anchorHeight = anchorView.getHeight();
  51 + // 获取屏幕的高宽
  52 + final int screenHeight = getScreenHeight(anchorView.getContext());
  53 + final int screenWidth = getScreenWidth(anchorView.getContext());
  54 + contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
  55 + // 计算contentView的高宽
  56 + final int windowHeight = contentView.getMeasuredHeight();
  57 + final int windowWidth = contentView.getMeasuredWidth();
  58 + // 判断需要向上弹出还是向下弹出显示
  59 + final boolean isNeedShowUp = (screenHeight - anchorLoc[1] - anchorHeight < windowHeight);
  60 + if (isNeedShowUp) {
  61 + windowPos[0] = screenWidth - windowWidth;
  62 + windowPos[1] = anchorLoc[1] - windowHeight;
  63 + } else {
  64 + windowPos[0] = screenWidth - windowWidth;
  65 + windowPos[1] = anchorLoc[1] + anchorHeight;
  66 + }
  67 + return windowPos;
  68 + }
  69 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/utils/StatusBarUtil2.java 0 → 100644
  1 +package com.cnlive.filespicker.utils;
  2 +
  3 +import android.annotation.TargetApi;
  4 +import android.app.Activity;
  5 +import android.content.Context;
  6 +import android.graphics.Color;
  7 +import android.os.Build;
  8 +import android.support.annotation.ColorInt;
  9 +import android.support.annotation.IntRange;
  10 +import android.support.annotation.NonNull;
  11 +import android.support.design.widget.CoordinatorLayout;
  12 +import android.support.v4.widget.DrawerLayout;
  13 +import android.view.View;
  14 +import android.view.ViewGroup;
  15 +import android.view.Window;
  16 +import android.view.WindowManager;
  17 +import android.widget.LinearLayout;
  18 +
  19 +import com.cnlive.filespicker.R;
  20 +
  21 +import java.lang.reflect.Field;
  22 +import java.lang.reflect.Method;
  23 +
  24 +/**
  25 + * Created by Jaeger on 16/2/14.
  26 + * <p>
  27 + * Email: chjie.jaeger@gmail.com
  28 + * GitHub: https://github.com/laobie
  29 + */
  30 +public class StatusBarUtil2 {
  31 +
  32 + public static final int DEFAULT_STATUS_BAR_ALPHA = 112;
  33 + private static final int FAKE_STATUS_BAR_VIEW_ID = R.id.statusbarutil_fake_status_bar_view;
  34 + private static final int FAKE_TRANSLUCENT_VIEW_ID = R.id.statusbarutil_translucent_view;
  35 + private static final int TAG_KEY_HAVE_SET_OFFSET = -123;
  36 +
  37 + /**
  38 + * 设置状态栏颜色
  39 + *
  40 + * @param activity 需要设置的 activity
  41 + * @param color 状态栏颜色值
  42 + */
  43 + public static void setColor(Activity activity, @ColorInt int color) {
  44 + setColor(activity, color, DEFAULT_STATUS_BAR_ALPHA);
  45 + }
  46 +
  47 + /**
  48 + * 设置状态栏颜色
  49 + *
  50 + * @param activity 需要设置的activity
  51 + * @param color 状态栏颜色值
  52 + * @param statusBarAlpha 状态栏透明度
  53 + */
  54 +
  55 + public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
  56 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  57 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  58 + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  59 + activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
  60 + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  61 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  62 + ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
  63 + View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
  64 + if (fakeStatusBarView != null) {
  65 + if (fakeStatusBarView.getVisibility() == View.GONE) {
  66 + fakeStatusBarView.setVisibility(View.VISIBLE);
  67 + }
  68 + fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
  69 + } else {
  70 + decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
  71 + }
  72 + setRootView(activity);
  73 + }
  74 + }
  75 +
  76 + /**
  77 + * 为滑动返回界面设置状态栏颜色
  78 + *
  79 + * @param activity 需要设置的activity
  80 + * @param color 状态栏颜色值
  81 + */
  82 + public static void setColorForSwipeBack(Activity activity, int color) {
  83 + setColorForSwipeBack(activity, color, DEFAULT_STATUS_BAR_ALPHA);
  84 + }
  85 +
  86 + /**
  87 + * 为滑动返回界面设置状态栏颜色
  88 + *
  89 + * @param activity 需要设置的activity
  90 + * @param color 状态栏颜色值
  91 + * @param statusBarAlpha 状态栏透明度
  92 + */
  93 + public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
  94 + @IntRange(from = 0, to = 255) int statusBarAlpha) {
  95 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  96 +
  97 + ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
  98 + View rootView = contentView.getChildAt(0);
  99 + int statusBarHeight = getStatusBarHeight(activity);
  100 + if (rootView != null && rootView instanceof CoordinatorLayout) {
  101 + final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
  102 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
  103 + coordinatorLayout.setFitsSystemWindows(false);
  104 + contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
  105 + boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
  106 + if (isNeedRequestLayout) {
  107 + contentView.setPadding(0, statusBarHeight, 0, 0);
  108 + coordinatorLayout.post(new Runnable() {
  109 + @Override
  110 + public void run() {
  111 + coordinatorLayout.requestLayout();
  112 + }
  113 + });
  114 + }
  115 + } else {
  116 + coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
  117 + }
  118 + } else {
  119 + contentView.setPadding(0, statusBarHeight, 0, 0);
  120 + contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
  121 + }
  122 + setTransparentForWindow(activity);
  123 + }
  124 + }
  125 +
  126 + /**
  127 + * 设置状态栏纯色 不加半透明效果
  128 + *
  129 + * @param activity 需要设置的 activity
  130 + * @param color 状态栏颜色值
  131 + */
  132 + public static void setColorNoTranslucent(Activity activity, @ColorInt int color) {
  133 + setColor(activity, color, 0);
  134 + }
  135 +
  136 + /**
  137 + * 设置状态栏颜色(5.0以下无半透明效果,不建议使用)
  138 + *
  139 + * @param activity 需要设置的 activity
  140 + * @param color 状态栏颜色值
  141 + */
  142 + @Deprecated
  143 + public static void setColorDiff(Activity activity, @ColorInt int color) {
  144 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  145 + return;
  146 + }
  147 + transparentStatusBar(activity);
  148 + ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
  149 + // 移除半透明矩形,以免叠加
  150 + View fakeStatusBarView = contentView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
  151 + if (fakeStatusBarView != null) {
  152 + if (fakeStatusBarView.getVisibility() == View.GONE) {
  153 + fakeStatusBarView.setVisibility(View.VISIBLE);
  154 + }
  155 + fakeStatusBarView.setBackgroundColor(color);
  156 + } else {
  157 + contentView.addView(createStatusBarView(activity, color));
  158 + }
  159 + setRootView(activity);
  160 + }
  161 +
  162 + /**
  163 + * 使状态栏半透明
  164 + * <p>
  165 + * 适用于图片作为背景的界面,此时需要图片填充到状态栏
  166 + *
  167 + * @param activity 需要设置的activity
  168 + */
  169 + public static void setTranslucent(Activity activity) {
  170 + setTranslucent(activity, DEFAULT_STATUS_BAR_ALPHA);
  171 + }
  172 +
  173 + /**
  174 + * 使状态栏半透明
  175 + * <p>
  176 + * 适用于图片作为背景的界面,此时需要图片填充到状态栏
  177 + *
  178 + * @param activity 需要设置的activity
  179 + * @param statusBarAlpha 状态栏透明度
  180 + */
  181 + public static void setTranslucent(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
  182 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  183 + return;
  184 + }
  185 + setTransparent(activity);
  186 + addTranslucentView(activity, statusBarAlpha);
  187 + }
  188 +
  189 + /**
  190 + * 针对根布局是 CoordinatorLayout, 使状态栏半透明
  191 + * <p>
  192 + * 适用于图片作为背景的界面,此时需要图片填充到状态栏
  193 + *
  194 + * @param activity 需要设置的activity
  195 + * @param statusBarAlpha 状态栏透明度
  196 + */
  197 + public static void setTranslucentForCoordinatorLayout(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
  198 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  199 + return;
  200 + }
  201 + transparentStatusBar(activity);
  202 + addTranslucentView(activity, statusBarAlpha);
  203 + }
  204 +
  205 + /**
  206 + * 设置状态栏全透明
  207 + *
  208 + * @param activity 需要设置的activity
  209 + */
  210 + public static void setTransparent(Activity activity) {
  211 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  212 + return;
  213 + }
  214 + transparentStatusBar(activity);
  215 + setRootView(activity);
  216 + }
  217 +
  218 + /**
  219 + * 使状态栏透明(5.0以上半透明效果,不建议使用)
  220 + * <p>
  221 + * 适用于图片作为背景的界面,此时需要图片填充到状态栏
  222 + *
  223 + * @param activity 需要设置的activity
  224 + */
  225 + @Deprecated
  226 + public static void setTranslucentDiff(Activity activity) {
  227 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  228 + // 设置状态栏透明
  229 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  230 + setRootView(activity);
  231 + }
  232 + }
  233 +
  234 + /**
  235 + * 为DrawerLayout 布局设置状态栏变色
  236 + *
  237 + * @param activity 需要设置的activity
  238 + * @param drawerLayout DrawerLayout
  239 + * @param color 状态栏颜色值
  240 + */
  241 + public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
  242 + setColorForDrawerLayout(activity, drawerLayout, color, DEFAULT_STATUS_BAR_ALPHA);
  243 + }
  244 +
  245 + /**
  246 + * 为DrawerLayout 布局设置状态栏颜色,纯色
  247 + *
  248 + * @param activity 需要设置的activity
  249 + * @param drawerLayout DrawerLayout
  250 + * @param color 状态栏颜色值
  251 + */
  252 + public static void setColorNoTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
  253 + setColorForDrawerLayout(activity, drawerLayout, color, 0);
  254 + }
  255 +
  256 + /**
  257 + * 为DrawerLayout 布局设置状态栏变色
  258 + *
  259 + * @param activity 需要设置的activity
  260 + * @param drawerLayout DrawerLayout
  261 + * @param color 状态栏颜色值
  262 + * @param statusBarAlpha 状态栏透明度
  263 + */
  264 + public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color,
  265 + @IntRange(from = 0, to = 255) int statusBarAlpha) {
  266 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  267 + return;
  268 + }
  269 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  270 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  271 + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  272 + activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
  273 + } else {
  274 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  275 + }
  276 + // 生成一个状态栏大小的矩形
  277 + // 添加 statusBarView 到布局中
  278 + ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
  279 + View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
  280 + if (fakeStatusBarView != null) {
  281 + if (fakeStatusBarView.getVisibility() == View.GONE) {
  282 + fakeStatusBarView.setVisibility(View.VISIBLE);
  283 + }
  284 + fakeStatusBarView.setBackgroundColor(color);
  285 + } else {
  286 + contentLayout.addView(createStatusBarView(activity, color), 0);
  287 + }
  288 + // 内容布局不是 LinearLayout 时,设置padding top
  289 + if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
  290 + contentLayout.getChildAt(1)
  291 + .setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(),
  292 + contentLayout.getPaddingRight(), contentLayout.getPaddingBottom());
  293 + }
  294 + // 设置属性
  295 + setDrawerLayoutProperty(drawerLayout, contentLayout);
  296 + addTranslucentView(activity, statusBarAlpha);
  297 + }
  298 +
  299 + /**
  300 + * 设置 DrawerLayout 属性
  301 + *
  302 + * @param drawerLayout DrawerLayout
  303 + * @param drawerLayoutContentLayout DrawerLayout 的内容布局
  304 + */
  305 + private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
  306 + ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
  307 + drawerLayout.setFitsSystemWindows(false);
  308 + drawerLayoutContentLayout.setFitsSystemWindows(false);
  309 + drawerLayoutContentLayout.setClipToPadding(true);
  310 + drawer.setFitsSystemWindows(false);
  311 + }
  312 +
  313 + /**
  314 + * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
  315 + *
  316 + * @param activity 需要设置的activity
  317 + * @param drawerLayout DrawerLayout
  318 + * @param color 状态栏颜色值
  319 + */
  320 + @Deprecated
  321 + public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
  322 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  323 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  324 + // 生成一个状态栏大小的矩形
  325 + ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
  326 + View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
  327 + if (fakeStatusBarView != null) {
  328 + if (fakeStatusBarView.getVisibility() == View.GONE) {
  329 + fakeStatusBarView.setVisibility(View.VISIBLE);
  330 + }
  331 + fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
  332 + } else {
  333 + // 添加 statusBarView 到布局中
  334 + contentLayout.addView(createStatusBarView(activity, color), 0);
  335 + }
  336 + // 内容布局不是 LinearLayout 时,设置padding top
  337 + if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
  338 + contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
  339 + }
  340 + // 设置属性
  341 + setDrawerLayoutProperty(drawerLayout, contentLayout);
  342 + }
  343 + }
  344 +
  345 + /**
  346 + * 为 DrawerLayout 布局设置状态栏透明
  347 + *
  348 + * @param activity 需要设置的activity
  349 + * @param drawerLayout DrawerLayout
  350 + */
  351 + public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
  352 + setTranslucentForDrawerLayout(activity, drawerLayout, DEFAULT_STATUS_BAR_ALPHA);
  353 + }
  354 +
  355 + /**
  356 + * 为 DrawerLayout 布局设置状态栏透明
  357 + *
  358 + * @param activity 需要设置的activity
  359 + * @param drawerLayout DrawerLayout
  360 + */
  361 + public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout,
  362 + @IntRange(from = 0, to = 255) int statusBarAlpha) {
  363 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  364 + return;
  365 + }
  366 + setTransparentForDrawerLayout(activity, drawerLayout);
  367 + addTranslucentView(activity, statusBarAlpha);
  368 + }
  369 +
  370 + /**
  371 + * 为 DrawerLayout 布局设置状态栏透明
  372 + *
  373 + * @param activity 需要设置的activity
  374 + * @param drawerLayout DrawerLayout
  375 + */
  376 + public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
  377 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  378 + return;
  379 + }
  380 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  381 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  382 + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  383 + activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
  384 + } else {
  385 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  386 + }
  387 +
  388 + ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
  389 + // 内容布局不是 LinearLayout 时,设置padding top
  390 + if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
  391 + contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
  392 + }
  393 +
  394 + // 设置属性
  395 + setDrawerLayoutProperty(drawerLayout, contentLayout);
  396 + }
  397 +
  398 + /**
  399 + * 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
  400 + *
  401 + * @param activity 需要设置的activity
  402 + * @param drawerLayout DrawerLayout
  403 + */
  404 + @Deprecated
  405 + public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
  406 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  407 + // 设置状态栏透明
  408 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  409 + // 设置内容布局属性
  410 + ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
  411 + contentLayout.setFitsSystemWindows(true);
  412 + contentLayout.setClipToPadding(true);
  413 + // 设置抽屉布局属性
  414 + ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
  415 + vg.setFitsSystemWindows(false);
  416 + // 设置 DrawerLayout 属性
  417 + drawerLayout.setFitsSystemWindows(false);
  418 + }
  419 + }
  420 +
  421 + /**
  422 + * 为头部是 ImageView 的界面设置状态栏全透明
  423 + *
  424 + * @param activity 需要设置的activity
  425 + * @param needOffsetView 需要向下偏移的 View
  426 + */
  427 + public static void setTransparentForImageView(Activity activity, View needOffsetView) {
  428 + setTranslucentForImageView(activity, 0, needOffsetView);
  429 + }
  430 +
  431 + /**
  432 + * 为头部是 ImageView 的界面设置状态栏透明(使用默认透明度)
  433 + *
  434 + * @param activity 需要设置的activity
  435 + * @param needOffsetView 需要向下偏移的 View
  436 + */
  437 + public static void setTranslucentForImageView(Activity activity, View needOffsetView) {
  438 + setTranslucentForImageView(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView);
  439 + }
  440 +
  441 + /**
  442 + * 为头部是 ImageView 的界面设置状态栏透明
  443 + *
  444 + * @param activity 需要设置的activity
  445 + * @param statusBarAlpha 状态栏透明度
  446 + * @param needOffsetView 需要向下偏移的 View
  447 + */
  448 + public static void setTranslucentForImageView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha,
  449 + View needOffsetView) {
  450 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
  451 + return;
  452 + }
  453 + setTransparentForWindow(activity);
  454 + addTranslucentView(activity, statusBarAlpha);
  455 + if (needOffsetView != null) {
  456 + Object haveSetOffset = needOffsetView.getTag(TAG_KEY_HAVE_SET_OFFSET);
  457 + if (haveSetOffset != null && (Boolean) haveSetOffset) {
  458 + return;
  459 + }
  460 + ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
  461 + layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + getStatusBarHeight(activity),
  462 + layoutParams.rightMargin, layoutParams.bottomMargin);
  463 + needOffsetView.setTag(TAG_KEY_HAVE_SET_OFFSET, true);
  464 + }
  465 + }
  466 +
  467 + /**
  468 + * 为 fragment 头部是 ImageView 的设置状态栏透明
  469 + *
  470 + * @param activity fragment 对应的 activity
  471 + * @param needOffsetView 需要向下偏移的 View
  472 + */
  473 + public static void setTranslucentForImageViewInFragment(Activity activity, View needOffsetView) {
  474 + setTranslucentForImageViewInFragment(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView);
  475 + }
  476 +
  477 + /**
  478 + * 为 fragment 头部是 ImageView 的设置状态栏透明
  479 + *
  480 + * @param activity fragment 对应的 activity
  481 + * @param needOffsetView 需要向下偏移的 View
  482 + */
  483 + public static void setTransparentForImageViewInFragment(Activity activity, View needOffsetView) {
  484 + setTranslucentForImageViewInFragment(activity, 0, needOffsetView);
  485 + }
  486 +
  487 + /**
  488 + * 为 fragment 头部是 ImageView 的设置状态栏透明
  489 + *
  490 + * @param activity fragment 对应的 activity
  491 + * @param statusBarAlpha 状态栏透明度
  492 + * @param needOffsetView 需要向下偏移的 View
  493 + */
  494 + public static void setTranslucentForImageViewInFragment(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha,
  495 + View needOffsetView) {
  496 + setTranslucentForImageView(activity, statusBarAlpha, needOffsetView);
  497 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
  498 + clearPreviousSetting(activity);
  499 + }
  500 + }
  501 +
  502 + /**
  503 + * 隐藏伪状态栏 View
  504 + *
  505 + * @param activity 调用的 Activity
  506 + */
  507 + public static void hideFakeStatusBarView(Activity activity) {
  508 + ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
  509 + View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
  510 + if (fakeStatusBarView != null) {
  511 + fakeStatusBarView.setVisibility(View.GONE);
  512 + }
  513 + View fakeTranslucentView = decorView.findViewById(FAKE_TRANSLUCENT_VIEW_ID);
  514 + if (fakeTranslucentView != null) {
  515 + fakeTranslucentView.setVisibility(View.GONE);
  516 + }
  517 + }
  518 +
  519 + @TargetApi(Build.VERSION_CODES.M)
  520 + public static void setLightMode(Activity activity) {
  521 + setMIUIStatusBarDarkIcon(activity, true);
  522 + setMeizuStatusBarDarkIcon(activity, true);
  523 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  524 + activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  525 + }
  526 + }
  527 +
  528 + @TargetApi(Build.VERSION_CODES.M)
  529 + public static void setDarkMode(Activity activity) {
  530 + setMIUIStatusBarDarkIcon(activity, false);
  531 + setMeizuStatusBarDarkIcon(activity, false);
  532 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  533 + activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  534 + }
  535 + }
  536 +
  537 + /**
  538 + * 修改 MIUI V6 以上状态栏颜色
  539 + */
  540 + private static void setMIUIStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) {
  541 + Class<? extends Window> clazz = activity.getWindow().getClass();
  542 + try {
  543 + Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
  544 + Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
  545 + int darkModeFlag = field.getInt(layoutParams);
  546 + Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
  547 + extraFlagField.invoke(activity.getWindow(), darkIcon ? darkModeFlag : 0, darkModeFlag);
  548 + } catch (Exception e) {
  549 + //e.printStackTrace();
  550 + }
  551 + }
  552 +
  553 + /**
  554 + * 修改魅族状态栏字体颜色 Flyme 4.0
  555 + */
  556 + private static void setMeizuStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) {
  557 + try {
  558 + WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
  559 + Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
  560 + Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
  561 + darkFlag.setAccessible(true);
  562 + meizuFlags.setAccessible(true);
  563 + int bit = darkFlag.getInt(null);
  564 + int value = meizuFlags.getInt(lp);
  565 + if (darkIcon) {
  566 + value |= bit;
  567 + } else {
  568 + value &= ~bit;
  569 + }
  570 + meizuFlags.setInt(lp, value);
  571 + activity.getWindow().setAttributes(lp);
  572 + } catch (Exception e) {
  573 + //e.printStackTrace();
  574 + }
  575 + }
  576 +
  577 + ///////////////////////////////////////////////////////////////////////////////////
  578 +
  579 + @TargetApi(Build.VERSION_CODES.KITKAT)
  580 + private static void clearPreviousSetting(Activity activity) {
  581 + ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
  582 + View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
  583 + if (fakeStatusBarView != null) {
  584 + decorView.removeView(fakeStatusBarView);
  585 + ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
  586 + rootView.setPadding(0, 0, 0, 0);
  587 + }
  588 + }
  589 +
  590 + /**
  591 + * 添加半透明矩形条
  592 + *
  593 + * @param activity 需要设置的 activity
  594 + * @param statusBarAlpha 透明值
  595 + */
  596 + public static void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
  597 + ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
  598 + View fakeTranslucentView = contentView.findViewById(FAKE_TRANSLUCENT_VIEW_ID);
  599 + if (fakeTranslucentView != null) {
  600 + if (fakeTranslucentView.getVisibility() == View.GONE) {
  601 + fakeTranslucentView.setVisibility(View.VISIBLE);
  602 + }
  603 + fakeTranslucentView.setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0));
  604 + } else {
  605 + contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
  606 + }
  607 + }
  608 +
  609 + /**
  610 + * 生成一个和状态栏大小相同的彩色矩形条
  611 + *
  612 + * @param activity 需要设置的 activity
  613 + * @param color 状态栏颜色值
  614 + * @return 状态栏矩形条
  615 + */
  616 + private static View createStatusBarView(Activity activity, @ColorInt int color) {
  617 + return createStatusBarView(activity, color, 0);
  618 + }
  619 +
  620 + /**
  621 + * 生成一个和状态栏大小相同的半透明矩形条
  622 + *
  623 + * @param activity 需要设置的activity
  624 + * @param color 状态栏颜色值
  625 + * @param alpha 透明值
  626 + * @return 状态栏矩形条
  627 + */
  628 + private static View createStatusBarView(Activity activity, @ColorInt int color, int alpha) {
  629 + // 绘制一个和状态栏一样高的矩形
  630 + View statusBarView = new View(activity);
  631 + LinearLayout.LayoutParams params =
  632 + new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
  633 + statusBarView.setLayoutParams(params);
  634 + statusBarView.setBackgroundColor(calculateStatusColor(color, alpha));
  635 + statusBarView.setId(FAKE_STATUS_BAR_VIEW_ID);
  636 + return statusBarView;
  637 + }
  638 +
  639 + /**
  640 + * 设置根布局参数
  641 + */
  642 + private static void setRootView(Activity activity) {
  643 + ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content);
  644 + for (int i = 0, count = parent.getChildCount(); i < count; i++) {
  645 + View childView = parent.getChildAt(i);
  646 + if (childView instanceof ViewGroup) {
  647 + childView.setFitsSystemWindows(true);
  648 + ((ViewGroup) childView).setClipToPadding(true);
  649 + }
  650 + }
  651 + }
  652 +
  653 + /**
  654 + * 设置透明
  655 + */
  656 + public static void setTransparentForWindow(Activity activity) {
  657 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  658 + activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
  659 + activity.getWindow()
  660 + .getDecorView()
  661 + .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  662 + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  663 + activity.getWindow()
  664 + .setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  665 + }
  666 + }
  667 +
  668 + /**
  669 + * 使状态栏透明
  670 + */
  671 + @TargetApi(Build.VERSION_CODES.KITKAT)
  672 + private static void transparentStatusBar(Activity activity) {
  673 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  674 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  675 + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  676 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
  677 + activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
  678 + } else {
  679 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  680 + }
  681 + }
  682 +
  683 + /**
  684 + * 创建半透明矩形 View
  685 + *
  686 + * @param alpha 透明值
  687 + * @return 半透明 View
  688 + */
  689 + private static View createTranslucentStatusBarView(Activity activity, int alpha) {
  690 + // 绘制一个和状态栏一样高的矩形
  691 + View statusBarView = new View(activity);
  692 + LinearLayout.LayoutParams params =
  693 + new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
  694 + statusBarView.setLayoutParams(params);
  695 + statusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
  696 + statusBarView.setId(FAKE_TRANSLUCENT_VIEW_ID);
  697 + return statusBarView;
  698 + }
  699 +
  700 + /**
  701 + * 获取状态栏高度
  702 + *
  703 + * @param context context
  704 + * @return 状态栏高度
  705 + */
  706 + public static int getStatusBarHeight(Context context) {
  707 + // 获得状态栏高度
  708 + int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
  709 + return context.getResources().getDimensionPixelSize(resourceId);
  710 + }
  711 +
  712 + /**
  713 + * 计算状态栏颜色
  714 + *
  715 + * @param color color值
  716 + * @param alpha alpha值
  717 + * @return 最终的状态栏颜色
  718 + */
  719 + private static int calculateStatusColor(@ColorInt int color, int alpha) {
  720 + if (alpha == 0) {
  721 + return color;
  722 + }
  723 + float a = 1 - alpha / 255f;
  724 + int red = color >> 16 & 0xff;
  725 + int green = color >> 8 & 0xff;
  726 + int blue = color & 0xff;
  727 + red = (int) (red * a + 0.5);
  728 + green = (int) (green * a + 0.5);
  729 + blue = (int) (blue * a + 0.5);
  730 + return 0xff << 24 | red << 16 | green << 8 | blue;
  731 + }
  732 +}
... ...
filespicker/src/main/java/com/cnlive/filespicker/utils/TimeUtil.java 0 → 100644
  1 +package com.cnlive.filespicker.utils;
  2 +
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.Calendar;
  5 +import java.util.Date;
  6 +
  7 +
  8 +/**
  9 + * 时间转换工具
  10 + */
  11 +public class TimeUtil {
  12 +
  13 + private static String dayNames[] = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
  14 +
  15 + /**
  16 + * 时间戳格式转换,会话列表页面,单位s
  17 + */
  18 + public static String getConversationTimeStr(long timeS) {
  19 + if (timeS <= 0) return "";
  20 + long timesamp = timeS * 1000;
  21 + String result = "";
  22 + Calendar todayCalendar = Calendar.getInstance();
  23 + Calendar otherCalendar = Calendar.getInstance();
  24 + otherCalendar.setTimeInMillis(timesamp);
  25 +
  26 + String timeFormat = "M月d日";
  27 + String yearTimeFormat = "yyyy年M月d日";
  28 +
  29 + boolean yearTemp = todayCalendar.get(Calendar.YEAR) == otherCalendar.get(Calendar.YEAR);
  30 + if (yearTemp) {
  31 + int todayMonth = todayCalendar.get(Calendar.MONTH);
  32 + int otherMonth = otherCalendar.get(Calendar.MONTH);
  33 + if (todayMonth == otherMonth) {//表示是同一个月
  34 + int temp = todayCalendar.get(Calendar.DATE) - otherCalendar.get(Calendar.DATE);
  35 + switch (temp) {
  36 + case 0:
  37 + result = getHourAndMin(timesamp);
  38 + break;
  39 + case 1:
  40 + result = "昨天 ";
  41 + break;
  42 + case 2:
  43 + case 3:
  44 + case 4:
  45 + case 5:
  46 + case 6:
  47 + int dayOfMonth = otherCalendar.get(Calendar.WEEK_OF_MONTH);
  48 + int todayOfMonth = todayCalendar.get(Calendar.WEEK_OF_MONTH);
  49 + if (dayOfMonth == todayOfMonth) {//表示是同一周
  50 + int dayOfWeek = otherCalendar.get(Calendar.DAY_OF_WEEK);
  51 + if (dayOfWeek != 1) {//判断当前是不是星期日 如想显示为:周日 12:09 可去掉此判断
  52 + result = dayNames[otherCalendar.get(Calendar.DAY_OF_WEEK) - 1];
  53 + } else {
  54 + result = getTime(timesamp, timeFormat);
  55 + }
  56 + } else {
  57 + result = getTime(timesamp, timeFormat);
  58 + }
  59 + break;
  60 + default:
  61 + result = getTime(timesamp, timeFormat);
  62 + break;
  63 + }
  64 + } else {
  65 + result = getTime(timesamp, timeFormat);
  66 + }
  67 + } else {
  68 + result = getYearTime(timesamp, yearTimeFormat);
  69 + }
  70 + return result;
  71 + }
  72 +
  73 + public static String getChatTimeStr(String timeS) {
  74 + long time = Long.decode(timeS) / 1000L;
  75 + return getChatTimeStr(time);
  76 + }
  77 +
  78 + /**
  79 + * 时间戳格式转换,聊天页面,单位s
  80 + */
  81 + public static String getChatTimeStr(long timeS) {
  82 + long timesamp = timeS * 1000;
  83 + String result = "";
  84 + Calendar todayCalendar = Calendar.getInstance();
  85 + Calendar otherCalendar = Calendar.getInstance();
  86 + otherCalendar.setTimeInMillis(timesamp);
  87 +
  88 + String timeFormat = "M月d日 HH:mm";
  89 + String yearTimeFormat = "yyyy年M月d日 HH:mm";
  90 + String am_pm = "";
  91 + int hour = otherCalendar.get(Calendar.HOUR_OF_DAY);
  92 + if (hour >= 0 && hour < 6) {
  93 + am_pm = "凌晨";
  94 + } else if (hour >= 6 && hour < 12) {
  95 + am_pm = "早上";
  96 + } else if (hour == 12) {
  97 + am_pm = "中午";
  98 + } else if (hour > 12 && hour < 18) {
  99 + am_pm = "下午";
  100 + } else if (hour >= 18) {
  101 + am_pm = "晚上";
  102 + }
  103 + timeFormat = "M月d日 " + am_pm + "HH:mm";
  104 + yearTimeFormat = "yyyy年M月d日 " + am_pm + "HH:mm";
  105 +
  106 + boolean yearTemp = todayCalendar.get(Calendar.YEAR) == otherCalendar.get(Calendar.YEAR);
  107 + if (yearTemp) {
  108 + int todayMonth = todayCalendar.get(Calendar.MONTH);
  109 + int otherMonth = otherCalendar.get(Calendar.MONTH);
  110 + if (todayMonth == otherMonth) {//表示是同一个月
  111 + int temp = todayCalendar.get(Calendar.DATE) - otherCalendar.get(Calendar.DATE);
  112 + switch (temp) {
  113 + case 0:
  114 + result = getHourAndMin(timesamp);
  115 + break;
  116 + case 1:
  117 + result = "昨天 " + getHourAndMin(timesamp);
  118 + break;
  119 + case 2:
  120 + case 3:
  121 + case 4:
  122 + case 5:
  123 + case 6:
  124 + int dayOfMonth = otherCalendar.get(Calendar.WEEK_OF_MONTH);
  125 + int todayOfMonth = todayCalendar.get(Calendar.WEEK_OF_MONTH);
  126 + if (dayOfMonth == todayOfMonth) {//表示是同一周
  127 + int dayOfWeek = otherCalendar.get(Calendar.DAY_OF_WEEK);
  128 + if (dayOfWeek != 1) {//判断当前是不是星期日 如想显示为:周日 12:09 可去掉此判断
  129 + result = dayNames[otherCalendar.get(Calendar.DAY_OF_WEEK) - 1] + getHourAndMin(timesamp);
  130 + } else {
  131 + result = getTime(timesamp, timeFormat);
  132 + }
  133 + } else {
  134 + result = getTime(timesamp, timeFormat);
  135 + }
  136 + break;
  137 + default:
  138 + result = getTime(timesamp, timeFormat);
  139 + break;
  140 + }
  141 + } else {
  142 + result = getTime(timesamp, timeFormat);
  143 + }
  144 + } else {
  145 + result = getYearTime(timesamp, yearTimeFormat);
  146 + }
  147 + return result;
  148 + }
  149 +
  150 + /**
  151 + * 当天的显示时间格式
  152 + *
  153 + * @param time
  154 + * @return
  155 + */
  156 + public static String getHourAndMin(long time) {
  157 + SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  158 + return format.format(new Date(time));
  159 + }
  160 +
  161 + /**
  162 + * 不同一周的显示时间格式
  163 + *
  164 + * @param time
  165 + * @param timeFormat
  166 + * @return
  167 + */
  168 + public static String getTime(long time, String timeFormat) {
  169 + SimpleDateFormat format = new SimpleDateFormat(timeFormat);
  170 + return format.format(new Date(time));
  171 + }
  172 +
  173 + /**
  174 + * 不同年的显示时间格式
  175 + *
  176 + * @param time
  177 + * @param yearTimeFormat
  178 + * @return
  179 + */
  180 + public static String getYearTime(long time, String yearTimeFormat) {
  181 + SimpleDateFormat format = new SimpleDateFormat(yearTimeFormat);
  182 + return format.format(new Date(time));
  183 + }
  184 +}
... ...
filespicker/src/main/res/drawable-hdpi/file_close.png 0 → 100644

459 Bytes

filespicker/src/main/res/drawable-hdpi/file_more.png 0 → 100644

313 Bytes

filespicker/src/main/res/drawable-hdpi/file_select.png 0 → 100644

1.39 KB

filespicker/src/main/res/drawable-hdpi/file_unselect.png 0 → 100644

1.3 KB

filespicker/src/main/res/drawable-hdpi/zw_zt.png 0 → 100644

8.19 KB

filespicker/src/main/res/drawable-xhdpi/file_close.png 0 → 100644

411 Bytes

filespicker/src/main/res/drawable-xhdpi/file_more.png 0 → 100644

162 Bytes

filespicker/src/main/res/drawable-xhdpi/file_select.png 0 → 100644

1.01 KB

filespicker/src/main/res/drawable-xhdpi/file_unselect.png 0 → 100644

1010 Bytes

filespicker/src/main/res/drawable-xhdpi/zw_zt.png 0 → 100644

9.85 KB

filespicker/src/main/res/drawable-xxhdpi/file_close.png 0 → 100644

884 Bytes

filespicker/src/main/res/drawable-xxhdpi/file_more.png 0 → 100644

259 Bytes

filespicker/src/main/res/drawable-xxhdpi/file_select.png 0 → 100644

2.28 KB

filespicker/src/main/res/drawable-xxhdpi/file_unselect.png 0 → 100644

2.68 KB

filespicker/src/main/res/drawable-xxhdpi/zw_zt.png 0 → 100644

19.3 KB

filespicker/src/main/res/drawable/bg_file_check.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<selector xmlns:android="http://schemas.android.com/apk/res/android">
  4 + <item android:drawable="@drawable/file_select" android:state_checked="true" />
  5 + <item android:drawable="@drawable/file_unselect" android:state_checked="false" />
  6 +</selector>
0 7 \ No newline at end of file
... ...
filespicker/src/main/res/drawable/chat_media_close.png 0 → 100644

1.11 KB

filespicker/src/main/res/drawable/ks_format_3gp.png 0 → 100644

9.66 KB

filespicker/src/main/res/drawable/ks_format_apk.png 0 → 100644

10.7 KB

filespicker/src/main/res/drawable/ks_format_asf.png 0 → 100644

9.53 KB

filespicker/src/main/res/drawable/ks_format_avi.png 0 → 100644

9.46 KB

filespicker/src/main/res/drawable/ks_format_bat.png 0 → 100644

3.96 KB

filespicker/src/main/res/drawable/ks_format_bin.png 0 → 100644

8.13 KB

filespicker/src/main/res/drawable/ks_format_bmp.png 0 → 100644

10.1 KB

filespicker/src/main/res/drawable/ks_format_c.png 0 → 100644

8.1 KB

filespicker/src/main/res/drawable/ks_format_chm.png 0 → 100644

3.56 KB

filespicker/src/main/res/drawable/ks_format_class.png 0 → 100644

9.01 KB

filespicker/src/main/res/drawable/ks_format_conf.png 0 → 100644

9.27 KB

filespicker/src/main/res/drawable/ks_format_cpp.png 0 → 100644

8.97 KB

filespicker/src/main/res/drawable/ks_format_dat.png 0 → 100644

2.98 KB

filespicker/src/main/res/drawable/ks_format_dll.png 0 → 100644

2.64 KB

filespicker/src/main/res/drawable/ks_format_doc.png 0 → 100644

9.3 KB

filespicker/src/main/res/drawable/ks_format_docx.png 0 → 100644

9.71 KB

filespicker/src/main/res/drawable/ks_format_exe.png 0 → 100644

9.79 KB

filespicker/src/main/res/drawable/ks_format_flac.png 0 → 100644

3.3 KB

filespicker/src/main/res/drawable/ks_format_flv.png 0 → 100644

3.5 KB

filespicker/src/main/res/drawable/ks_format_forder.png 0 → 100644

1.82 KB

filespicker/src/main/res/drawable/ks_format_gif.png 0 → 100644

9.6 KB

filespicker/src/main/res/drawable/ks_format_gtar.png 0 → 100644

8.73 KB

filespicker/src/main/res/drawable/ks_format_gz.png 0 → 100644

8.11 KB

filespicker/src/main/res/drawable/ks_format_h.png 0 → 100644

8.04 KB

filespicker/src/main/res/drawable/ks_format_htm.png 0 → 100644

10.9 KB

filespicker/src/main/res/drawable/ks_format_html.png 0 → 100644

11.1 KB

filespicker/src/main/res/drawable/ks_format_inf.png 0 → 100644

2.76 KB

filespicker/src/main/res/drawable/ks_format_ini.png 0 → 100644

2.67 KB

filespicker/src/main/res/drawable/ks_format_jar.png 0 → 100644

9.85 KB

filespicker/src/main/res/drawable/ks_format_java.png 0 → 100644

11.9 KB

filespicker/src/main/res/drawable/ks_format_jif.png 0 → 100644

9.25 KB

filespicker/src/main/res/drawable/ks_format_jpeg.png 0 → 100644

10.2 KB

filespicker/src/main/res/drawable/ks_format_jpg.png 0 → 100644

9.96 KB

filespicker/src/main/res/drawable/ks_format_js.png 0 → 100644

9.07 KB

filespicker/src/main/res/drawable/ks_format_log.png 0 → 100644

7.87 KB

filespicker/src/main/res/drawable/ks_format_m.png 0 → 100644

8.47 KB

filespicker/src/main/res/drawable/ks_format_m3u.png 0 → 100644

9.26 KB

filespicker/src/main/res/drawable/ks_format_m4a.png 0 → 100644

9.11 KB

filespicker/src/main/res/drawable/ks_format_m4b.png 0 → 100644

8.92 KB

filespicker/src/main/res/drawable/ks_format_m4p.png 0 → 100644

8.97 KB

filespicker/src/main/res/drawable/ks_format_m4u.png 0 → 100644

10 KB

filespicker/src/main/res/drawable/ks_format_m4v.png 0 → 100644

9.83 KB

filespicker/src/main/res/drawable/ks_format_mid.png 0 → 100644

2.86 KB

filespicker/src/main/res/drawable/ks_format_mkv.png 0 → 100644

5.86 KB

filespicker/src/main/res/drawable/ks_format_mov.png 0 → 100644

10.2 KB

filespicker/src/main/res/drawable/ks_format_mp2.png 0 → 100644

8.87 KB

filespicker/src/main/res/drawable/ks_format_mp3.png 0 → 100644

9.03 KB

filespicker/src/main/res/drawable/ks_format_mp4.png 0 → 100644

9.65 KB

filespicker/src/main/res/drawable/ks_format_mpc.png 0 → 100644

10.2 KB

filespicker/src/main/res/drawable/ks_format_mpe.png 0 → 100644

8.72 KB

filespicker/src/main/res/drawable/ks_format_mpeg.png 0 → 100644

10.4 KB

filespicker/src/main/res/drawable/ks_format_mpg.png 0 → 100644

10.1 KB

filespicker/src/main/res/drawable/ks_format_mpg4.png 0 → 100644

10.7 KB

filespicker/src/main/res/drawable/ks_format_mpga.png 0 → 100644

10.2 KB

filespicker/src/main/res/drawable/ks_format_msg.png 0 → 100644

8.81 KB

filespicker/src/main/res/drawable/ks_format_ogg.png 0 → 100644

9.38 KB

filespicker/src/main/res/drawable/ks_format_pdf.png 0 → 100644

10.2 KB

filespicker/src/main/res/drawable/ks_format_png.png 0 → 100644

9.58 KB

filespicker/src/main/res/drawable/ks_format_pps.png 0 → 100644

9.66 KB

filespicker/src/main/res/drawable/ks_format_ppt.png 0 → 100644

8.87 KB

filespicker/src/main/res/drawable/ks_format_pptx.png 0 → 100644

9.46 KB

filespicker/src/main/res/drawable/ks_format_prop.png 0 → 100644

8.96 KB

filespicker/src/main/res/drawable/ks_format_ram.png 0 → 100644

2.21 KB

filespicker/src/main/res/drawable/ks_format_rar.png 0 → 100644

10.7 KB