mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Fix crash when trying to persist expand status with null context
Change-Id: I4748445f4cf6701e417d137958859157fab72a38
This commit is contained in:
parent
387459ae6b
commit
86108b1031
1 changed files with 4 additions and 5 deletions
|
@ -562,7 +562,7 @@ class RoomListFragment @Inject constructor(
|
|||
}
|
||||
|
||||
private fun persistExpandStatus() {
|
||||
val spEdit = getSharedPreferences().edit()
|
||||
val spEdit = getSharedPreferences()?.edit() ?: return
|
||||
roomListViewModel.sections.forEach{section ->
|
||||
val isExpanded = section.isExpanded.value
|
||||
if (isExpanded != null) {
|
||||
|
@ -580,14 +580,13 @@ class RoomListFragment @Inject constructor(
|
|||
}
|
||||
|
||||
private fun shouldInitiallyExpand(section: RoomsSection): Boolean {
|
||||
val sp = getSharedPreferences()
|
||||
val sp = getSharedPreferences() ?: return true
|
||||
val pref = getRoomListExpandedPref(section)
|
||||
return sp.getBoolean(pref, true)
|
||||
}
|
||||
|
||||
private fun getSharedPreferences(): SharedPreferences {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context)
|
||||
}
|
||||
private fun getSharedPreferences() = context?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
||||
|
||||
private fun getRoomListExpandedPref(section: RoomsSection): String {
|
||||
return "${ROOM_LIST_ROOM_EXPANDED_ANY_PREFIX}_${section.sectionName}_${roomListParams.displayMode}_${expandStatusSpaceId}"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue