list = FileUtils.getFileListByDirPath(path, filter);
73 | //进行过滤文件大小
74 | Iterator iterator = list.iterator();
75 | while (iterator.hasNext()) {
76 | File f = (File) iterator.next();
77 | if (f.isFile()) {
78 | //获取当前文件大小
79 | long size = FileUtils.getFileLength(f);
80 | if (isGreater) {
81 | //当前想要留下大于指定大小的文件,所以过滤掉小于指定大小的文件
82 | if (size < targetSize) {
83 | iterator.remove();
84 | }
85 | } else {
86 | //当前想要留下小于指定大小的文件,所以过滤掉大于指定大小的文件
87 | if (size > targetSize) {
88 | iterator.remove();
89 | }
90 | }
91 | }
92 | }
93 | return list;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/java/com/leon/lfilepickerlibrary/utils/MemoryConstant.java:
--------------------------------------------------------------------------------
1 | package com.leon.lfilepickerlibrary.utils;
2 |
3 | import android.support.annotation.IntDef;
4 |
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 |
8 | /**
9 | *
10 | * author: Blankj
11 | * blog : http://blankj.com
12 | * time : 2017/03/13
13 | * desc : 存储相关常量
14 | *
15 | */
16 | public class MemoryConstant {
17 |
18 | /**
19 | * Byte与Byte的倍数
20 | */
21 | public static final int BYTE = 1;
22 | /**
23 | * KB与Byte的倍数
24 | */
25 | public static final int KB = 1024;
26 | /**
27 | * MB与Byte的倍数
28 | */
29 | public static final int MB = 1048576;
30 | /**
31 | * GB与Byte的倍数
32 | */
33 | public static final int GB = 1073741824;
34 |
35 | @IntDef({BYTE, KB, MB, GB})
36 | @Retention(RetentionPolicy.SOURCE)
37 | public @interface Unit {
38 | }
39 | }
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/java/com/leon/lfilepickerlibrary/utils/StringUtils.java:
--------------------------------------------------------------------------------
1 | package com.leon.lfilepickerlibrary.utils;
2 |
3 | /**
4 | *
5 | * author: Blankj
6 | * blog : http://blankj.com
7 | * time : 2016/8/16
8 | * desc : 字符串相关工具类
9 | *
10 | */
11 | public class StringUtils {
12 |
13 | private StringUtils() {
14 | throw new UnsupportedOperationException("u can't instantiate me...");
15 | }
16 |
17 | /**
18 | * 判断字符串是否为null或长度为0
19 | *
20 | * @param s 待校验字符串
21 | * @return {@code true}: 空
{@code false}: 不为空
22 | */
23 | public static boolean isEmpty(CharSequence s) {
24 | return s == null || s.length() == 0;
25 | }
26 |
27 | /**
28 | * 判断字符串是否为null或全为空格
29 | *
30 | * @param s 待校验字符串
31 | * @return {@code true}: null或全空格
{@code false}: 不为null且不全空格
32 | */
33 | public static boolean isSpace(String s) {
34 | return (s == null || s.trim().length() == 0);
35 | }
36 |
37 | /**
38 | * 判断两字符串是否相等
39 | *
40 | * @param a 待校验字符串a
41 | * @param b 待校验字符串b
42 | * @return {@code true}: 相等
{@code false}: 不相等
43 | */
44 | public static boolean equals(CharSequence a, CharSequence b) {
45 | if (a == b) return true;
46 | int length;
47 | if (a != null && b != null && (length = a.length()) == b.length()) {
48 | if (a instanceof String && b instanceof String) {
49 | return a.equals(b);
50 | } else {
51 | for (int i = 0; i < length; i++) {
52 | if (a.charAt(i) != b.charAt(i)) return false;
53 | }
54 | return true;
55 | }
56 | }
57 | return false;
58 | }
59 |
60 | /**
61 | * 判断两字符串忽略大小写是否相等
62 | *
63 | * @param a 待校验字符串a
64 | * @param b 待校验字符串b
65 | * @return {@code true}: 相等
{@code false}: 不相等
66 | */
67 | public static boolean equalsIgnoreCase(String a, String b) {
68 | return (a == b) || (b != null) && (a.length() == b.length()) && a.regionMatches(true, 0, b, 0, b.length());
69 | }
70 |
71 | /**
72 | * null转为长度为0的字符串
73 | *
74 | * @param s 待转字符串
75 | * @return s为null转为长度为0字符串,否则不改变
76 | */
77 | public static String null2Length0(String s) {
78 | return s == null ? "" : s;
79 | }
80 |
81 | /**
82 | * 返回字符串长度
83 | *
84 | * @param s 字符串
85 | * @return null返回0,其他返回自身长度
86 | */
87 | public static int length(CharSequence s) {
88 | return s == null ? 0 : s.length();
89 | }
90 |
91 | /**
92 | * 首字母大写
93 | *
94 | * @param s 待转字符串
95 | * @return 首字母大写字符串
96 | */
97 | public static String upperFirstLetter(String s) {
98 | if (isEmpty(s) || !Character.isLowerCase(s.charAt(0))) return s;
99 | return String.valueOf((char) (s.charAt(0) - 32)) + s.substring(1);
100 | }
101 |
102 | /**
103 | * 首字母小写
104 | *
105 | * @param s 待转字符串
106 | * @return 首字母小写字符串
107 | */
108 | public static String lowerFirstLetter(String s) {
109 | if (isEmpty(s) || !Character.isUpperCase(s.charAt(0))) return s;
110 | return String.valueOf((char) (s.charAt(0) + 32)) + s.substring(1);
111 | }
112 |
113 | /**
114 | * 反转字符串
115 | *
116 | * @param s 待反转字符串
117 | * @return 反转字符串
118 | */
119 | public static String reverse(String s) {
120 | int len = length(s);
121 | if (len <= 1) return s;
122 | int mid = len >> 1;
123 | char[] chars = s.toCharArray();
124 | char c;
125 | for (int i = 0; i < mid; ++i) {
126 | c = chars[i];
127 | chars[i] = chars[len - i - 1];
128 | chars[len - i - 1] = c;
129 | }
130 | return new String(chars);
131 | }
132 |
133 | /**
134 | * 转化为半角字符
135 | *
136 | * @param s 待转字符串
137 | * @return 半角字符串
138 | */
139 | public static String toDBC(String s) {
140 | if (isEmpty(s)) return s;
141 | char[] chars = s.toCharArray();
142 | for (int i = 0, len = chars.length; i < len; i++) {
143 | if (chars[i] == 12288) {
144 | chars[i] = ' ';
145 | } else if (65281 <= chars[i] && chars[i] <= 65374) {
146 | chars[i] = (char) (chars[i] - 65248);
147 | } else {
148 | chars[i] = chars[i];
149 | }
150 | }
151 | return new String(chars);
152 | }
153 |
154 | /**
155 | * 转化为全角字符
156 | *
157 | * @param s 待转字符串
158 | * @return 全角字符串
159 | */
160 | public static String toSBC(String s) {
161 | if (isEmpty(s)) return s;
162 | char[] chars = s.toCharArray();
163 | for (int i = 0, len = chars.length; i < len; i++) {
164 | if (chars[i] == ' ') {
165 | chars[i] = (char) 12288;
166 | } else if (33 <= chars[i] && chars[i] <= 126) {
167 | chars[i] = (char) (chars[i] + 65248);
168 | } else {
169 | chars[i] = chars[i];
170 | }
171 | }
172 | return new String(chars);
173 | }
174 | }
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/java/com/leon/lfilepickerlibrary/widget/EmptyRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.leon.lfilepickerlibrary.widget;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 |
9 | /**
10 | * 作者:Leon
11 | * 时间:2017/3/17 13:44
12 | */
13 | public class EmptyRecyclerView extends RecyclerView {
14 | private View mEmptyView;
15 |
16 | public EmptyRecyclerView(Context context) {
17 | super(context);
18 | }
19 |
20 | public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
25 | super(context, attrs, defStyle);
26 | }
27 |
28 | /**
29 | * 根据数据源判断是否显示空白view
30 | */
31 | private void checkIfEmpty() {
32 | if (mEmptyView != null || getAdapter() != null) {
33 | mEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE);
34 | }
35 | }
36 |
37 | public void setmEmptyView(View mEmptyView) {
38 | this.mEmptyView = mEmptyView;
39 | checkIfEmpty();
40 | }
41 |
42 | @Override
43 | public void setAdapter(Adapter adapter) {
44 | Adapter adapterOld = getAdapter();
45 | if (adapterOld != null) {
46 | adapterOld.unregisterAdapterDataObserver(observer);
47 | }
48 | super.setAdapter(adapter);
49 | if (adapter != null) {
50 | adapter.registerAdapterDataObserver(observer);
51 | }
52 | }
53 |
54 | AdapterDataObserver observer = new AdapterDataObserver() {
55 | @Override
56 | public void onChanged() {
57 | super.onChanged();
58 | checkIfEmpty();
59 | }
60 | };
61 | }
62 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable-v21/lfile_back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable-v21/lfile_btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable/back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable/btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable/item_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable/lfile_back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/drawable/lfile_btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/layout/activity_lfile_picker.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
25 |
26 |
36 |
37 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/layout/lfile_emptyview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
18 |
19 |
26 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/layout/lfile_listitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
26 |
27 |
36 |
37 |
41 |
42 |
46 |
47 |
48 |
49 |
55 |
56 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/menu/menu_main_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_back1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_back1.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_back2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_back2.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_emptyimg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_emptyimg.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_file_style_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_file_style_blue.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_file_style_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_file_style_green.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_file_style_yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_file_style_yellow.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_folder_style_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_folder_style_blue.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_folder_style_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_folder_style_green.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_folder_style_yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_folder_style_yellow.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/lfilepickerlibrary/src/main/res/mipmap-xhdpi/lfile_up.png
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/values-zh/values-zh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 请至少选择一个
4 | SD 存储卡状态不可用
5 | 上一级
6 | 选中
7 | 项
8 | 详情
9 | 文件大小 :
10 | 已经达到最大选择数量
11 | 全选
12 | 取消全选
13 | 确定
14 | 请选择文件夹
15 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #92B4F4
4 | #92B4F4
5 | #92B4F4
6 | #cccccc
7 | #dddddd
8 | #fff
9 | #92B4F4
10 |
11 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Please select a file at least
3 | The sd card is not available
4 | Up
5 | selected
6 | item
7 | detail
8 | size :
9 | Has reached the maximum number
10 | SelectAll
11 | Cancel
12 | OK
13 | Please select folders path
14 |
15 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
16 |
20 |
21 |
24 |
25 |
29 |
30 |
40 |
41 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/lfilepickerlibrary/src/main/res/xml/provider_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-132717.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-132717.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-133458.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-133458.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-133811.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-133811.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-133831.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-133831.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-133836.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-133836.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-133844.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-133844.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-134316.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-134316.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-134327.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-134327.png
--------------------------------------------------------------------------------
/screenshot/Screenshot_20170330-134333.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/Screenshot_20170330-134333.png
--------------------------------------------------------------------------------
/screenshot/操作.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/操作.gif
--------------------------------------------------------------------------------
/screenshot/简单操作01.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/简单操作01.gif
--------------------------------------------------------------------------------
/screenshot/简单操作02.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/简单操作02.gif
--------------------------------------------------------------------------------
/screenshot/简单操作03.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/简单操作03.gif
--------------------------------------------------------------------------------
/screenshot/简单操作04.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leonHua/LFilePicker/cf668428c50a2a4bc8d06907c02343373b982f3d/screenshot/简单操作04.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lfilepickerlibrary'
2 |
--------------------------------------------------------------------------------