|
|
@ -149,11 +149,7 @@ class FilePickerDialog : DialogFragment(), |
|
|
|
override fun onMenuItemClick(item: MenuItem?): Boolean { |
|
|
|
override fun onMenuItemClick(item: MenuItem?): Boolean { |
|
|
|
when (item?.itemId) { |
|
|
|
when (item?.itemId) { |
|
|
|
R.id.menu_ok -> fileAdapter.currentPath?.let { |
|
|
|
R.id.menu_ok -> fileAdapter.currentPath?.let { |
|
|
|
val data = Intent().setData(Uri.fromFile(File(it))) |
|
|
|
setData(it) |
|
|
|
(parentFragment as? CallBack) |
|
|
|
|
|
|
|
?.onActivityResult(requestCode, Activity.RESULT_OK, data) |
|
|
|
|
|
|
|
(activity as? CallBack) |
|
|
|
|
|
|
|
?.onActivityResult(requestCode, Activity.RESULT_OK, data) |
|
|
|
|
|
|
|
dismiss() |
|
|
|
dismiss() |
|
|
|
} |
|
|
|
} |
|
|
|
else -> item?.title?.let { |
|
|
|
else -> item?.title?.let { |
|
|
@ -176,11 +172,7 @@ class FilePickerDialog : DialogFragment(), |
|
|
|
} else if (allowExtensions == null || |
|
|
|
} else if (allowExtensions == null || |
|
|
|
allowExtensions?.contains(FileUtils.getExtension(path)) == true |
|
|
|
allowExtensions?.contains(FileUtils.getExtension(path)) == true |
|
|
|
) { |
|
|
|
) { |
|
|
|
val data = Intent().setData(Uri.fromFile(File(path))) |
|
|
|
setData(path) |
|
|
|
(parentFragment as? CallBack) |
|
|
|
|
|
|
|
?.onActivityResult(requestCode, Activity.RESULT_OK, data) |
|
|
|
|
|
|
|
(activity as? CallBack) |
|
|
|
|
|
|
|
?.onActivityResult(requestCode, Activity.RESULT_OK, data) |
|
|
|
|
|
|
|
dismiss() |
|
|
|
dismiss() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
toast("不能打开此文件") |
|
|
|
toast("不能打开此文件") |
|
|
@ -215,6 +207,14 @@ class FilePickerDialog : DialogFragment(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setData(path: String) { |
|
|
|
|
|
|
|
val data = Intent().setData(Uri.fromFile(File(path))) |
|
|
|
|
|
|
|
(parentFragment as? CallBack) |
|
|
|
|
|
|
|
?.onActivityResult(requestCode, Activity.RESULT_OK, data) |
|
|
|
|
|
|
|
(activity as? CallBack) |
|
|
|
|
|
|
|
?.onActivityResult(requestCode, Activity.RESULT_OK, data) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) |
|
|
|
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) |
|
|
|
fun onMenuClick(menu: String) {} |
|
|
|
fun onMenuClick(menu: String) {} |
|
|
|