|
| 1 | +package com.blankj.utilcode.pkg.feature.file |
| 2 | + |
| 3 | +import android.content.Context |
| 4 | +import android.content.Intent |
| 5 | +import com.blankj.common.activity.CommonActivity |
| 6 | +import com.blankj.common.item.CommonItem |
| 7 | +import com.blankj.common.item.CommonItemTitle |
| 8 | +import com.blankj.utilcode.pkg.Config.CACHE_PATH |
| 9 | +import com.blankj.utilcode.pkg.R |
| 10 | +import com.blankj.utilcode.util.CollectionUtils |
| 11 | +import com.blankj.utilcode.util.FileUtils |
| 12 | +import com.blankj.utilcode.util.PathUtils |
| 13 | +import com.blankj.utilcode.util.SnackbarUtils |
| 14 | +import java.io.File |
| 15 | + |
| 16 | +/** |
| 17 | + * ``` |
| 18 | + * author: Blankj |
| 19 | + * blog : http://blankj.com |
| 20 | + * time : 2016/09/29 |
| 21 | + * desc : demo about ClickUtils |
| 22 | + * ``` |
| 23 | + */ |
| 24 | +class FileActivity : CommonActivity() { |
| 25 | + |
| 26 | + companion object { |
| 27 | + fun start(context: Context) { |
| 28 | + val starter = Intent(context, FileActivity::class.java) |
| 29 | + context.startActivity(starter) |
| 30 | + } |
| 31 | + |
| 32 | + val TEST_FILE_PATH: String = CACHE_PATH + "test_file.txt" |
| 33 | + } |
| 34 | + |
| 35 | + override fun bindTitleRes(): Int { |
| 36 | + return R.string.demo_file |
| 37 | + } |
| 38 | + |
| 39 | + override fun bindItems(): MutableList<CommonItem<*>> { |
| 40 | + return CollectionUtils.newArrayList( |
| 41 | + CommonItemTitle("isFileExists: " + PathUtils.getInternalAppFilesPath(), "" + FileUtils.isFileExists(PathUtils.getInternalAppFilesPath())), |
| 42 | + CommonItemTitle("isFileExists: " + PathUtils.getExternalAppFilesPath(), "" + FileUtils.isFileExists(PathUtils.getExternalAppFilesPath())), |
| 43 | + CommonItemTitle("isFileExists: " + PathUtils.getExternalStoragePath(), "" + FileUtils.isFileExists(PathUtils.getExternalStoragePath())), |
| 44 | + CommonItemTitle("isFileExists: " + PathUtils.getDownloadCachePath(), "" + FileUtils.isFileExists(PathUtils.getDownloadCachePath())), |
| 45 | + CommonItemTitle("isFileExists: " + PathUtils.getExternalDownloadsPath(), "" + FileUtils.isFileExists(PathUtils.getExternalDownloadsPath() + "/" + "app-release.apk1")), |
| 46 | + |
| 47 | + CommonItemTitle("isFileExists: " + PathUtils.getInternalAppFilesPath(), "" + FileUtils.isFileExists(File(PathUtils.getInternalAppFilesPath()))), |
| 48 | + CommonItemTitle("isFileExists: " + PathUtils.getExternalAppFilesPath(), "" + FileUtils.isFileExists(File(PathUtils.getExternalAppFilesPath()))), |
| 49 | + CommonItemTitle("isFileExists: " + PathUtils.getExternalStoragePath(), "" + FileUtils.isFileExists(File(PathUtils.getExternalStoragePath()))), |
| 50 | + CommonItemTitle("isFileExists: " + PathUtils.getDownloadCachePath(), "" + FileUtils.isFileExists(File(PathUtils.getDownloadCachePath()))), |
| 51 | + CommonItemTitle("isFileExists: " + PathUtils.getExternalDownloadsPath(), "" + FileUtils.isFileExists(File(PathUtils.getExternalDownloadsPath() + "/" + "app-release.apk1"))) |
| 52 | + ) |
| 53 | + } |
| 54 | + |
| 55 | + override fun onDestroy() { |
| 56 | + super.onDestroy() |
| 57 | + SnackbarUtils.dismiss() |
| 58 | + } |
| 59 | +} |
0 commit comments