mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix: safely access binding in delayed view callbacks
This commit is contained in:
parent
0c6a0c5307
commit
5b5ec1707d
1 changed files with 15 additions and 14 deletions
|
|
@ -561,7 +561,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
binding.progressBarEdit.visibility = View.GONE
|
bindingOrNull?.progressBarEdit?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
|
@ -636,7 +636,7 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onMediaRefreshed(media: Media) {
|
private fun onMediaRefreshed(media: Media) {
|
||||||
media.categories = this.media!!.categories
|
media.categories = this.media?.categories
|
||||||
this.media = media
|
this.media = media
|
||||||
setTextFields(media)
|
setTextFields(media)
|
||||||
compositeDisposable.addAll(
|
compositeDisposable.addAll(
|
||||||
|
|
@ -650,29 +650,30 @@ class MediaDetailFragment : CommonsDaggerSupportFragment(), CategoryEditHelper.C
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onDiscussionLoaded(discussion: String) {
|
private fun onDiscussionLoaded(discussion: String) {
|
||||||
binding.mediaDetailDisc.text = prettyDiscussion(discussion.trim { it <= ' ' })
|
bindingOrNull?.mediaDetailDisc?.text = prettyDiscussion(discussion.trim { it <= ' ' })
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onDeletionPageExists(deletionPageExists: Boolean) {
|
private fun onDeletionPageExists(deletionPageExists: Boolean) {
|
||||||
if (getUserName(requireContext()) == null && getUserName(requireContext()) != media!!.author) {
|
val safeBinding = bindingOrNull ?: return
|
||||||
binding.nominateDeletion.visibility = View.GONE
|
|
||||||
binding.nominatedDeletionBanner.visibility = View.GONE
|
if (getUserName(requireContext()) == null && getUserName(requireContext()) != media?.author) {
|
||||||
|
safeBinding.nominateDeletion.visibility = View.GONE
|
||||||
|
safeBinding.nominatedDeletionBanner.visibility = View.GONE
|
||||||
} else if (deletionPageExists) {
|
} else if (deletionPageExists) {
|
||||||
if (applicationKvStore.getBoolean(
|
if (applicationKvStore.getBoolean(
|
||||||
String.format(NOMINATING_FOR_DELETION_MEDIA, media!!.imageUrl), false
|
String.format(NOMINATING_FOR_DELETION_MEDIA, media?.imageUrl), false
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
applicationKvStore.remove(
|
applicationKvStore.remove(
|
||||||
String.format(NOMINATING_FOR_DELETION_MEDIA, media!!.imageUrl)
|
String.format(NOMINATING_FOR_DELETION_MEDIA, media?.imageUrl)
|
||||||
)
|
)
|
||||||
binding.progressBarDeletion.visibility = View.GONE
|
safeBinding.progressBarDeletion.visibility = View.GONE
|
||||||
}
|
}
|
||||||
binding.nominateDeletion.visibility = View.GONE
|
safeBinding.nominateDeletion.visibility = View.GONE
|
||||||
|
safeBinding.nominatedDeletionBanner.visibility = View.VISIBLE
|
||||||
binding.nominatedDeletionBanner.visibility = View.VISIBLE
|
|
||||||
} else if (!isCategoryImage) {
|
} else if (!isCategoryImage) {
|
||||||
binding.nominateDeletion.visibility = View.VISIBLE
|
safeBinding.nominateDeletion.visibility = View.VISIBLE
|
||||||
binding.nominatedDeletionBanner.visibility = View.GONE
|
safeBinding.nominatedDeletionBanner.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue