Antennapod: ViewPager state not refreshed on rotate

Created on 6 May 2020  路  9Comments  路  Source: AntennaPod/AntennaPod

App version: 2.0.0 develop

Android version: 10

Device model: OnePlus 3T

Current behaviour:

When rotating the screen, the ViewPager state is not refreshed. The pages are not snapped and stay between two states. See screenshot below:

@ebraminio I guess this is caused by the switch to ViewPager2. Could you please have a look?

confirmed bug

Most helpful comment

No problem, ViewPager2 is a big step forward (but a few tiny steps back). Thanks for bringing the RTL problems to my attention and fixing so many of them! That makes AntennaPod a lot better.

All 9 comments

Sure, am looking at it

Fixes when orientation is removed from configs an activity can handles itself, given how careful AntennaPod is to store states I believe orientation should have handled by its normal way. I have this particular issue in my other app also so guess is ViewPager2's issue.

diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bd539c70f..bcb55de78 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -72,7 +72,7 @@

         <activity
             android:name=".activity.MainActivity"
-            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:configChanges="keyboardHidden|screenSize"
             android:windowSoftInputMode="stateHidden"
             android:launchMode="singleTask"
             android:label="@string/app_name">

I am not too happy about that because it requires to re-load everything from the database after rotating. This is pretty slow and less smooth than handling it ourselves. Can this be done in something like onConfigChanged?

I am playing with changing layout in onConfigChanged for another PR, still messing with the layout

This https://github.com/persian-calendar/DroidPersianCalendar/commit/50de19d67c2ec53dc847407c7c23abf332a07650 has fixed the issue in my other app so there should be something specific about our ViewPager2 use here as the same issue doesn't happen in other pagers of the app also AFAICS.

as the same issue doesn't happen in other pagers of the app also AFAICS.

Seems to happen on the player page as well (not on the first page but on all others).

It works when removing pager.setOffscreenPageLimit(1). We can not do that for the player page (otherwise the method for finding the scrollable view breaks). Also, without enabling off-screen pages, you always see the progress bar when swiping between episodes.

Looks like ViewPager2 1.1.0-alpha01 fixes this (have not found the actual commit but confirmed by testing manually). The version also fixes the duplicate toolbar menu items (that you have worked around) https://issuetracker.google.com/issues/144442240

I don't like to use alpha dependencies but I guess we need to do it in this case.

I don't like to use alpha dependencies but I guess we need to do it in this case.

I am sorry about it :/

No problem, ViewPager2 is a big step forward (but a few tiny steps back). Thanks for bringing the RTL problems to my attention and fixing so many of them! That makes AntennaPod a lot better.

Was this page helpful?
0 / 5 - 0 ratings