mirror of
https://github.com/etesync/android
synced 2025-02-08 21:52:47 +00:00
Import from file: dismiss dialog and print an error in a missed error case.
This commit is contained in:
parent
51a29b4401
commit
4fb49cf5f4
@ -139,22 +139,31 @@ class ImportFragment : DialogFragment() {
|
|||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
REQUEST_CODE -> if (resultCode == Activity.RESULT_OK) {
|
REQUEST_CODE -> {
|
||||||
if (data != null) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
// Get the URI of the selected file
|
if (data != null) {
|
||||||
val uri = data.data
|
// Get the URI of the selected file
|
||||||
App.log.info("Importing uri = " + uri!!.toString())
|
val uri = data.data
|
||||||
try {
|
App.log.info("Importing uri = " + uri!!.toString())
|
||||||
importFile = File(com.etesync.syncadapter.utils.FileUtils.getPath(context!!, uri))
|
try {
|
||||||
|
importFile = File(com.etesync.syncadapter.utils.FileUtils.getPath(context!!, uri))
|
||||||
|
|
||||||
|
Thread(ImportCalendarsLoader()).start()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
App.log.severe("File select error: ${e.message}")
|
||||||
|
|
||||||
|
val importResult = ImportResult()
|
||||||
|
importResult.e = e
|
||||||
|
|
||||||
|
(activity as ResultFragment.OnImportCallback).onImportResult(importResult)
|
||||||
|
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
|
||||||
Thread(ImportCalendarsLoader()).start()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
App.log.severe("File select error: " + e.localizedMessage)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dismissAllowingStateLoss()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
Loading…
Reference in New Issue
Block a user