1.修复dialog有时为空的问题

2.文件选择器选择apk文件后,下次默认打开上次打开的目录
pull/15/head
kai-city 4 years ago
parent 6d4ea870ce
commit 18fa69a190
  1. 36
      app/src/main/java/top/niunaijun/blackdex/view/main/MainActivity.kt

@ -27,6 +27,7 @@ import top.niunaijun.blackdex.util.LoadingUtil
import top.niunaijun.blackdex.util.inflate
import top.niunaijun.blackdex.view.base.PermissionActivity
import top.niunaijun.blackdex.view.setting.SettingActivity
import java.io.File
class MainActivity : PermissionActivity() {
@ -39,6 +40,8 @@ class MainActivity : PermissionActivity() {
private lateinit var loadingView: CatLoadingView
private var initialDir: File? = null
private var appList: List<AppInfo> = ArrayList()
override fun onCreate(savedInstanceState: Bundle?) {
@ -72,7 +75,9 @@ class MainActivity : PermissionActivity() {
this.requestPermissionCallback = {
if (it) {
this.requestPermissionCallback = null
val initialDir = Environment.getExternalStorageDirectory()
if (initialDir == null) {
initialDir = Environment.getExternalStorageDirectory()
}
MaterialDialog(this).show {
fileChooser(
this@MainActivity,
@ -80,9 +85,10 @@ class MainActivity : PermissionActivity() {
filter = FileUtil::filterApk,
) { _, file ->
viewModel.startDexDump(file.absolutePath)
this@MainActivity.initialDir = file.parentFile
}
negativeButton(res = R.string.cancel)
negativeButton(R.string.cancel)
}
}
@ -117,12 +123,11 @@ class MainActivity : PermissionActivity() {
showLoading()
}
DumpInfo.TIMEOUT -> {
loadingView.dismiss()
hideLoading()
MaterialDialog(this).show {
title(res = R.string.unpack_fail)
message(res = R.string.jump_issue)
negativeButton(res = R.string.github) {
negativeButton(text = "Github") {
title(R.string.unpack_fail)
message(R.string.jump_issue)
negativeButton(R.string.github) {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/CodingGay/BlackDex/issues")
@ -133,19 +138,18 @@ class MainActivity : PermissionActivity() {
}
}
}
else -> {
viewModel.dexDumpSuccess()
hideLoading()
val title = if (it.state == DumpInfo.SUCCESS) {
getString(R.string.unpack_success)
R.string.unpack_success
} else {
getString(R.string.unpack_fail)
R.string.unpack_fail
}
loadingView.dismiss()
MaterialDialog(this).show {
title(text = title)
title(title)
message(text = it.msg)
positiveButton(res = R.string.confirm)
positiveButton(R.string.confirm)
}
}
}
@ -212,6 +216,12 @@ class MainActivity : PermissionActivity() {
LoadingUtil.showLoading(loadingView, supportFragmentManager)
}
private fun hideLoading() {
if (this::loadingView.isInitialized) {
loadingView.dismiss()
}
}
private fun hideKeyboard() {
val imm: InputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
window.peekDecorView()?.run {

Loading…
Cancel
Save