+
+ // Store the populated string builder in the locale string.
+ localeString = localesStringBuilder.toString();
+ } else { // SDK < 24 only has a primary locale.
+ // Store the locale in the locale string.
+ localeString = Locale.getDefault().toString();
+ }
+
+ // Instantiate the proxy helper.
+ ProxyHelper proxyHelper = new ProxyHelper();
+
+ // Get the current proxy.
+ Proxy proxy = proxyHelper.getCurrentProxy(this);
+
+ // Make the progress bar visible.
+ progressBar.setVisibility(View.VISIBLE);
+
+ // Set the progress bar to be indeterminate.
+ progressBar.setIndeterminate(true);
+
+ // Instantiate the WebView source factory.
+ ViewModelProvider.Factory webViewSourceFactory = new WebViewSourceFactory(currentUrl, userAgent, doNotTrack, localeString, proxy, MainWebViewActivity.executorService);
+
+ // Instantiate the WebView source view model class.
+ final WebViewSource webViewSource = new ViewModelProvider(this, webViewSourceFactory).get(WebViewSource.class);
+
+ // Create a source observer.
+ webViewSource.observeSource().observe(this, sourceStringArray -> {
+ // Populate the text views. This can take a long time, and freezes the user interface, if the response body is particularly large.
+ requestHeadersTextView.setText(sourceStringArray[0]);
+ responseMessageTextView.setText(sourceStringArray[1]);
+ responseHeadersTextView.setText(sourceStringArray[2]);
+ responseBodyTextView.setText(sourceStringArray[3]);
+
+ // Hide the progress bar.
+ progressBar.setIndeterminate(false);
+ progressBar.setVisibility(View.GONE);
+
+ //Stop the swipe to refresh indicator if it is running
+ swipeRefreshLayout.setRefreshing(false);