1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Performance fix: ensure the ViewPager is only made visible when the adapter is set to avoid it to layout pages too early

This commit is contained in:
Christophe Beyls 2019-01-25 02:00:48 +01:00
parent 7e15f7de55
commit b79e29a67c
3 changed files with 8 additions and 8 deletions

View file

@ -3,9 +3,7 @@ package be.digitalia.fosdem.activities;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.BaseColumns;
import com.viewpagerindicator.UnderlinePageIndicator;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
@ -27,6 +25,7 @@ import be.digitalia.fosdem.utils.NfcUtils;
import be.digitalia.fosdem.utils.NfcUtils.CreateNfcAppDataCallback;
import be.digitalia.fosdem.utils.ThemeUtils;
import be.digitalia.fosdem.widgets.ContentLoadingProgressBar;
import com.viewpagerindicator.UnderlinePageIndicator;
/**
* Event view of the track schedule; allows to slide between events of the same track using a ViewPager.
@ -67,8 +66,6 @@ public class TrackScheduleEventActivity extends AppCompatActivity implements Loa
if (savedInstanceState == null) {
initialPosition = extras.getInt(EXTRA_POSITION, -1);
pager.setAdapter(adapter);
pageIndicator.setViewPager(pager);
}
ActionBar bar = getSupportActionBar();
@ -121,9 +118,10 @@ public class TrackScheduleEventActivity extends AppCompatActivity implements Loa
setCustomProgressVisibility(false);
if (data != null) {
pager.setVisibility(View.VISIBLE);
adapter.setCursor(data);
// Delay setting the adapter when the instance state is restored
// Delay setting the adapter
// to ensure the current position is restored properly
if (pager.getAdapter() == null) {
pager.setAdapter(adapter);

View file

@ -8,7 +8,8 @@
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"

View file

@ -14,7 +14,8 @@
<androidx.viewpager.widget.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:visibility="gone"/>
<com.viewpagerindicator.UnderlinePageIndicator
android:id="@+id/indicator"