From 3302d77fb7709ce4b13604a87fd89ac33ac9acc1 Mon Sep 17 00:00:00 2001 From: Steven Schoen Date: Tue, 29 May 2018 19:18:01 -0700 Subject: [PATCH] Fix crash when picking destination folder --- app/build.gradle | 4 ++-- .../putionew/files/FilesFragment.kt | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c9387a8f..304496fe 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,8 +16,8 @@ android { applicationId 'com.stevenschoen.putionew' minSdkVersion 21 targetSdkVersion 27 - versionCode 129 - versionName '4.3.0' + versionCode 130 + versionName '4.3.1' multiDexEnabled true kapt { diff --git a/app/src/main/java/com/stevenschoen/putionew/files/FilesFragment.kt b/app/src/main/java/com/stevenschoen/putionew/files/FilesFragment.kt index f3575cb2..fbbb92a1 100644 --- a/app/src/main/java/com/stevenschoen/putionew/files/FilesFragment.kt +++ b/app/src/main/java/com/stevenschoen/putionew/files/FilesFragment.kt @@ -63,15 +63,19 @@ open class FilesFragment : RxFragment() { setHasOptionsMenu(true) - if (savedInstanceState != null) { - pages.addAll(savedInstanceState.getParcelableArrayList(STATE_PAGES)) - if (savedInstanceState.containsKey(STATE_CURRENT_PAGE)) { - currentPage = savedInstanceState.getParcelable(STATE_CURRENT_PAGE) + when { + savedInstanceState != null -> { + pages.addAll(savedInstanceState.getParcelableArrayList(STATE_PAGES)) + if (savedInstanceState.containsKey(STATE_CURRENT_PAGE)) { + currentPage = savedInstanceState.getParcelable(STATE_CURRENT_PAGE) + } + } + arguments?.containsKey(EXTRA_FOLDER) == true -> { + pages.add(Page.File(arguments!!.getParcelable(EXTRA_FOLDER))) + } + else -> { + pages.add(Page.File(PutioFile.makeRootFolder(resources))) } - } else if (arguments!!.containsKey(EXTRA_FOLDER)) { - pages.add(Page.File(arguments!!.getParcelable(EXTRA_FOLDER))) - } else { - pages.add(Page.File(PutioFile.makeRootFolder(resources))) } fileListFragmentsAdapter.notifyDataSetChanged() }