1
0
mirror of https://github.com/etesync/android synced 2025-05-24 01:38:48 +00:00

Import from file: dismiss dialog and print an error in a missed error case.

This commit is contained in:
Tom Hacohen 2019-02-23 21:24:26 +00:00
parent 51a29b4401
commit 4fb49cf5f4

View File

@ -139,7 +139,8 @@ 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 (resultCode == Activity.RESULT_OK) {
if (data != null) { if (data != null) {
// Get the URI of the selected file // Get the URI of the selected file
val uri = data.data val uri = data.data
@ -149,7 +150,14 @@ class ImportFragment : DialogFragment() {
Thread(ImportCalendarsLoader()).start() Thread(ImportCalendarsLoader()).start()
} catch (e: Exception) { } catch (e: Exception) {
App.log.severe("File select error: " + e.localizedMessage) App.log.severe("File select error: ${e.message}")
val importResult = ImportResult()
importResult.e = e
(activity as ResultFragment.OnImportCallback).onImportResult(importResult)
dismissAllowingStateLoss()
} }
} }
@ -157,6 +165,7 @@ class ImportFragment : DialogFragment() {
dismissAllowingStateLoss() dismissAllowingStateLoss()
} }
} }
}
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
} }