pull/457/head
gedoor 4 years ago
parent 33a09ae46c
commit b04b6c6b2c
  1. 44
      app/src/main/java/io/legado/app/ui/filepicker/FilePicker.kt

@ -10,8 +10,6 @@ import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.utils.applyTint import io.legado.app.utils.applyTint
import io.legado.app.utils.toast
import org.jetbrains.anko.toast
@Suppress("unused") @Suppress("unused")
object FilePicker { object FilePicker {
@ -39,7 +37,13 @@ object FilePicker {
activity.startActivityForResult(intent, requestCode) activity.startActivityForResult(intent, requestCode)
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
e.printStackTrace() e.printStackTrace()
activity.toast(e.localizedMessage ?: "ERROR") checkPermissions(activity) {
FilePickerDialog.show(
activity.supportFragmentManager,
requestCode,
mode = FilePickerDialog.DIRECTORY
)
}
} }
} }
else -> { else -> {
@ -84,7 +88,13 @@ object FilePicker {
fragment.startActivityForResult(intent, requestCode) fragment.startActivityForResult(intent, requestCode)
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
e.printStackTrace() e.printStackTrace()
fragment.toast(e.localizedMessage ?: "ERROR") checkPermissions(fragment) {
FilePickerDialog.show(
fragment.childFragmentManager,
requestCode,
mode = FilePickerDialog.DIRECTORY
)
}
} }
} }
else -> { else -> {
@ -134,17 +144,16 @@ object FilePicker {
activity.startActivityForResult(intent, requestCode) activity.startActivityForResult(intent, requestCode)
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
e.printStackTrace() e.printStackTrace()
activity.toast(e.localizedMessage ?: "ERROR") checkPermissions(activity) {
FilePickerDialog.show(
activity.supportFragmentManager,
requestCode,
mode = FilePickerDialog.FILE,
allowExtensions = allowExtensions
)
}
} }
} }
1 -> checkPermissions(activity) {
FilePickerDialog.show(
activity.supportFragmentManager,
requestCode,
mode = FilePickerDialog.FILE,
allowExtensions = allowExtensions
)
}
else -> { else -> {
val selectText = selectList[index] val selectText = selectList[index]
if (selectText == activity.getString(R.string.app_file_picker)) { if (selectText == activity.getString(R.string.app_file_picker)) {
@ -193,7 +202,14 @@ object FilePicker {
fragment.startActivityForResult(intent, requestCode) fragment.startActivityForResult(intent, requestCode)
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
e.printStackTrace() e.printStackTrace()
fragment.toast(e.localizedMessage ?: "ERROR") checkPermissions(fragment) {
FilePickerDialog.show(
fragment.childFragmentManager,
requestCode,
mode = FilePickerDialog.FILE,
allowExtensions = allowExtensions
)
}
} }
} }
else -> { else -> {

Loading…
Cancel
Save