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.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
import android.provider.BaseColumns; import android.provider.BaseColumns;
import android.view.View;
import com.viewpagerindicator.UnderlinePageIndicator;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity; 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.NfcUtils.CreateNfcAppDataCallback;
import be.digitalia.fosdem.utils.ThemeUtils; import be.digitalia.fosdem.utils.ThemeUtils;
import be.digitalia.fosdem.widgets.ContentLoadingProgressBar; 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. * 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) { if (savedInstanceState == null) {
initialPosition = extras.getInt(EXTRA_POSITION, -1); initialPosition = extras.getInt(EXTRA_POSITION, -1);
pager.setAdapter(adapter);
pageIndicator.setViewPager(pager);
} }
ActionBar bar = getSupportActionBar(); ActionBar bar = getSupportActionBar();
@ -121,9 +118,10 @@ public class TrackScheduleEventActivity extends AppCompatActivity implements Loa
setCustomProgressVisibility(false); setCustomProgressVisibility(false);
if (data != null) { if (data != null) {
pager.setVisibility(View.VISIBLE);
adapter.setCursor(data); 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 // to ensure the current position is restored properly
if (pager.getAdapter() == null) { if (pager.getAdapter() == null) {
pager.setAdapter(adapter); pager.setAdapter(adapter);

View file

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

View file

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