]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/asynctasks/PopulateBlocklists.java
Release 3.1.
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / asynctasks / PopulateBlocklists.java
index f7fa50886569b72c544afe3dac3adca794c61850..106c8d9c919a8ddbad8e16fbe92c1fd7c0bcd0a2 100644 (file)
@@ -24,6 +24,7 @@ import android.content.Context;
 import android.os.AsyncTask;
 import android.view.View;
 import android.widget.LinearLayout;
+import android.widget.ProgressBar;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
@@ -61,6 +62,30 @@ public class PopulateBlocklists extends AsyncTask<Void, String, ArrayList<ArrayL
         populateBlocklistsListener = (PopulateBlocklistsListener) context;
     }
 
+    // `onPreExecute()` operates on the UI thread.
+    @Override
+    protected void onPreExecute() {
+        // Get a handle for the activity.
+        Activity activity = activityWeakReference.get();
+
+        // Abort if the activity is gone.
+        if ((activity == null) || activity.isFinishing()) {
+            return;
+        }
+
+        // Get handles for the views.
+        Toolbar toolbar = activity.findViewById(R.id.toolbar);
+        LinearLayout tabsLinearLayout = activity.findViewById(R.id.tabs_linearlayout);
+        RelativeLayout loadingBlocklistsRelativeLayout = activity.findViewById(R.id.loading_blocklists_relativelayout);
+
+        // Hide the toolbar and tabs linear layout, which will be visible if this is being run after the app process has been killed in the background.
+        toolbar.setVisibility(View.GONE);
+        tabsLinearLayout.setVisibility(View.GONE);
+
+        // Show the loading blocklists screen.
+        loadingBlocklistsRelativeLayout.setVisibility(View.VISIBLE);
+    }
+
     @Override
     protected ArrayList<ArrayList<List<String[]>>> doInBackground(Void... none) {
         // Get a handle for the context.