├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ └── commons-io-2.5.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── filemanager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── filemanager │ │ │ ├── AboutActivity.java │ │ │ ├── FileActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MemoryActivity.java │ │ │ ├── MyApplication.java │ │ │ ├── ShowActivity.java │ │ │ ├── adapter │ │ │ ├── ApkAdapter.java │ │ │ ├── FileNameAdapter.java │ │ │ ├── ImageAdapter.java │ │ │ ├── MusicAdapter.java │ │ │ ├── VideoAdapter.java │ │ │ ├── WordAdapter.java │ │ │ └── ZipAdapter.java │ │ │ ├── fragment │ │ │ ├── ApkFragment.java │ │ │ ├── FileNameFragment.java │ │ │ ├── FileTypeFragment.java │ │ │ ├── ImageFragment.java │ │ │ ├── MusicFragment.java │ │ │ ├── VideoFragment.java │ │ │ ├── WordFragment.java │ │ │ └── ZipFragment.java │ │ │ └── util │ │ │ ├── ACache.java │ │ │ ├── ApkDetial.java │ │ │ ├── Fab.java │ │ │ └── FileUtil.java │ └── res │ │ ├── anim │ │ ├── slide_in_left.xml │ │ ├── slide_in_right.xml │ │ ├── slide_out_left.xml │ │ └── slide_out_right.xml │ │ ├── drawable-hdpi │ │ ├── file_menu3.png │ │ ├── ic_highlight_off_white_24dp.png │ │ ├── ic_menu.png │ │ ├── ic_menu_90.png │ │ ├── ic_menu_check.png │ │ ├── ic_menu_close.png │ │ ├── ic_menu_find.png │ │ ├── ic_menu_user.png │ │ ├── ic_return.png │ │ ├── ic_search_white_24dp.png │ │ └── night.png │ │ ├── drawable-mdpi │ │ ├── file_menu3.png │ │ ├── ic_highlight_off_white_24dp.png │ │ ├── ic_menu.png │ │ ├── ic_menu_90.png │ │ ├── ic_menu_check.png │ │ ├── ic_menu_close.png │ │ ├── ic_menu_find.png │ │ ├── ic_menu_user.png │ │ ├── ic_return.png │ │ ├── ic_search_white_24dp.png │ │ └── night.png │ │ ├── drawable-v21 │ │ └── ripple_bg.xml │ │ ├── drawable-xhdpi │ │ ├── file_menu3.png │ │ ├── ic_highlight_off_white_24dp.png │ │ ├── ic_menu.png │ │ ├── ic_menu_90.png │ │ ├── ic_menu_check.png │ │ ├── ic_menu_close.png │ │ ├── ic_menu_find.png │ │ ├── ic_menu_user.png │ │ ├── ic_return.png │ │ ├── ic_search_white_24dp.png │ │ ├── loading.gif │ │ └── night.png │ │ ├── drawable-xxhdpi │ │ ├── file_menu3.png │ │ ├── ic_highlight_off_white_24dp.png │ │ ├── ic_menu.png │ │ ├── ic_menu_90.png │ │ ├── ic_menu_check.png │ │ ├── ic_menu_close.png │ │ ├── ic_menu_find.png │ │ ├── ic_menu_user.png │ │ ├── ic_return.png │ │ ├── ic_search_white_24dp.png │ │ └── night.png │ │ ├── drawable-xxxhdpi │ │ ├── file_menu3.png │ │ ├── ic_highlight_off_white_24dp.png │ │ ├── ic_menu_check.png │ │ ├── ic_menu_close.png │ │ ├── ic_menu_find.png │ │ ├── ic_menu_user.png │ │ ├── ic_search_white_24dp.png │ │ └── night.png │ │ ├── drawable │ │ ├── button_select.xml │ │ ├── ripple_bg.xml │ │ └── ripple_bg_drawable.xml │ │ ├── layout-v21 │ │ └── activity_file.xml │ │ ├── layout │ │ ├── activity_about.xml │ │ ├── activity_file.xml │ │ ├── activity_main.xml │ │ ├── activity_memory.xml │ │ ├── activity_show.xml │ │ ├── fragment_apk.xml │ │ ├── fragment_file_name.xml │ │ ├── fragment_file_type.xml │ │ ├── fragment_image.xml │ │ ├── fragment_music.xml │ │ ├── fragment_video.xml │ │ ├── fragment_word.xml │ │ ├── fragment_zip.xml │ │ ├── guillotine.xml │ │ ├── item_apk.xml │ │ ├── item_file.xml │ │ ├── item_image.xml │ │ ├── item_music.xml │ │ ├── item_video.xml │ │ ├── item_word.xml │ │ ├── item_zip.xml │ │ ├── show_list.xml │ │ └── show_toolbar.xml │ │ ├── menu │ │ └── toolbar_menu.xml │ │ ├── mipmap-hdpi │ │ ├── ad_app_icon.png │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── ad_app_icon.png │ │ ├── error.jpg │ │ ├── ic_launcher.png │ │ └── openpager.png │ │ ├── mipmap-xxhdpi │ │ ├── ad_app_icon.png │ │ ├── file_apk.png │ │ ├── file_file.png │ │ ├── file_image.png │ │ ├── file_music.png │ │ ├── file_video.png │ │ ├── file_word.png │ │ ├── file_zip.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-night │ │ └── colors.xml │ │ ├── values-v19 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── filemanager │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | #IntellJ IDEA 2 | .idea/ 3 | *.iml 4 | *.ipr 5 | *.iws 6 | out/ 7 | 8 | #Gradle build folder 9 | build/ 10 | .gradle/ 11 | 12 | #Android 13 | local.properties 14 | bin/ 15 | gen/ 16 | 17 | # JNI compile files 18 | *.o 19 | *.o.d 20 | 21 | # OS autogen folder information 22 | .DS_Store 23 | Thumbs.db 24 | 25 | # Temp files 26 | *.bak 27 | *.tmp 28 | *.temp 29 | *.swp 30 | *.*~ 31 | ~*.* 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 快客文件管理器 2 | 3 | 4 | 5 | 6 | 7 |
version 1.0.0API 15+QQ:779754469
8 | 9 | 完整的基于Android的文件管理器的APP,百度手机助手已上线。 10 | 11 | [下载地址](https://shouji.baidu.com/software/10939153.html) 12 | 13 | - 完整的文件管理功能,包括文件分享,文件展示,文件操作等等。 14 | - Material Design 设计风格,同时兼容较低的Android版本。 15 | - 流畅优雅的动画和交互反馈。 16 | - Mini体积的安装包。 17 | - 应用商店四位数的下载量,受宠若惊。 18 | - 我编不下去了......,往下看图吧。 19 | 20 | ## 主页/夜间模式的设置 21 | 22 | 基于Android的Material Design的设计规范设计的主页面,用来显示文件分类。该应用中几乎所有的交互都有合理的动画过渡效果,希望借此提高用户的体验,最低版本兼容到API 15。 23 | 24 | 25 | 26 | 27 |
主页夜间模式
28 | 29 | ## 文件列表的展示和操作 30 | 31 | 不同的文件类型采用不同的列表布局方式,图片列表采用瀑布流布局,视频类文件采用列表布局。为了界面的优雅,文件的操作也比较隐蔽:一般的文件操作放在了长按显示的菜单中,删除的操作则添加在了侧滑菜单中。文件的不同类型的文件列表均作了相应的处理,比如:视频列表页面显示视频的截图,APK列表页面显示安装包的ICON和应用名等。 32 | 33 | 34 | 35 | 36 |
列表展示列表展示
37 | 38 | ## 其他功能 39 | 40 | 除了文件管理器的基本功能以外,还有一些其他的Gift: 41 | 42 | - 你在首页点击左上角的菜单键,会酷炫的显示一个系统菜单,他的主要功能是酷炫,并没有什么实际功能。 ORZ 43 | - 首页有个搜索按钮,可以根据文件名的关键字进行模糊搜索,也可以输入文件的后缀名,系统帮你搜集到这个设备上所有该类型的文件。 44 | 45 | ## TODO 46 | 47 | 虽然这个APP基本完成,但通往完美的路还有很远...... 48 | 49 | - 文件集合按时间顺序排列 50 | - 文件展示后返回本程序(APP中的文件打开均适用设备中已安装的应用) 51 | 52 | ## Last 53 | 54 | 联系方式:
55 | 邮箱:qizewei@vip.qq.com
56 | WeChat:779754469
57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | #IntellJ IDEA 3 | .idea/ 4 | *.iml 5 | *.ipr 6 | *.iws 7 | out/ 8 | 9 | #Gradle build folder 10 | build/ 11 | .gradle/ 12 | 13 | #Android 14 | local.properties 15 | bin/ 16 | gen/ 17 | 18 | # JNI compile files 19 | *.o 20 | *.o.d 21 | 22 | # OS autogen folder information 23 | .DS_Store 24 | Thumbs.db 25 | 26 | # Temp files 27 | *.bak 28 | *.tmp 29 | *.temp 30 | *.swp 31 | *.*~ 32 | ~*.* 33 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.neenbedankt.android-apt' 3 | 4 | android { 5 | compileSdkVersion 24 6 | buildToolsVersion "25.0.1" 7 | defaultConfig { 8 | applicationId "com.filemanager" 9 | minSdkVersion 15 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | // multiDexEnabled true 15 | } 16 | 17 | buildTypes { 18 | release { 19 | debuggable false 20 | minifyEnabled true 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(include: ['*.jar'], dir: 'libs') 28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 29 | exclude group: 'com.android.support', module: 'support-annotations' 30 | }) 31 | compile files('libs/commons-io-2.5.jar') 32 | compile 'com.blankj:utilcode:1.3.4' 33 | compile 'com.android.support:appcompat-v7:24.2.1' 34 | compile 'com.android.support:recyclerview-v7:24.2.1' 35 | compile 'com.android.support:cardview-v7:24.2.1' 36 | compile 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.2.4' 37 | compile 'com.android.support:design:25.1.0' 38 | compile 'com.github.bumptech.glide:glide:3.7.0' 39 | compile 'com.github.Yalantis:GuillotineMenu-Android:1.2' 40 | compile 'com.umeng.analytics:analytics:latest.integration' 41 | compile 'com.google.code.gson:gson:2.2.4' 42 | compile 'com.balysv:material-ripple:1.0.2' 43 | compile 'com.gordonwong:material-sheet-fab:1.2.1' 44 | compile 'com.android.support:support-v4:24.2.1' 45 | compile 'com.github.yalantis:taurus:1.0.2' 46 | compile 'com.jakewharton:butterknife:8.1.0' 47 | apt 'com.jakewharton:butterknife-compiler:8.1.0' 48 | testCompile 'junit:junit:4.12' 49 | } 50 | -------------------------------------------------------------------------------- /app/libs/commons-io-2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/libs/commons-io-2.5.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in F:\AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/filemanager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.filemanager", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 36 | 37 | 38 | 39 | 42 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | 6 | import com.umeng.analytics.MobclickAgent; 7 | 8 | public class AboutActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_about); 14 | } 15 | public void onResume() { 16 | super.onResume(); 17 | MobclickAgent.onResume(this); 18 | } 19 | public void onPause() { 20 | super.onPause(); 21 | MobclickAgent.onPause(this); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.SystemClock; 6 | import android.support.v7.app.AppCompatActivity; 7 | 8 | /** 9 | * 启动页,线程睡眠 2 秒后跳到主页面 10 | */ 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | CheckOpen(); 18 | } 19 | 20 | private void CheckOpen() { 21 | new Thread(new Runnable() { 22 | @Override 23 | public void run() { 24 | SystemClock.sleep(2000); 25 | startActivity(new Intent(MainActivity.this,FileActivity.class)); 26 | finish(); 27 | } 28 | }).start(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/MemoryActivity.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.Toolbar; 6 | import android.widget.TextView; 7 | 8 | import com.blankj.utilcode.utils.DeviceUtils; 9 | import com.blankj.utilcode.utils.PhoneUtils; 10 | import com.umeng.analytics.MobclickAgent; 11 | 12 | public class MemoryActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_memory); 18 | initView(); 19 | } 20 | 21 | private void initView() { 22 | Toolbar toolbar = (Toolbar) findViewById(R.id.Detial_toolbar); 23 | toolbar.setTitle(""); 24 | setSupportActionBar(toolbar); 25 | 26 | TextView total = (TextView) findViewById(R.id.detial_total); 27 | TextView free = (TextView) findViewById(R.id.detial_free); 28 | total.setText(getIntent().getStringExtra("total")); 29 | free.setText(getIntent().getStringExtra("free")); 30 | 31 | String model = DeviceUtils.getModel(); 32 | String manufacturer = DeviceUtils.getManufacturer(); 33 | boolean root = DeviceUtils.isDeviceRoot(); 34 | int version = DeviceUtils.getSDKVersion(); 35 | String IMEI = PhoneUtils.getIMEI(this); 36 | 37 | TextView DetailModelModel = (TextView) findViewById(R.id.detial_model); 38 | DetailModelModel.setText(model); 39 | TextView DetailFactory = (TextView) findViewById(R.id.detial_factory); 40 | DetailFactory.setText(manufacturer); 41 | TextView DetailIMEI = (TextView) findViewById(R.id.detial_imei); 42 | DetailIMEI.setText(IMEI); 43 | 44 | TextView DetailRoot = (TextView) findViewById(R.id.detial_root); 45 | if (root) { 46 | DetailRoot.setText("你的设备已Root"); 47 | } else 48 | DetailRoot.setText("您的设备未Root"); 49 | TextView DetailVersion = (TextView) findViewById(R.id.detial_version); 50 | if (version == 23) { 51 | DetailVersion.setText("6.0.0"); 52 | } else if (version == 22) { 53 | DetailVersion.setText("5.1.0"); 54 | } else if (version == 21) { 55 | DetailVersion.setText("5.0.0"); 56 | } else if (version == 20) { 57 | DetailVersion.setText("4.4.0 W"); 58 | } else if (version == 19) { 59 | DetailVersion.setText("4.4.0"); 60 | } else if (version == 18) { 61 | DetailVersion.setText("4.3.0"); 62 | } else if (version == 17) { 63 | DetailVersion.setText("4.2.0"); 64 | } else if (version == 16) { 65 | DetailVersion.setText("4.1.0"); 66 | } else if (version == 15) { 67 | DetailVersion.setText("4.0.0"); 68 | } else if (version <= 14) { 69 | DetailVersion.setText("恭喜,你是地球上Android版本最低的3%的人之一。"); 70 | } 71 | } 72 | 73 | public void onResume() { 74 | super.onResume(); 75 | MobclickAgent.onResume(this); 76 | } 77 | 78 | public void onPause() { 79 | super.onPause(); 80 | MobclickAgent.onPause(this); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import android.app.Application; 4 | 5 | import com.umeng.analytics.MobclickAgent; 6 | 7 | /** 8 | * Created by 齐泽威 on 2017/2/1. 9 | */ 10 | 11 | public class MyApplication extends Application { 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | //友盟统计 16 | MobclickAgent.UMAnalyticsConfig config = new MobclickAgent.UMAnalyticsConfig(this, "9cefd91191d36d9023985dc24c860b39", "MoRen"); 17 | MobclickAgent.startWithConfigure(config); 18 | MobclickAgent.openActivityDurationTrack(false); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/ShowActivity.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentTransaction; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.fileManager.fragment.ApkFragment; 8 | import com.fileManager.fragment.FileNameFragment; 9 | import com.fileManager.fragment.FileTypeFragment; 10 | import com.fileManager.fragment.ImageFragment; 11 | import com.fileManager.fragment.MusicFragment; 12 | import com.fileManager.fragment.VideoFragment; 13 | import com.fileManager.fragment.WordFragment; 14 | import com.fileManager.fragment.ZipFragment; 15 | import com.umeng.analytics.MobclickAgent; 16 | 17 | public class ShowActivity extends AppCompatActivity { 18 | 19 | @Override 20 | 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_show); 24 | 25 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); 26 | String aClass = getIntent().getStringExtra("class"); 27 | switch (aClass) { 28 | case "image": 29 | transaction.add(R.id.show_detial, new ImageFragment()); 30 | break; 31 | case "music": 32 | transaction.add(R.id.show_detial, new MusicFragment()); 33 | break; 34 | case "video": 35 | transaction.add(R.id.show_detial, new VideoFragment()); 36 | break; 37 | case "word": 38 | transaction.add(R.id.show_detial, new WordFragment()); 39 | break; 40 | case "apk": 41 | transaction.add(R.id.show_detial, new ApkFragment()); 42 | break; 43 | case "zip": 44 | transaction.add(R.id.show_detial, new ZipFragment()); 45 | break; 46 | case "filename": 47 | transaction.add(R.id.show_detial,new FileNameFragment()); 48 | break; 49 | case "filetype": 50 | transaction.add(R.id.show_detial,new FileTypeFragment()); 51 | break; 52 | } 53 | transaction.commit(); 54 | } 55 | 56 | public void onResume() { 57 | super.onResume(); 58 | MobclickAgent.onResume(this); 59 | } 60 | 61 | public void onPause() { 62 | super.onPause(); 63 | MobclickAgent.onPause(this); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/adapter/FileNameAdapter.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.support.v7.app.AlertDialog; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.EditText; 13 | import android.widget.LinearLayout; 14 | import android.widget.TextView; 15 | import android.widget.Toast; 16 | 17 | import com.blankj.utilcode.utils.FileUtils; 18 | import com.blankj.utilcode.utils.TimeUtils; 19 | import com.fileManager.R; 20 | import com.fileManager.util.FileUtil; 21 | 22 | import java.io.File; 23 | import java.util.List; 24 | 25 | /** 26 | * Created by 齐泽威 on 2017/2/8. 27 | */ 28 | 29 | public class FileNameAdapter extends RecyclerView.Adapter{ 30 | private List mDatas; 31 | private Context mContext; 32 | private FileNameAdapter.OnItemClickLitener mOnItemClickLitener; 33 | 34 | public FileNameAdapter(Context context, List Data) { 35 | this.mDatas = Data; 36 | this.mContext = context; 37 | 38 | } 39 | 40 | public void setOnItemClickLitener(FileNameAdapter.OnItemClickLitener mOnItemClickLitener) { 41 | this.mOnItemClickLitener = mOnItemClickLitener; 42 | } 43 | 44 | @Override 45 | public FileNameAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 46 | FileNameAdapter.MyViewHolder holder = new FileNameAdapter.MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_file, parent, 47 | false)); 48 | return holder; 49 | } 50 | 51 | @Override 52 | public void onBindViewHolder(final FileNameAdapter.MyViewHolder holder, final int position) { 53 | holder.tv.setText(mDatas.get(position).getName()); 54 | 55 | // 如果设置了回调,则设置点击事件 56 | if (mOnItemClickLitener != null) { 57 | holder.mLayout.setOnClickListener(new View.OnClickListener() { 58 | @Override 59 | public void onClick(View v) { 60 | int pos = holder.getLayoutPosition(); 61 | mOnItemClickLitener.onItemClick(holder.mLayout, pos); 62 | 63 | String path = mDatas.get(pos).getPath(); 64 | Intent intent = FileUtil.openFile(path); 65 | mContext.startActivity(intent); 66 | } 67 | }); 68 | 69 | holder.mLayout.setOnLongClickListener(new View.OnLongClickListener() { 70 | @Override 71 | public boolean onLongClick(View v) { 72 | final String items[] = {"重命名文件", "文件详情","分享"}; 73 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); //先得到构造器 74 | builder.setItems(items, new DialogInterface.OnClickListener() { 75 | @Override 76 | public void onClick(DialogInterface dialog, int which) { 77 | //dialog.dismiss(); 78 | if (which == 0) { 79 | ReName(position); 80 | } else if (which == 1) 81 | ShowDetial(position); 82 | else if (which ==2) { 83 | Intent intent = new Intent(Intent.ACTION_SEND); 84 | intent.setType("application/vnd.android.package-archive"); 85 | Uri uri = Uri.fromFile(mDatas.get(position)); intent.putExtra(Intent.EXTRA_STREAM, uri); 86 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 87 | mContext.startActivity(Intent.createChooser(intent,"分享到")); 88 | } 89 | } 90 | }); 91 | builder.create().show(); 92 | return false; 93 | 94 | } 95 | }); 96 | 97 | 98 | holder.file_file_delete.setOnClickListener(new View.OnClickListener() { 99 | @Override 100 | public void onClick(View v) { 101 | int pos = holder.getLayoutPosition(); 102 | mOnItemClickLitener.onItemClick(holder.tv, pos); 103 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 104 | builder.setTitle("确认删除"); 105 | builder.setMessage("是否确认删除该文件"); 106 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 107 | @Override 108 | public void onClick(DialogInterface dialog, int which) { 109 | 110 | } 111 | }); 112 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 113 | @Override 114 | public void onClick(DialogInterface dialog, int which) { 115 | removeData(holder.getAdapterPosition()); 116 | } 117 | }); 118 | AlertDialog dialog = builder.create(); 119 | dialog.show(); 120 | 121 | synchronized (this) { 122 | this.notify(); 123 | } 124 | } 125 | }); 126 | } 127 | } 128 | 129 | private void ShowDetial(int position) { 130 | File file = mDatas.get(position); 131 | String size = FileUtils.getFileSize(file); 132 | String name = file.getName(); 133 | String path = file.getAbsolutePath(); 134 | String time = TimeUtils.milliseconds2String(file.lastModified()); 135 | 136 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 137 | builder.setTitle("文件属性") 138 | .setCancelable(false) 139 | .setNegativeButton("确定", null) 140 | .setMessage("\n" + "文件名:" + name + "\n\n" + "文件大小:" + size + "\n\n" + "文件路径:" + 141 | path + "\n\n" + "时间:" + time ) 142 | .show(); 143 | 144 | } 145 | 146 | private void ReName(final int position) { 147 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 148 | final EditText userId = new EditText(mContext); 149 | userId.setHint("注意请加上文件后缀名,例如:.mp4"); 150 | builder.setTitle("请输入新命名:") 151 | .setCancelable(false) 152 | .setNegativeButton("取消", null) 153 | .setPositiveButton("确定", new DialogInterface.OnClickListener() { 154 | @Override 155 | public void onClick(DialogInterface dialogInterface, int i) { 156 | String newName = userId.getText().toString().trim(); 157 | if (newName.equals("")) { 158 | Toast.makeText(mContext, "输入不能为空", Toast.LENGTH_SHORT).show(); 159 | } else { 160 | //重命名File 161 | FileUtils.rename(mDatas.get(position), newName ); 162 | 163 | //更新显示数据 164 | String path = mDatas.get(position).getParent(); 165 | File file = new File(path + "/" + newName); 166 | mDatas.remove(position); 167 | mDatas.add(position, file); 168 | notifyDataSetChanged(); 169 | Toast.makeText(mContext, "重命名文件成功", Toast.LENGTH_SHORT).show(); 170 | 171 | 172 | } 173 | } 174 | }) 175 | .setView(userId, 150, 20, 70, 20) 176 | .show(); 177 | } 178 | 179 | @Override 180 | public int getItemCount() { 181 | return mDatas.size(); 182 | } 183 | 184 | private void removeData(int position) { 185 | String path = mDatas.get(position).getAbsolutePath(); 186 | FileUtils.deleteFile(path); 187 | mDatas.remove(position); 188 | notifyItemRemoved(position); 189 | notifyItemRangeChanged(position, position + 1); 190 | 191 | } 192 | 193 | public interface OnItemClickLitener { 194 | void onItemClick(View view, int position); 195 | 196 | void onItemLongClick(View view, int position); 197 | } 198 | 199 | class MyViewHolder extends RecyclerView.ViewHolder { 200 | 201 | TextView tv, file_file_delete; 202 | LinearLayout mLayout; 203 | 204 | MyViewHolder(View view) { 205 | super(view); 206 | tv = (TextView) view.findViewById(R.id.item_file_name); 207 | mLayout = (LinearLayout) view.findViewById(R.id.file_linear); 208 | file_file_delete = (TextView) view.findViewById(R.id.file_file_delete); 209 | } 210 | 211 | } 212 | 213 | 214 | } 215 | 216 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/adapter/MusicAdapter.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.support.v7.app.AlertDialog; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.EditText; 13 | import android.widget.LinearLayout; 14 | import android.widget.TextView; 15 | import android.widget.Toast; 16 | 17 | import com.blankj.utilcode.utils.FileUtils; 18 | import com.blankj.utilcode.utils.TimeUtils; 19 | import com.fileManager.R; 20 | import com.fileManager.util.ACache; 21 | import com.fileManager.util.FileUtil; 22 | import com.google.gson.Gson; 23 | 24 | import java.io.File; 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | /** 29 | * Created by 齐泽威 on 2016/12/7. 30 | */ 31 | 32 | public class MusicAdapter extends RecyclerView.Adapter { 33 | private List mDatas; 34 | private Context mContext; 35 | private MusicAdapter.OnItemClickLitener mOnItemClickLitener; 36 | private ACache mCache; 37 | private Gson mGson; 38 | 39 | 40 | public MusicAdapter(Context context, List Data) { 41 | this.mDatas = Data; 42 | this.mContext = context; 43 | this.mGson = new Gson(); 44 | try { 45 | mCache = ACache.get(mContext); 46 | }catch (Exception e){ 47 | //子线程未销毁可能时执行 48 | } 49 | 50 | } 51 | 52 | public void setOnItemClickLitener(MusicAdapter.OnItemClickLitener mOnItemClickLitener) { 53 | this.mOnItemClickLitener = mOnItemClickLitener; 54 | } 55 | 56 | @Override 57 | public MusicAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 58 | MusicAdapter.MyViewHolder holder = new MusicAdapter.MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_music, parent, 59 | false)); 60 | return holder; 61 | } 62 | 63 | @Override 64 | public void onBindViewHolder(final MusicAdapter.MyViewHolder holder, final int position) { 65 | holder.tv.setText(mDatas.get(position).getName()); 66 | 67 | // 如果设置了回调,则设置点击事件 68 | if (mOnItemClickLitener != null) { 69 | holder.linear.setOnClickListener(new View.OnClickListener() { 70 | @Override 71 | public void onClick(View v) { 72 | int pos = holder.getLayoutPosition(); 73 | mOnItemClickLitener.onItemClick(holder.linear, pos); 74 | 75 | String path = mDatas.get(pos).getPath(); 76 | Intent intent = FileUtil.openFile(path); 77 | mContext.startActivity(intent); 78 | 79 | } 80 | }); 81 | 82 | holder.linear.setOnLongClickListener(new View.OnLongClickListener() { 83 | @Override 84 | public boolean onLongClick(View v) { 85 | final String items[] = {"重命名文件", "文件详情","分享"}; 86 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); //先得到构造器 87 | builder.setItems(items, new DialogInterface.OnClickListener() { 88 | @Override 89 | public void onClick(DialogInterface dialog, int which) { 90 | //dialog.dismiss(); 91 | if (which == 0) { 92 | ReName(position); 93 | } else if (which == 1) 94 | ShowDetial(position); 95 | else if (which ==2) { 96 | Intent intent = new Intent(Intent.ACTION_SEND); 97 | intent.setType("audio/*"); 98 | Uri uri = Uri.fromFile(mDatas.get(position)); intent.putExtra(Intent.EXTRA_STREAM, uri); 99 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 100 | mContext.startActivity(Intent.createChooser(intent,"分享到")); 101 | } 102 | } 103 | }); 104 | builder.create().show(); 105 | return false; 106 | 107 | } 108 | }); 109 | 110 | holder.item_music_delete.setOnClickListener(new View.OnClickListener() { 111 | @Override 112 | public void onClick(View v) { 113 | int pos = holder.getLayoutPosition(); 114 | mOnItemClickLitener.onItemClick(holder.tv, pos); 115 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 116 | builder.setTitle("确认删除"); 117 | builder.setMessage("是否确认删除该文件"); 118 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 119 | @Override 120 | public void onClick(DialogInterface dialog, int which) { 121 | 122 | } 123 | }); 124 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 125 | @Override 126 | public void onClick(DialogInterface dialog, int which) { 127 | removeData(holder.getAdapterPosition()); 128 | } 129 | }); 130 | AlertDialog dialog = builder.create(); 131 | dialog.show(); 132 | 133 | synchronized (this) { 134 | this.notify(); 135 | } 136 | } 137 | }); 138 | 139 | 140 | } 141 | } 142 | 143 | @Override 144 | public int getItemCount() { 145 | return mDatas.size(); 146 | } 147 | 148 | private void removeData(int position) { 149 | String path = mDatas.get(position).getAbsolutePath(); 150 | FileUtils.deleteFile(path); 151 | 152 | for (int i = 0; i < mDatas.size(); i++) { 153 | String s = String.valueOf(i); 154 | mCache.remove(s+"music"); 155 | } 156 | 157 | mDatas.remove(position); 158 | notifyItemRemoved(position); 159 | notifyItemRangeChanged(position,position+1); 160 | //reset all catch 161 | ArrayList strings = new ArrayList<>(); 162 | for (int i = 0; i < mDatas.size(); i++) { 163 | String s = mGson.toJson(mDatas.get(i)); 164 | strings.add(s); 165 | } 166 | for (int i = 0; i < strings.size(); i++) { 167 | String s = String.valueOf(i); 168 | mCache.put(s+"music", strings.get(i), ACache.TIME_DAY); 169 | } 170 | } 171 | 172 | public interface OnItemClickLitener { 173 | void onItemClick(View view, int position); 174 | 175 | void onItemLongClick(View view, int position); 176 | } 177 | 178 | private void ShowDetial(int position) { 179 | File file = mDatas.get(position); 180 | String size = FileUtils.getFileSize(file); 181 | String name = file.getName(); 182 | String path = file.getAbsolutePath(); 183 | String time = TimeUtils.milliseconds2String(file.lastModified()); 184 | 185 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 186 | builder.setTitle("文件属性") 187 | .setCancelable(false) 188 | .setNegativeButton("确定", null) 189 | .setMessage("\n" + "文件名:" + name + "\n\n" + "文件大小:" + size + "\n\n" + "文件路径:" + 190 | path + "\n\n" + "时间:" + time ) 191 | .show(); 192 | 193 | } 194 | 195 | private void ReName(final int position) { 196 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 197 | final EditText userId = new EditText(mContext); 198 | builder.setTitle("请输入新命名:") 199 | .setCancelable(false) 200 | .setNegativeButton("取消", null) 201 | .setPositiveButton("确定", new DialogInterface.OnClickListener() { 202 | @Override 203 | public void onClick(DialogInterface dialogInterface, int i) { 204 | String newName = userId.getText().toString().trim(); 205 | if (newName.equals("")) { 206 | Toast.makeText(mContext, "输入不能为空", Toast.LENGTH_SHORT).show(); 207 | } else { 208 | //重命名File 209 | FileUtils.rename(mDatas.get(position), newName + ".mp3"); 210 | 211 | //更新显示数据 212 | String path = mDatas.get(position).getParent(); 213 | File file = new File(path + "/" + newName + ".mp3"); 214 | mDatas.remove(position); 215 | mDatas.add(position, file); 216 | notifyDataSetChanged(); 217 | Toast.makeText(mContext, "重命名文件成功", Toast.LENGTH_SHORT).show(); 218 | 219 | //更新缓存 220 | String s = String.valueOf(position); 221 | String name = "{\"path\":\"" + file.getAbsolutePath() + "\"}"; 222 | mCache.put(s + "music", name); 223 | 224 | } 225 | } 226 | }) 227 | .setView(userId, 150, 20, 70, 20) 228 | .show(); 229 | } 230 | 231 | class MyViewHolder extends RecyclerView.ViewHolder { 232 | TextView tv, item_music_delete; 233 | LinearLayout linear; 234 | 235 | public MyViewHolder(View view) { 236 | super(view); 237 | tv = (TextView) view.findViewById(R.id.item_music_filename); 238 | linear = (LinearLayout)view.findViewById(R.id.music_linear); 239 | item_music_delete = (TextView) view.findViewById(R.id.item_music_delete); 240 | } 241 | } 242 | 243 | } 244 | 245 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/adapter/WordAdapter.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.support.v7.app.AlertDialog; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.EditText; 13 | import android.widget.LinearLayout; 14 | import android.widget.TextView; 15 | import android.widget.Toast; 16 | 17 | import com.blankj.utilcode.utils.FileUtils; 18 | import com.blankj.utilcode.utils.TimeUtils; 19 | import com.fileManager.R; 20 | import com.fileManager.util.ACache; 21 | import com.fileManager.util.FileUtil; 22 | import com.google.gson.Gson; 23 | 24 | import java.io.File; 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | /** 29 | * Created by 齐泽威 on 2016/12/7. 30 | */ 31 | 32 | public class WordAdapter extends RecyclerView.Adapter { 33 | private List mDatas; 34 | private Context mContext; 35 | private ACache mCache; 36 | private Gson mGson; 37 | private WordAdapter.OnItemClickLitener mOnItemClickLitener; 38 | 39 | public WordAdapter(Context context, List Data) { 40 | this.mDatas = Data; 41 | this.mContext = context; 42 | this.mGson = new Gson(); 43 | try { 44 | mCache = ACache.get(mContext); 45 | }catch (Exception e){ 46 | //子线程未销毁可能时执行 47 | } 48 | 49 | } 50 | public void setOnItemClickLitener(WordAdapter.OnItemClickLitener mOnItemClickLitener) { 51 | this.mOnItemClickLitener = mOnItemClickLitener; 52 | } 53 | 54 | @Override 55 | public WordAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 56 | WordAdapter.MyViewHolder holder = new WordAdapter.MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_word, parent, 57 | false)); 58 | return holder; 59 | } 60 | 61 | @Override 62 | public void onBindViewHolder(final WordAdapter.MyViewHolder holder, final int position) { 63 | holder.tv.setText(mDatas.get(position).getName()); 64 | 65 | // 如果设置了回调,则设置点击事件 66 | if (mOnItemClickLitener != null) { 67 | holder.mLayout.setOnClickListener(new View.OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | int pos = holder.getLayoutPosition(); 71 | mOnItemClickLitener.onItemClick(holder.mLayout, pos); 72 | 73 | String path = mDatas.get(pos).getPath(); 74 | Intent intent = FileUtil.openFile(path); 75 | mContext.startActivity(intent); 76 | } 77 | }); 78 | 79 | holder.mLayout.setOnLongClickListener(new View.OnLongClickListener() { 80 | @Override 81 | public boolean onLongClick(View v) { 82 | final String items[] = {"重命名文件", "文件详情","分享"}; 83 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); //先得到构造器 84 | builder.setItems(items, new DialogInterface.OnClickListener() { 85 | @Override 86 | public void onClick(DialogInterface dialog, int which) { 87 | //dialog.dismiss(); 88 | if (which == 0) { 89 | ReName(position); 90 | } else if (which == 1) 91 | ShowDetial(position); 92 | else if (which ==2) { 93 | Intent intent = new Intent(Intent.ACTION_SEND); 94 | intent.setType("application/vnd.android.package-archive"); 95 | Uri uri = Uri.fromFile(mDatas.get(position)); intent.putExtra(Intent.EXTRA_STREAM, uri); 96 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 97 | mContext.startActivity(Intent.createChooser(intent,"分享到")); 98 | } 99 | } 100 | }); 101 | builder.create().show(); 102 | return false; 103 | } 104 | }); 105 | 106 | holder.file_word_delete.setOnClickListener(new View.OnClickListener() { 107 | @Override 108 | public void onClick(View v) { 109 | int pos = holder.getLayoutPosition(); 110 | mOnItemClickLitener.onItemClick(holder.tv, pos); 111 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 112 | builder.setTitle("确认删除"); 113 | builder.setMessage("是否确认删除该文件"); 114 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 115 | @Override 116 | public void onClick(DialogInterface dialog, int which) { 117 | 118 | } 119 | }); 120 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 121 | @Override 122 | public void onClick(DialogInterface dialog, int which) { 123 | removeData(holder.getAdapterPosition()); 124 | } 125 | }); 126 | AlertDialog dialog = builder.create(); 127 | dialog.show(); 128 | 129 | synchronized (this) { 130 | this.notify(); 131 | } 132 | } 133 | }); 134 | 135 | } 136 | } 137 | @Override 138 | public int getItemCount() { 139 | return mDatas.size(); 140 | } 141 | 142 | private void removeData(int position) { 143 | String path = mDatas.get(position).getAbsolutePath(); 144 | FileUtils.deleteFile(path); 145 | 146 | for (int i = 0; i < mDatas.size(); i++) { 147 | String s = String.valueOf(i); 148 | mCache.remove(s+"word"); 149 | } 150 | 151 | mDatas.remove(position); 152 | notifyItemRemoved(position); 153 | notifyItemRangeChanged(position,position+1); 154 | 155 | //reset all catch 156 | ArrayList strings = new ArrayList<>(); 157 | for (int i = 0; i < mDatas.size(); i++) { 158 | String s = mGson.toJson(mDatas.get(i)); 159 | strings.add(s); 160 | } 161 | for (int i = 0; i < strings.size(); i++) { 162 | String s = String.valueOf(i); 163 | mCache.put(s+"word", strings.get(i), ACache.TIME_DAY); 164 | } 165 | } 166 | 167 | public interface OnItemClickLitener { 168 | void onItemClick(View view, int position); 169 | 170 | void onItemLongClick(View view, int position); 171 | } 172 | 173 | private void ReName(final int position) { 174 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 175 | final EditText userId = new EditText(mContext); 176 | builder.setTitle("请输入新命名:") 177 | .setCancelable(false) 178 | .setNegativeButton("取消", null) 179 | .setPositiveButton("确定", new DialogInterface.OnClickListener() { 180 | @Override 181 | public void onClick(DialogInterface dialogInterface, int i) { 182 | String newName = userId.getText().toString().trim(); 183 | if (newName.equals("")) { 184 | Toast.makeText(mContext, "输入不能为空", Toast.LENGTH_SHORT).show(); 185 | } else { 186 | //重命名File 187 | FileUtils.rename(mDatas.get(position), newName + ".txt"); 188 | 189 | //更新显示数据 190 | String path = mDatas.get(position).getParent(); 191 | File file = new File(path + "/" + newName + ".txt"); 192 | mDatas.remove(position); 193 | mDatas.add(position, file); 194 | notifyDataSetChanged(); 195 | Toast.makeText(mContext, "重命名文件成功", Toast.LENGTH_SHORT).show(); 196 | 197 | //更新缓存 198 | String s = String.valueOf(position); 199 | String name = "{\"path\":\"" + file.getAbsolutePath() + "\"}"; 200 | mCache.put(s + "word", name); 201 | 202 | } 203 | } 204 | }) 205 | .setView(userId, 150, 20, 70, 20) 206 | .show(); 207 | } 208 | 209 | private void ShowDetial(int position) { 210 | File file = mDatas.get(position); 211 | String size = FileUtils.getFileSize(file); 212 | String name = file.getName(); 213 | String path = file.getAbsolutePath(); 214 | String time = TimeUtils.milliseconds2String(file.lastModified()); 215 | 216 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 217 | builder.setTitle("文件属性") 218 | .setCancelable(false) 219 | .setNegativeButton("确定", null) 220 | .setMessage("\n" + "文件名:" + name + "\n\n" + "文件大小:" + size + "\n\n" + "文件路径:" + 221 | path + "\n\n" + "时间:" + time ) 222 | .show(); 223 | 224 | } 225 | 226 | class MyViewHolder extends RecyclerView.ViewHolder { 227 | TextView tv, file_word_delete; 228 | LinearLayout mLayout; 229 | public MyViewHolder(View view) { 230 | super(view); 231 | tv = (TextView) view.findViewById(R.id.item_word_name); 232 | mLayout = (LinearLayout)view.findViewById(R.id.word_linear); 233 | file_word_delete = (TextView) view.findViewById(R.id.file_word_delete); 234 | } 235 | } 236 | } 237 | 238 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/adapter/ZipAdapter.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.support.v7.app.AlertDialog; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.EditText; 13 | import android.widget.LinearLayout; 14 | import android.widget.TextView; 15 | import android.widget.Toast; 16 | 17 | import com.blankj.utilcode.utils.FileUtils; 18 | import com.blankj.utilcode.utils.TimeUtils; 19 | import com.fileManager.R; 20 | import com.fileManager.util.ACache; 21 | import com.fileManager.util.FileUtil; 22 | import com.google.gson.Gson; 23 | 24 | import java.io.File; 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | /** 29 | * Created by 齐泽威 on 2016/12/7. 30 | */ 31 | 32 | public class ZipAdapter extends RecyclerView.Adapter { 33 | private List mDatas; 34 | private Context mContext; 35 | private ACache mCache; 36 | private Gson mGson; 37 | private ZipAdapter.OnItemClickLitener mOnItemClickLitener; 38 | 39 | 40 | public ZipAdapter(Context context, List Data) { 41 | this.mDatas = Data; 42 | this.mContext = context; 43 | this.mGson = new Gson(); 44 | try { 45 | mCache = ACache.get(mContext); 46 | }catch (Exception e){ 47 | //子线程未销毁可能时执行 48 | } 49 | } 50 | 51 | public void setOnItemClickLitener(ZipAdapter.OnItemClickLitener mOnItemClickLitener) { 52 | this.mOnItemClickLitener = mOnItemClickLitener; 53 | } 54 | 55 | @Override 56 | public ZipAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 57 | ZipAdapter.MyViewHolder holder = new ZipAdapter.MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_zip, parent, 58 | false)); 59 | return holder; 60 | } 61 | 62 | @Override 63 | public void onBindViewHolder(final ZipAdapter.MyViewHolder holder, final int position) { 64 | holder.tv.setText(mDatas.get(position).getName()); 65 | 66 | // 如果设置了回调,则设置点击事件 67 | if (mOnItemClickLitener != null) { 68 | holder.mLayout.setOnClickListener(new View.OnClickListener() { 69 | @Override 70 | public void onClick(View v) { 71 | int pos = holder.getLayoutPosition(); 72 | mOnItemClickLitener.onItemClick(holder.mLayout, pos); 73 | 74 | String path = mDatas.get(pos).getPath(); 75 | Intent intent = FileUtil.openFile(path); 76 | mContext.startActivity(intent); 77 | } 78 | }); 79 | holder.mLayout.setOnLongClickListener(new View.OnLongClickListener() { 80 | @Override 81 | public boolean onLongClick(View v) { 82 | final String items[] = {"重命名文件", "文件详情","分享"}; 83 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); //先得到构造器 84 | builder.setItems(items, new DialogInterface.OnClickListener() { 85 | @Override 86 | public void onClick(DialogInterface dialog, int which) { 87 | //dialog.dismiss(); 88 | if (which == 0) { 89 | ReName(position); 90 | } else if (which == 1) 91 | ShowDetial(position); 92 | else if (which ==2) { 93 | Intent intent = new Intent(Intent.ACTION_SEND); 94 | intent.setType("application/vnd.android.package-archive"); 95 | Uri uri = Uri.fromFile(mDatas.get(position)); intent.putExtra(Intent.EXTRA_STREAM, uri); 96 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 97 | mContext.startActivity(Intent.createChooser(intent,"分享到")); 98 | } 99 | } 100 | }); 101 | builder.create().show(); 102 | return false; 103 | } 104 | }); 105 | 106 | holder.file_zip_delete.setOnClickListener(new View.OnClickListener() { 107 | @Override 108 | public void onClick(View v) { 109 | int pos = holder.getLayoutPosition(); 110 | mOnItemClickLitener.onItemClick(holder.tv, pos); 111 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 112 | builder.setTitle("确认删除"); 113 | builder.setMessage("是否确认删除该文件"); 114 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 115 | @Override 116 | public void onClick(DialogInterface dialog, int which) { 117 | 118 | } 119 | }); 120 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 121 | @Override 122 | public void onClick(DialogInterface dialog, int which) { 123 | removeData(holder.getAdapterPosition()); 124 | } 125 | }); 126 | AlertDialog dialog = builder.create(); 127 | dialog.show(); 128 | 129 | synchronized (this) { 130 | this.notify(); 131 | } 132 | } 133 | }); 134 | 135 | } 136 | } 137 | 138 | @Override 139 | public int getItemCount() { 140 | return mDatas.size(); 141 | } 142 | 143 | private void removeData(int position) { 144 | String path = mDatas.get(position).getAbsolutePath(); 145 | FileUtils.deleteFile(path); 146 | 147 | for (int i = 0; i < mDatas.size(); i++) { 148 | String s = String.valueOf(i); 149 | mCache.remove(s+"zip"); 150 | } 151 | 152 | mDatas.remove(position); 153 | notifyItemRemoved(position); 154 | notifyItemRangeChanged(position,position+1); 155 | //reset all catch 156 | ArrayList strings = new ArrayList<>(); 157 | for (int i = 0; i < mDatas.size(); i++) { 158 | String s = mGson.toJson(mDatas.get(i)); 159 | strings.add(s); 160 | } 161 | for (int i = 0; i < strings.size(); i++) { 162 | String s = String.valueOf(i); 163 | mCache.put(s+"zip", strings.get(i), ACache.TIME_DAY); 164 | } 165 | } 166 | 167 | public interface OnItemClickLitener { 168 | void onItemClick(View view, int position); 169 | 170 | void onItemLongClick(View view, int position); 171 | } 172 | 173 | private void ReName(final int position) { 174 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 175 | final EditText userId = new EditText(mContext); 176 | builder.setTitle("请输入新命名:") 177 | .setCancelable(false) 178 | .setNegativeButton("取消", null) 179 | .setPositiveButton("确定", new DialogInterface.OnClickListener() { 180 | @Override 181 | public void onClick(DialogInterface dialogInterface, int i) { 182 | String newName = userId.getText().toString().trim(); 183 | if (newName.equals("")) { 184 | Toast.makeText(mContext, "输入不能为空", Toast.LENGTH_SHORT).show(); 185 | } else { 186 | //重命名File 187 | FileUtils.rename(mDatas.get(position), newName + ".zip"); 188 | 189 | //更新显示数据 190 | String path = mDatas.get(position).getParent(); 191 | File file = new File(path + "/" + newName + ".zip"); 192 | mDatas.remove(position); 193 | mDatas.add(position, file); 194 | notifyDataSetChanged(); 195 | Toast.makeText(mContext, "重命名文件成功", Toast.LENGTH_SHORT).show(); 196 | 197 | //更新缓存 198 | String s = String.valueOf(position); 199 | String name = "{\"path\":\"" + file.getAbsolutePath() + "\"}"; 200 | mCache.put(s + "zip", name); 201 | 202 | } 203 | } 204 | }) 205 | .setView(userId, 150, 20, 70, 20) 206 | .show(); 207 | } 208 | 209 | private void ShowDetial(int position) { 210 | File file = mDatas.get(position); 211 | String size = FileUtils.getFileSize(file); 212 | String name = file.getName(); 213 | String path = file.getAbsolutePath(); 214 | String time = TimeUtils.milliseconds2String(file.lastModified()); 215 | 216 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); 217 | builder.setTitle("文件属性") 218 | .setCancelable(false) 219 | .setNegativeButton("确定", null) 220 | .setMessage("\n" + "文件名:" + name + "\n\n" + "文件大小:" + size + "\n\n" + "文件路径:" + 221 | path + "\n\n" + "时间:" + time ) 222 | .show(); 223 | 224 | } 225 | 226 | 227 | class MyViewHolder extends RecyclerView.ViewHolder { 228 | TextView tv, file_zip_delete; 229 | LinearLayout mLayout; 230 | 231 | public MyViewHolder(View view) { 232 | super(view); 233 | tv = (TextView) view.findViewById(R.id.item_zip_name); 234 | file_zip_delete = (TextView) view.findViewById(R.id.file_zip_delete); 235 | mLayout = (LinearLayout) view.findViewById(R.id.zip_linear); 236 | } 237 | } 238 | } 239 | 240 | 241 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/ApkFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Environment; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v7.widget.DefaultItemAnimator; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.support.v7.widget.StaggeredGridLayoutManager; 14 | import android.util.Log; 15 | import android.view.LayoutInflater; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.widget.ImageView; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import com.blankj.utilcode.utils.FileUtils; 23 | import com.bumptech.glide.Glide; 24 | import com.fileManager.R; 25 | import com.fileManager.adapter.ApkAdapter; 26 | import com.fileManager.util.ACache; 27 | import com.google.gson.Gson; 28 | import com.umeng.analytics.MobclickAgent; 29 | import com.yalantis.taurus.PullToRefreshView; 30 | 31 | import java.io.File; 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | 35 | /** 36 | * A simple {@link Fragment} subclass. 37 | */ 38 | public class ApkFragment extends Fragment { 39 | private RecyclerView mRecyclerView; 40 | private List mFiles; 41 | private ApkAdapter mAdapter; 42 | private Gson mGson; 43 | private ImageView mLoading; 44 | private TextView mLoadingText; 45 | private ACache mCatch; 46 | private SharedPreferences mPreferences; 47 | private PullToRefreshView mPullToRefreshView; 48 | 49 | private Handler myHandler = new Handler() { 50 | public void handleMessage(Message msg) { 51 | switch (msg.what) { 52 | case 1: 53 | mRecyclerView.setAdapter(mAdapter = new ApkAdapter(getContext(), mFiles)); 54 | mLoading.setVisibility(View.INVISIBLE); 55 | mLoadingText.setVisibility(View.INVISIBLE); 56 | mPullToRefreshView.setVisibility(View.VISIBLE); 57 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 58 | mAdapter.setOnItemClickLitener(new ApkAdapter.OnItemClickLitener() { 59 | @Override 60 | public void onItemClick(View view, int position) { 61 | } 62 | 63 | @Override 64 | public void onItemLongClick(View view, int position) { 65 | } 66 | }); 67 | break; 68 | } 69 | super.handleMessage(msg); 70 | } 71 | }; 72 | 73 | 74 | public ApkFragment() { 75 | // Required empty public constructor 76 | } 77 | 78 | 79 | @Override 80 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 81 | Bundle savedInstanceState) { 82 | // Inflate the layout for this fragment 83 | View ret = inflater.inflate(R.layout.fragment_apk, container, false); 84 | 85 | TextView title = (TextView) ret.findViewById(R.id.title); 86 | title.setText("安装包"); 87 | ImageView reicon = (ImageView)ret.findViewById(R.id.return_index); 88 | reicon.setOnClickListener(new View.OnClickListener() { 89 | @Override 90 | public void onClick(View v) { 91 | getActivity().finish(); 92 | } 93 | }); 94 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif); 95 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 96 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 97 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 98 | mPullToRefreshView = (PullToRefreshView) ret.findViewById(R.id.pull_to_refresh); 99 | 100 | Glide.with(getContext()).load(R.drawable.loading) 101 | .asGif().into(mLoading); 102 | mFiles = new ArrayList<>(); 103 | mGson = new Gson(); 104 | mCatch = ACache.get(getContext()); 105 | mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)); 106 | 107 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 108 | @Override 109 | public void onRefresh() { 110 | new Thread(new Runnable() { 111 | @Override 112 | public void run() { 113 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".apk"); 114 | addCatch(); 115 | try{ 116 | getActivity().runOnUiThread(new Runnable() { 117 | @Override 118 | public void run() { 119 | mAdapter.notifyDataSetChanged(); 120 | mPullToRefreshView.setRefreshing(false); 121 | onCreate(null); 122 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 123 | } 124 | });} 125 | catch (Exception e){ 126 | 127 | } 128 | } 129 | }).start(); 130 | 131 | } 132 | }); 133 | initDate(); 134 | return ret; 135 | } 136 | 137 | private void initDate() { 138 | //开线程初始化数据 139 | new Thread(new Runnable() { 140 | @Override 141 | public void run() { 142 | judge(); 143 | Message message = new Message(); 144 | message.what = 1; 145 | myHandler.sendMessage(message); 146 | } 147 | }).start(); 148 | } 149 | 150 | private void judge() { 151 | try { 152 | mPreferences = getContext().getSharedPreferences("table", Context.MODE_PRIVATE); 153 | } catch (Exception e) { 154 | //子线程未销毁可能时执行 155 | } 156 | 157 | boolean first = mPreferences.getBoolean("firstApk", true); 158 | int num = mPreferences.getInt("numApk", 0); 159 | 160 | long time = mPreferences.getLong("ApkTime", 0); 161 | long cha = System.currentTimeMillis() - time; 162 | //判断缓存时间是否过期 163 | 164 | if (!first && time != 0 & cha < 86400000) { 165 | for (int i = 0; i < num; i++) { 166 | String s = String.valueOf(i); 167 | String string = mCatch.getAsString(s + "apk"); 168 | if (string!=null) { 169 | Log.d("aaa", "judge: ++++++++==" ); 170 | File file = mGson.fromJson(string, File.class); 171 | mFiles.add(file); 172 | } 173 | 174 | } 175 | } else { 176 | 177 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".apk"); 178 | addCatch(); 179 | } 180 | } 181 | 182 | private void addCatch() { 183 | ArrayList strings = new ArrayList<>(); 184 | for (int i = 0; i < mFiles.size(); i++) { 185 | String s = mGson.toJson(mFiles.get(i)); 186 | strings.add(s); 187 | } 188 | for (int i = 0; i < strings.size(); i++) { 189 | String s = String.valueOf(i); 190 | mCatch.put(s + "apk", strings.get(i), ACache.TIME_DAY); 191 | } 192 | 193 | SharedPreferences.Editor edit = mPreferences.edit(); 194 | edit.putBoolean("firstApk", false); 195 | edit.putInt("numApk", strings.size()); 196 | edit.putLong("ApkTime", System.currentTimeMillis()); 197 | edit.commit(); 198 | } 199 | 200 | public void onResume() { 201 | super.onResume(); 202 | MobclickAgent.onPageStart("APK_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 203 | } 204 | 205 | public void onPause() { 206 | super.onPause(); 207 | MobclickAgent.onPageEnd("APK_Fragment"); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/FileNameFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.os.Environment; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v4.widget.SwipeRefreshLayout; 10 | import android.support.v7.widget.DefaultItemAnimator; 11 | import android.support.v7.widget.LinearLayoutManager; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.util.Log; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.blankj.utilcode.utils.FileUtils; 22 | import com.bumptech.glide.Glide; 23 | import com.fileManager.R; 24 | import com.fileManager.adapter.FileNameAdapter; 25 | import com.fileManager.util.FileUtil; 26 | import com.umeng.analytics.MobclickAgent; 27 | 28 | import java.io.File; 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | /** 33 | * A simple {@link Fragment} subclass. 34 | */ 35 | public class FileNameFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { 36 | private RecyclerView mRecyclerView; 37 | private List mFiles; 38 | private FileNameAdapter mAdapter; 39 | private SwipeRefreshLayout mRefreshLayout; 40 | private ImageView mLoading; 41 | private TextView mLoadingText; 42 | private String filename; 43 | private TextView noSearch; 44 | private Handler myHandler = new Handler() { 45 | public void handleMessage(Message msg) { 46 | switch (msg.what) { 47 | case 1: 48 | mRecyclerView.setAdapter(mAdapter = new FileNameAdapter(getContext(), mFiles)); 49 | mLoading.setVisibility(View.INVISIBLE); 50 | mLoadingText.setVisibility(View.INVISIBLE); 51 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 52 | mAdapter.setOnItemClickLitener(new FileNameAdapter.OnItemClickLitener() { 53 | @Override 54 | public void onItemClick(View view, int position) { 55 | } 56 | 57 | @Override 58 | public void onItemLongClick(View view, int position) { 59 | } 60 | }); 61 | break; 62 | case 0: 63 | mLoading.setVisibility(View.INVISIBLE); 64 | mLoadingText.setVisibility(View.INVISIBLE); 65 | noSearch.setVisibility(View.VISIBLE); 66 | break; 67 | } 68 | super.handleMessage(msg); 69 | } 70 | }; 71 | 72 | 73 | public FileNameFragment() { 74 | // Required empty public constructor 75 | } 76 | 77 | 78 | @Override 79 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 80 | Bundle savedInstanceState) { 81 | // Inflate the layout for this fragment 82 | View ret = inflater.inflate(R.layout.fragment_file_name, container, false); 83 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif_1); 84 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 85 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 86 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 87 | mRefreshLayout = (SwipeRefreshLayout) ret.findViewById(R.id.filename_refresh); 88 | noSearch = (TextView)ret.findViewById(R.id.no_search); 89 | Glide.with(getContext()).load(R.drawable.loading) 90 | .asGif().into(mLoading); 91 | mFiles = new ArrayList<>(); 92 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 93 | mRefreshLayout.setColorSchemeResources(R.color.colorPrimary); 94 | mRefreshLayout.setOnRefreshListener(this); 95 | initDate(); 96 | return ret; 97 | } 98 | 99 | private void initDate() { 100 | //开线程初始化数据 101 | new Thread(new Runnable() { 102 | @Override 103 | public void run() { 104 | filename = getActivity().getIntent().getStringExtra("filename"); 105 | mFiles = FileUtil.searchFileInDir(Environment.getExternalStorageDirectory(),filename); 106 | Log.d("aaa", "run: "+ mFiles.size()); 107 | 108 | Message message = new Message(); 109 | if (mFiles.size()==0) { 110 | message.what = 0; 111 | }else 112 | message.what = 1; 113 | myHandler.sendMessage(message); 114 | } 115 | }).start(); 116 | } 117 | 118 | 119 | @Override 120 | public void onRefresh() { 121 | new Thread(new Runnable() { 122 | @Override 123 | public void run() { 124 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), filename); 125 | getActivity().runOnUiThread(new Runnable() { 126 | @Override 127 | public void run() { 128 | 129 | mAdapter.notifyDataSetChanged(); 130 | mRefreshLayout.setRefreshing(false); 131 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 132 | } 133 | }); 134 | } 135 | }).start(); 136 | 137 | } 138 | 139 | public void onResume() { 140 | super.onResume(); 141 | MobclickAgent.onPageStart("NameSearch_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 142 | } 143 | 144 | public void onPause() { 145 | super.onPause(); 146 | MobclickAgent.onPageEnd("NameSearch_Fragmenn"); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/FileTypeFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.os.Environment; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v4.widget.SwipeRefreshLayout; 10 | import android.support.v7.widget.DefaultItemAnimator; 11 | import android.support.v7.widget.LinearLayoutManager; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.util.Log; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.blankj.utilcode.utils.FileUtils; 22 | import com.bumptech.glide.Glide; 23 | import com.fileManager.R; 24 | import com.fileManager.adapter.FileNameAdapter; 25 | import com.umeng.analytics.MobclickAgent; 26 | 27 | import java.io.File; 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | 31 | 32 | 33 | /** 34 | * A simple {@link Fragment} subclass. 35 | */ 36 | public class FileTypeFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { 37 | private RecyclerView mRecyclerView; 38 | private List mFiles; 39 | private FileNameAdapter mAdapter; 40 | private SwipeRefreshLayout mRefreshLayout; 41 | private ImageView mLoading; 42 | private TextView mLoadingText; 43 | private String filetype; 44 | private TextView noSearch; 45 | private Handler myHandler = new Handler() { 46 | public void handleMessage(Message msg) { 47 | switch (msg.what) { 48 | case 1: 49 | mRecyclerView.setAdapter(mAdapter = new FileNameAdapter(getContext(), mFiles)); 50 | mLoading.setVisibility(View.INVISIBLE); 51 | mLoadingText.setVisibility(View.INVISIBLE); 52 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 53 | mAdapter.setOnItemClickLitener(new FileNameAdapter.OnItemClickLitener() { 54 | @Override 55 | public void onItemClick(View view, int position) { 56 | } 57 | 58 | @Override 59 | public void onItemLongClick(View view, int position) { 60 | } 61 | }); 62 | break; 63 | case 0: 64 | mLoading.setVisibility(View.INVISIBLE); 65 | mLoadingText.setVisibility(View.INVISIBLE); 66 | noSearch.setVisibility(View.VISIBLE); 67 | break; 68 | } 69 | super.handleMessage(msg); 70 | } 71 | }; 72 | 73 | 74 | public FileTypeFragment() { 75 | 76 | } 77 | 78 | 79 | @Override 80 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 81 | Bundle savedInstanceState) { 82 | // Required empty public constructor 83 | View ret = inflater.inflate(R.layout.fragment_file_type, container, false); 84 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif_2); 85 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 86 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 87 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 88 | mRefreshLayout = (SwipeRefreshLayout) ret.findViewById(R.id.filename_refresh); 89 | noSearch = (TextView) ret.findViewById(R.id.no_search); 90 | Glide.with(getContext()).load(R.drawable.loading) 91 | .asGif().into(mLoading); 92 | mFiles = new ArrayList<>(); 93 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 94 | mRefreshLayout.setColorSchemeResources(R.color.colorPrimary); 95 | mRefreshLayout.setOnRefreshListener(this); 96 | initDate(); 97 | return ret; 98 | } 99 | 100 | private void initDate() { 101 | //开线程初始化数据 102 | new Thread(new Runnable() { 103 | @Override 104 | public void run() { 105 | filetype = getActivity().getIntent().getStringExtra("filetype"); 106 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), "." + filetype); 107 | 108 | Log.d("aaa", "run: " + mFiles.size()); 109 | 110 | Message message = new Message(); 111 | if (mFiles.size() == 0) { 112 | message.what = 0; 113 | } else 114 | message.what = 1; 115 | myHandler.sendMessage(message); 116 | } 117 | }).start(); 118 | } 119 | 120 | 121 | @Override 122 | public void onRefresh() { 123 | new Thread(new Runnable() { 124 | @Override 125 | public void run() { 126 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), "." + filetype); 127 | getActivity().runOnUiThread(new Runnable() { 128 | @Override 129 | public void run() { 130 | 131 | mAdapter.notifyDataSetChanged(); 132 | mRefreshLayout.setRefreshing(false); 133 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 134 | } 135 | }); 136 | } 137 | }).start(); 138 | } 139 | 140 | public void onResume() { 141 | super.onResume(); 142 | MobclickAgent.onPageStart("TypeScreen_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 143 | } 144 | 145 | public void onPause() { 146 | super.onPause(); 147 | MobclickAgent.onPageEnd("TypeSearch_Fragment"); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/ImageFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Environment; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v7.widget.DefaultItemAnimator; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.support.v7.widget.StaggeredGridLayoutManager; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.blankj.utilcode.utils.FileUtils; 22 | import com.bumptech.glide.Glide; 23 | import com.fileManager.R; 24 | import com.fileManager.adapter.ImageAdapter; 25 | import com.fileManager.util.ACache; 26 | import com.google.gson.Gson; 27 | import com.umeng.analytics.MobclickAgent; 28 | import com.yalantis.taurus.PullToRefreshView; 29 | 30 | import java.io.File; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | 35 | /** 36 | * A simple {@link Fragment} subclass. 37 | */ 38 | public class ImageFragment extends Fragment { 39 | private RecyclerView mRecyclerView; 40 | private List mFiles; 41 | private ImageAdapter mAdapter; 42 | private Gson mGson; 43 | private ImageView mLoading; 44 | private TextView mLoadingText; 45 | private ACache mCatch; 46 | private SharedPreferences mPreferences; 47 | private PullToRefreshView mPullToRefreshView; 48 | 49 | private Handler myHandler = new Handler() { 50 | public void handleMessage(Message msg) { 51 | switch (msg.what) { 52 | case 1: 53 | mRecyclerView.setAdapter(mAdapter = new ImageAdapter(getContext(), mFiles)); 54 | mLoading.setVisibility(View.INVISIBLE); 55 | mLoadingText.setVisibility(View.INVISIBLE); 56 | mPullToRefreshView.setVisibility(View.VISIBLE); 57 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 58 | mAdapter.setOnItemClickLitener(new ImageAdapter.OnItemClickLitener() { 59 | @Override 60 | public void onItemClick(View view, int position) { 61 | } 62 | 63 | @Override 64 | public void onItemLongClick(View view, int position) { 65 | } 66 | }); 67 | break; 68 | } 69 | super.handleMessage(msg); 70 | } 71 | }; 72 | 73 | 74 | public ImageFragment() { 75 | // Required empty public constructor 76 | } 77 | 78 | @Override 79 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 80 | Bundle savedInstanceState) { 81 | // Inflate the layout for this fragment 82 | View ret = inflater.inflate(R.layout.fragment_image, container, false); 83 | 84 | TextView title = (TextView) ret.findViewById(R.id.title); 85 | title.setText("图片"); 86 | ImageView reicon = (ImageView)ret.findViewById(R.id.return_index); 87 | reicon.setOnClickListener(new View.OnClickListener() { 88 | @Override 89 | public void onClick(View v) { 90 | getActivity().finish(); 91 | } 92 | }); 93 | 94 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif); 95 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 96 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 97 | mPullToRefreshView = (PullToRefreshView) ret.findViewById(R.id.pull_to_refresh); 98 | Glide.with(getContext()).load(R.drawable.loading) 99 | .asGif().into(mLoading); 100 | mFiles = new ArrayList<>(); 101 | mGson = new Gson(); 102 | mCatch = ACache.get(getContext()); 103 | 104 | mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)); 105 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 106 | @Override 107 | public void onRefresh() { 108 | new Thread(new Runnable() { 109 | @Override 110 | public void run() { 111 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".jpg"); 112 | addCatch(); 113 | try { 114 | getActivity().runOnUiThread(new Runnable() { 115 | @Override 116 | public void run() { 117 | mAdapter.notifyDataSetChanged(); 118 | mPullToRefreshView.setRefreshing(false); 119 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 120 | } 121 | }); 122 | } catch (Exception e) { 123 | } 124 | } 125 | }).start(); 126 | 127 | } 128 | }); 129 | 130 | initData(); 131 | return ret; 132 | } 133 | 134 | 135 | private void initData() { 136 | //开线程初始化数据 137 | 138 | new Thread(new Runnable() { 139 | 140 | @Override 141 | public void run() { 142 | judge(); 143 | Message message = new Message(); 144 | message.what = 1; 145 | myHandler.sendMessage(message); 146 | } 147 | }).start(); 148 | } 149 | 150 | /** 151 | * 判断缓存是否存在,初始化数据 152 | */ 153 | private void judge() { 154 | try { 155 | mPreferences = getContext().getSharedPreferences("table", Context.MODE_PRIVATE); 156 | } catch (Exception e) { 157 | //子线程未销毁可能时执行 158 | } 159 | boolean first = mPreferences.getBoolean("firstImage", true); 160 | int num = mPreferences.getInt("numImage", 0); 161 | 162 | long time = mPreferences.getLong("ImageTime", 0); 163 | long cha = System.currentTimeMillis() - time; 164 | //判断缓存时间是否过期 165 | 166 | if (!first && time != 0 & cha < 86400000) { 167 | for (int i = 0; i < num; i++) { 168 | String s = String.valueOf(i); 169 | String string = mCatch.getAsString(s); 170 | if (string!=null) { 171 | File file = mGson.fromJson(string, File.class); 172 | mFiles.add(file); 173 | } 174 | 175 | } 176 | } else { 177 | 178 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".jpg"); 179 | addCatch(); 180 | } 181 | } 182 | 183 | /** 184 | * 添加缓存 185 | */ 186 | public void addCatch() { 187 | 188 | ArrayList strings = new ArrayList<>(); 189 | for (int i = 0; i < mFiles.size(); i++) { 190 | String s = mGson.toJson(mFiles.get(i)); 191 | strings.add(s); 192 | } 193 | for (int i = 0; i < strings.size(); i++) { 194 | String s = String.valueOf(i); 195 | mCatch.put(s, strings.get(i), ACache.TIME_DAY); 196 | } 197 | 198 | 199 | SharedPreferences.Editor edit = mPreferences.edit(); 200 | edit.putBoolean("firstImage", false); 201 | edit.putInt("numImage", strings.size()); 202 | edit.putLong("ImageTime", System.currentTimeMillis()); 203 | edit.commit(); 204 | } 205 | 206 | public void onResume() { 207 | super.onResume(); 208 | MobclickAgent.onPageStart("Image_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 209 | } 210 | 211 | public void onPause() { 212 | super.onPause(); 213 | MobclickAgent.onPageEnd("Image_Fragment"); 214 | } 215 | 216 | } -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/MusicFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Environment; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v7.widget.DefaultItemAnimator; 12 | import android.support.v7.widget.RecyclerView; 13 | import android.support.v7.widget.StaggeredGridLayoutManager; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.blankj.utilcode.utils.FileUtils; 22 | import com.bumptech.glide.Glide; 23 | import com.fileManager.R; 24 | import com.fileManager.adapter.MusicAdapter; 25 | import com.fileManager.util.ACache; 26 | import com.google.gson.Gson; 27 | import com.umeng.analytics.MobclickAgent; 28 | import com.yalantis.taurus.PullToRefreshView; 29 | 30 | import java.io.File; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | /** 35 | * A simple {@link Fragment} subclass. 36 | */ 37 | public class MusicFragment extends Fragment { 38 | private RecyclerView mRecyclerView; 39 | private List mFiles; 40 | private MusicAdapter mAdapter; 41 | private Gson mGson; 42 | private ImageView mLoading; 43 | private TextView mLoadingText; 44 | private ACache mCatch; 45 | private SharedPreferences mPreferences; 46 | private PullToRefreshView mPullToRefreshView; 47 | 48 | private Handler myHandler = new Handler() { 49 | public void handleMessage(Message msg) { 50 | switch (msg.what) { 51 | case 1: 52 | mRecyclerView.setAdapter(mAdapter = new MusicAdapter(getContext(), mFiles)); 53 | mLoading.setVisibility(View.INVISIBLE); 54 | mLoadingText.setVisibility(View.INVISIBLE); 55 | mPullToRefreshView.setVisibility(View.VISIBLE); 56 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 57 | mAdapter.setOnItemClickLitener(new MusicAdapter.OnItemClickLitener() { 58 | @Override 59 | public void onItemClick(View view, int position) { 60 | } 61 | 62 | @Override 63 | public void onItemLongClick(View view, int position) { 64 | } 65 | }); 66 | break; 67 | } 68 | super.handleMessage(msg); 69 | } 70 | }; 71 | 72 | 73 | public MusicFragment() { 74 | // Required empty public constructor 75 | } 76 | 77 | 78 | @Override 79 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 80 | Bundle savedInstanceState) { 81 | // Inflate the layout for this fragment 82 | View ret = inflater.inflate(R.layout.fragment_music, container, false); 83 | 84 | TextView title = (TextView) ret.findViewById(R.id.title); 85 | title.setText("音乐"); 86 | ImageView reicon = (ImageView)ret.findViewById(R.id.return_index); 87 | reicon.setOnClickListener(new View.OnClickListener() { 88 | @Override 89 | public void onClick(View v) { 90 | getActivity().finish(); 91 | } 92 | }); 93 | 94 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif); 95 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 96 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 97 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 98 | mPullToRefreshView = (PullToRefreshView) ret.findViewById(R.id.pull_to_refresh); 99 | Glide.with(getContext()).load(R.drawable.loading) 100 | .asGif().into(mLoading); 101 | mFiles = new ArrayList<>(); 102 | mGson = new Gson(); 103 | mCatch = ACache.get(getContext()); 104 | 105 | mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)); 106 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 107 | @Override 108 | public void onRefresh() { 109 | new Thread(new Runnable() { 110 | @Override 111 | public void run() { 112 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".mp3"); 113 | addCatch(); 114 | try { 115 | getActivity().runOnUiThread(new Runnable() { 116 | @Override 117 | public void run() { 118 | 119 | mAdapter.notifyDataSetChanged(); 120 | mPullToRefreshView.setRefreshing(false); 121 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 122 | } 123 | }); 124 | }catch (Exception e){ 125 | 126 | } 127 | } 128 | }).start(); 129 | 130 | } 131 | }); 132 | initDate(); 133 | return ret; 134 | } 135 | 136 | private void initDate() { 137 | //开线程初始化数据 138 | 139 | new Thread(new Runnable() { 140 | 141 | @Override 142 | public void run() { 143 | judge(); 144 | Message message = new Message(); 145 | message.what = 1; 146 | myHandler.sendMessage(message); 147 | } 148 | }).start(); 149 | } 150 | 151 | private void judge() { 152 | try { 153 | mPreferences = getContext().getSharedPreferences("table", Context.MODE_PRIVATE); 154 | } catch (Exception e) { 155 | //子线程未销毁可能时执行 156 | } 157 | 158 | boolean first = mPreferences.getBoolean("firstMusic", true); 159 | int num = mPreferences.getInt("numMusic", 0); 160 | 161 | long time = mPreferences.getLong("MusicTime", 0); 162 | long cha = System.currentTimeMillis() - time; 163 | //判断缓存时间是否过期 164 | 165 | if (!first && time!=0 & cha<86400000) { 166 | for (int i = 0; i < num; i++) { 167 | String s = String.valueOf(i); 168 | String string = mCatch.getAsString(s + "music"); 169 | if (string!=null) { 170 | File file = mGson.fromJson(string, File.class); 171 | mFiles.add(file); 172 | } 173 | 174 | } 175 | } else { 176 | 177 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".mp3"); 178 | addCatch(); 179 | } 180 | } 181 | 182 | private void addCatch() { 183 | ArrayList strings = new ArrayList<>(); 184 | for (int i = 0; i < mFiles.size(); i++) { 185 | String s = mGson.toJson(mFiles.get(i)); 186 | strings.add(s); 187 | } 188 | for (int i = 0; i < strings.size(); i++) { 189 | String s = String.valueOf(i); 190 | mCatch.put(s + "music", strings.get(i), ACache.TIME_DAY); 191 | } 192 | 193 | 194 | SharedPreferences.Editor edit = mPreferences.edit(); 195 | edit.putBoolean("firstMusic", false); 196 | edit.putInt("numMusic", strings.size()); 197 | edit.putLong("MusicTime",System.currentTimeMillis()); 198 | edit.commit(); 199 | } 200 | 201 | public void onResume() { 202 | super.onResume(); 203 | MobclickAgent.onPageStart("Music_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 204 | } 205 | 206 | public void onPause() { 207 | super.onPause(); 208 | MobclickAgent.onPageEnd("Music_Fragment"); 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/VideoFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Environment; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v7.widget.DefaultItemAnimator; 12 | import android.support.v7.widget.LinearLayoutManager; 13 | import android.support.v7.widget.RecyclerView; 14 | import android.util.Log; 15 | import android.view.LayoutInflater; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.widget.ImageView; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import com.blankj.utilcode.utils.FileUtils; 23 | import com.bumptech.glide.Glide; 24 | import com.fileManager.R; 25 | import com.fileManager.adapter.VideoAdapter; 26 | import com.fileManager.util.ACache; 27 | import com.google.gson.Gson; 28 | import com.umeng.analytics.MobclickAgent; 29 | import com.yalantis.taurus.PullToRefreshView; 30 | 31 | import java.io.File; 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | 35 | /** 36 | * A simple {@link Fragment} subclass. 37 | */ 38 | public class VideoFragment extends Fragment { 39 | 40 | private RecyclerView mRecyclerView; 41 | private List mFiles; 42 | private VideoAdapter mAdapter; 43 | private PullToRefreshView mPullToRefreshView; 44 | private Gson mGson; 45 | private ImageView mLoading; 46 | private TextView mLoadingText; 47 | private ACache mCatch; 48 | private SharedPreferences mPreferences; 49 | 50 | private Handler myHandler = new Handler() { 51 | public void handleMessage(Message msg) { 52 | switch (msg.what) { 53 | case 1: 54 | mRecyclerView.setAdapter(mAdapter = new VideoAdapter(getContext(), mFiles)); 55 | mLoading.setVisibility(View.INVISIBLE); 56 | mLoadingText.setVisibility(View.INVISIBLE); 57 | mPullToRefreshView.setVisibility(View.VISIBLE); 58 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 59 | mAdapter.setOnItemClickLitener(new VideoAdapter.OnItemClickLitener() { 60 | @Override 61 | public void onItemClick(View view, int position) { 62 | } 63 | 64 | @Override 65 | public void onItemLongClick(View view, int position) { 66 | } 67 | }); 68 | break; 69 | } 70 | super.handleMessage(msg); 71 | } 72 | }; 73 | 74 | public VideoFragment() { 75 | // Required empty public constructor 76 | } 77 | 78 | 79 | @Override 80 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 81 | Bundle savedInstanceState) { 82 | // Inflate the layout for this fragment 83 | View ret = inflater.inflate(R.layout.fragment_video, container, false); 84 | 85 | TextView title = (TextView) ret.findViewById(R.id.title); 86 | title.setText("视频"); 87 | ImageView reicon = (ImageView)ret.findViewById(R.id.return_index); 88 | reicon.setOnClickListener(new View.OnClickListener() { 89 | @Override 90 | public void onClick(View v) { 91 | getActivity().finish(); 92 | } 93 | }); 94 | 95 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif); 96 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 97 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 98 | mPullToRefreshView = (PullToRefreshView) ret.findViewById(R.id.pull_to_refresh); 99 | Glide.with(getContext()).load(R.drawable.loading) 100 | .asGif().into(mLoading); 101 | mFiles = new ArrayList<>(); 102 | mGson = new Gson(); 103 | mCatch = ACache.get(getContext()); 104 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 105 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 106 | @Override 107 | public void onRefresh() { 108 | new Thread(new Runnable() { 109 | @Override 110 | public void run() { 111 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".mp4"); 112 | addCatch(); 113 | try { 114 | getActivity().runOnUiThread(new Runnable() { 115 | @Override 116 | public void run() { 117 | 118 | mAdapter.notifyDataSetChanged(); 119 | mPullToRefreshView.setRefreshing(false); 120 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 121 | } 122 | }); 123 | }catch (Exception e){ 124 | 125 | } 126 | } 127 | }).start(); 128 | 129 | } 130 | }); 131 | initDate(); 132 | return ret; 133 | } 134 | 135 | private void initDate() { 136 | //开线程初始化数据 137 | new Thread(new Runnable() { 138 | @Override 139 | public void run() { 140 | judge(); 141 | Message message = new Message(); 142 | message.what = 1; 143 | myHandler.sendMessage(message); 144 | } 145 | }).start(); 146 | } 147 | 148 | private void judge() { 149 | try { 150 | mPreferences = getContext().getSharedPreferences("table", Context.MODE_PRIVATE); 151 | } catch (Exception e) { 152 | //子线程未销毁可能时执行 153 | } 154 | 155 | boolean first = mPreferences.getBoolean("firstVideo", true); 156 | int num = mPreferences.getInt("numVideo", 0); 157 | 158 | long time = mPreferences.getLong("VideoTime", 0); 159 | long cha = System.currentTimeMillis() - time; 160 | //判断缓存时间是否过期 161 | 162 | if (!first && time != 0 & cha < 86400000) { 163 | for (int i = 0; i < num; i++) { 164 | String s = String.valueOf(i); 165 | String string = mCatch.getAsString(s + "video"); 166 | if (string!=null) { 167 | Log.d("aaa", "judge: " +string); 168 | File file = mGson.fromJson(string, File.class); 169 | mFiles.add(file); 170 | } 171 | } 172 | } else { 173 | 174 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".mp4"); 175 | addCatch(); 176 | } 177 | } 178 | 179 | private void addCatch() { 180 | ArrayList strings = new ArrayList<>(); 181 | for (int i = 0; i < mFiles.size(); i++) { 182 | String s = mGson.toJson(mFiles.get(i)); 183 | strings.add(s); 184 | } 185 | for (int i = 0; i < strings.size(); i++) { 186 | String s = String.valueOf(i); 187 | mCatch.put(s + "video", strings.get(i), ACache.TIME_DAY); 188 | } 189 | 190 | 191 | SharedPreferences.Editor edit = mPreferences.edit(); 192 | edit.putBoolean("firstVideo", false); 193 | edit.putInt("numVideo", strings.size()); 194 | edit.putLong("VideoTime", System.currentTimeMillis()); 195 | edit.commit(); 196 | } 197 | 198 | public void onResume() { 199 | super.onResume(); 200 | MobclickAgent.onPageStart("Video_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 201 | } 202 | 203 | public void onPause() { 204 | super.onPause(); 205 | MobclickAgent.onPageEnd("Video_Fragment"); 206 | } 207 | } -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/WordFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Environment; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v7.widget.DefaultItemAnimator; 12 | import android.support.v7.widget.LinearLayoutManager; 13 | import android.support.v7.widget.RecyclerView; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.blankj.utilcode.utils.FileUtils; 22 | import com.bumptech.glide.Glide; 23 | import com.fileManager.R; 24 | import com.fileManager.adapter.WordAdapter; 25 | import com.fileManager.util.ACache; 26 | import com.google.gson.Gson; 27 | import com.umeng.analytics.MobclickAgent; 28 | import com.yalantis.taurus.PullToRefreshView; 29 | 30 | import java.io.File; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | /** 35 | * A simple {@link Fragment} subclass. 36 | */ 37 | public class WordFragment extends Fragment{ 38 | private RecyclerView mRecyclerView; 39 | private List mFiles; 40 | private WordAdapter mAdapter; 41 | private Gson mGson; 42 | private ImageView mLoading; 43 | private TextView mLoadingText; 44 | private ACache mCatch; 45 | private SharedPreferences mPreferences; 46 | private PullToRefreshView mPullToRefreshView; 47 | 48 | 49 | private Handler myHandler = new Handler() { 50 | public void handleMessage(Message msg) { 51 | switch (msg.what) { 52 | case 1: 53 | mRecyclerView.setAdapter(mAdapter = new WordAdapter(getContext(), mFiles)); 54 | mLoading.setVisibility(View.INVISIBLE); 55 | mLoadingText.setVisibility(View.INVISIBLE); 56 | mPullToRefreshView.setVisibility(View.VISIBLE); 57 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 58 | mAdapter.setOnItemClickLitener(new WordAdapter.OnItemClickLitener() { 59 | @Override 60 | public void onItemClick(View view, int position) { 61 | } 62 | 63 | @Override 64 | public void onItemLongClick(View view, int position) { 65 | } 66 | }); 67 | break; 68 | } 69 | super.handleMessage(msg); 70 | } 71 | }; 72 | 73 | 74 | public WordFragment() { 75 | // Required empty public constructor 76 | } 77 | 78 | 79 | @Override 80 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 81 | Bundle savedInstanceState) { 82 | // Inflate the layout for this fragment 83 | View ret = inflater.inflate(R.layout.fragment_word, container, false); 84 | 85 | TextView title = (TextView) ret.findViewById(R.id.title); 86 | title.setText("文档"); 87 | ImageView reicon = (ImageView)ret.findViewById(R.id.return_index); 88 | reicon.setOnClickListener(new View.OnClickListener() { 89 | @Override 90 | public void onClick(View v) { 91 | getActivity().finish(); 92 | } 93 | }); 94 | 95 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif); 96 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 97 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 98 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 99 | mPullToRefreshView = (PullToRefreshView) ret.findViewById(R.id.pull_to_refresh); 100 | 101 | Glide.with(getContext()).load(R.drawable.loading) 102 | .asGif().into(mLoading); 103 | mFiles = new ArrayList<>(); 104 | mGson = new Gson(); 105 | mCatch = ACache.get(getContext()); 106 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 107 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 108 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 109 | @Override 110 | public void onRefresh() { 111 | new Thread(new Runnable() { 112 | @Override 113 | public void run() { 114 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".txt"); 115 | addCatch(); 116 | try{ 117 | getActivity().runOnUiThread(new Runnable() { 118 | @Override 119 | public void run() { 120 | 121 | mAdapter.notifyDataSetChanged(); 122 | mPullToRefreshView.setRefreshing(false); 123 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 124 | } 125 | });} 126 | catch (Exception e){ 127 | 128 | } 129 | } 130 | }).start(); 131 | 132 | } 133 | }); 134 | initDate(); 135 | 136 | return ret; 137 | } 138 | 139 | private void initDate() { 140 | //开线程初始化数据 141 | new Thread(new Runnable() { 142 | @Override 143 | public void run() { 144 | judge(); 145 | Message message = new Message(); 146 | message.what = 1; 147 | myHandler.sendMessage(message); 148 | } 149 | }).start(); 150 | } 151 | 152 | private void judge() { 153 | try { 154 | mPreferences = getContext().getSharedPreferences("table", Context.MODE_PRIVATE); 155 | } catch (Exception e) { 156 | //子线程未销毁可能时执行 157 | } 158 | boolean first = mPreferences.getBoolean("firstWord", true); 159 | int num = mPreferences.getInt("numWord", 0); 160 | long time = mPreferences.getLong("WordTime", 0); 161 | long cha = System.currentTimeMillis() - time; 162 | //判断缓存时间是否过期 163 | 164 | if (!first && time != 0 & cha < 86400000) { 165 | for (int i = 0; i < num; i++) { 166 | String s = String.valueOf(i); 167 | String string = mCatch.getAsString(s + "word"); 168 | if (string!=null) { 169 | File file = mGson.fromJson(string, File.class); 170 | mFiles.add(file); 171 | } 172 | 173 | } 174 | } else { 175 | 176 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".txt"); 177 | addCatch(); 178 | } 179 | } 180 | 181 | private void addCatch() { 182 | ArrayList strings = new ArrayList<>(); 183 | for (int i = 0; i < mFiles.size(); i++) { 184 | String s = mGson.toJson(mFiles.get(i)); 185 | strings.add(s); 186 | } 187 | for (int i = 0; i < strings.size(); i++) { 188 | String s = String.valueOf(i); 189 | mCatch.put(s + "word", strings.get(i), ACache.TIME_DAY); 190 | } 191 | 192 | 193 | SharedPreferences.Editor edit = mPreferences.edit(); 194 | edit.putBoolean("firstWord", false); 195 | edit.putInt("numWord", strings.size()); 196 | edit.putLong("WordTime", System.currentTimeMillis()); 197 | edit.commit(); 198 | } 199 | 200 | public void onResume() { 201 | super.onResume(); 202 | MobclickAgent.onPageStart("Word_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 203 | } 204 | 205 | public void onPause() { 206 | super.onPause(); 207 | MobclickAgent.onPageEnd("Word_Fragment"); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/fragment/ZipFragment.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.fragment; 2 | 3 | 4 | import android.content.Context; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Environment; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v7.widget.DefaultItemAnimator; 12 | import android.support.v7.widget.LinearLayoutManager; 13 | import android.support.v7.widget.RecyclerView; 14 | import android.view.LayoutInflater; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.blankj.utilcode.utils.FileUtils; 22 | import com.bumptech.glide.Glide; 23 | import com.fileManager.R; 24 | import com.fileManager.adapter.ZipAdapter; 25 | import com.fileManager.util.ACache; 26 | import com.google.gson.Gson; 27 | import com.umeng.analytics.MobclickAgent; 28 | import com.yalantis.taurus.PullToRefreshView; 29 | 30 | import java.io.File; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | /** 35 | * A simple {@link Fragment} subclass. 36 | */ 37 | public class ZipFragment extends Fragment { 38 | 39 | private RecyclerView mRecyclerView; 40 | private List mFiles; 41 | private ZipAdapter mAdapter; 42 | private Gson mGson; 43 | private ImageView mLoading; 44 | private TextView mLoadingText; 45 | private ACache mCatch; 46 | private SharedPreferences mPreferences; 47 | private PullToRefreshView mPullToRefreshView; 48 | 49 | private Handler myHandler = new Handler() { 50 | public void handleMessage(Message msg) { 51 | switch (msg.what) { 52 | case 1: 53 | mRecyclerView.setAdapter(mAdapter = new ZipAdapter(getContext(), mFiles)); 54 | mLoading.setVisibility(View.INVISIBLE); 55 | mLoadingText.setVisibility(View.INVISIBLE); 56 | mPullToRefreshView.setVisibility(View.VISIBLE); 57 | mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 58 | mAdapter.setOnItemClickLitener(new ZipAdapter.OnItemClickLitener() { 59 | @Override 60 | public void onItemClick(View view, int position) { 61 | } 62 | 63 | @Override 64 | public void onItemLongClick(View view, int position) { 65 | } 66 | }); 67 | break; 68 | } 69 | super.handleMessage(msg); 70 | } 71 | }; 72 | 73 | 74 | public ZipFragment() { 75 | // Required empty public constructor 76 | } 77 | 78 | 79 | @Override 80 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 81 | Bundle savedInstanceState) { 82 | // Inflate the layout for this fragment 83 | View ret = inflater.inflate(R.layout.fragment_zip, container, false); 84 | 85 | TextView title = (TextView) ret.findViewById(R.id.title); 86 | title.setText("压缩包"); 87 | ImageView reicon = (ImageView)ret.findViewById(R.id.return_index); 88 | reicon.setOnClickListener(new View.OnClickListener() { 89 | @Override 90 | public void onClick(View v) { 91 | getActivity().finish(); 92 | } 93 | }); 94 | mLoading = (ImageView) ret.findViewById(R.id.loading_gif); 95 | mRecyclerView = (RecyclerView) ret.findViewById(R.id.id_recyclerview); 96 | mLoadingText = (TextView) ret.findViewById(R.id.loading_text); 97 | mPullToRefreshView = (PullToRefreshView) ret.findViewById(R.id.pull_to_refresh); 98 | Glide.with(getContext()).load(R.drawable.loading) 99 | .asGif().into(mLoading); 100 | mFiles = new ArrayList<>(); 101 | mGson = new Gson(); 102 | mCatch = ACache.get(getContext()); 103 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 104 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 105 | @Override 106 | public void onRefresh() { 107 | new Thread(new Runnable() { 108 | @Override 109 | public void run() { 110 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".zip"); 111 | addCatch(); 112 | try{ 113 | getActivity().runOnUiThread(new Runnable() { 114 | @Override 115 | public void run() { 116 | 117 | mAdapter.notifyDataSetChanged(); 118 | mPullToRefreshView.setRefreshing(false); 119 | Toast.makeText(getContext(), "刷新完成", Toast.LENGTH_SHORT).show(); 120 | } 121 | });} 122 | catch (Exception e){ 123 | 124 | } 125 | } 126 | }).start(); 127 | 128 | } 129 | }); 130 | initDate(); 131 | return ret; 132 | } 133 | 134 | private void initDate() { 135 | //开线程初始化数据 136 | 137 | new Thread(new Runnable() { 138 | @Override 139 | public void run() { 140 | judge(); 141 | Message message = new Message(); 142 | message.what = 1; 143 | myHandler.sendMessage(message); 144 | } 145 | }).start(); 146 | } 147 | 148 | private void judge() { 149 | try { 150 | mPreferences = getContext().getSharedPreferences("table", Context.MODE_PRIVATE); 151 | } catch (Exception e) { 152 | //子线程未销毁可能时执行 153 | } 154 | 155 | boolean first = mPreferences.getBoolean("firstZip", true); 156 | int num = mPreferences.getInt("numZip", 0); 157 | 158 | long time = mPreferences.getLong("ZipTime", 0); 159 | long cha = System.currentTimeMillis() - time; 160 | //判断缓存时间是否过期 161 | 162 | if (!first && time != 0 & cha < 86400000) { 163 | for (int i = 0; i < num; i++) { 164 | String s = String.valueOf(i); 165 | String string = mCatch.getAsString(s + "zip"); 166 | if (string!=null) { 167 | File file = mGson.fromJson(string, File.class); 168 | mFiles.add(file); 169 | } 170 | 171 | } 172 | } else { 173 | 174 | mFiles = FileUtils.listFilesInDirWithFilter(Environment.getExternalStorageDirectory(), ".zip"); 175 | addCatch(); 176 | } 177 | } 178 | 179 | private void addCatch() { 180 | ArrayList strings = new ArrayList<>(); 181 | for (int i = 0; i < mFiles.size(); i++) { 182 | String s = mGson.toJson(mFiles.get(i)); 183 | strings.add(s); 184 | } 185 | for (int i = 0; i < strings.size(); i++) { 186 | String s = String.valueOf(i); 187 | mCatch.put(s + "zip", strings.get(i), ACache.TIME_DAY); 188 | } 189 | 190 | 191 | SharedPreferences.Editor edit = mPreferences.edit(); 192 | edit.putBoolean("firstZip", false); 193 | edit.putInt("numZip", strings.size()); 194 | edit.putLong("ZipTime", System.currentTimeMillis()); 195 | edit.commit(); 196 | } 197 | 198 | public void onResume() { 199 | super.onResume(); 200 | MobclickAgent.onPageStart("Zip_Fragment"); //统计页面,"MainScreen"为页面名称,可自定义 201 | } 202 | 203 | public void onPause() { 204 | super.onPause(); 205 | MobclickAgent.onPageEnd("Zip_Fragment"); 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/util/ApkDetial.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.util; 2 | 3 | 4 | import android.graphics.drawable.Drawable; 5 | 6 | /** 7 | * Created by 齐泽威 on 2017/1/30. 8 | */ 9 | 10 | public class ApkDetial { 11 | private String name; 12 | private String version; 13 | private Drawable icon; 14 | 15 | public Drawable getIcon() { 16 | return icon; 17 | } 18 | 19 | public void setIcon(Drawable icon) { 20 | this.icon = icon; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public String getVersion() { 32 | return version; 33 | } 34 | 35 | public void setVersion(String version) { 36 | this.version = version; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/util/Fab.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.util; 2 | 3 | import android.content.Context; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.view.animation.Animation; 8 | import android.view.animation.AnimationUtils; 9 | import android.view.animation.Interpolator; 10 | import android.view.animation.ScaleAnimation; 11 | 12 | import com.fileManager.R; 13 | import com.gordonwong.materialsheetfab.AnimatedFab; 14 | 15 | /** 16 | * Created by 齐泽威 on 2017/2/8. 17 | */ 18 | 19 | public class Fab extends FloatingActionButton implements AnimatedFab { 20 | 21 | private static final int FAB_ANIM_DURATION = 200; 22 | 23 | public Fab(Context context) { 24 | super(context); 25 | } 26 | 27 | public Fab(Context context, AttributeSet attrs) { 28 | super(context, attrs); 29 | } 30 | 31 | public Fab(Context context, AttributeSet attrs, int defStyleAttr) { 32 | super(context, attrs, defStyleAttr); 33 | } 34 | 35 | /** 36 | * Shows the FAB. 37 | */ 38 | @Override 39 | public void show() { 40 | show(0, 0); 41 | } 42 | 43 | /** 44 | * Shows the FAB and sets the FAB's translation. 45 | * 46 | * @param translationX translation X value 47 | * @param translationY translation Y value 48 | */ 49 | @Override 50 | public void show(float translationX, float translationY) { 51 | // Set FAB's translation 52 | setTranslation(translationX, translationY); 53 | 54 | // Only use scale animation if FAB is hidden 55 | if (getVisibility() != View.VISIBLE) { 56 | // Pivots indicate where the animation begins from 57 | float pivotX = getPivotX() + translationX; 58 | float pivotY = getPivotY() + translationY; 59 | 60 | ScaleAnimation anim; 61 | // If pivots are 0, that means the FAB hasn't been drawn yet so just use the 62 | // center of the FAB 63 | if (pivotX == 0 || pivotY == 0) { 64 | anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, 65 | Animation.RELATIVE_TO_SELF, 0.5f); 66 | } else { 67 | anim = new ScaleAnimation(0, 1, 0, 1, pivotX, pivotY); 68 | } 69 | 70 | // Animate FAB expanding 71 | anim.setDuration(FAB_ANIM_DURATION); 72 | anim.setInterpolator(getInterpolator()); 73 | startAnimation(anim); 74 | } 75 | setVisibility(View.VISIBLE); 76 | } 77 | 78 | /** 79 | * Hides the FAB. 80 | */ 81 | @Override 82 | public void hide() { 83 | // Only use scale animation if FAB is visible 84 | if (getVisibility() == View.VISIBLE) { 85 | // Pivots indicate where the animation begins from 86 | float pivotX = getPivotX() + getTranslationX(); 87 | float pivotY = getPivotY() + getTranslationY(); 88 | 89 | // Animate FAB shrinking 90 | ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY); 91 | anim.setDuration(FAB_ANIM_DURATION); 92 | anim.setInterpolator(getInterpolator()); 93 | startAnimation(anim); 94 | } 95 | setVisibility(View.INVISIBLE); 96 | } 97 | 98 | private void setTranslation(float translationX, float translationY) { 99 | animate().setInterpolator(getInterpolator()).setDuration(FAB_ANIM_DURATION) 100 | .translationX(translationX).translationY(translationY); 101 | } 102 | 103 | private Interpolator getInterpolator() { 104 | return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator); 105 | } 106 | } -------------------------------------------------------------------------------- /app/src/main/java/com/filemanager/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.fileManager.util; 2 | 3 | import android.content.ContentResolver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.database.Cursor; 7 | import android.net.Uri; 8 | import android.provider.MediaStore; 9 | import android.util.Log; 10 | 11 | import java.io.File; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | import static com.blankj.utilcode.utils.FileUtils.isDir; 16 | 17 | /** 18 | * Created by 齐泽威 on 2016/12/6. 19 | */ 20 | 21 | public class FileUtil { 22 | 23 | //扫描外存,返回指定类型文件集合 24 | public static List getSpecificTypeOfFile(Context context, String[] extension) { 25 | List fileUrls = new ArrayList<>(); 26 | 27 | //从外存中获取 28 | Uri fileUri = MediaStore.Files.getContentUri("external"); 29 | //筛选列,这里只筛选了:文件路径和不含后缀的文件名 30 | String[] projection = new String[]{ 31 | MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.TITLE 32 | }; 33 | //构造筛选语句 34 | String selection = ""; 35 | for (int i = 0; i < extension.length; i++) { 36 | if (i != 0) { 37 | selection = selection + " OR "; 38 | } 39 | selection = selection + MediaStore.Files.FileColumns.DATA + " LIKE '%" + extension[i] + "'"; 40 | } 41 | //按时间递增顺序对结果进行排序;待会从后往前移动游标就可实现时间递减 42 | String sortOrder = MediaStore.Files.FileColumns.DATE_MODIFIED; 43 | //获取内容解析器对象 44 | ContentResolver resolver = context.getContentResolver(); 45 | //获取游标 46 | Cursor cursor = resolver.query(fileUri, projection, selection, null, sortOrder); 47 | if (cursor == null) 48 | return null; 49 | //游标从最后开始往前递减,以此实现时间递减顺序(最近访问的文件,优先显示) 50 | if (cursor.moveToLast()) { 51 | do { 52 | //输出文件的完整路径 53 | String data = cursor.getString(0); 54 | Log.d("tag", data); 55 | fileUrls.add(data); 56 | 57 | } while (cursor.moveToPrevious()); 58 | } 59 | cursor.close(); 60 | List rets = new ArrayList<>(); 61 | for (int i = 0; i < fileUrls.size(); i++) { 62 | File file = new File(fileUrls.get(i)); 63 | rets.add(file); 64 | } 65 | Log.d("ccccccc", "getSpecificTypeOfFile: " + rets.size()); 66 | return rets; 67 | } 68 | 69 | public static Intent openFile(String filePath){ 70 | 71 | 72 | File file = new File(filePath); 73 | if(!file.exists()) return null; 74 | /* 取得扩展名 */ 75 | String end=file.getName().substring(file.getName().lastIndexOf(".") + 1,file.getName().length()).toLowerCase(); 76 | /* 依扩展名的类型决定MimeType */ 77 | if(end.equals("m4a")||end.equals("mp3")||end.equals("mid")|| 78 | end.equals("xmf")||end.equals("ogg")||end.equals("wav")){ 79 | return getAudioFileIntent(filePath); 80 | }else if(end.equals("3gp")||end.equals("mp4")){ 81 | return getVideoFileIntent(filePath); 82 | }else if(end.equals("jpg")||end.equals("gif")||end.equals("png")|| 83 | end.equals("jpeg")||end.equals("bmp")){ 84 | return getImageFileIntent(filePath); 85 | }else if(end.equals("apk")){ 86 | return getApkFileIntent(filePath); 87 | }else if(end.equals("ppt")){ 88 | return getPptFileIntent(filePath); 89 | }else if(end.equals("xls")){ 90 | return getExcelFileIntent(filePath); 91 | }else if(end.equals("doc")){ 92 | return getWordFileIntent(filePath); 93 | }else if(end.equals("pdf")){ 94 | return getPdfFileIntent(filePath); 95 | }else if(end.equals("chm")){ 96 | return getChmFileIntent(filePath); 97 | }else if(end.equals("txt")){ 98 | return getTextFileIntent(filePath,false); 99 | }else{ 100 | return getAllIntent(filePath); 101 | } 102 | } 103 | 104 | //Android获取一个用于打开APK文件的intent 105 | public static Intent getAllIntent( String param ) { 106 | 107 | Intent intent = new Intent(); 108 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 109 | intent.setAction(android.content.Intent.ACTION_VIEW); 110 | Uri uri = Uri.fromFile(new File(param )); 111 | intent.setDataAndType(uri,"*/*"); 112 | return intent; 113 | } 114 | //Android获取一个用于打开APK文件的intent 115 | public static Intent getApkFileIntent( String param ) { 116 | 117 | Intent intent = new Intent(); 118 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 119 | intent.setAction(android.content.Intent.ACTION_VIEW); 120 | Uri uri = Uri.fromFile(new File(param )); 121 | intent.setDataAndType(uri,"application/vnd.android.package-archive"); 122 | return intent; 123 | } 124 | 125 | //Android获取一个用于打开VIDEO文件的intent 126 | public static Intent getVideoFileIntent( String param ) { 127 | 128 | Intent intent = new Intent("android.intent.action.VIEW"); 129 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 130 | intent.putExtra("oneshot", 0); 131 | intent.putExtra("configchange", 0); 132 | Uri uri = Uri.fromFile(new File(param )); 133 | intent.setDataAndType(uri, "video/*"); 134 | return intent; 135 | } 136 | 137 | //Android获取一个用于打开AUDIO文件的intent 138 | public static Intent getAudioFileIntent( String param ){ 139 | 140 | Intent intent = new Intent("android.intent.action.VIEW"); 141 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 142 | intent.putExtra("oneshot", 0); 143 | intent.putExtra("configchange", 0); 144 | Uri uri = Uri.fromFile(new File(param )); 145 | intent.setDataAndType(uri, "audio/*"); 146 | return intent; 147 | } 148 | 149 | //Android获取一个用于打开Html文件的intent 150 | public static Intent getHtmlFileIntent( String param ){ 151 | 152 | Uri uri = Uri.parse(param ).buildUpon().encodedAuthority("com.android.htmlfileprovider").scheme("content").encodedPath(param ).build(); 153 | Intent intent = new Intent("android.intent.action.VIEW"); 154 | intent.setDataAndType(uri, "text/html"); 155 | return intent; 156 | } 157 | 158 | //Android获取一个用于打开图片文件的intent 159 | public static Intent getImageFileIntent( String param ) { 160 | 161 | Intent intent = new Intent("android.intent.action.VIEW"); 162 | intent.addCategory("android.intent.category.DEFAULT"); 163 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 164 | Uri uri = Uri.fromFile(new File(param )); 165 | intent.setDataAndType(uri, "image/*"); 166 | return intent; 167 | } 168 | 169 | //Android获取一个用于打开PPT文件的intent 170 | public static Intent getPptFileIntent( String param ){ 171 | 172 | Intent intent = new Intent("android.intent.action.VIEW"); 173 | intent.addCategory("android.intent.category.DEFAULT"); 174 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 175 | Uri uri = Uri.fromFile(new File(param )); 176 | intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); 177 | return intent; 178 | } 179 | 180 | //Android获取一个用于打开Excel文件的intent 181 | public static Intent getExcelFileIntent( String param ){ 182 | 183 | Intent intent = new Intent("android.intent.action.VIEW"); 184 | intent.addCategory("android.intent.category.DEFAULT"); 185 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 186 | Uri uri = Uri.fromFile(new File(param )); 187 | intent.setDataAndType(uri, "application/vnd.ms-excel"); 188 | return intent; 189 | } 190 | 191 | //Android获取一个用于打开Word文件的intent 192 | public static Intent getWordFileIntent( String param ){ 193 | 194 | Intent intent = new Intent("android.intent.action.VIEW"); 195 | intent.addCategory("android.intent.category.DEFAULT"); 196 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 197 | Uri uri = Uri.fromFile(new File(param )); 198 | intent.setDataAndType(uri, "application/msword"); 199 | return intent; 200 | } 201 | 202 | //Android获取一个用于打开CHM文件的intent 203 | public static Intent getChmFileIntent( String param ){ 204 | 205 | Intent intent = new Intent("android.intent.action.VIEW"); 206 | intent.addCategory("android.intent.category.DEFAULT"); 207 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 208 | Uri uri = Uri.fromFile(new File(param )); 209 | intent.setDataAndType(uri, "application/x-chm"); 210 | return intent; 211 | } 212 | 213 | //Android获取一个用于打开文本文件的intent 214 | public static Intent getTextFileIntent( String param, boolean paramBoolean){ 215 | 216 | Intent intent = new Intent("android.intent.action.VIEW"); 217 | intent.addCategory("android.intent.category.DEFAULT"); 218 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 219 | if (paramBoolean){ 220 | Uri uri1 = Uri.parse(param ); 221 | intent.setDataAndType(uri1, "text/plain"); 222 | }else{ 223 | Uri uri2 = Uri.fromFile(new File(param )); 224 | intent.setDataAndType(uri2, "text/plain"); 225 | } 226 | return intent; 227 | } 228 | //Android获取一个用于打开PDF文件的intent 229 | public static Intent getPdfFileIntent( String param ){ 230 | 231 | Intent intent = new Intent("android.intent.action.VIEW"); 232 | intent.addCategory("android.intent.category.DEFAULT"); 233 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 234 | Uri uri = Uri.fromFile(new File(param )); 235 | intent.setDataAndType(uri, "application/pdf"); 236 | return intent; 237 | } 238 | 239 | /** 240 | * 获取目录下指定文件名的文件包括子目录 241 | *

大小写忽略

242 | * 243 | * @param dir 目录 244 | * @param fileName 文件名 245 | * @return 文件链表 246 | */ 247 | public static List searchFileInDir(File dir, String fileName) { 248 | if (dir == null || !isDir(dir)) return null; 249 | List list = new ArrayList<>(); 250 | File[] files = dir.listFiles(); 251 | if (files != null && files.length != 0) { 252 | for (File file : files) { 253 | // (str.indexOf("ABC")!=-1 254 | if (file.getName().toUpperCase().contains(fileName.toUpperCase())) { 255 | list.add(file); 256 | } 257 | if (file.isDirectory()) { 258 | list.addAll(searchFileInDir(file, fileName)); 259 | } 260 | } 261 | } 262 | return list; 263 | } 264 | 265 | } 266 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_in_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_out_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file_menu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/file_menu3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_highlight_off_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_highlight_off_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_menu.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_menu_90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_menu_90.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_menu_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_menu_check.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_menu_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_menu_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_menu_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_menu_find.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_menu_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_menu_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_return.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_search_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/ic_search_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-hdpi/night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/file_menu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/file_menu3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_highlight_off_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_highlight_off_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_menu.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_menu_90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_menu_90.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_menu_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_menu_check.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_menu_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_menu_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_menu_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_menu_find.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_menu_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_menu_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_return.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_search_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/ic_search_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-mdpi/night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ripple_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/file_menu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/file_menu3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_highlight_off_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_highlight_off_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_menu.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu_90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_menu_90.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_menu_check.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_menu_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_menu_find.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_menu_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_menu_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_return.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/loading.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xhdpi/night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/file_menu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/file_menu3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_highlight_off_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_highlight_off_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_menu.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu_90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_menu_90.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_menu_check.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_menu_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_menu_find.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_menu_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_menu_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_return.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxhdpi/night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/file_menu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/file_menu3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_highlight_off_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/ic_highlight_off_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_menu_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/ic_menu_check.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_menu_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/ic_menu_close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_menu_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/ic_menu_find.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_menu_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/ic_menu_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_search_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/ic_search_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/drawable-xxxhdpi/night.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_bg_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 24 | 25 | 33 | 40 | 41 | 46 | 51 | 52 | 53 | 59 | 64 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_memory.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 16 | 17 | 24 | 25 | 26 | 34 | 35 | 36 | 37 | 44 | 45 | 51 | 52 | 59 | 60 | 64 | 65 | 70 | 71 | 72 | 73 | 79 | 80 | 84 | 85 | 90 | 91 | 92 | 93 | 99 | 100 | 104 | 105 | 110 | 111 | 112 | 113 | 119 | 120 | 124 | 125 | 130 | 131 | 132 | 133 | 139 | 140 | 144 | 145 | 150 | 151 | 152 | 153 | 159 | 160 | 164 | 165 | 170 | 171 | 175 | 176 | 177 | 178 | 184 | 185 | 189 | 190 | 195 | 196 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_show.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 20 | 21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_apk.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_file_name.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | 27 | 28 | 29 | 34 | 42 | 43 | 50 | 51 | 61 | 62 | 66 | 67 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_file_type.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | 27 | 28 | 29 | 34 | 42 | 43 | 50 | 51 | 61 | 62 | 66 | 67 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_image.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_music.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_video.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_word.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_zip.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/guillotine.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 19 | 20 | 24 | 25 | 26 | 35 | 41 | 50 | 51 | 60 | 61 | 62 | 63 | 69 | 70 | 78 | 87 | 88 | 94 | 95 | 102 | 103 | 104 | 105 | 113 | 122 | 123 | 129 | 130 | 137 | 138 | 139 | 140 | 147 | 157 | 158 | 164 | 165 | 172 | 173 | 174 | 175 | 182 | 191 | 192 | 198 | 199 | 206 | 207 | 208 | 209 | 210 | 222 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_apk.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 22 | 23 | 28 | 29 | 39 | 40 | 41 | 42 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_file.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 16 | 17 | 25 | 26 | 31 | 32 | 39 | 40 | 41 | 42 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_music.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 22 | 23 | 27 | 28 | 38 | 39 | 40 | 41 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_video.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 17 | 18 | 26 | 27 | 31 | 32 | 39 | 40 | 41 | 48 | 49 | 50 | 51 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_word.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 14 | 22 | 23 | 27 | 28 | 35 | 36 | 37 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_zip.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 23 | 24 | 28 | 29 | 36 | 37 | 38 | 39 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/show_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 17 | 18 | 28 | 29 | 35 | 36 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/show_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/menu/toolbar_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ad_app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-hdpi/ad_app_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ad_app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xhdpi/ad_app_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xhdpi/error.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/openpager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xhdpi/openpager.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ad_app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/ad_app_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_apk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_apk.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_file.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_image.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_music.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_video.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_video.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_word.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/file_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/file_zip.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #242635 4 | #232222 5 | #FF504d 6 | #242635 7 | #388cff 8 | #388cff 9 | #2f3045 10 | #a9a9a9 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #388cff 4 | #036cfc 5 | #FF504d 6 | #eae7dd 7 | #1d1d1d 8 | #ffffff 9 | #fff 10 | #a9a9a9 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 快客 3 | 4 | 5 | Hello blank fragment 6 | \n关于一些操作使用: 7 | \n1.在进入文件展示页面后,可以通过左划文件,长按文件可操作文件; 8 | \n2.在分类页面可通过下拉刷新内存信息,在文件展示页面,可下拉刷新文件列表; 9 | \n3.本软件的默认文件类型:图片(jpg),视频(mp4),音乐(mp3),压缩包(zip),安装包(apk),文档(txt)。 10 | 如果您想查看其他类型的文件,可通过主分类页面右下角的搜索入口进行搜索; 11 | \n\t\t\t\t\t感谢您对本软件的使用和支持,如果您对本软件有任何建议和问题,欢迎您 12 | 通过本页面下方的邮箱联系作者本人,我会尽快回应您的反馈并表示感谢。再次感谢您的使用,祝您生活愉快, 13 | 鸡年大吉吧。 14 | 快客 15 | 总共: 16 | 正在读取 17 | GB 18 | 剩余: 19 | 图片 20 | 视频 21 | 音乐 22 | 文档 23 | 安装包 24 | 压缩包 25 | 文件名搜索 26 | 类型文件搜索 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 18 | 19 | 25 | 26 | 33 | 34 | 41 | 42 | 48 | 49 | 57 | 58 | 67 | 68 | 74 | 75 | 79 | 80 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /app/src/test/java/com/filemanager/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.fileManager; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | maven { url "https://jitpack.io" } 17 | } 18 | } 19 | 20 | task clean(type: Delete) { 21 | delete rootProject.buildDir 22 | } 23 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | -keepclassmembers class * { 20 | public (org.json.JSONObject); 21 | } 22 | 23 | -libraryjars libs/BmobStat_v1.1_170114.jar 24 | -keep class cn.bmob.v3.statistics.AppStat { *; } 25 | 26 | -keep class io.codetail.animation.arcanimator.** { *; } 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qizewei/FileManager/3e40610ef14881b4b36f281247c515e0dd8f7ec4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed May 17 20:47:34 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------