Commit a3a7ee80e099ede550cea21efdd523762ab9f8ab

Authored by 韩亚云
1 parent c57fee4c

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

Showing 164 changed files with 4256 additions and 417 deletions
.idea/vcs.xml
@@ -2,5 +2,6 @@ @@ -2,5 +2,6 @@
2 <project version="4"> 2 <project version="4">
3 <component name="VcsDirectoryMappings"> 3 <component name="VcsDirectoryMappings">
4 <mapping directory="" vcs="Git" /> 4 <mapping directory="" vcs="Git" />
  5 + <mapping directory="$PROJECT_DIR$/Updown" vcs="Git" />
5 </component> 6 </component>
6 </project> 7 </project>
7 \ No newline at end of file 8 \ No newline at end of file
app/build.gradle
@@ -34,4 +34,9 @@ dependencies { @@ -34,4 +34,9 @@ dependencies {
34 androidTestImplementation 'com.android.support.test:runner:1.0.2' 34 androidTestImplementation 'com.android.support.test:runner:1.0.2'
35 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 35 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
36 api project(':updownfile') 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,7 +4,8 @@ import android.content.Intent;
4 import android.support.v7.app.AppCompatActivity; 4 import android.support.v7.app.AppCompatActivity;
5 import android.os.Bundle; 5 import android.os.Bundle;
6 6
7 -import com.cnlive.updownfile.InitViewActivity; 7 +import com.cnlive.updownfile.xiaoRay.InitViewActivity;
  8 +
8 9
9 public class MainActivity extends AppCompatActivity { 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 \ No newline at end of file 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 \ No newline at end of file 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 \ No newline at end of file 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

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

8.93 KB

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

4.2 KB

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

3.63 KB

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

9.91 KB

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

9.68 KB

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

8 KB

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

3.64 KB

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

8.7 KB

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

10.4 KB

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

8.74 KB

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

1.85 KB

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

3.45 KB

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

9.41 KB

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

9.4 KB

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

10.3 KB

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

9.98 KB

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

10.5 KB

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

10.7 KB

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

11.2 KB

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

11.1 KB

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

9.68 KB

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

9.38 KB

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

191 Bytes

filespicker/src/main/res/layout/activity_file_picker.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:background="@android:color/white"
  6 + android:orientation="vertical">
  7 +
  8 + <LinearLayout
  9 + android:id="@+id/topBar"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="?attr/actionBarSize"
  12 + android:background="@color/top_bar_color"
  13 + android:gravity="center_vertical"
  14 + android:orientation="horizontal">
  15 +
  16 + <ImageView
  17 + android:id="@+id/close"
  18 + android:layout_width="34dp"
  19 + android:layout_height="34dp"
  20 + android:layout_marginLeft="2dp"
  21 + android:layout_marginRight="4dp"
  22 + android:padding="10dp"
  23 + android:src="@drawable/file_close" />
  24 +
  25 + <LinearLayout
  26 + android:layout_width="wrap_content"
  27 + android:layout_height="wrap_content"
  28 + android:layout_weight="1"
  29 + android:orientation="vertical">
  30 +
  31 + <TextView
  32 + android:id="@+id/title"
  33 + android:layout_width="match_parent"
  34 + android:layout_height="wrap_content"
  35 + android:textColor="@android:color/white"
  36 + android:textSize="18sp" />
  37 +
  38 + <TextView
  39 + android:id="@+id/path"
  40 + android:layout_width="wrap_content"
  41 + android:layout_height="wrap_content"
  42 + android:singleLine="true"
  43 + android:textColor="@android:color/white"
  44 + android:textSize="12sp" />
  45 +
  46 + </LinearLayout>
  47 +
  48 + <TextView
  49 + android:id="@+id/send"
  50 + android:layout_width="wrap_content"
  51 + android:layout_height="wrap_content"
  52 + android:layout_marginRight="15dp"
  53 + android:singleLine="true"
  54 + android:text="发送"
  55 + android:textColor="@color/color_13cc0c"
  56 + android:textSize="17sp" />
  57 +
  58 + </LinearLayout>
  59 +
  60 + <android.support.v7.widget.RecyclerView
  61 + android:id="@+id/recyclerView"
  62 + android:layout_width="match_parent"
  63 + android:layout_height="match_parent"
  64 + android:layout_above="@+id/bottomLayout"
  65 + android:layout_below="@id/topBar" />
  66 +
  67 + <LinearLayout
  68 + android:id="@+id/bottomLayout"
  69 + android:layout_width="match_parent"
  70 + android:layout_height="48dp"
  71 + android:layout_alignParentBottom="true"
  72 + android:background="@color/top_bar_color"
  73 + android:gravity="center_vertical"
  74 + android:orientation="horizontal">
  75 +
  76 + <RelativeLayout
  77 + android:id="@+id/selectView"
  78 + android:layout_width="wrap_content"
  79 + android:layout_height="match_parent">
  80 +
  81 + <TextView
  82 + android:id="@+id/selectFolder"
  83 + android:layout_width="wrap_content"
  84 + android:layout_height="wrap_content"
  85 + android:layout_centerVertical="true"
  86 + android:paddingLeft="11dp"
  87 + android:paddingRight="7dp"
  88 + android:text="网++文件"
  89 + android:textColor="@android:color/white"
  90 + android:textSize="17sp" />
  91 +
  92 + <ImageView
  93 + android:layout_width="10dp"
  94 + android:layout_height="9dp"
  95 + android:layout_alignBottom="@+id/selectFolder"
  96 + android:layout_toRightOf="@+id/selectFolder"
  97 + android:background="@drawable/file_more" />
  98 + </RelativeLayout>
  99 +
  100 + <TextView
  101 + android:id="@+id/totalSize"
  102 + android:layout_width="0dp"
  103 + android:layout_height="wrap_content"
  104 + android:layout_gravity="right|center_vertical"
  105 + android:layout_marginRight="15dp"
  106 + android:layout_weight="1"
  107 + android:gravity="right"
  108 + android:textColor="@android:color/white"
  109 + android:textSize="17sp" />
  110 +
  111 + </LinearLayout>
  112 +
  113 + <LinearLayout
  114 + android:id="@+id/emptyView"
  115 + android:layout_width="match_parent"
  116 + android:layout_height="match_parent"
  117 + android:layout_above="@+id/bottomLayout"
  118 + android:layout_below="@id/topBar"
  119 + android:gravity="center"
  120 + android:orientation="vertical"
  121 + android:visibility="gone">
  122 +
  123 + <ImageView
  124 + android:layout_width="142dp"
  125 + android:layout_height="112dp"
  126 + android:background="@drawable/zw_zt" />
  127 +
  128 + <android.support.v7.widget.AppCompatTextView
  129 + android:layout_width="wrap_content"
  130 + android:layout_height="wrap_content"
  131 + android:layout_gravity="center"
  132 + android:layout_marginTop="20dp"
  133 + android:gravity="center_horizontal"
  134 + android:text="@string/empty_directory"
  135 + android:textColor="@color/color_d3d3d3"
  136 + android:textSize="12sp" />
  137 + </LinearLayout>
  138 +
  139 +</RelativeLayout>
filespicker/src/main/res/layout/list_item_file.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:id="@+id/rootLayout"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="70dp">
  6 +
  7 + <ImageView
  8 + android:id="@+id/icon"
  9 + android:layout_width="48dp"
  10 + android:layout_height="48dp"
  11 + android:layout_centerVertical="true"
  12 + android:layout_marginLeft="14dp"
  13 + android:layout_marginRight="12dp"
  14 + android:scaleType="centerInside" />
  15 +
  16 + <LinearLayout
  17 + android:layout_width="match_parent"
  18 + android:layout_height="wrap_content"
  19 + android:layout_centerVertical="true"
  20 + android:layout_marginRight="10dp"
  21 + android:layout_toLeftOf="@+id/checkLayout"
  22 + android:layout_toRightOf="@+id/icon"
  23 + android:orientation="vertical">
  24 +
  25 + <TextView
  26 + android:id="@+id/title"
  27 + android:layout_width="wrap_content"
  28 + android:layout_height="wrap_content"
  29 + android:singleLine="true"
  30 + android:textColor="@color/color_282828"
  31 + android:textSize="17sp" />
  32 +
  33 + <TextView
  34 + android:id="@+id/desc"
  35 + android:layout_width="wrap_content"
  36 + android:layout_height="wrap_content"
  37 + android:layout_marginTop="5dp"
  38 + android:singleLine="true"
  39 + android:textColor="#656565"
  40 + android:textSize="12sp" />
  41 +
  42 + </LinearLayout>
  43 +
  44 + <LinearLayout
  45 + android:id="@+id/checkLayout"
  46 + android:layout_width="wrap_content"
  47 + android:layout_height="wrap_content"
  48 + android:layout_alignParentRight="true"
  49 + android:layout_centerVertical="true"
  50 + android:layout_marginRight="9dp"
  51 + android:padding="10dp">
  52 +
  53 + <CheckBox
  54 + android:id="@+id/checkbox"
  55 + android:layout_width="21dp"
  56 + android:layout_height="21dp"
  57 + android:button="@drawable/bg_file_check"
  58 + android:clickable="false"
  59 + android:focusable="false" />
  60 +
  61 + </LinearLayout>
  62 +
  63 + <View
  64 + android:layout_width="match_parent"
  65 + android:layout_height="1px"
  66 + android:layout_alignParentBottom="true"
  67 + android:layout_marginLeft="12dp"
  68 + android:layout_marginRight="12dp"
  69 + android:background="@color/colorDivider2" />
  70 +
  71 +</RelativeLayout>
0 \ No newline at end of file 72 \ No newline at end of file
filespicker/src/main/res/layout/list_item_select.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="wrap_content"
  5 + android:orientation="vertical">
  6 +
  7 + <TextView
  8 + android:id="@+id/text"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="48dp"
  11 + android:gravity="center_vertical"
  12 + android:paddingLeft="23dp"
  13 + android:textColor="@color/color_282828"
  14 + android:textSize="17sp" />
  15 +
  16 + <View
  17 + android:layout_width="match_parent"
  18 + android:layout_height="1px"
  19 + android:layout_marginLeft="12dp"
  20 + android:layout_marginRight="12dp"
  21 + android:background="@color/colorDivider2" />
  22 +
  23 +</LinearLayout>
0 \ No newline at end of file 24 \ No newline at end of file
filespicker/src/main/res/values/colors.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <color name="top_bar_color">#2c2c2c</color>
  4 + <color name="text_color">#ffffff</color>
  5 + <color name="colorDivider2">#c3c3c3</color>
  6 + <color name="color_13cc0c">#ff13cc0c</color>
  7 + <color name="color_282828">#282828</color>
  8 + <color name="color_656565">#656565</color>
  9 + <color name="color_d3d3d3">#d3d3d3</color>
  10 +
  11 +</resources>
0 \ No newline at end of file 12 \ No newline at end of file
filespicker/src/main/res/values/ids.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <item name="statusbarutil_fake_status_bar_view" type="id" />
  4 + <item name="statusbarutil_translucent_view" type="id" />
  5 +</resources>
0 \ No newline at end of file 6 \ No newline at end of file
filespicker/src/main/res/values/strings.xml 0 → 100644
  1 +<resources>
  2 + <string name="app_name">FilesPicker</string>
  3 + <string name="permission_write_storage_checker">应用程序需要获取存储权限,否则无法正常使用存储功能</string>
  4 + <string name="empty_directory">暂无文件</string>
  5 + <string name="max_file_count">最多只能选择9个文件</string>
  6 + <string name="max_file_size">文件太大无法选择</string>
  7 + <string name="min_file_size">文件为空无法选择</string>
  8 + <string name="select_no_file">请选择需要发送的文件</string>
  9 +</resources>
filespicker/src/main/res/values/styles.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <style name="CustomDialogStyle" parent="@android:style/Theme.Dialog">
  4 + <item name="android:windowFrame">@null</item>
  5 + <item name="android:windowIsFloating">true</item>
  6 + <item name="android:windowIsTranslucent">true</item>
  7 + <item name="android:windowNoTitle">true</item>
  8 + <item name="android:windowBackground">@android:color/transparent</item>
  9 + <item name="android:backgroundDimEnabled">true</item>
  10 + <item name="android:backgroundDimAmount">0.6</item>
  11 + <item name="android:windowCloseOnTouchOutside">true</item>
  12 + </style>
  13 +</resources>
0 \ No newline at end of file 14 \ No newline at end of file
settings.gradle
1 -include ':app', ':updownfile' 1 +include ':app', ':updownfile','filespicker'
updownfile/build.gradle
@@ -41,16 +41,14 @@ dependencies { @@ -41,16 +41,14 @@ dependencies {
41 implementation 'com.cnlive.libs:base:1.0.7' 41 implementation 'com.cnlive.libs:base:1.0.7'
42 implementation 'com.cnlive:lib_video_qiniu:1.0.2' 42 implementation 'com.cnlive:lib_video_qiniu:1.0.2'
43 implementation 'com.cnlive.libs:mediapicker:1.2.2' 43 implementation 'com.cnlive.libs:mediapicker:1.2.2'
44 -  
45 -  
46 implementation files('libs/mylib.jar') 44 implementation files('libs/mylib.jar')
47 - implementation "com.android.support:recyclerview-v7:28.0.0"  
48 - implementation "com.github.bumptech.glide:glide:4.5.0"  
49 - implementation "com.cnlive.libs:largeimage:1.0.0" 45 + implementation 'com.android.support:recyclerview-v7:28.0.0'
  46 + implementation 'com.github.bumptech.glide:glide:4.5.0'
  47 + implementation 'com.cnlive.libs:largeimage:1.0.0'
50 implementation 'com.android.support:support-v4:28.0.0' 48 implementation 'com.android.support:support-v4:28.0.0'
51 implementation 'org.greenrobot:greendao:3.2.2' 49 implementation 'org.greenrobot:greendao:3.2.2'
52 -  
53 implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.40' 50 implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.40'
54 implementation 'com.lcodecorex:tkrefreshlayout:1.0.7' 51 implementation 'com.lcodecorex:tkrefreshlayout:1.0.7'
  52 + implementation project(path: ':filespicker')
55 53
56 } 54 }
updownfile/libs/mylib.jar
No preview for this file type
updownfile/src/main/AndroidManifest.xml
@@ -8,8 +8,9 @@ @@ -8,8 +8,9 @@
8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 8 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9 9
10 <application> 10 <application>
11 - <activity android:name=".DiretoryActivity"></activity>  
12 - <activity android:name=".InitViewActivity" /> 11 + <activity android:name=".xiaoRay.DiretoryActivity" />
  12 + <activity android:name=".xiaoRay.InitViewActivity" />
  13 + <activity android:name="com.cnlive.filespicker.ui.FilePickerActivity" />
13 14
14 <service android:name="com.xiaoray.raysdk.service.TaskUploadService" /> 15 <service android:name="com.xiaoray.raysdk.service.TaskUploadService" />
15 <service android:name="com.xiaoray.raysdk.service.TaskDownloadService" /> 16 <service android:name="com.xiaoray.raysdk.service.TaskDownloadService" />
updownfile/src/main/java/com/cnlive/updownfile/DiretoryActivity.java deleted 100644 → 0
1 -package com.cnlive.updownfile;  
2 -  
3 -import android.content.Intent;  
4 -import android.support.v7.app.AppCompatActivity;  
5 -import android.os.Bundle;  
6 -import android.support.v7.widget.LinearLayoutManager;  
7 -import android.support.v7.widget.RecyclerView;  
8 -import android.text.TextUtils;  
9 -import android.view.View;  
10 -import android.widget.Button;  
11 -import android.widget.EditText;  
12 -  
13 -import com.chad.library.adapter.base.BaseQuickAdapter;  
14 -import com.cnlive.updownfile.adapter.ShowDiretoryAdapter;  
15 -import com.cnlive.updownfile.bean.DirectoryBean;  
16 -import com.cnlive.updownfile.bean.FileBean;  
17 -import com.cnlive.updownfile.view.RefreshHeaderView;  
18 -import com.google.gson.Gson;  
19 -import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;  
20 -import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;  
21 -import com.xiaoray.raysdk.RayLib;  
22 -import com.xiaoray.raysdk.constant.FileType;  
23 -import com.xiaoray.raysdk.utils.OkHttpUtils.HttpResult;  
24 -import com.xiaoray.raysdk.view.RayToast;  
25 -  
26 -import java.io.File;  
27 -import java.util.ArrayList;  
28 -import java.util.List;  
29 -  
30 -public class DiretoryActivity extends AppCompatActivity {  
31 -  
32 - RecyclerView rcyDataShow;  
33 - EditText editNewFolder;  
34 - Button btnCreateNewFolder;  
35 - TwinklingRefreshLayout refreshDataShow;  
36 - private ShowDiretoryAdapter showFilesAdapter;  
37 - private int page = 1;  
38 - private boolean isLoadingFinished = true;  
39 - private String folderPath = "/";  
40 - private final int REQUEST_WRITE_CONTENT = 2;  
41 - private final int QUERY_METHODE_ALLFILES = 0;  
42 - private final int QUERY_METHODE_ONLY_DIRETORY = 1;  
43 -  
44 - @Override  
45 - protected void onCreate(Bundle savedInstanceState) {  
46 - super.onCreate(savedInstanceState);  
47 - setContentView(R.layout.activity_diretory);  
48 - folderPath = getIntent().getStringExtra("path");  
49 - init();  
50 - initListener();  
51 - }  
52 -  
53 - private void init() {  
54 - rcyDataShow = findViewById(R.id.rcy_data_show);  
55 - editNewFolder = findViewById(R.id.edit_new_folder);  
56 - btnCreateNewFolder = findViewById(R.id.btn_create_new_folder);  
57 - refreshDataShow = findViewById(R.id.refresh_data_show);  
58 - refreshDataShow.setHeaderView(new RefreshHeaderView(this));  
59 - showFilesAdapter = new ShowDiretoryAdapter(R.layout.item_directory, new ArrayList<FileBean>());  
60 - rcyDataShow.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));  
61 - rcyDataShow.setAdapter(showFilesAdapter);  
62 - refreshDataShow.setEnableLoadmore(false);  
63 - refreshDataShow.startRefresh();  
64 - }  
65 -  
66 - private void initListener() {  
67 - refreshDataShow.setOnRefreshListener(new RefreshListenerAdapter() {  
68 - @Override  
69 - public void onRefresh(TwinklingRefreshLayout refreshLayout) {  
70 - super.onRefresh(refreshLayout);  
71 - getDiretorys(true);  
72 - }  
73 - });  
74 - showFilesAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {  
75 - @Override  
76 - public void onLoadMoreRequested() {  
77 - getDiretorys(false);  
78 - }  
79 - });  
80 - showFilesAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {  
81 - @Override  
82 - public void onItemClick(BaseQuickAdapter adapter, View view, int position) {  
83 - if (showFilesAdapter.getData().get(position).getFile_type_Int() == FileType.TYPE_DIRECTORY) {  
84 - Intent intent = new Intent(DiretoryActivity.this, DiretoryActivity.class);  
85 - intent.putExtra("path", showFilesAdapter.getData().get(position).getPath() + showFilesAdapter.getData().get(position).getFname() + File.separator);  
86 - startActivity(intent);  
87 - }  
88 -  
89 - }  
90 - });  
91 - btnCreateNewFolder.setOnClickListener(new View.OnClickListener() {  
92 - @Override  
93 - public void onClick(View v) {  
94 - if (TextUtils.isEmpty(editNewFolder.getText().toString())) {  
95 - RayToast.showShort("输入文件夹名称");  
96 - return;  
97 - }  
98 - RayLib.createNewFolderInCloud(editNewFolder.getText().toString(), DiretoryActivity.this, folderPath, new HttpResult() {  
99 - @Override  
100 - public void onError(int errorCode, String error) {  
101 -  
102 - }  
103 -  
104 - @Override  
105 - public void onResponseString(String s) {  
106 - refreshDataShow.startRefresh();  
107 - }  
108 - });  
109 - }  
110 - });  
111 - }  
112 -  
113 -  
114 - private void getDiretorys(final boolean header) {  
115 - if (!isLoadingFinished) {  
116 - if (header) refreshDataShow.finishRefreshing();  
117 - return;  
118 - }  
119 - isLoadingFinished = false;  
120 - RayLib.getFilesByDirectory(QUERY_METHODE_ALLFILES, folderPath, page = header ? 1 : page, 50, 1, 1, this, new HttpResult() {  
121 - @Override  
122 - public void onError(int errorCode, String error) {  
123 - if (header)  
124 - refreshDataShow.finishRefreshing();  
125 - else  
126 - showFilesAdapter.loadMoreFail();  
127 - isLoadingFinished = true;  
128 - }  
129 -  
130 - @Override  
131 - public void onResponseString(String s) {  
132 - isLoadingFinished = true;  
133 - if (header) {  
134 - showFilesAdapter.setNewData(parseResult(s));  
135 - refreshDataShow.finishRefreshing();  
136 - } else {  
137 - if (parseResult(s) != null)  
138 - showFilesAdapter.addData(parseResult(s));  
139 - else  
140 - showFilesAdapter.loadMoreEnd();  
141 - }  
142 - page++;  
143 -  
144 - }  
145 - });  
146 - }  
147 -  
148 - private List<FileBean> parseResult(String json) {  
149 - try {  
150 - Gson gson = new Gson();  
151 - DirectoryBean bean = gson.fromJson(json, DirectoryBean.class);  
152 - if (bean != null && bean.getData() != null && bean.getData().size() > 0) {  
153 - return bean.getData();  
154 - } else  
155 - return null;  
156 - } catch (Exception e) {  
157 - e.printStackTrace();  
158 - return null;  
159 - }  
160 -  
161 - }  
162 -}  
updownfile/src/main/java/com/cnlive/updownfile/InitViewActivity.java deleted 100644 → 0
1 -package com.cnlive.updownfile;  
2 -  
3 -import android.Manifest;  
4 -import android.content.Intent;  
5 -import android.os.Environment;  
6 -import android.support.v4.app.ActivityCompat;  
7 -import android.support.v4.content.ContextCompat;  
8 -import android.support.v7.app.AppCompatActivity;  
9 -import android.os.Bundle;  
10 -import android.text.TextUtils;  
11 -import android.view.View;  
12 -import android.widget.EditText;  
13 -import android.widget.TextView;  
14 -import android.widget.Toast;  
15 -  
16 -import com.cnlive.media.picker.ImagePicker;  
17 -import com.cnlive.media.picker.PickerConfig;  
18 -import com.cnlive.media.picker.entity.Media;  
19 -import com.cnlive.updownfile.adapter.ShowFilesAdapter;  
20 -import com.cnlive.updownfile.bean.FileBean;  
21 -import com.cnlive.updownfile.util.Constant;  
22 -import com.cnlive.updownfile.util.DownloadUtil;  
23 -import com.cnlive.updownfile.util.UploadUtil;  
24 -import com.xiaoray.raysdk.RayLib;  
25 -import com.xiaoray.raysdk.entity.bean.LocalCloudPath;  
26 -import com.xiaoray.raysdk.listener.ConnectCloudListener;  
27 -import com.xiaoray.raysdk.service.TaskDownloadService;  
28 -import com.xiaoray.raysdk.service.TaskUploadService;  
29 -import com.xiaoray.raysdk.utils.OkHttpUtils.CloudRequest;  
30 -  
31 -import java.util.ArrayList;  
32 -  
33 -import static android.support.v4.content.PermissionChecker.PERMISSION_DENIED;  
34 -import static android.support.v4.content.PermissionChecker.PERMISSION_GRANTED;  
35 -  
36 -public class InitViewActivity extends AppCompatActivity implements View.OnClickListener {  
37 -  
38 - private TextView up_task;  
39 - private TextView down_task;  
40 - private TextView show_data;  
41 - private TextView enter_file;  
42 - private EditText cloud_path;  
43 - public static final int REQUEST_PICKER = 0X1001;  
44 - private final int REQUEST_WRITE_CONTENT = 2;  
45 -  
46 - @Override  
47 - protected void onCreate(Bundle savedInstanceState) {  
48 - super.onCreate(savedInstanceState);  
49 - setContentView(R.layout.activity_init_view);  
50 - initView();  
51 - RayLib.init(this);  
52 - RayLib.connectCloud(InitViewActivity.this, "a4:11:63:61:00:02", "8656", "625624",  
53 - "3D6B5148-98D8-4642-9909-45AEBBEEC8E0", new ConnectCloudListener() {  
54 - @Override  
55 - public void connectSuc() {  
56 - Toast.makeText(InitViewActivity.this, "连接设备成功,IP:" + CloudRequest.getInstance()  
57 - .getIp(), Toast.LENGTH_LONG).show();  
58 - }  
59 -  
60 - @Override  
61 - public void error(int error, String errorInfo) {  
62 - Toast.makeText(InitViewActivity.this, "连接设备失败:" + error, Toast.LENGTH_SHORT)  
63 - .show();  
64 - }  
65 -  
66 - @Override  
67 - public void response(Object object) {  
68 -  
69 - }  
70 - });  
71 - }  
72 -  
73 - private void initView(){  
74 - up_task = findViewById(R.id.up_task);  
75 - down_task = findViewById(R.id.down_task);  
76 - show_data = findViewById(R.id.show_data);  
77 - enter_file = findViewById(R.id.enter_file);  
78 - cloud_path = findViewById(R.id.cloud_path);  
79 - cloud_path.setVisibility(View.GONE);  
80 -  
81 - up_task.setOnClickListener(this);  
82 - down_task.setOnClickListener(this);  
83 - show_data.setOnClickListener(this);  
84 - enter_file.setOnClickListener(this);  
85 - }  
86 -  
87 - @Override  
88 - public void onClick(View v) {  
89 - int i = v.getId();  
90 - if (i == R.id.up_task) {  
91 - startPickerImageAndVideo();  
92 - } else if (i == R.id.down_task) {  
93 - int permissionCheck = ContextCompat.checkSelfPermission(InitViewActivity.this,  
94 - Manifest.permission.WRITE_EXTERNAL_STORAGE);  
95 - if (permissionCheck == PERMISSION_DENIED) {  
96 - ActivityCompat.requestPermissions(InitViewActivity.this,  
97 - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE_CONTENT);  
98 - } else if (permissionCheck == PERMISSION_GRANTED) {  
99 - cloud_path.setVisibility(View.VISIBLE);  
100 - if("".equals(cloud_path.getText().toString().trim())){  
101 - Toast.makeText(InitViewActivity.this, "请输入下载文件目录。。。" , Toast.LENGTH_SHORT)  
102 - .show();  
103 - return;  
104 - }  
105 - addDownload("");  
106 - }  
107 - } else if (i == R.id.show_data) {  
108 - } else if (i == R.id.enter_file) {  
109 - Intent intent=new Intent(InitViewActivity.this, DiretoryActivity.class);  
110 - intent.putExtra("path","/");  
111 - startActivity(intent);  
112 - }  
113 - }  
114 -  
115 -  
116 - /**  
117 - * 从相册选择图片或者视频  
118 - */  
119 - private void startPickerImageAndVideo() {  
120 - ImagePicker imagePicker = new ImagePicker.Builder()  
121 - .setSelectGif(true)  
122 - .maxNum(9)  
123 - .selectMode(PickerConfig.PICKER_IMAGE_VIDEO)  
124 - .maxVideoSize(Constant.MEDIA_MAX_SIZE)  
125 - .maxImageSize(Constant.IMAGE_MAX_SIZE)  
126 -// .cachePath(CacheUtil.getConversationCachePath())  
127 - .builder();  
128 - imagePicker.start(this, REQUEST_PICKER, PickerConfig.DEFAULT_RESULT_CODE);  
129 - }  
130 -  
131 -  
132 - @Override  
133 - protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
134 - super.onActivityResult(requestCode, resultCode, data);  
135 - switch (requestCode) {  
136 - case REQUEST_PICKER:  
137 - if(data == null){  
138 - return;  
139 - }  
140 - ArrayList<Media> selectList = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT);  
141 - ArrayList lists = new ArrayList();  
142 - for (int i = 0; i < selectList.size(); i++) {  
143 - LocalCloudPath localCloudPath = new LocalCloudPath();  
144 - localCloudPath.setLocal(selectList.get(i).path);  
145 - localCloudPath.setCloud("/");  
146 - lists.add(localCloudPath);  
147 - }  
148 - UploadUtil.xiaoRayUploadFile(this,lists);  
149 - Toast.makeText(this, "正在开始上传", Toast.LENGTH_LONG).show();  
150 - break;  
151 - }  
152 - }  
153 -  
154 - /**  
155 - * 文件下载  
156 - */  
157 - private void addDownload(String cloudPath) {  
158 - ArrayList<LocalCloudPath> arrayLists = new ArrayList<>();  
159 - String localPath = Environment.getExternalStorageDirectory().toString();  
160 - LocalCloudPath localCloudPath = new LocalCloudPath();  
161 - localCloudPath.setCloud(cloudPath);  
162 - localCloudPath.setLocal(localPath);  
163 - arrayLists.add(localCloudPath);  
164 - DownloadUtil.addDownload(InitViewActivity.this,arrayLists);  
165 - }  
166 -}  
updownfile/src/main/java/com/cnlive/updownfile/util/Constant.java deleted 100644 → 0
1 -package com.cnlive.updownfile.util;  
2 -  
3 -public class Constant {  
4 - //聊天页面视频文件最大19.5M(腾讯短视频最大20M,存在问题)  
5 - public static final int MEDIA_MAX_SIZE = 19 * 1024 * 1024 + 512 * 1024;  
6 - //聊天页面图片文件最大20M  
7 - public static final int IMAGE_MAX_SIZE = 20 * 1024 * 1024;  
8 -}  
updownfile/src/main/java/com/cnlive/updownfile/util/DownloadUtil.java
@@ -20,4 +20,20 @@ public class DownloadUtil { @@ -20,4 +20,20 @@ public class DownloadUtil {
20 RayLib.controlDownload(context, TaskDownloadService.FROM_SELECT_DOWNLOAD, arrayLists); 20 RayLib.controlDownload(context, TaskDownloadService.FROM_SELECT_DOWNLOAD, arrayLists);
21 } 21 }
22 22
  23 + /**
  24 + *文件下载
  25 + * @param context
  26 + * @param downLoadUrl 下载地址
  27 + * @param position 方便列表刷新标记位置
  28 + * @param localPath 本地位置
  29 + * @param isNeedZip 是否需要压缩
  30 + */
  31 + public static void dowLoadFile(Context context,String downLoadUrl,int position,String localPath,boolean isNeedZip){
  32 +// FileInfo info = new FileInfo(downLoadUrl,0,0,0,position,localPath,isNeedZip);
  33 +// Intent intent = new Intent(context, DownLoadService.class);
  34 +// intent.setAction(DownLoadService.ACTION_START);
  35 +// intent.putExtra("fileUrl",info);
  36 +// context.startService(intent);
  37 + }
  38 +
23 } 39 }
updownfile/src/main/java/com/cnlive/updownfile/util/EnterFile.java 0 → 100644
  1 +package com.cnlive.updownfile.util;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Intent;
  5 +
  6 +import com.cnlive.media.picker.ImagePicker;
  7 +import com.cnlive.media.picker.PickerConfig;
  8 +import com.cnlive.media.picker.entity.Media;
  9 +import com.cnlive.updownfile.xiaoRay.Constant;
  10 +
  11 +import java.util.ArrayList;
  12 +
  13 +public class EnterFile {
  14 +
  15 +
  16 + /**
  17 + * 进入相册展示图片与视频
  18 + * @param context
  19 + * @param isGif 知否支持gif
  20 + * @param maxNum 可以选中的最大数目
  21 + * @param selectMode PickerConfig.PICKER_IMAGE_VIDEO or PickerConfig.PICKER_IMAGE or PickerConfig.PICKER_VIDEO
  22 + * @param maxVideoSize 视频大小
  23 + * @param maxImageSize 图片大小
  24 + * @param cachePath 缓存路径
  25 + * @param resultCode 状态码
  26 + */
  27 + public static void startPickerImageAndVideo(Activity context,boolean isGif,int maxNum,int selectMode,int maxVideoSize,int maxImageSize,String cachePath, int resultCode) {
  28 + ImagePicker imagePicker = new ImagePicker.Builder()
  29 + .setSelectGif(isGif)
  30 + .maxNum(maxNum)
  31 + .selectMode(selectMode)
  32 + .maxVideoSize(maxVideoSize)
  33 + .maxImageSize(maxImageSize)
  34 + .cachePath(cachePath)
  35 + .builder();
  36 + imagePicker.start(context, resultCode, PickerConfig.DEFAULT_RESULT_CODE);
  37 + }
  38 +
  39 + /**
  40 + * 获取选择的相册以及视频
  41 + * @param data
  42 + * @return
  43 + */
  44 + public static ArrayList<Media> getSelectImageVodeo(Intent data){
  45 + return data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT);
  46 + }
  47 +
  48 + /**
  49 + * 选择文件
  50 + */
  51 + private void startPickerFile() {
  52 +// ExFilePicker exFilePicker = new ExFilePicker();
  53 +// exFilePicker.setStartDirectory(CacheUtil.getConversationCacheDownloadPath());
  54 +// exFilePicker.setMaxFileCount(9);
  55 +// exFilePicker.setMaxFileSize(Constant.FILE_MAX_SIZE);
  56 +// exFilePicker.setMaxImageSize(Constant.IMAGE_MAX_SIZE);
  57 +// exFilePicker.setMaxVideoSize(Constant.MEDIA_MAX_SIZE);
  58 +// exFilePicker.start(getActivity(), 1009);
  59 + }
  60 +}
updownfile/src/main/java/com/cnlive/updownfile/util/UploadUtil.java
@@ -7,8 +7,8 @@ import com.cnlive.libs.base.application.AppConfig; @@ -7,8 +7,8 @@ import com.cnlive.libs.base.application.AppConfig;
7 import com.cnlive.libs.base.logic.callback.DataCallback; 7 import com.cnlive.libs.base.logic.callback.DataCallback;
8 import com.cnlive.libs.base.logic.callback.ProgressCallback; 8 import com.cnlive.libs.base.logic.callback.ProgressCallback;
9 import com.cnlive.libs.base.util.StringUtils; 9 import com.cnlive.libs.base.util.StringUtils;
10 -import com.cnlive.updownfile.view.FileUtil;  
11 -import com.cnlive.updownfile.view.IDUtils; 10 +import com.cnlive.updownfile.xiaoRay.view.FileUtil;
  11 +import com.cnlive.updownfile.xiaoRay.view.IDUtils;
12 import com.qiniu.android.http.ResponseInfo; 12 import com.qiniu.android.http.ResponseInfo;
13 import com.qiniu.android.storage.UpCompletionHandler; 13 import com.qiniu.android.storage.UpCompletionHandler;
14 import com.qiniu.android.storage.UpProgressHandler; 14 import com.qiniu.android.storage.UpProgressHandler;
updownfile/src/main/java/com/cnlive/updownfile/util/ZipUtil.java
@@ -11,7 +11,7 @@ import com.cnlive.libs.base.logic.Config; @@ -11,7 +11,7 @@ import com.cnlive.libs.base.logic.Config;
11 import com.cnlive.libs.base.logic.callback.DataCallback; 11 import com.cnlive.libs.base.logic.callback.DataCallback;
12 import com.cnlive.libs.base.util.AlertUtil; 12 import com.cnlive.libs.base.util.AlertUtil;
13 import com.cnlive.media.picker.utils.FileTypeUtil; 13 import com.cnlive.media.picker.utils.FileTypeUtil;
14 -import com.cnlive.updownfile.view.MD5; 14 +import com.cnlive.updownfile.xiaoRay.view.MD5;
15 import com.qiniu.pili.droid.shortvideo.PLShortVideoTranscoder; 15 import com.qiniu.pili.droid.shortvideo.PLShortVideoTranscoder;
16 import com.qiniu.pili.droid.shortvideo.PLVideoSaveListener; 16 import com.qiniu.pili.droid.shortvideo.PLVideoSaveListener;
17 17
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/Constant.java 0 → 100644
  1 +package com.cnlive.updownfile.xiaoRay;
  2 +
  3 +import android.app.ProgressDialog;
  4 +import android.content.Context;
  5 +import android.widget.Toast;
  6 +
  7 +import com.xiaoray.raysdk.RayLib;
  8 +import com.xiaoray.raysdk.listener.ConnectCloudListener;
  9 +import com.xiaoray.raysdk.utils.OkHttpUtils.CloudRequest;
  10 +
  11 +public class Constant {
  12 + //聊天页面视频文件最大19.5M(腾讯短视频最大20M,存在问题)
  13 + public static final int MEDIA_MAX_SIZE = 19 * 1024 * 1024 + 512 * 1024;
  14 + //聊天页面图片文件最大20M
  15 + public static final int IMAGE_MAX_SIZE = 20 * 1024 * 1024;
  16 + //聊天页面文件最大28M
  17 + public static final int FILE_MAX_SIZE = 28 * 1024 * 1024;
  18 +
  19 + public static void initXiaoRay(Context context, String mac, String u_id, String code, String term_id) {
  20 + RayLib.init(context);
  21 + ProgressDialog waitingDialog = new ProgressDialog(context);
  22 + waitingDialog.setMessage("正在连接IP地址");
  23 + waitingDialog.setIndeterminate(true);
  24 + waitingDialog.setCancelable(false);
  25 + waitingDialog.show();
  26 + RayLib.connectCloud(context, mac, u_id, code,
  27 + term_id, new ConnectCloudListener() {
  28 + @Override
  29 + public void connectSuc() {
  30 + if(waitingDialog.isShowing())waitingDialog.dismiss();
  31 + Toast.makeText(context, "连接设备成功,IP:" + CloudRequest.getInstance()
  32 + .getIp(), Toast.LENGTH_LONG).show();
  33 + }
  34 +
  35 + @Override
  36 + public void error(int error, String errorInfo) {
  37 + if(waitingDialog.isShowing())waitingDialog.dismiss();
  38 + Toast.makeText(context, "连接设备失败:" + error, Toast.LENGTH_LONG)
  39 + .show();
  40 + }
  41 +
  42 + @Override
  43 + public void response(Object object) {
  44 +
  45 + }
  46 + });
  47 + }
  48 +}
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/DiretoryActivity.java 0 → 100644
  1 +package com.cnlive.updownfile.xiaoRay;
  2 +
  3 +import android.Manifest;
  4 +import android.content.Context;
  5 +import android.content.DialogInterface;
  6 +import android.content.Intent;
  7 +import android.graphics.Bitmap;
  8 +import android.media.ThumbnailUtils;
  9 +import android.os.Environment;
  10 +import android.provider.MediaStore;
  11 +import android.support.v4.app.ActivityCompat;
  12 +import android.support.v7.app.AlertDialog;
  13 +import android.support.v7.app.AppCompatActivity;
  14 +import android.os.Bundle;
  15 +import android.support.v7.widget.LinearLayoutManager;
  16 +import android.support.v7.widget.RecyclerView;
  17 +import android.text.TextUtils;
  18 +import android.view.Gravity;
  19 +import android.view.MenuInflater;
  20 +import android.view.MenuItem;
  21 +import android.view.View;
  22 +import android.widget.Button;
  23 +import android.widget.EditText;
  24 +import android.widget.LinearLayout;
  25 +import android.widget.PopupMenu;
  26 +import android.widget.RadioGroup;
  27 +import android.widget.RelativeLayout;
  28 +import android.widget.Toast;
  29 +
  30 +import com.chad.library.adapter.base.BaseQuickAdapter;
  31 +import com.cnlive.filespicker.ExFilePicker;
  32 +import com.cnlive.filespicker.ui.model.FilePickerResult;
  33 +import com.cnlive.media.picker.ImagePicker;
  34 +import com.cnlive.media.picker.PickerConfig;
  35 +import com.cnlive.media.picker.entity.Media;
  36 +import com.cnlive.updownfile.R;
  37 +import com.cnlive.updownfile.util.UploadUtil;
  38 +import com.cnlive.updownfile.xiaoRay.adapter.ShowDiretoryAdapter;
  39 +import com.cnlive.updownfile.xiaoRay.bean.DirectoryBean;
  40 +import com.cnlive.updownfile.xiaoRay.bean.DirectoryTypeBean;
  41 +import com.cnlive.updownfile.xiaoRay.bean.FileBean;
  42 +import com.cnlive.updownfile.xiaoRay.bean.Move2Json;
  43 +import com.cnlive.updownfile.xiaoRay.bean.RecyclerBean;
  44 +import com.cnlive.updownfile.xiaoRay.view.RefreshHeaderView;
  45 +import com.google.gson.Gson;
  46 +import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
  47 +import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
  48 +import com.xiaoray.raysdk.RayLib;
  49 +import com.xiaoray.raysdk.constant.FileType;
  50 +import com.xiaoray.raysdk.entity.bean.LocalCloudPath;
  51 +import com.xiaoray.raysdk.manager.RayConstant;
  52 +import com.xiaoray.raysdk.service.TaskDownloadService;
  53 +import com.xiaoray.raysdk.utils.OkHttpUtils.HttpResult;
  54 +import com.xiaoray.raysdk.utils.RayLog;
  55 +import com.xiaoray.raysdk.view.RayToast;
  56 +
  57 +import org.json.JSONArray;
  58 +
  59 +import java.io.File;
  60 +import java.util.ArrayList;
  61 +import java.util.List;
  62 +
  63 +public class DiretoryActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
  64 +
  65 + RecyclerView rcyDataShow;
  66 + EditText editNewFolder;
  67 + Button btnCreateNewFolder;
  68 + Button btnCreateNewFile;
  69 + Button add_picture;
  70 + Button add_file;
  71 + Button clear_recyfile;
  72 +
  73 + RadioGroup file_type;
  74 + RadioGroup file_time;
  75 + RadioGroup file_updown;
  76 + Button sure;
  77 + LinearLayout choose;
  78 + RelativeLayout loadingLocal;
  79 + TwinklingRefreshLayout refreshDataShow;
  80 + private ShowDiretoryAdapter showFilesAdapter;
  81 + private int page = 1;
  82 + private boolean isLoadingFinished = true;
  83 + private String folderPath = "/";
  84 + private String type;
  85 + private static int REQUEST_PERMISSION_CODE = 1;
  86 + public static final int REQUEST_PICKER = 0X1001;
  87 + private static String[] PERMISSIONS_STORAGE = {
  88 + Manifest.permission.READ_EXTERNAL_STORAGE,
  89 + Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
  90 +
  91 + private int fileType = 0, sort, seq;//文件类型,排序方式,排序顺序
  92 +
  93 + public static void startDiretoryActivity(Context context, String type, String path) {
  94 + Intent intent = new Intent(context, DiretoryActivity.class);
  95 + intent.putExtra("type", type);
  96 + intent.putExtra("path", path);
  97 + context.startActivity(intent);
  98 + }
  99 +
  100 + @Override
  101 + protected void onCreate(Bundle savedInstanceState) {
  102 + super.onCreate(savedInstanceState);
  103 + setContentView(R.layout.activity_diretory);
  104 + folderPath = getIntent().getStringExtra("path");
  105 + type = getIntent().getStringExtra("type");
  106 + init();
  107 + initListener();
  108 + }
  109 +
  110 + private void init() {
  111 + rcyDataShow = findViewById(R.id.rcy_data_show);
  112 + editNewFolder = findViewById(R.id.edit_new_folder);
  113 + btnCreateNewFolder = findViewById(R.id.btn_create_new_folder);
  114 + btnCreateNewFile = findViewById(R.id.sure_createfile);
  115 + refreshDataShow = findViewById(R.id.refresh_data_show);
  116 + loadingLocal = findViewById(R.id.loadingLocal);
  117 + add_picture = findViewById(R.id.add_picture);
  118 + add_file = findViewById(R.id.add_file);
  119 + clear_recyfile = findViewById(R.id.clear_recyfile);
  120 + file_type = findViewById(R.id.file_type);
  121 + file_time = findViewById(R.id.file_time);
  122 + file_updown = findViewById(R.id.file_updown);
  123 + sure = findViewById(R.id.sure);
  124 + choose = findViewById(R.id.choose);
  125 + if ("recy".equals(type)) {
  126 + add_file.setVisibility(View.GONE);
  127 + add_picture.setVisibility(View.GONE);
  128 + clear_recyfile.setVisibility(View.VISIBLE);
  129 + choose.setVisibility(View.GONE);
  130 + btnCreateNewFolder.setVisibility(View.GONE);
  131 + }
  132 + refreshDataShow.setHeaderView(new RefreshHeaderView(this));
  133 + showFilesAdapter = new ShowDiretoryAdapter(R.layout.item_directory, new ArrayList<FileBean>());
  134 + ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, REQUEST_PERMISSION_CODE);
  135 + showFilesAdapter.setOnLongClickListener(new ShowDiretoryAdapter.OnLongClickListener() {
  136 + @Override
  137 + public void onLongClick(FileBean fileBean, View v) {
  138 + PopupMenu popup = new PopupMenu(DiretoryActivity.this, v);//第二个参数是绑定的那个view
  139 + //获取菜单填充器
  140 + MenuInflater inflater = popup.getMenuInflater();
  141 + //填充菜单
  142 + inflater.inflate(R.menu.main, popup.getMenu());
  143 + if ("recy".equals(type)) {
  144 + popup.getMenu().getItem(1).setVisible(false);
  145 + popup.getMenu().getItem(3).setVisible(false);
  146 + popup.getMenu().getItem(4).setVisible(false);
  147 + } else {
  148 + popup.getMenu().getItem(2).setVisible(false);
  149 + }
  150 + //绑定菜单项的点击事件
  151 + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  152 + @Override
  153 + public boolean onMenuItemClick(MenuItem item) {
  154 + if (item.getItemId() == R.id.delete) {//删除
  155 + JSONArray jsonArray = new JSONArray();
  156 + JSONArray jsonArray1 = new JSONArray();
  157 + jsonArray1.put(fileBean.getInode());
  158 + jsonArray1.put(fileBean.getFile_type_Int() == FileType.TYPE_DIRECTORY ? fileBean.getPath() + fileBean.getFname() : fileBean.getPath());
  159 + jsonArray1.put(fileBean.getFile_type_Int() == FileType.TYPE_DIRECTORY ? 1 : 0);
  160 + jsonArray.put(jsonArray1);
  161 + AlertDialog.Builder builder = new AlertDialog.Builder(DiretoryActivity.this);
  162 + builder.setMessage("确定删除吗");
  163 + builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
  164 + @Override
  165 + public void onClick(DialogInterface dialog, int which) {
  166 + loadingLocal.setVisibility(View.VISIBLE);
  167 + String delType = RayConstant.ACT_ADD;
  168 + if ("recy".equals(type)) {
  169 + delType = RayConstant.ACT_DEL;
  170 + }
  171 + RayLib.deleteAndRestoreFile(delType, jsonArray.toString(), DiretoryActivity.this, new HttpResult() {
  172 + @Override
  173 + public void onError(int i, String s) {
  174 + loadingLocal.setVisibility(View.GONE);
  175 + RayToast.showShort("删除失败");
  176 + }
  177 +
  178 + @Override
  179 + public void onResponseString(String s) {
  180 + getDiretorys(true, fileType == 0 ? true : false);
  181 + loadingLocal.setVisibility(View.GONE);
  182 + RayToast.showShort("删除成功");
  183 + }
  184 + });
  185 + }
  186 + });
  187 + builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
  188 + @Override
  189 + public void onClick(DialogInterface dialog, int which) {
  190 + loadingLocal.setVisibility(View.GONE);
  191 + dialog.dismiss();
  192 + }
  193 + });
  194 + builder.create().show();
  195 + } else if (item.getItemId() == R.id.rename) {//重命名
  196 + final EditText editText = new EditText(DiretoryActivity.this);
  197 + editText.setText(fileBean.getFname());
  198 + AlertDialog.Builder builder = new AlertDialog.Builder(DiretoryActivity.this)
  199 + .setView(editText)
  200 + .setPositiveButton("确定", new DialogInterface.OnClickListener() {
  201 + @Override
  202 + public void onClick(DialogInterface dialog, int which) {
  203 + if (TextUtils.isEmpty(editText.getText().toString())) {
  204 + RayToast.showShort("输入文件夹名称");
  205 + return;
  206 + }
  207 + loadingLocal.setVisibility(View.VISIBLE);
  208 + RayLib.renameFile(fileBean.getPath(), editText.getText().toString(), fileBean.getFname(), DiretoryActivity.this, new HttpResult() {
  209 + @Override
  210 + public void onError(int i, String s) {
  211 + loadingLocal.setVisibility(View.GONE);
  212 + RayToast.showShort("重命名失败");
  213 + }
  214 +
  215 + @Override
  216 + public void onResponseString(String s) {
  217 + loadingLocal.setVisibility(View.GONE);
  218 + RayToast.showShort("重命名成功");
  219 + getDiretorys(true, fileType == 0 ? true : false);
  220 + }
  221 + });
  222 + }
  223 + }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
  224 + @Override
  225 + public void onClick(DialogInterface dialog, int which) {
  226 + dialog.dismiss();
  227 + }
  228 + });
  229 + builder.create().show();
  230 + } else if (item.getItemId() == R.id.restore) {
  231 + JSONArray jsonArray = new JSONArray();
  232 + JSONArray jsonArray1 = new JSONArray();
  233 + jsonArray1.put(fileBean.getInode());
  234 + jsonArray1.put(fileBean.getFile_type_Int() == FileType.TYPE_DIRECTORY ? fileBean.getPath() + fileBean.getFname() : fileBean.getPath());
  235 + jsonArray1.put(fileBean.getFile_type_Int() == FileType.TYPE_DIRECTORY ? 1 : 0);
  236 + jsonArray.put(jsonArray1);
  237 + RayLib.deleteAndRestoreFile(RayConstant.ACT_RESTORE, jsonArray.toString(), DiretoryActivity.this, new HttpResult() {
  238 + @Override
  239 + public void onError(int i, String s) {
  240 + loadingLocal.setVisibility(View.GONE);
  241 + RayToast.showShort("恢复失败");
  242 + }
  243 +
  244 + @Override
  245 + public void onResponseString(String s) {
  246 + getDiretorys(true, fileType == 0 ? true : false);
  247 + loadingLocal.setVisibility(View.GONE);
  248 + RayToast.showShort("恢复成功");
  249 + }
  250 + });
  251 + }else if (item.getItemId() == R.id.move) {
  252 + Move2Json.MoveBean moveBean = new Move2Json.MoveBean();
  253 + List<String> files = new ArrayList<>();
  254 + List<String> dirs = new ArrayList<>();
  255 + if (fileBean.getFile_type_Int() != FileType.TYPE_DIRECTORY) {
  256 + files.add(fileBean.getFname());
  257 + } else
  258 + dirs.add(fileBean.getFname());
  259 + moveBean.setDirs(dirs);
  260 + moveBean.setFiles(files);
  261 + String json = new Gson().toJson(new Move2Json(moveBean));
  262 + RayLog.i(json);
  263 + RayLib.moveFile(fileBean.getPath(), "/ll/", 1, json, DiretoryActivity.this, new HttpResult() {
  264 + @Override
  265 + public void onError(int i, String s) {
  266 + RayToast.showShort("失败" + i);
  267 + }
  268 +
  269 + @Override
  270 + public void onResponseString(String s) {
  271 + RayToast.showShort("移动成功");
  272 + getDiretorys(true, fileType == 0 ? true : false);
  273 + }
  274 + });
  275 + }else if(item.getItemId() == R.id.menu_down){
  276 + RayToast.showShort("本地文件中的xiaoRay查看");
  277 + ArrayList<LocalCloudPath> arrayLists = new ArrayList<>();
  278 + String localPath = Environment.getExternalStorageDirectory().toString() + "/xiaoRay";
  279 + File file = new File(localPath);
  280 + if(!file.exists())file.mkdirs();
  281 + LocalCloudPath localCloudPath = new LocalCloudPath();
  282 + localCloudPath.setCloud(fileBean.getUrl());
  283 + localCloudPath.setLocal(localPath);
  284 + arrayLists.add(localCloudPath);
  285 + RayLib.controlDownload(DiretoryActivity.this, TaskDownloadService
  286 + .FROM_SELECT_DOWNLOAD, arrayLists);
  287 + }
  288 + return false;
  289 + }
  290 + });
  291 + popup.show();
  292 + }
  293 + });
  294 + rcyDataShow.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
  295 + rcyDataShow.setAdapter(showFilesAdapter);
  296 + refreshDataShow.setEnableLoadmore(false);
  297 + refreshDataShow.startRefresh();
  298 + }
  299 +
  300 + private void initListener() {
  301 + refreshDataShow.setOnRefreshListener(new RefreshListenerAdapter() {
  302 + @Override
  303 + public void onRefresh(TwinklingRefreshLayout refreshLayout) {
  304 + super.onRefresh(refreshLayout);
  305 + page = 1;
  306 + getDiretorys(true, fileType == 0 ? true : false);
  307 + }
  308 + });
  309 + showFilesAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
  310 + @Override
  311 + public void onLoadMoreRequested() {
  312 + getDiretorys(true, fileType == 0 ? true : false);
  313 + }
  314 + });
  315 + showFilesAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
  316 + @Override
  317 + public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
  318 + if (showFilesAdapter.getData().get(position).getFile_type_Int() == FileType.TYPE_DIRECTORY) {
  319 + Intent intent = new Intent(DiretoryActivity.this, DiretoryActivity.class);
  320 + intent.putExtra("path", showFilesAdapter.getData().get(position).getPath() + showFilesAdapter.getData().get(position).getFname() + File.separator);
  321 + startActivity(intent);
  322 + }
  323 +
  324 + }
  325 + });
  326 + btnCreateNewFolder.setOnClickListener(this);
  327 + btnCreateNewFile.setOnClickListener(this);
  328 + add_picture.setOnClickListener(this);
  329 + add_file.setOnClickListener(this);
  330 + clear_recyfile.setOnClickListener(this);
  331 + sure.setOnClickListener(this);
  332 +
  333 + file_type.setOnCheckedChangeListener(this);
  334 + file_time.setOnCheckedChangeListener(this);
  335 + file_updown.setOnCheckedChangeListener(this);
  336 + }
  337 +
  338 +
  339 + private void getDiretorys(final boolean header, boolean hasType) {
  340 + if (!isLoadingFinished) {
  341 + if (header) refreshDataShow.finishRefreshing();
  342 + return;
  343 + }
  344 + if (header) page = 1;
  345 + isLoadingFinished = false;
  346 + if ("recy".equals(type)) {
  347 + RayLib.getRecyclerFiles(page, 50, DiretoryActivity.this, new HttpResult() {
  348 + @Override
  349 + public void onError(int i, String s) {
  350 + if (header)
  351 + refreshDataShow.finishRefreshing();
  352 + else
  353 + showFilesAdapter.loadMoreFail();
  354 + isLoadingFinished = true;
  355 + RayToast.showShort("连接失败");
  356 + }
  357 +
  358 + @Override
  359 + public void onResponseString(String s) {
  360 + Gson gson = new Gson();
  361 + RecyclerBean bean = gson.fromJson(s, RecyclerBean.class);
  362 + refreshDataShow.finishRefreshing();
  363 + isLoadingFinished = true;
  364 + if (header) {
  365 + showFilesAdapter.setNewData(bean.getData());
  366 + refreshDataShow.finishRefreshing();
  367 + showFilesAdapter.loadMoreEnd();
  368 + } else {
  369 + if (bean.getData().size() > 0)
  370 + showFilesAdapter.addData(bean.getData());
  371 + else {
  372 + showFilesAdapter.loadMoreEnd();
  373 + }
  374 + }
  375 + page++;
  376 + }
  377 + });
  378 + } else {
  379 + if (hasType) {//全部加载
  380 + RayLib.getFilesByDirectory(0, folderPath, page = header ? 1 : page, 50, 1, 1, this, new HttpResult() {
  381 + @Override
  382 + public void onError(int errorCode, String error) {
  383 + if (header)
  384 + refreshDataShow.finishRefreshing();
  385 + else
  386 + showFilesAdapter.loadMoreFail();
  387 + isLoadingFinished = true;
  388 + }
  389 +
  390 + @Override
  391 + public void onResponseString(String s) {
  392 + refreshDataShow.finishRefreshing();
  393 + isLoadingFinished = true;
  394 + if (header) {
  395 + showFilesAdapter.setNewData(parseResult(s, false));
  396 + refreshDataShow.finishRefreshing();
  397 + showFilesAdapter.loadMoreEnd();
  398 + } else {
  399 + if (parseResult(s, false) != null && parseResult(s, false).size() > 0)
  400 + showFilesAdapter.addData(parseResult(s, false));
  401 + else {
  402 + showFilesAdapter.loadMoreEnd();
  403 + }
  404 + }
  405 + page++;
  406 +
  407 + }
  408 + });
  409 + } else {
  410 + RayLib.getFilesByType(fileType, 50, page, sort, seq, DiretoryActivity.this, new HttpResult() {
  411 + @Override
  412 + public void onError(int i, String s) {
  413 + if (header)
  414 + refreshDataShow.finishRefreshing();
  415 + else
  416 + showFilesAdapter.loadMoreFail();
  417 + isLoadingFinished = true;
  418 + }
  419 +
  420 + @Override
  421 + public void onResponseString(String s) {
  422 + refreshDataShow.finishRefreshing();
  423 + isLoadingFinished = true;
  424 + if (header) {
  425 + showFilesAdapter.setNewData(parseResult(s, true));
  426 + refreshDataShow.finishRefreshing();
  427 + showFilesAdapter.loadMoreEnd();
  428 + } else {
  429 + if (parseResult(s, true) != null && parseResult(s, true).size() > 0)
  430 + showFilesAdapter.addData(parseResult(s, true));
  431 + else {
  432 + showFilesAdapter.loadMoreEnd();
  433 + }
  434 + }
  435 + page++;
  436 + }
  437 + });
  438 + }
  439 + }
  440 +
  441 + }
  442 +
  443 + private List<FileBean> parseResult(String json, boolean isType) {
  444 + try {
  445 + Gson gson = new Gson();
  446 + if (isType) {
  447 + DirectoryTypeBean bean = gson.fromJson(json, DirectoryTypeBean.class);
  448 + if (bean != null && bean.getData() != null && bean.getData().getItems() != null && bean.getData().getItems().size() > 0) {
  449 + return bean.getData().getItems();
  450 + } else
  451 + return null;
  452 + } else {
  453 + DirectoryBean bean = gson.fromJson(json, DirectoryBean.class);
  454 + if (bean != null && bean.getData() != null && bean.getData().size() > 0) {
  455 + return bean.getData();
  456 + } else
  457 + return null;
  458 + }
  459 + } catch (Exception e) {
  460 + e.printStackTrace();
  461 + return null;
  462 + }
  463 + }
  464 +
  465 + @Override
  466 + public void onClick(View v) {
  467 + int vid = v.getId();
  468 + if (vid == R.id.btn_create_new_folder) {
  469 + if ("新建文件夹".equals(btnCreateNewFolder.getText().toString().trim())) {
  470 + btnCreateNewFolder.setText("取消创建");
  471 + btnCreateNewFile.setVisibility(View.VISIBLE);
  472 + editNewFolder.setVisibility(View.VISIBLE);
  473 + } else if ("取消创建".equals(btnCreateNewFolder.getText().toString().trim())) {
  474 + btnCreateNewFolder.setText("新建文件夹");
  475 + btnCreateNewFile.setVisibility(View.GONE);
  476 + editNewFolder.setVisibility(View.GONE);
  477 + }
  478 + } else if (vid == R.id.sure_createfile) {
  479 + if (TextUtils.isEmpty(editNewFolder.getText().toString())) {
  480 + RayToast.showShort("输入文件夹名称");
  481 + return;
  482 + }
  483 + loadingLocal.setVisibility(View.VISIBLE);
  484 + RayLib.createNewFolderInCloud(editNewFolder.getText().toString(), DiretoryActivity.this, folderPath, new HttpResult() {
  485 + @Override
  486 + public void onError(int errorCode, String error) {
  487 + loadingLocal.setVisibility(View.GONE);
  488 + RayToast.showShort("创建失败");
  489 + }
  490 +
  491 + @Override
  492 + public void onResponseString(String s) {
  493 + loadingLocal.setVisibility(View.GONE);
  494 + btnCreateNewFolder.setText("新建文件夹");
  495 + btnCreateNewFile.setVisibility(View.GONE);
  496 + editNewFolder.setVisibility(View.GONE);
  497 + editNewFolder.setText("");
  498 + refreshDataShow.startRefresh();
  499 + }
  500 + });
  501 + } else if (vid == R.id.add_picture) {//添加文件
  502 + ImagePicker imagePicker = new ImagePicker.Builder()
  503 + .setSelectGif(true)
  504 + .maxNum(9)
  505 + .selectMode(PickerConfig.PICKER_IMAGE_VIDEO)
  506 + .maxVideoSize(Constant.MEDIA_MAX_SIZE)
  507 + .maxImageSize(Constant.IMAGE_MAX_SIZE)
  508 +// .cachePath(CacheUtil.getConversationCachePath())
  509 + .builder();
  510 + imagePicker.start(DiretoryActivity.this, REQUEST_PICKER, PickerConfig.DEFAULT_RESULT_CODE);
  511 +// EnterFile.startPickerImageAndVideo(DiretoryActivity.this,true,9, PickerConfig.PICKER_IMAGE_VIDEO,
  512 +// Constant.MEDIA_MAX_SIZE,Constant.IMAGE_MAX_SIZE,"",REQUEST_PICKER);
  513 + } else if (vid == R.id.add_file) {
  514 + startPickerFile();
  515 + } else if (vid == R.id.clear_recyfile) {//清空回收站
  516 + loadingLocal.setVisibility(View.VISIBLE);
  517 + RayLib.deleteAndRestoreFile(RayConstant.ACT_CLEAR, "", DiretoryActivity.this, new HttpResult() {
  518 + @Override
  519 + public void onError(int i, String s) {
  520 + loadingLocal.setVisibility(View.GONE);
  521 + RayToast.showShort("清空失败");
  522 + }
  523 +
  524 + @Override
  525 + public void onResponseString(String s) {
  526 + getDiretorys(true, fileType == 0 ? true : false);
  527 + loadingLocal.setVisibility(View.GONE);
  528 + RayToast.showShort("清空成功");
  529 + }
  530 + });
  531 + } else if (vid == R.id.sure) {
  532 + getDiretorys(true, fileType == 0 ? true : false);
  533 + }
  534 + }
  535 +
  536 + @Override
  537 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  538 + super.onActivityResult(requestCode, resultCode, data);
  539 + switch (requestCode) {
  540 + case REQUEST_PICKER:
  541 + if (data == null) {
  542 + return;
  543 + }
  544 + ArrayList<Media> selectList = data.getParcelableArrayListExtra(PickerConfig.EXTRA_RESULT);
  545 + ArrayList lists = new ArrayList();
  546 + for (int i = 0; i < selectList.size(); i++) {
  547 + LocalCloudPath localCloudPath = new LocalCloudPath();
  548 + localCloudPath.setLocal(selectList.get(i).path);
  549 + localCloudPath.setCloud("/");
  550 + lists.add(localCloudPath);
  551 + }
  552 + UploadUtil.xiaoRayUploadFile(this, lists);
  553 + Toast.makeText(this, "正在开始上传", Toast.LENGTH_LONG).show();
  554 + break;
  555 + case 1009:
  556 + FilePickerResult result = (FilePickerResult) FilePickerResult.getPickerResult(data);
  557 + ArrayList listss = new ArrayList();
  558 + for (int i = 0; i < result.getFileList().size(); i++) {
  559 + File file = result.getFileList().get(i);
  560 + String fileName = file.getName();
  561 + String filePath = file.getAbsolutePath();
  562 + LocalCloudPath localCloudPath = new LocalCloudPath();
  563 + localCloudPath.setLocal(filePath);
  564 + localCloudPath.setCloud("/");
  565 + listss.add(localCloudPath);
  566 + }
  567 + UploadUtil.xiaoRayUploadFile(this, listss);
  568 + Toast.makeText(this, "正在开始上传", Toast.LENGTH_LONG).show();
  569 + break;
  570 + }
  571 + }
  572 +
  573 + /**
  574 + * 选择文件
  575 + */
  576 + private void startPickerFile() {
  577 + ExFilePicker exFilePicker = new ExFilePicker();
  578 + exFilePicker.setStartDirectory(Environment.getExternalStorageDirectory().getAbsolutePath() + "/strike");
  579 + exFilePicker.setMaxFileCount(9);
  580 + exFilePicker.setMaxFileSize(Constant.FILE_MAX_SIZE);
  581 + exFilePicker.setMaxImageSize(Constant.IMAGE_MAX_SIZE);
  582 + exFilePicker.setMaxVideoSize(Constant.MEDIA_MAX_SIZE);
  583 + exFilePicker.start(this, 1009);
  584 + }
  585 +
  586 +
  587 + @Override
  588 + public void onCheckedChanged(RadioGroup group, int checkedId) {
  589 + if (checkedId == R.id.type_picture) {
  590 + fileType = 2;
  591 + } else if (checkedId == R.id.all) {
  592 + fileType = 0;
  593 + } else if (checkedId == R.id.type_vedio) {
  594 + fileType = 3;
  595 + } else if (checkedId == R.id.type_music) {
  596 + fileType = 4;
  597 + } else if (checkedId == R.id.type_world) {
  598 + fileType = 5;
  599 + } else if (checkedId == R.id.type_other) {
  600 + fileType = 6;
  601 + } else if (checkedId == R.id.create_time) {
  602 + sort = 1;
  603 + } else if (checkedId == R.id.up_time) {
  604 + sort = 2;
  605 + } else if (checkedId == R.id.name) {
  606 + sort = 3;
  607 + } else if (checkedId == R.id.up) {
  608 + seq = 1;
  609 + } else if (checkedId == R.id.down) {
  610 + seq = 2;
  611 + }
  612 + }
  613 +}
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/InitViewActivity.java 0 → 100644
  1 +package com.cnlive.updownfile.xiaoRay;
  2 +
  3 +import android.os.Environment;
  4 +import android.support.v7.app.AppCompatActivity;
  5 +import android.os.Bundle;
  6 +import android.view.View;
  7 +import android.widget.TextView;
  8 +import com.cnlive.updownfile.R;
  9 +import com.cnlive.updownfile.util.DownloadUtil;
  10 +import com.xiaoray.raysdk.RayLib;
  11 +import com.xiaoray.raysdk.entity.bean.LocalCloudPath;
  12 +import com.xiaoray.raysdk.utils.OkHttpUtils.HttpResult;
  13 +import com.xiaoray.raysdk.view.RayToast;
  14 +
  15 +import java.util.ArrayList;
  16 +
  17 +
  18 +public class InitViewActivity extends AppCompatActivity implements View.OnClickListener {
  19 +
  20 + private TextView show_data;
  21 + private TextView enter_file;
  22 + private TextView recyclerFiles;
  23 +
  24 + @Override
  25 + protected void onCreate(Bundle savedInstanceState) {
  26 + super.onCreate(savedInstanceState);
  27 + setContentView(R.layout.activity_init_view);
  28 + Constant.initXiaoRay(this, "a4:11:63:61:00:02", "8656", "625624", "3D6B5148-98D8-4642-9909-45AEBBEEC8E0");
  29 + initView();
  30 + }
  31 +
  32 + private void initView() {
  33 + show_data = findViewById(R.id.show_data);
  34 + enter_file = findViewById(R.id.enter_file);
  35 + recyclerFiles = findViewById(R.id.recyclerFiles);
  36 +
  37 +
  38 + show_data.setOnClickListener(this);
  39 + enter_file.setOnClickListener(this);
  40 + recyclerFiles.setOnClickListener(this);
  41 + }
  42 +
  43 + @Override
  44 + public void onClick(View v) {
  45 + int i = v.getId();
  46 + if (i == R.id.show_data) {
  47 + } else if (i == R.id.enter_file) {
  48 + DiretoryActivity.startDiretoryActivity(InitViewActivity.this,"dire","/");
  49 + } else if (i == R.id.recyclerFiles) {
  50 + RayLib.getRecyclerFiles(1, 50, InitViewActivity.this, new HttpResult() {
  51 + @Override
  52 + public void onError(int i, String s) {
  53 + RayToast.showShort("连接失败");
  54 + }
  55 +
  56 + @Override
  57 + public void onResponseString(String s) {
  58 + DiretoryActivity.startDiretoryActivity(InitViewActivity.this,"recy","/");
  59 + }
  60 + });
  61 + }
  62 + }
  63 +
  64 + /**
  65 + * 文件下载
  66 + */
  67 + private void addDownload(String cloudPath) {
  68 + ArrayList<LocalCloudPath> arrayLists = new ArrayList<>();
  69 + String localPath = Environment.getExternalStorageDirectory().toString();
  70 + LocalCloudPath localCloudPath = new LocalCloudPath();
  71 + localCloudPath.setCloud(cloudPath);
  72 + localCloudPath.setLocal(localPath);
  73 + arrayLists.add(localCloudPath);
  74 + DownloadUtil.addDownload(InitViewActivity.this, arrayLists);
  75 + }
  76 +}
updownfile/src/main/java/com/cnlive/updownfile/adapter/ShowDiretoryAdapter.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/adapter/ShowDiretoryAdapter.java
1 -package com.cnlive.updownfile.adapter; 1 +package com.cnlive.updownfile.xiaoRay.adapter;
2 2
3 import android.support.annotation.Nullable; 3 import android.support.annotation.Nullable;
  4 +import android.view.View;
4 import android.widget.ImageView; 5 import android.widget.ImageView;
5 6
6 import com.bumptech.glide.Glide; 7 import com.bumptech.glide.Glide;
7 import com.chad.library.adapter.base.BaseQuickAdapter; 8 import com.chad.library.adapter.base.BaseQuickAdapter;
8 import com.chad.library.adapter.base.BaseViewHolder; 9 import com.chad.library.adapter.base.BaseViewHolder;
9 import com.cnlive.updownfile.R; 10 import com.cnlive.updownfile.R;
10 -import com.cnlive.updownfile.bean.FileBean; 11 +import com.cnlive.updownfile.xiaoRay.bean.FileBean;
11 import com.xiaoray.raysdk.constant.FileType; 12 import com.xiaoray.raysdk.constant.FileType;
  13 +import com.xiaoray.raysdk.utils.RayUtil;
12 14
13 import java.util.List; 15 import java.util.List;
14 16
@@ -19,6 +21,17 @@ import java.util.List; @@ -19,6 +21,17 @@ import java.util.List;
19 * @filename ShowDiretoryAdapter 21 * @filename ShowDiretoryAdapter
20 */ 22 */
21 public class ShowDiretoryAdapter extends BaseQuickAdapter<FileBean, BaseViewHolder> { 23 public class ShowDiretoryAdapter extends BaseQuickAdapter<FileBean, BaseViewHolder> {
  24 +
  25 + private OnLongClickListener onLongClickListener;
  26 +
  27 + public OnLongClickListener getOnLongClickListener() {
  28 + return onLongClickListener;
  29 + }
  30 +
  31 + public void setOnLongClickListener(OnLongClickListener onLongClickListener) {
  32 + this.onLongClickListener = onLongClickListener;
  33 + }
  34 +
22 public ShowDiretoryAdapter(int layoutResId, @Nullable List<FileBean> data) { 35 public ShowDiretoryAdapter(int layoutResId, @Nullable List<FileBean> data) {
23 super(layoutResId, data); 36 super(layoutResId, data);
24 } 37 }
@@ -30,5 +43,17 @@ public class ShowDiretoryAdapter extends BaseQuickAdapter&lt;FileBean, BaseViewHold @@ -30,5 +43,17 @@ public class ShowDiretoryAdapter extends BaseQuickAdapter&lt;FileBean, BaseViewHold
30 else 43 else
31 Glide.with(mContext).load(R.drawable.bg_txt).into((ImageView) helper.getView(R.id.iv_item_file_icon)); 44 Glide.with(mContext).load(R.drawable.bg_txt).into((ImageView) helper.getView(R.id.iv_item_file_icon));
32 helper.setText(R.id.tv_item_file_name, item.getFname()); 45 helper.setText(R.id.tv_item_file_name, item.getFname());
  46 + if(item.getUpload_time() != null)helper.setText(R.id.tv_item_file_date, RayUtil.formatPhotoDateSecond(item.getUpload_time()));
  47 + if(onLongClickListener != null) helper.itemView.setOnLongClickListener(new View.OnLongClickListener() {
  48 + @Override
  49 + public boolean onLongClick(View v) {
  50 + onLongClickListener.onLongClick(item,v);
  51 + return false;
  52 + }
  53 + });
  54 + }
  55 +
  56 + public interface OnLongClickListener{
  57 + void onLongClick(FileBean fileBean,View v);
33 } 58 }
34 } 59 }
updownfile/src/main/java/com/cnlive/updownfile/adapter/ShowFilesAdapter.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/adapter/ShowFilesAdapter.java
1 -package com.cnlive.updownfile.adapter; 1 +package com.cnlive.updownfile.xiaoRay.adapter;
2 2
3 import android.support.annotation.Nullable; 3 import android.support.annotation.Nullable;
4 import android.widget.ImageView; 4 import android.widget.ImageView;
@@ -6,8 +6,8 @@ import android.widget.ImageView; @@ -6,8 +6,8 @@ import android.widget.ImageView;
6 import com.chad.library.adapter.base.BaseQuickAdapter; 6 import com.chad.library.adapter.base.BaseQuickAdapter;
7 import com.chad.library.adapter.base.BaseViewHolder; 7 import com.chad.library.adapter.base.BaseViewHolder;
8 import com.cnlive.updownfile.R; 8 import com.cnlive.updownfile.R;
9 -import com.cnlive.updownfile.bean.FileBean;  
10 -import com.cnlive.updownfile.util.RayGlide; 9 +import com.cnlive.updownfile.xiaoRay.bean.FileBean;
  10 +import com.cnlive.updownfile.xiaoRay.view.RayGlide;
11 import com.xiaoray.raysdk.utils.OkHttpUtils.CloudRequest; 11 import com.xiaoray.raysdk.utils.OkHttpUtils.CloudRequest;
12 12
13 import java.util.List; 13 import java.util.List;
updownfile/src/main/java/com/cnlive/updownfile/bean/DirectoryBean.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/DirectoryBean.java
1 -package com.cnlive.updownfile.bean; 1 +package com.cnlive.updownfile.xiaoRay.bean;
2 2
3 import java.util.List; 3 import java.util.List;
4 4
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/DirectoryTypeBean.java 0 → 100644
  1 +package com.cnlive.updownfile.xiaoRay.bean;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class DirectoryTypeBean {
  6 +
  7 + /**
  8 + * data : {"items":[{"user_id":8656,"ctime":1533868384,"tags":[],"file_type":6,"utime":1539051860,"dir_id":1,"file_id":993,"fname":"wxwork_android_2.4.99.7079_100034.apk","mtime":1533868384,"url":"/vn/static/raw/wxwork_android_2.4.99.7079_100034.apk","path":"/","size":66303426,"inode":286739,"md5":"bbfbe382d57fcf6c10fa61b2ca1f3d8a"},{"user_id":8656,"ctime":1533868387,"tags":[],"file_type":6,"utime":1539051834,"dir_id":1,"file_id":859,"fname":"app-debug.apk","mtime":1533868386,"url":"/vn/static/raw/app-debug.apk","path":"/","size":14193529,"inode":315398,"md5":"bd649262894db822e6135129a29f9e1d"},{"user_id":1,"ctime":1538982799,"tags":[],"file_type":6,"utime":1538982799,"dir_id":2,"file_id":532,"fname":"微信Android 5.0 直装破解版2.0WeirChat2.0.apk","mtime":1538982799,"url":"/vn/static/raw/云盘迁回/微信Android 5.0 直装破解版2.0WeirChat2.0.apk","path":"/云盘迁回","size":23539432,"inode":266280,"md5":"e82a3316122f44070f17a439f3ea8bf1"},{"user_id":8656,"ctime":1538993340,"tags":[],"file_type":6,"utime":1539051823,"dir_id":1,"file_id":832,"fname":"app-release2.3.0.apk","mtime":1538993340,"url":"/vn/static/raw/app-release2.3.0.apk","path":"/","size":39577358,"inode":266282,"md5":"cf569d3b30ce6d1dff040c7dc92b223f"},{"user_id":8656,"ctime":1538993537,"tags":[],"file_type":6,"utime":1538993538,"dir_id":11,"file_id":534,"fname":"1538992574434","mtime":1538993537,"url":"/vn/static/raw/Android/data/com.android.providers.media/albumthumbs/1538992574434","path":"/Android/data/com.android.providers.media/albumthumbs","size":0,"inode":282766,"md5":"d41d8cd98f00b204e9800998ecf8427e"},{"user_id":8656,"ctime":1538993537,"tags":[],"file_type":6,"utime":1538993538,"dir_id":11,"file_id":535,"fname":"1538992575358","mtime":1538993537,"url":"/vn/static/raw/Android/data/com.android.providers.media/albumthumbs/1538992575358","path":"/Android/data/com.android.providers.media/albumthumbs","size":18032,"inode":282767,"md5":"4f53ec062148313b46a0c032f7da7eba"},{"user_id":8656,"ctime":1538993537,"tags":[],"file_type":6,"utime":1538993538,"dir_id":12,"file_id":536,"fname":"external-2122085.db","mtime":1538993537,"url":"/vn/static/raw/Android/data/com.android.providers.media/databases/external-2122085.db","path":"/Android/data/com.android.providers.media/databases","size":167936,"inode":287068,"md5":"ea3b8f3e46340054f279fbde2ec33ad0"}],"unisize":7,"dupsize":7}
  9 + * ret : 0
  10 + */
  11 +
  12 + private DataBean data;
  13 + private int ret;
  14 +
  15 + public DataBean getData() {
  16 + return data;
  17 + }
  18 +
  19 + public void setData(DataBean data) {
  20 + this.data = data;
  21 + }
  22 +
  23 + public int getRet() {
  24 + return ret;
  25 + }
  26 +
  27 + public void setRet(int ret) {
  28 + this.ret = ret;
  29 + }
  30 +
  31 + public static class DataBean {
  32 + /**
  33 + * items : [{"user_id":8656,"ctime":1533868384,"tags":[],"file_type":6,"utime":1539051860,"dir_id":1,"file_id":993,"fname":"wxwork_android_2.4.99.7079_100034.apk","mtime":1533868384,"url":"/vn/static/raw/wxwork_android_2.4.99.7079_100034.apk","path":"/","size":66303426,"inode":286739,"md5":"bbfbe382d57fcf6c10fa61b2ca1f3d8a"},{"user_id":8656,"ctime":1533868387,"tags":[],"file_type":6,"utime":1539051834,"dir_id":1,"file_id":859,"fname":"app-debug.apk","mtime":1533868386,"url":"/vn/static/raw/app-debug.apk","path":"/","size":14193529,"inode":315398,"md5":"bd649262894db822e6135129a29f9e1d"},{"user_id":1,"ctime":1538982799,"tags":[],"file_type":6,"utime":1538982799,"dir_id":2,"file_id":532,"fname":"微信Android 5.0 直装破解版2.0WeirChat2.0.apk","mtime":1538982799,"url":"/vn/static/raw/云盘迁回/微信Android 5.0 直装破解版2.0WeirChat2.0.apk","path":"/云盘迁回","size":23539432,"inode":266280,"md5":"e82a3316122f44070f17a439f3ea8bf1"},{"user_id":8656,"ctime":1538993340,"tags":[],"file_type":6,"utime":1539051823,"dir_id":1,"file_id":832,"fname":"app-release2.3.0.apk","mtime":1538993340,"url":"/vn/static/raw/app-release2.3.0.apk","path":"/","size":39577358,"inode":266282,"md5":"cf569d3b30ce6d1dff040c7dc92b223f"},{"user_id":8656,"ctime":1538993537,"tags":[],"file_type":6,"utime":1538993538,"dir_id":11,"file_id":534,"fname":"1538992574434","mtime":1538993537,"url":"/vn/static/raw/Android/data/com.android.providers.media/albumthumbs/1538992574434","path":"/Android/data/com.android.providers.media/albumthumbs","size":0,"inode":282766,"md5":"d41d8cd98f00b204e9800998ecf8427e"},{"user_id":8656,"ctime":1538993537,"tags":[],"file_type":6,"utime":1538993538,"dir_id":11,"file_id":535,"fname":"1538992575358","mtime":1538993537,"url":"/vn/static/raw/Android/data/com.android.providers.media/albumthumbs/1538992575358","path":"/Android/data/com.android.providers.media/albumthumbs","size":18032,"inode":282767,"md5":"4f53ec062148313b46a0c032f7da7eba"},{"user_id":8656,"ctime":1538993537,"tags":[],"file_type":6,"utime":1538993538,"dir_id":12,"file_id":536,"fname":"external-2122085.db","mtime":1538993537,"url":"/vn/static/raw/Android/data/com.android.providers.media/databases/external-2122085.db","path":"/Android/data/com.android.providers.media/databases","size":167936,"inode":287068,"md5":"ea3b8f3e46340054f279fbde2ec33ad0"}]
  34 + * unisize : 7
  35 + * dupsize : 7
  36 + */
  37 +
  38 + private int unisize;
  39 + private int dupsize;
  40 + private List<FileBean> items;
  41 +
  42 + public int getUnisize() {
  43 + return unisize;
  44 + }
  45 +
  46 + public void setUnisize(int unisize) {
  47 + this.unisize = unisize;
  48 + }
  49 +
  50 + public int getDupsize() {
  51 + return dupsize;
  52 + }
  53 +
  54 + public void setDupsize(int dupsize) {
  55 + this.dupsize = dupsize;
  56 + }
  57 +
  58 + public List<FileBean> getItems() {
  59 + return items;
  60 + }
  61 +
  62 + public void setItems(List<FileBean> items) {
  63 + this.items = items;
  64 + }
  65 + }
  66 +}
updownfile/src/main/java/com/cnlive/updownfile/bean/FileBean.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/FileBean.java
1 -package com.cnlive.updownfile.bean; 1 +package com.cnlive.updownfile.xiaoRay.bean;
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.List; 4 import java.util.List;
@@ -31,6 +31,12 @@ public class FileBean { @@ -31,6 +31,12 @@ public class FileBean {
31 private long duration; 31 private long duration;
32 private long file_id; 32 private long file_id;
33 private boolean chooseFrom;//用于发布的一个属性 33 private boolean chooseFrom;//用于发布的一个属性
  34 + private long dir_id;
  35 + private String md5;
  36 + private String is_file;
  37 + private String tt1;
  38 + private String del_ts;
  39 + private String dir;
34 40
35 public String getUtime() { 41 public String getUtime() {
36 return utime; 42 return utime;
@@ -112,15 +118,42 @@ public class FileBean { @@ -112,15 +118,42 @@ public class FileBean {
112 this.md5 = md5; 118 this.md5 = md5;
113 } 119 }
114 120
115 - private long dir_id;  
116 - private String md5; 121 + public String getIs_file() {
  122 + return is_file;
  123 + }
  124 +
  125 + public void setIs_file(String is_file) {
  126 + this.is_file = is_file;
  127 + }
  128 +
  129 + public String getTt1() {
  130 + return tt1;
  131 + }
  132 +
  133 + public void setTt1(String tt1) {
  134 + this.tt1 = tt1;
  135 + }
  136 +
  137 + public String getDel_ts() {
  138 + return del_ts;
  139 + }
  140 +
  141 + public void setDel_ts(String del_ts) {
  142 + this.del_ts = del_ts;
  143 + }
117 144
  145 + public String getDir() {
  146 + return dir;
  147 + }
  148 +
  149 + public void setDir(String dir) {
  150 + this.dir = dir;
  151 + }
118 152
119 - public FileBean(String inode, String utime, String mtime, String l2url, String l1url,  
120 - String url, String fname, String size,  
121 - String file_type, String path) { 153 + public FileBean(String utime, String mtime, String ctime, String l2url, String l1url, String url, String fname, String size, String file_type, String path, String inode, List<String> tags, String img_position, int pos_id, int width, int height, int user_id, long duration, long file_id, boolean chooseFrom, long dir_id, String md5, String is_file, String tt1, String del_ts, String dir) {
122 this.utime = utime; 154 this.utime = utime;
123 this.mtime = mtime; 155 this.mtime = mtime;
  156 + this.ctime = ctime;
124 this.l2url = l2url; 157 this.l2url = l2url;
125 this.l1url = l1url; 158 this.l1url = l1url;
126 this.url = url; 159 this.url = url;
@@ -129,6 +162,21 @@ public class FileBean { @@ -129,6 +162,21 @@ public class FileBean {
129 this.file_type = file_type; 162 this.file_type = file_type;
130 this.path = path; 163 this.path = path;
131 this.inode = inode; 164 this.inode = inode;
  165 + this.tags = tags;
  166 + this.img_position = img_position;
  167 + this.pos_id = pos_id;
  168 + this.width = width;
  169 + this.height = height;
  170 + this.user_id = user_id;
  171 + this.duration = duration;
  172 + this.file_id = file_id;
  173 + this.chooseFrom = chooseFrom;
  174 + this.dir_id = dir_id;
  175 + this.md5 = md5;
  176 + this.is_file = is_file;
  177 + this.tt1 = tt1;
  178 + this.del_ts = del_ts;
  179 + this.dir = dir;
132 } 180 }
133 181
134 public List<String> getTags() { 182 public List<String> getTags() {
updownfile/src/main/java/com/cnlive/updownfile/bean/FileRootBean.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/FileRootBean.java
1 -package com.cnlive.updownfile.bean; 1 +package com.cnlive.updownfile.xiaoRay.bean;
2 2
3 import java.util.List; 3 import java.util.List;
4 4
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/Move2Json.java 0 → 100644
  1 +package com.cnlive.updownfile.xiaoRay.bean;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class Move2Json {
  6 + public Move2Json(MoveBean data) {
  7 + this.data = data;
  8 + }
  9 +
  10 + private MoveBean data;
  11 +
  12 + public MoveBean getData() {
  13 + return data;
  14 + }
  15 +
  16 + public void setData(MoveBean data) {
  17 + this.data = data;
  18 + }
  19 +
  20 + public static class MoveBean {
  21 + private List<String> files;
  22 + private List<String> dirs;
  23 +
  24 + public void setFiles(List<String> files) {
  25 + this.files = files;
  26 + }
  27 +
  28 + public List<String> getFiles() {
  29 + return this.files;
  30 + }
  31 +
  32 + public void setDirs(List<String> dirs) {
  33 + this.dirs = dirs;
  34 + }
  35 +
  36 + public List<String> getDirs() {
  37 + return this.dirs;
  38 + }
  39 +
  40 + }
  41 +}
0 \ No newline at end of file 42 \ No newline at end of file
updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/bean/RecyclerBean.java 0 → 100644
  1 +package com.cnlive.updownfile.xiaoRay.bean;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class RecyclerBean {
  6 +
  7 + /**
  8 + * data : [{"file_type":1,"l2url":"","dir_id":1,"is_file":0,"ttl":2522662,"path":"/","inode":45057,"size":0,"fname":"2222","del_ts":1553067950,"dir":"/"},{"file_type":1,"l2url":"","dir_id":1,"is_file":0,"ttl":2522646,"path":"/","inode":20482,"size":0,"fname":"1111","del_ts":1553067934,"dir":"/"},{"file_type":1,"l2url":"","dir_id":4,"is_file":0,"ttl":2522590,"path":"/微信互联","inode":65540,"size":0,"fname":"new0","del_ts":1553067878,"dir":"/微信互联"},{"file_type":1,"l2url":"","dir_id":1,"is_file":0,"ttl":2520822,"path":"/","inode":65539,"size":0,"fname":"new0","del_ts":1553066110,"dir":"/"},{"file_type":1,"l2url":"","dir_id":4,"is_file":0,"ttl":2509045,"path":"/微信互联","inode":61441,"size":0,"fname":"new","del_ts":1553054333,"dir":"/微信互联"},{"file_type":1,"l2url":"","dir_id":1,"is_file":0,"ttl":2502646,"path":"/","inode":61443,"size":0,"fname":"尝试一下","del_ts":1553047934,"dir":"/"},{"file_type":6,"l2url":"/vn/static/thumb/e6/788_L2.jpg","dir_id":27,"is_file":0,"ttl":2446094,"path":"/picture/new","inode":944008,"size":16937740,"fname":"RayCloudPriApp_latest (1).apk","del_ts":1552991382,"dir":"/picture/new"},{"file_type":4,"l2url":"/vn/static/thumb/c0/2f_L2.jpg","dir_id":32,"is_file":0,"ttl":2445041,"path":"/music","inode":49199,"size":4595845,"fname":"Schnuffel - Ich schenk dir die ganze Welt.mp3","del_ts":1552990329,"dir":"/music"},{"file_type":2,"l2url":"/vn/static/thumb/e0/02_L2.jpg","dir_id":1,"is_file":0,"ttl":2444992,"path":"/","inode":57346,"size":1014994,"fname":"timg.jpg","del_ts":1552990280,"dir":"/"},{"file_type":4,"l2url":"/vn/static/thumb/30/08_L2.jpg","dir_id":1,"is_file":0,"ttl":2444271,"path":"/","inode":12296,"size":15104371,"fname":"Encounter.flac","del_ts":1552989559,"dir":"/"},{"file_type":4,"l2url":"/vn/static/thumb/e5/030_L2.jpg","dir_id":1,"is_file":0,"ttl":2444194,"path":"/","inode":938032,"size":13965556,"fname":"Polonaise.flac","del_ts":1552989482,"dir":"/"}]
  9 + * ret : 0
  10 + */
  11 +
  12 + private String ret;
  13 + private List<FileBean> data;
  14 +
  15 + public String getRet() {
  16 + return ret;
  17 + }
  18 +
  19 + public void setRet(String ret) {
  20 + this.ret = ret;
  21 + }
  22 +
  23 + public List<FileBean> getData() {
  24 + return data;
  25 + }
  26 +
  27 + public void setData(List<FileBean> data) {
  28 + this.data = data;
  29 + }
  30 +
  31 +// public static class DataBean {
  32 +// /**
  33 +// * file_type : 1
  34 +// * l2url :
  35 +// * dir_id : 1
  36 +// * is_file : 0
  37 +// * ttl : 2522662
  38 +// * path : /
  39 +// * inode : 45057
  40 +// * size : 0
  41 +// * fname : 2222
  42 +// * del_ts : 1553067950
  43 +// * dir : /
  44 +// */
  45 +//
  46 +// private int file_type;
  47 +// private String l2url;
  48 +// private int dir_id;
  49 +// private int is_file;
  50 +// private int ttl;
  51 +// private String path;
  52 +// private int inode;
  53 +// private int size;
  54 +// private String fname;
  55 +// private int del_ts;
  56 +// private String dir;
  57 +//
  58 +// public int getFile_type() {
  59 +// return file_type;
  60 +// }
  61 +//
  62 +// public void setFile_type(int file_type) {
  63 +// this.file_type = file_type;
  64 +// }
  65 +//
  66 +// public String getL2url() {
  67 +// return l2url;
  68 +// }
  69 +//
  70 +// public void setL2url(String l2url) {
  71 +// this.l2url = l2url;
  72 +// }
  73 +//
  74 +// public int getDir_id() {
  75 +// return dir_id;
  76 +// }
  77 +//
  78 +// public void setDir_id(int dir_id) {
  79 +// this.dir_id = dir_id;
  80 +// }
  81 +//
  82 +// public int getIs_file() {
  83 +// return is_file;
  84 +// }
  85 +//
  86 +// public void setIs_file(int is_file) {
  87 +// this.is_file = is_file;
  88 +// }
  89 +//
  90 +// public int getTtl() {
  91 +// return ttl;
  92 +// }
  93 +//
  94 +// public void setTtl(int ttl) {
  95 +// this.ttl = ttl;
  96 +// }
  97 +//
  98 +// public String getPath() {
  99 +// return path;
  100 +// }
  101 +//
  102 +// public void setPath(String path) {
  103 +// this.path = path;
  104 +// }
  105 +//
  106 +// public int getInode() {
  107 +// return inode;
  108 +// }
  109 +//
  110 +// public void setInode(int inode) {
  111 +// this.inode = inode;
  112 +// }
  113 +//
  114 +// public int getSize() {
  115 +// return size;
  116 +// }
  117 +//
  118 +// public void setSize(int size) {
  119 +// this.size = size;
  120 +// }
  121 +//
  122 +// public String getFname() {
  123 +// return fname;
  124 +// }
  125 +//
  126 +// public void setFname(String fname) {
  127 +// this.fname = fname;
  128 +// }
  129 +//
  130 +// public int getDel_ts() {
  131 +// return del_ts;
  132 +// }
  133 +//
  134 +// public void setDel_ts(int del_ts) {
  135 +// this.del_ts = del_ts;
  136 +// }
  137 +//
  138 +// public String getDir() {
  139 +// return dir;
  140 +// }
  141 +//
  142 +// public void setDir(String dir) {
  143 +// this.dir = dir;
  144 +// }
  145 +// }
  146 +}
updownfile/src/main/java/com/cnlive/updownfile/view/FileUtil.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/FileUtil.java
1 -package com.cnlive.updownfile.view; 1 +package com.cnlive.updownfile.xiaoRay.view;
2 2
3 import android.content.ContentValues; 3 import android.content.ContentValues;
4 import android.content.Context; 4 import android.content.Context;
updownfile/src/main/java/com/cnlive/updownfile/view/IDUtils.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/IDUtils.java
1 -package com.cnlive.updownfile.view; 1 +package com.cnlive.updownfile.xiaoRay.view;
2 2
3 public class IDUtils { 3 public class IDUtils {
4 private static byte[] lock = new byte[0]; 4 private static byte[] lock = new byte[0];
updownfile/src/main/java/com/cnlive/updownfile/view/MD5.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/MD5.java
1 -package com.cnlive.updownfile.view; 1 +package com.cnlive.updownfile.xiaoRay.view;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.os.Bundle; 4 import android.os.Bundle;
updownfile/src/main/java/com/cnlive/updownfile/util/RayGlide.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/RayGlide.java
1 -package com.cnlive.updownfile.util; 1 +package com.cnlive.updownfile.xiaoRay.view;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.widget.ImageView; 4 import android.widget.ImageView;
@@ -41,10 +41,6 @@ public class RayGlide { @@ -41,10 +41,6 @@ public class RayGlide {
41 } 41 }
42 42
43 43
44 -  
45 -  
46 -  
47 -  
48 private static RequestOptions normalOptions(int defaultResId) { 44 private static RequestOptions normalOptions(int defaultResId) {
49 return new RequestOptions() 45 return new RequestOptions()
50 .centerCrop().placeholder(defaultResId) 46 .centerCrop().placeholder(defaultResId)
@@ -52,11 +48,6 @@ public class RayGlide { @@ -52,11 +48,6 @@ public class RayGlide {
52 .error(defaultResId).priority(Priority.HIGH); 48 .error(defaultResId).priority(Priority.HIGH);
53 } 49 }
54 50
55 -  
56 -  
57 -  
58 -  
59 -  
60 /** 51 /**
61 * 清除磁盘缓存,需要在子线程中执行 52 * 清除磁盘缓存,需要在子线程中执行
62 */ 53 */
updownfile/src/main/java/com/cnlive/updownfile/view/RefreshHeaderView.java renamed to updownfile/src/main/java/com/cnlive/updownfile/xiaoRay/view/RefreshHeaderView.java
1 -package com.cnlive.updownfile.view; 1 +package com.cnlive.updownfile.xiaoRay.view;
2 2
3 3
4 import android.content.Context; 4 import android.content.Context;
updownfile/src/main/res/drawable-hdpi/loading.png 0 → 100644

695 Bytes

updownfile/src/main/res/drawable/anim.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:drawable="@drawable/loading"
  4 + android:fromDegrees="0.0"
  5 + android:pivotX="50.0%"
  6 + android:pivotY="50.0%"
  7 + android:toDegrees="360.0" />
0 \ No newline at end of file 8 \ No newline at end of file
updownfile/src/main/res/drawable/gr_bg_nor.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  4 + <solid android:color="#cbd3d7" />
  5 + <corners android:radius="100dp" />
  6 + <size android:height="24dp" />
  7 +</shape>
0 \ No newline at end of file 8 \ No newline at end of file
updownfile/src/main/res/layout/activity_diretory.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent" 5 android:layout_width="match_parent"
6 android:layout_height="match_parent" 6 android:layout_height="match_parent"
7 android:orientation="vertical" 7 android:orientation="vertical"
8 - android:layout_margin="10dp"  
9 - tools:context=".DiretoryActivity"> 8 + tools:context=".xiaoRay.DiretoryActivity">
10 9
11 <LinearLayout 10 <LinearLayout
  11 + android:id="@+id/choose"
12 android:layout_width="match_parent" 12 android:layout_width="match_parent"
13 android:layout_height="wrap_content" 13 android:layout_height="wrap_content"
14 - android:orientation="horizontal">  
15 -  
16 - <Button  
17 - android:id="@+id/btn_create_new_folder" 14 + android:orientation="vertical">
  15 + <RadioGroup
  16 + android:id="@+id/file_type"
18 android:layout_width="wrap_content" 17 android:layout_width="wrap_content"
19 android:layout_height="wrap_content" 18 android:layout_height="wrap_content"
20 - android:background="@drawable/anchor_barrage_bg_nor"  
21 - android:padding="10dp"  
22 - android:text="新建文件夹" />  
23 - <EditText  
24 - android:id="@+id/edit_new_folder" 19 + android:orientation="horizontal">
  20 + <RadioButton
  21 + android:id="@+id/all"
  22 + android:layout_width="wrap_content"
  23 + android:layout_height="wrap_content"
  24 + android:checked="true"
  25 + android:text="全部"
  26 + />
  27 + <RadioButton
  28 + android:id="@+id/type_picture"
  29 + android:layout_width="wrap_content"
  30 + android:layout_height="wrap_content"
  31 + android:text="照片"
  32 + />
  33 + <RadioButton
  34 + android:id="@+id/type_vedio"
  35 + android:layout_width="wrap_content"
  36 + android:layout_height="wrap_content"
  37 + android:text="视频"
  38 + />
  39 + <RadioButton
  40 + android:id="@+id/type_music"
  41 + android:layout_width="wrap_content"
  42 + android:layout_height="wrap_content"
  43 + android:text="音乐"
  44 + />
  45 + <RadioButton
  46 + android:id="@+id/type_world"
  47 + android:layout_width="wrap_content"
  48 + android:layout_height="wrap_content"
  49 + android:text="文档"
  50 + />
  51 + <RadioButton
  52 + android:id="@+id/type_other"
  53 + android:layout_width="wrap_content"
  54 + android:layout_height="wrap_content"
  55 + android:text="其他"
  56 + />
  57 + </RadioGroup>
  58 + <View
  59 + android:layout_width="match_parent"
  60 + android:layout_height="1dp"
  61 + android:background="#3F3B3B"
  62 + />
  63 + <RadioGroup
  64 + android:id="@+id/file_time"
  65 + android:layout_width="wrap_content"
  66 + android:layout_height="wrap_content"
  67 + android:orientation="horizontal">
  68 + <RadioButton
  69 + android:id="@+id/create_time"
  70 + android:layout_width="wrap_content"
  71 + android:layout_height="wrap_content"
  72 + android:text="创建时间"
  73 + />
  74 + <RadioButton
  75 + android:id="@+id/up_time"
  76 + android:layout_width="wrap_content"
  77 + android:layout_height="wrap_content"
  78 + android:text="上传时间"
  79 + />
  80 + <RadioButton
  81 + android:id="@+id/name"
  82 + android:layout_width="wrap_content"
  83 + android:layout_height="wrap_content"
  84 + android:text="名称"
  85 + />
  86 + </RadioGroup>
  87 + <View
25 android:layout_width="match_parent" 88 android:layout_width="match_parent"
  89 + android:layout_height="1dp"
  90 + android:background="#3F3B3B"
  91 + />
  92 + <RadioGroup
  93 + android:id="@+id/file_updown"
  94 + android:layout_width="wrap_content"
26 android:layout_height="wrap_content" 95 android:layout_height="wrap_content"
27 - android:layout_marginLeft="10dp"  
28 - android:hint="输入文件夹名称" /> 96 + android:orientation="horizontal">
  97 + <RadioButton
  98 + android:id="@+id/up"
  99 + android:layout_width="wrap_content"
  100 + android:layout_height="wrap_content"
  101 + android:text="正序"
  102 + />
  103 + <RadioButton
  104 + android:id="@+id/down"
  105 + android:layout_width="wrap_content"
  106 + android:layout_height="wrap_content"
  107 + android:text="倒序"
  108 + />
  109 + </RadioGroup>
  110 + <Button
  111 + android:id="@+id/sure"
  112 + android:layout_width="50dp"
  113 + android:layout_height="30dp"
  114 + android:background="@drawable/anchor_barrage_bg_nor"
  115 + android:text="确定"
  116 + android:layout_margin="10dp"
  117 + />
  118 + <View
  119 + android:layout_width="match_parent"
  120 + android:layout_height="1dp"
  121 + android:background="#3F3B3B"
  122 + />
29 </LinearLayout> 123 </LinearLayout>
30 124
31 <com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout 125 <com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
32 android:id="@+id/refresh_data_show" 126 android:id="@+id/refresh_data_show"
33 android:layout_width="match_parent" 127 android:layout_width="match_parent"
34 android:layout_height="match_parent" 128 android:layout_height="match_parent"
  129 + android:layout_below="@id/choose"
35 app:tr_enable_loadmore="false"> 130 app:tr_enable_loadmore="false">
36 131
37 <android.support.v7.widget.RecyclerView 132 <android.support.v7.widget.RecyclerView
@@ -42,4 +137,94 @@ @@ -42,4 +137,94 @@
42 android:paddingRight="-1dp" /> 137 android:paddingRight="-1dp" />
43 </com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout> 138 </com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
44 139
45 -</LinearLayout>  
46 \ No newline at end of file 140 \ No newline at end of file
  141 +<LinearLayout
  142 + android:layout_width="match_parent"
  143 + android:layout_height="wrap_content"
  144 + android:layout_alignParentRight="true"
  145 + android:layout_centerVertical="true"
  146 + android:orientation="vertical">
  147 +
  148 + <Button
  149 + android:id="@+id/add_file"
  150 + android:layout_width="70dp"
  151 + android:layout_height="70dp"
  152 + android:background="@drawable/gr_bg_nor"
  153 + android:padding="10dp"
  154 + android:layout_gravity="right"
  155 + android:text="上传文件" />
  156 +
  157 + <Button
  158 + android:id="@+id/add_picture"
  159 + android:layout_width="70dp"
  160 + android:layout_height="70dp"
  161 + android:background="@drawable/gr_bg_nor"
  162 + android:padding="10dp"
  163 + android:layout_marginTop="10dp"
  164 + android:layout_gravity="right"
  165 + android:text="上传图片" />
  166 +
  167 + <LinearLayout
  168 + android:layout_width="wrap_content"
  169 + android:layout_height="wrap_content"
  170 + android:layout_gravity="right"
  171 + android:layout_marginTop="10dp"
  172 + android:orientation="horizontal">
  173 + <Button
  174 + android:id="@+id/btn_create_new_folder"
  175 + android:layout_width="70dp"
  176 + android:layout_height="70dp"
  177 + android:layout_alignParentRight="true"
  178 + android:layout_centerVertical="true"
  179 + android:background="@drawable/gr_bg_nor"
  180 + android:padding="10dp"
  181 + android:layout_gravity="center"
  182 + android:text="新建文件夹" />
  183 +
  184 + <EditText
  185 + android:id="@+id/edit_new_folder"
  186 + android:layout_width="wrap_content"
  187 + android:layout_height="50dp"
  188 + android:layout_centerInParent="true"
  189 + android:layout_gravity="center"
  190 + android:visibility="gone"
  191 + android:background="@drawable/anchor_barrage_bg_nor"
  192 + android:hint="输入文件夹名称"
  193 + android:padding="10dp" />
  194 + <Button
  195 + android:id="@+id/sure_createfile"
  196 + android:layout_width="50dp"
  197 + android:layout_height="wrap_content"
  198 + android:background="@drawable/gr_bg_nor"
  199 + android:visibility="gone"
  200 + android:layout_gravity="center"
  201 + android:text="确定"
  202 + />
  203 + </LinearLayout>
  204 + <Button
  205 + android:id="@+id/clear_recyfile"
  206 + android:layout_width="70dp"
  207 + android:layout_height="70dp"
  208 + android:background="@drawable/gr_bg_nor"
  209 + android:padding="10dp"
  210 + android:layout_marginTop="10dp"
  211 + android:layout_gravity="right"
  212 + android:visibility="gone"
  213 + android:text="清空回收站" />
  214 +</LinearLayout>
  215 +
  216 +
  217 + <RelativeLayout
  218 + android:id="@+id/loadingLocal"
  219 + android:layout_width="match_parent"
  220 + android:layout_height="match_parent"
  221 + android:background="#4f000000"
  222 + android:visibility="gone">
  223 + <ProgressBar
  224 + android:layout_width="50dp"
  225 + android:layout_height="50dp"
  226 + android:indeterminateBehavior="repeat"
  227 + android:layout_centerInParent="true"
  228 + android:indeterminateDrawable="@drawable/anim" />
  229 + </RelativeLayout>
  230 +
  231 +</RelativeLayout>
47 \ No newline at end of file 232 \ No newline at end of file
updownfile/src/main/res/layout/activity_init_view.xml
@@ -6,53 +6,38 @@ @@ -6,53 +6,38 @@
6 android:layout_height="match_parent" 6 android:layout_height="match_parent"
7 android:orientation="vertical" 7 android:orientation="vertical"
8 android:padding="50dp" 8 android:padding="50dp"
9 - tools:context=".InitViewActivity"> 9 + tools:context=".xiaoRay.InitViewActivity">
10 <TextView 10 <TextView
11 - android:id="@+id/up_task"  
12 - android:layout_width="match_parent"  
13 - android:layout_height="wrap_content"  
14 - android:background="@drawable/anchor_barrage_bg_nor"  
15 - android:text="上传图片视频到云盘"  
16 - android:padding="10dp"  
17 - android:gravity="center"  
18 - />  
19 - <EditText  
20 - android:id="@+id/cloud_path"  
21 - android:layout_width="match_parent"  
22 - android:layout_height="wrap_content"  
23 - android:layout_marginTop="10dp"  
24 - android:padding="10dp"  
25 - android:hint="点击请输入下载地址:"  
26 - />  
27 - <TextView  
28 - android:id="@+id/down_task" 11 + android:id="@+id/show_data"
29 android:layout_width="match_parent" 12 android:layout_width="match_parent"
30 android:layout_height="wrap_content" 13 android:layout_height="wrap_content"
31 android:layout_marginTop="10dp" 14 android:layout_marginTop="10dp"
32 android:background="@drawable/anchor_barrage_bg_nor" 15 android:background="@drawable/anchor_barrage_bg_nor"
  16 + android:text="展示相册"
33 android:padding="10dp" 17 android:padding="10dp"
34 - android:text="下载到本地"  
35 android:gravity="center" 18 android:gravity="center"
  19 + android:visibility="gone"
36 /> 20 />
37 <TextView 21 <TextView
38 - android:id="@+id/show_data" 22 + android:id="@+id/enter_file"
39 android:layout_width="match_parent" 23 android:layout_width="match_parent"
40 android:layout_height="wrap_content" 24 android:layout_height="wrap_content"
41 android:layout_marginTop="10dp" 25 android:layout_marginTop="10dp"
42 android:background="@drawable/anchor_barrage_bg_nor" 26 android:background="@drawable/anchor_barrage_bg_nor"
43 - android:text="展示相册"  
44 android:padding="10dp" 27 android:padding="10dp"
  28 + android:text="进入云盘"
45 android:gravity="center" 29 android:gravity="center"
46 - android:visibility="gone"  
47 /> 30 />
  31 +
  32 +
48 <TextView 33 <TextView
49 - android:id="@+id/enter_file" 34 + android:id="@+id/recyclerFiles"
50 android:layout_width="match_parent" 35 android:layout_width="match_parent"
51 android:layout_height="wrap_content" 36 android:layout_height="wrap_content"
52 android:layout_marginTop="10dp" 37 android:layout_marginTop="10dp"
53 android:background="@drawable/anchor_barrage_bg_nor" 38 android:background="@drawable/anchor_barrage_bg_nor"
54 android:padding="10dp" 39 android:padding="10dp"
55 - android:text="进入云盘" 40 + android:text="进入回收站"
56 android:gravity="center" 41 android:gravity="center"
57 /> 42 />
58 </LinearLayout> 43 </LinearLayout>
59 \ No newline at end of file 44 \ No newline at end of file
updownfile/src/main/res/layout/item_directory.xml
@@ -49,7 +49,6 @@ @@ -49,7 +49,6 @@
49 android:layout_width="wrap_content" 49 android:layout_width="wrap_content"
50 android:layout_height="wrap_content" 50 android:layout_height="wrap_content"
51 android:layout_weight="1" 51 android:layout_weight="1"
52 - android:text="2018-06-13 15:40"  
53 android:textColor="#AAAAAA" 52 android:textColor="#AAAAAA"
54 android:textSize="12dp" /> 53 android:textSize="12dp" />
55 54
updownfile/src/main/res/menu/main.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<menu xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <!--<item android:id="@+id/exit"-->
  5 + <!--android:title="退出"/>-->
  6 + <!--<item android:id="@+id/set"-->
  7 + <!--android:title="设置"/>-->
  8 + <item android:id="@+id/delete"
  9 + android:title="删除"/>
  10 + <item android:id="@+id/rename"
  11 + android:title="重命名"/>
  12 + <item android:id="@+id/restore"
  13 + android:title="恢复"/>
  14 + <item android:id="@+id/move"
  15 + android:title="移动到ll文件夹"/>
  16 + <item android:id="@+id/menu_down"
  17 + android:title="下载"
  18 + android:visible="false"/>
  19 +</menu>
0 \ No newline at end of file 20 \ No newline at end of file