mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fix NullPointerException in onBackPressed() (#6249)
This commit is contained in:
parent
e1466c866b
commit
67ac92ff57
1 changed files with 20 additions and 15 deletions
|
|
@ -387,35 +387,40 @@ after opening the app.
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (contributionsFragment != null && activeFragment == ActiveFragment.CONTRIBUTIONS) {
|
when (activeFragment) {
|
||||||
|
ActiveFragment.CONTRIBUTIONS -> {
|
||||||
// Means that contribution fragment is visible
|
// Means that contribution fragment is visible
|
||||||
if (!contributionsFragment!!.backButtonClicked()) { //If this one does not wan't to handle
|
if (contributionsFragment?.backButtonClicked() != true) { //If this one does not want to handle
|
||||||
// the back press, let the activity do so
|
// the back press, let the activity do so
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (nearbyParentFragment != null && activeFragment == ActiveFragment.NEARBY) {
|
ActiveFragment.NEARBY -> {
|
||||||
// Means that nearby fragment is visible
|
// Means that nearby fragment is visible
|
||||||
/* If function nearbyParentFragment.backButtonClick() returns false, it means that the bottomsheet is
|
if (nearbyParentFragment?.backButtonClicked() != true) {
|
||||||
not expanded. So if the back button is pressed, then go back to the Contributions tab */
|
nearbyParentFragment?.let {
|
||||||
if (!nearbyParentFragment!!.backButtonClicked()) {
|
supportFragmentManager.beginTransaction().remove(it).commit()
|
||||||
supportFragmentManager.beginTransaction().remove(nearbyParentFragment!!)
|
}
|
||||||
.commit()
|
|
||||||
setSelectedItemId(NavTab.CONTRIBUTIONS.code())
|
setSelectedItemId(NavTab.CONTRIBUTIONS.code())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (exploreFragment != null && activeFragment == ActiveFragment.EXPLORE) {
|
ActiveFragment.EXPLORE -> {
|
||||||
// Means that explore fragment is visible
|
// Explore Fragment is visible
|
||||||
if (!exploreFragment!!.onBackPressed()) {
|
if (exploreFragment?.onBackPressed() != true) {
|
||||||
if (applicationKvStore!!.getBoolean("login_skipped")) {
|
if (applicationKvStore?.getBoolean("login_skipped") == true) {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
} else {
|
} else {
|
||||||
setSelectedItemId(NavTab.CONTRIBUTIONS.code())
|
setSelectedItemId(NavTab.CONTRIBUTIONS.code())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (bookmarkFragment != null && activeFragment == ActiveFragment.BOOKMARK) {
|
ActiveFragment.BOOKMARK -> {
|
||||||
// Means that bookmark fragment is visible
|
// Means that bookmark fragment is visible
|
||||||
bookmarkFragment!!.onBackPressed()
|
bookmarkFragment?.onBackPressed()
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue