]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/adapters/AboutPagerAdapter.java
Save and restore the app state. https://redmine.stoutner.com/issues/461
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / adapters / AboutPagerAdapter.java
index 0d9a15867db8a0c2ef436b9a02a5b487758a9863..9d4c9191d3a745d880a9cf89506660110615ae55 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
@@ -21,6 +21,7 @@ package com.stoutner.privacybrowser.adapters;
 
 import android.content.Context;
 
+import androidx.annotation.NonNull;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentPagerAdapter;
@@ -29,18 +30,16 @@ import com.stoutner.privacybrowser.R;
 import com.stoutner.privacybrowser.fragments.AboutTabFragment;
 
 public class AboutPagerAdapter extends FragmentPagerAdapter {
-    // Define the class variable to store the blocklist versions.
+    // Define the class variables.
     private Context context;
     private String[] blocklistVersions;
 
     public AboutPagerAdapter(FragmentManager fragmentManager, Context context, String[] blocklistVersions) {
         // Run the default commands.
-        super(fragmentManager);
+        super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
 
-        // Store the context in a class variable.
+        // Store the class variables.
         this.context = context;
-
-        // Store the blocklist versions in a class variable.
         this.blocklistVersions = blocklistVersions;
     }
 
@@ -55,25 +54,25 @@ public class AboutPagerAdapter extends FragmentPagerAdapter {
     public CharSequence getPageTitle(int tab) {
         switch (tab) {
             case 0:
-                return context.getResources().getString(R.string.version);
+                return context.getString(R.string.version);
 
             case 1:
-                return context.getResources().getString(R.string.permissions);
+                return context.getString(R.string.permissions);
 
             case 2:
-                return context.getResources().getString(R.string.privacy_policy);
+                return context.getString(R.string.privacy_policy);
 
             case 3:
-                return context.getResources().getString(R.string.changelog);
+                return context.getString(R.string.changelog);
 
             case 4:
-                return context.getResources().getString(R.string.licenses);
+                return context.getString(R.string.licenses);
 
             case 5:
-                return context.getResources().getString(R.string.contributors);
+                return context.getString(R.string.contributors);
 
             case 6:
-                return context.getResources().getString(R.string.links);
+                return context.getString(R.string.links);
 
             default:
                 return "";
@@ -81,6 +80,7 @@ public class AboutPagerAdapter extends FragmentPagerAdapter {
     }
 
     @Override
+    @NonNull
     // Setup each tab.
     public Fragment getItem(int tabNumber) {
         return AboutTabFragment.createTab(tabNumber, blocklistVersions);