Use FragmentActivity for AboutActivity's viewpager2

This commit is contained in:
TacoTheDank 2020-10-31 15:54:39 -04:00
parent 1a64d8aec9
commit 6db560fd2c
1 changed files with 4 additions and 6 deletions

View File

@ -12,8 +12,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2; import androidx.viewpager2.widget.ViewPager2;
@ -95,8 +94,7 @@ public class AboutActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Create the adapter that will return a fragment for each of the three // Create the adapter that will return a fragment for each of the three
// primary sections of the activity. // primary sections of the activity.
mSectionsPagerAdapter = mSectionsPagerAdapter = new SectionsPagerAdapter(this);
new SectionsPagerAdapter(getSupportFragmentManager(), getLifecycle());
// Set up the ViewPager with the sections adapter. // Set up the ViewPager with the sections adapter.
mViewPager = findViewById(R.id.container); mViewPager = findViewById(R.id.container);
@ -179,8 +177,8 @@ public class AboutActivity extends AppCompatActivity {
* one of the sections/tabs/pages. * one of the sections/tabs/pages.
*/ */
public static class SectionsPagerAdapter extends FragmentStateAdapter { public static class SectionsPagerAdapter extends FragmentStateAdapter {
public SectionsPagerAdapter(final FragmentManager fm, final Lifecycle lifecycle) { public SectionsPagerAdapter(final FragmentActivity fa) {
super(fm, lifecycle); super(fa);
} }
@NonNull @NonNull