Skip to content

Commit 845a901

Browse files
authored
Fixes commons-app#4385 - App crash On categoryDetail activity when click on image after orientation change (commons-app#4397)
* fix issue 4385 * fix orientation change issue * added javadoc Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
1 parent 3577bd9 commit 845a901

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@
111111
<activity
112112
android:name=".category.CategoryDetailsActivity"
113113
android:label="@string/title_activity_featured_images"
114+
android:configChanges="screenSize|keyboard|orientation"
114115
android:parentActivityName=".contributions.MainActivity" />
115116

116117
<activity
117118
android:name=".explore.depictions.WikidataItemDetailsActivity"
118119
android:label="@string/title_activity_featured_images"
120+
android:configChanges="screenSize|keyboard|orientation"
119121
android:parentActivityName=".contributions.MainActivity" />
120122

121123
<activity

app/src/main/java/fr/free/nrw/commons/explore/paging/BasePagingFragment.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ abstract class BasePagingFragment<T> : CommonsDaggerSupportFragment(),
4848
)
4949
}
5050

51+
/**
52+
* Called on configuration change, update the spanCount according to the orientation state.
53+
*/
54+
override fun onConfigurationChanged(newConfig: Configuration) {
55+
super.onConfigurationChanged(newConfig)
56+
paginatedSearchResultsList.apply {
57+
layoutManager = GridLayoutManager(context, if (isPortrait) 1 else 2)
58+
}
59+
}
60+
5161
override fun observePagingResults(searchResults: LiveData<PagedList<T>>) {
5262
this.searchResults?.removeObservers(viewLifecycleOwner)
5363
this.searchResults = searchResults

0 commit comments

Comments
 (0)