Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private void openFavoritesTab() {
}

private void openMediaTab(int menuItemId) {
GalleryFragment.Companion.clearSavedScrollState();
GalleryFragment.Companion.clearSavedViewState();
resetOnlyPersonalAndOnDevice();
setupToolbar();
startPhotoSearch(menuItemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class GalleryFragment :
photoSearchTask?.cancel()
savedScrollState = recyclerView?.layoutManager?.onSaveInstanceState()
savedLoadedItemCount = loadedItemCount
savedMediaState = bottomSheet?.currMediaState
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Expand All @@ -177,6 +178,9 @@ class GalleryFragment :
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT
requireActivity().invalidateOptionsMenu()

if (savedMediaState != null) {
bottomSheet?.currMediaState = savedMediaState!!
}
updateSubtitle(bottomSheet?.currMediaState)

// Restore the previously loaded window so a saved scroll position still resolves to a valid item.
Expand Down Expand Up @@ -321,7 +325,7 @@ class GalleryFragment :
// TODO: Fix folder change, it seems it doesn't work at all
loadedItemCount = INITIAL_GALLERY_WINDOW
restoreScrollPending = false
clearSavedScrollState()
clearSavedViewState()
endDate = System.currentTimeMillis() / 1000
isPhotoSearchQueryRunning = true
runGallerySearchTask()
Expand Down Expand Up @@ -393,7 +397,7 @@ class GalleryFragment :
override fun updateMediaContent(mediaState: MediaState) {
loadedItemCount = INITIAL_GALLERY_WINDOW
restoreScrollPending = false
clearSavedScrollState()
clearSavedViewState()
showAllGalleryItems()
}

Expand Down Expand Up @@ -488,10 +492,12 @@ class GalleryFragment :
// so the grid reopens at the same scroll position and with the same loaded window.
private var savedScrollState: Parcelable? = null
private var savedLoadedItemCount: Int? = null
private var savedMediaState: MediaState? = null

fun clearSavedScrollState() {
fun clearSavedViewState() {
savedScrollState = null
savedLoadedItemCount = null
savedMediaState = null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ class GalleryFragmentBottomSheetDialog :
actions?.updateMediaContent(currentMediaState)
}

val currMediaState: MediaState
var currMediaState: MediaState
get() = currentMediaState
set(value) {
currentMediaState = value
}

enum class MediaState {
MEDIA_STATE_DEFAULT,
Expand Down
Loading