mirror of
https://github.com/MatomoCamp/matomocamp-companion-android.git
synced 2024-09-19 16:13:46 +02:00
Updated the code to allow fragments in ViewPager to start as soon as they are visible
This commit is contained in:
parent
97156d6061
commit
cb054007da
2 changed files with 10 additions and 12 deletions
|
@ -65,12 +65,11 @@ public class LiveFragment extends Fragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
super.setPrimaryItem(container, position, object);
|
||||
// Hack to allow the non-primary fragments to start properly
|
||||
if (object != null) {
|
||||
((Fragment) object).setUserVisibleHint(false);
|
||||
}
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
// Allow the non-primary fragments to start as soon as they are visible
|
||||
Fragment f = (Fragment) super.instantiateItem(container, position);
|
||||
f.setUserVisibleHint(true);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,12 +186,11 @@ public class TracksFragment extends Fragment implements LoaderCallbacks<List<Day
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
super.setPrimaryItem(container, position, object);
|
||||
// Hack to allow the non-primary fragments to start properly
|
||||
if (object != null) {
|
||||
((Fragment) object).setUserVisibleHint(false);
|
||||
}
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
// Allow the non-primary fragments to start as soon as they are visible
|
||||
Fragment f = (Fragment) super.instantiateItem(container, position);
|
||||
f.setUserVisibleHint(true);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue