double open dialog
annng opened this issue · comments
I have implement and tested on Asus Zenfone Max Pro M1. when I selected file, the dialog doesn't dismiss but back to root directory. I selected again and the second one dismiss dialog. It also happen when I click cancel. But I called dialog.show() just one time.
Could you provide your DialogProperties configuration?
properties = DialogProperties()
properties.selection_mode = DialogConfigs.SINGLE_MODE
properties.selection_type = DialogConfigs.FILE_SELECT
properties.root = File(DialogConfigs.DEFAULT_DIR)
properties.error_dir = File(DialogConfigs.DEFAULT_DIR)
properties.offset = File(DialogConfigs.DEFAULT_DIR)
properties.extensions = null
properties.show_hidden_files = false
I wasn't able to reproduce your error.
Could you give us a bit more context? From which lifecycle method do you call dialog.show()? Would be nice, if you send us a gist of your code file, that we can find the bug.
lateinit var properties: DialogProperties
lateinit var dialogFile : FilePickerDialog
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
// TODO: Use the ViewModel
initPickerFileProperties()
listView.setOnItemClickListener{ position ->
openFilePicker(position)
}
}
fun initPickerFileProperties() {
properties = DialogProperties()
properties.selection_mode = DialogConfigs.SINGLE_MODE
properties.selection_type = DialogConfigs.FILE_SELECT
properties.root = File(DialogConfigs.DEFAULT_DIR)
properties.error_dir = File(DialogConfigs.DEFAULT_DIR)
properties.offset = File(DialogConfigs.DEFAULT_DIR)
properties.extensions = null
properties.show_hidden_files = false
dialogFile = FilePickerDialog(activity!!, properties)
}
fun openFilePicker(position: Int) {
dialogFile = FilePickerDialog(activity!!, properties)
dialogFile.setTitle(attachments[position].fileName)
dialogFile.setDialogSelectionListener {
attachments[position].path = it[0]
attachmentAdapter.notifyDataSetChanged()
}
Toast.makeText(activity!!, "file picker called", Toast.LENGTH_LONG).show()
dialogFile.show()
}
I tested your code with my Google Pixel 3a (Android 10) and on an Android emulator with Android 8.1. It works like a charm.
I wonder why you create an instance of FilePickerDialog twice, but that's propably not the reason of this strange behaviour. You could replace the Toast with a Log.d command, so that you see, if the method is called twice.
By the way: You don't need to reassign DialogProperties parameters with the default values. You can just leave that out.