From 845a901604241fa01a1d140b3fa26ff1a9f52ade Mon Sep 17 00:00:00 2001 From: Pratham Pahariya <54663429+Pratham2305@users.noreply.github.com> Date: Sat, 8 May 2021 15:15:32 +0530 Subject: [PATCH] Fixes #4385 - App crash On categoryDetail activity when click on image after orientation change (#4397) * fix issue 4385 * fix orientation change issue * added javadoc Co-authored-by: Pratham2305 --- app/src/main/AndroidManifest.xml | 2 ++ .../nrw/commons/explore/paging/BasePagingFragment.kt | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a1e81be2e..47d102fdc 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -111,11 +111,13 @@ : CommonsDaggerSupportFragment(), ) } + /** + * Called on configuration change, update the spanCount according to the orientation state. + */ + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + paginatedSearchResultsList.apply { + layoutManager = GridLayoutManager(context, if (isPortrait) 1 else 2) + } + } + override fun observePagingResults(searchResults: LiveData>) { this.searchResults?.removeObservers(viewLifecycleOwner) this.searchResults = searchResults