зеркало из https://github.com/nextcloud/android.git
Fix crash
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
Родитель
5b9cfc1a1f
Коммит
bebdcd6a8e
|
@ -151,7 +151,7 @@ class SyncedFoldersActivity :
|
|||
lateinit var binding: SyncedFoldersLayoutBinding
|
||||
lateinit var adapter: SyncedFolderAdapter
|
||||
|
||||
private var syncedFolderPreferencesDialogFragment: SyncedFolderPreferencesDialogFragment? = null
|
||||
private var dialogFragment: SyncedFolderPreferencesDialogFragment? = null
|
||||
private var path: String? = null
|
||||
private var type = 0
|
||||
private var loadJob: Job? = null
|
||||
|
@ -577,15 +577,26 @@ class SyncedFoldersActivity :
|
|||
}
|
||||
|
||||
override fun onSyncFolderSettingsClick(section: Int, syncedFolderDisplayItem: SyncedFolderDisplayItem) {
|
||||
val fm = supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
syncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
|
||||
if (isFinishing || isDestroyed) {
|
||||
Log_OC.d(TAG, "Activity destroyed or finished")
|
||||
return
|
||||
}
|
||||
|
||||
val fragmentTransaction = supportFragmentManager.beginTransaction().apply {
|
||||
addToBackStack(null)
|
||||
}
|
||||
|
||||
dialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
|
||||
syncedFolderDisplayItem,
|
||||
section
|
||||
).also {
|
||||
it.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG)
|
||||
)
|
||||
|
||||
if (dialogFragment?.isStateSaved == true) {
|
||||
Log_OC.d(TAG, "SyncedFolderPreferencesDialogFragment state is saved cannot be shown")
|
||||
return
|
||||
}
|
||||
|
||||
dialogFragment?.show(fragmentTransaction, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG)
|
||||
}
|
||||
|
||||
override fun onVisibilityToggleClick(section: Int, syncedFolder: SyncedFolderDisplayItem) {
|
||||
|
@ -620,18 +631,18 @@ class SyncedFoldersActivity :
|
|||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER &&
|
||||
resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null
|
||||
resultCode == RESULT_OK && dialogFragment != null
|
||||
) {
|
||||
val chosenFolder: OCFile? = FolderPickerActivity.EXTRA_FOLDER?.let {
|
||||
data?.getParcelableArgument(it, OCFile::class.java)
|
||||
}
|
||||
syncedFolderPreferencesDialogFragment?.setRemoteFolderSummary(chosenFolder?.remotePath)
|
||||
dialogFragment?.setRemoteFolderSummary(chosenFolder?.remotePath)
|
||||
} else if (
|
||||
requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_LOCAL_FOLDER &&
|
||||
resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null
|
||||
resultCode == RESULT_OK && dialogFragment != null
|
||||
) {
|
||||
val localPath = data!!.getStringExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES)
|
||||
syncedFolderPreferencesDialogFragment!!.setLocalFolderSummary(localPath)
|
||||
dialogFragment!!.setLocalFolderSummary(localPath)
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
@ -688,7 +699,7 @@ class SyncedFoldersActivity :
|
|||
|
||||
adapter.notifyItemChanged(adapter.getSectionHeaderIndex(syncedFolder.section))
|
||||
}
|
||||
syncedFolderPreferencesDialogFragment = null
|
||||
dialogFragment = null
|
||||
if (syncedFolder.isEnabled) {
|
||||
showBatteryOptimizationInfo()
|
||||
}
|
||||
|
@ -728,7 +739,7 @@ class SyncedFoldersActivity :
|
|||
}
|
||||
|
||||
override fun onCancelSyncedFolderPreference() {
|
||||
syncedFolderPreferencesDialogFragment = null
|
||||
dialogFragment = null
|
||||
}
|
||||
|
||||
override fun onDeleteSyncedFolderPreference(syncedFolder: SyncedFolderParcelable?) {
|
||||
|
|
|
@ -456,7 +456,6 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable {
|
|||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
outState.putBoolean(BEHAVIOUR_DIALOG_STATE, behaviourDialogShown)
|
||||
outState.putBoolean(NAME_COLLISION_POLICY_DIALOG_STATE, nameCollisionPolicyDialogShown)
|
||||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onViewStateRestored(savedInstanceState: Bundle?) {
|
||||
|
@ -523,14 +522,19 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable {
|
|||
private const val alphaDisabled = 0.7f
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(syncedFolder: SyncedFolderDisplayItem?, section: Int): SyncedFolderPreferencesDialogFragment {
|
||||
requireNotNull(syncedFolder) { "SyncedFolder is mandatory but NULL!" }
|
||||
val args = Bundle()
|
||||
args.putParcelable(SYNCED_FOLDER_PARCELABLE, SyncedFolderParcelable(syncedFolder, section))
|
||||
val dialogFragment = SyncedFolderPreferencesDialogFragment()
|
||||
dialogFragment.arguments = args
|
||||
dialogFragment.setStyle(STYLE_NORMAL, R.style.Theme_ownCloud_Dialog)
|
||||
return dialogFragment
|
||||
fun newInstance(syncedFolder: SyncedFolderDisplayItem?, section: Int): SyncedFolderPreferencesDialogFragment? {
|
||||
if (syncedFolder == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val args = Bundle().apply {
|
||||
putParcelable(SYNCED_FOLDER_PARCELABLE, SyncedFolderParcelable(syncedFolder, section))
|
||||
}
|
||||
|
||||
return SyncedFolderPreferencesDialogFragment().apply {
|
||||
arguments = args
|
||||
setStyle(STYLE_NORMAL, R.style.Theme_ownCloud_Dialog)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче