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 <Pratham2305@users.noreply.github.com>
This commit is contained in:
Pratham Pahariya 2021-05-08 15:15:32 +05:30 committed by GitHub
parent 3577bd9e3e
commit 845a901604
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -111,11 +111,13 @@
<activity
android:name=".category.CategoryDetailsActivity"
android:label="@string/title_activity_featured_images"
android:configChanges="screenSize|keyboard|orientation"
android:parentActivityName=".contributions.MainActivity" />
<activity
android:name=".explore.depictions.WikidataItemDetailsActivity"
android:label="@string/title_activity_featured_images"
android:configChanges="screenSize|keyboard|orientation"
android:parentActivityName=".contributions.MainActivity" />
<activity

View file

@ -48,6 +48,16 @@ abstract class BasePagingFragment<T> : 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<PagedList<T>>) {
this.searchResults?.removeObservers(viewLifecycleOwner)
this.searchResults = searchResults