Skip to content

Commit

Permalink
add ProgressBar
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximBelov committed Sep 22, 2024
1 parent e2d8429 commit e145021
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

Expand Down Expand Up @@ -126,6 +127,7 @@ public class InAppBrowser extends CordovaPlugin {
private InAppBrowserDialog dialog;
private WebView inAppWebView;
private EditText edittext;
private ProgressBar progressBar;
private CallbackContext callbackContext;
private boolean showLocationBar = true;
private boolean showZoomControls = true;
Expand Down Expand Up @@ -1044,6 +1046,13 @@ public void postMessage(String data) {
main.addView(toolbar);
}

// Progress Bar
progressBar = new ProgressBar(webView.getContext(), null, android.R.attr.progressBarStyleHorizontal);
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.GONE);

main.addView(progressBar);

// Add our webview to our main view/layout
RelativeLayout webViewLayout = new RelativeLayout(cordova.getActivity());
webViewLayout.addView(inAppWebView);
Expand Down Expand Up @@ -1367,6 +1376,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
} catch (JSONException ex) {
LOG.e(LOG_TAG, "URI passed in has caused a JSON error.");
}
progressBar.setVisibility(View.VISIBLE);
}

public void onPageFinished(WebView view, String url) {
Expand All @@ -1391,6 +1401,7 @@ public void onPageFinished(WebView view, String url) {
} catch (JSONException ex) {
LOG.d(LOG_TAG, "Should never happen");
}
progressBar.setVisibility(View.GONE);
}

public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Expand All @@ -1407,6 +1418,7 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
} catch (JSONException ex) {
LOG.d(LOG_TAG, "Should never happen");
}
progressBar.setVisibility(View.GONE);
}

@Override
Expand Down

0 comments on commit e145021

Please sign in to comment.