Search in sources :

Example 61 with ProgressBar

use of android.widget.ProgressBar in project materialistic by hidroh.

the class OfflineWebActivity method onCreate.

@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getStringExtra(EXTRA_URL);
    if (TextUtils.isEmpty(url)) {
        finish();
        return;
    }
    setTitle(url);
    setContentView(R.layout.activity_offline_web);
    final NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scroll_view);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setSubtitle(R.string.offline);
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
    final WebView webView = (WebView) findViewById(R.id.web_view);
    webView.setBackgroundColor(Color.TRANSPARENT);
    webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this)) {

        @Override
        public void onPageFinished(WebView view, String url) {
            setTitle(view.getTitle());
        }
    });
    webView.setWebChromeClient(new CacheableWebView.ArchiveClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            progressBar.setVisibility(View.VISIBLE);
            progressBar.setProgress(newProgress);
            if (newProgress == 100) {
                progressBar.setVisibility(View.GONE);
                webView.setBackgroundColor(Color.WHITE);
                webView.setVisibility(View.VISIBLE);
            }
        }
    });
    AppUtils.toggleWebViewZoom(webView.getSettings(), true);
    webView.loadUrl(url);
}
Also used : AdBlockWebViewClient(io.github.hidroh.materialistic.widget.AdBlockWebViewClient) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) NestedScrollView(android.support.v4.widget.NestedScrollView) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) WebView(android.webkit.WebView) ProgressBar(android.widget.ProgressBar) Toolbar(android.support.v7.widget.Toolbar)

Example 62 with ProgressBar

use of android.widget.ProgressBar in project android_frameworks_base by ParanoidAndroid.

the class ActionBarView method initProgress.

public void initProgress() {
    mProgressView = new ProgressBar(mContext, null, 0, mProgressStyle);
    mProgressView.setId(R.id.progress_horizontal);
    mProgressView.setMax(10000);
    mProgressView.setVisibility(GONE);
    addView(mProgressView);
}
Also used : ProgressBar(android.widget.ProgressBar)

Example 63 with ProgressBar

use of android.widget.ProgressBar in project Android-DialogFragments by wada811.

the class ProgressDialogBase method getHorizontalView.

protected View getHorizontalView() {
    final Context context = getContext();
    final float density = context.getResources().getDisplayMetrics().density;
    final RelativeLayout root = new RelativeLayout(context);
    root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    final int marginH = (int) (10 * density);
    final int marginT = (int) (12 * density);
    final RelativeLayout.LayoutParams progressParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    progressParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    progressParams.topMargin = marginT;
    progressParams.bottomMargin = (int) (density + 0.5f);
    progressParams.leftMargin = marginH;
    progressParams.rightMargin = marginH;
    final ProgressBar progress = progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    progress.setLayoutParams(progressParams);
    progress.setId(android.R.id.progress);
    root.addView(progress);
    final RelativeLayout.LayoutParams percentParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    percentParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    percentParams.addRule(RelativeLayout.BELOW, android.R.id.progress);
    percentParams.leftMargin = marginH;
    percentParams.rightMargin = marginH;
    final TextView percent = progressPercent = new TextView(context);
    percent.setLayoutParams(percentParams);
    root.addView(percent);
    final RelativeLayout.LayoutParams numberParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    numberParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    numberParams.addRule(RelativeLayout.BELOW, android.R.id.progress);
    numberParams.leftMargin = marginH;
    numberParams.rightMargin = marginH;
    final TextView number = progressNumber = new TextView(context);
    number.setLayoutParams(numberParams);
    root.addView(number);
    return root;
}
Also used : Context(android.content.Context) LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar)

Example 64 with ProgressBar

use of android.widget.ProgressBar in project Android-DialogFragments by wada811.

the class ProgressDialogBase method getSpinnerView.

protected View getSpinnerView() {
    final Context context = getContext();
    final float density = context.getResources().getDisplayMetrics().density;
    final FrameLayout root = new FrameLayout(context);
    root.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    final int paddingH = (int) (8 * density);
    final int paddingV = (int) (10 * density);
    final LinearLayout container = new LinearLayout(context);
    container.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    container.setOrientation(LinearLayout.HORIZONTAL);
    container.setBaselineAligned(false);
    container.setPadding(paddingH, paddingV, paddingH, paddingV);
    root.addView(container);
    final LinearLayout.LayoutParams progressParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    progressParams.rightMargin = (int) (12 * density);
    final ProgressBar progress = progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyle);
    progress.setLayoutParams(progressParams);
    progress.setId(android.R.id.progress);
    progress.setMax(10000);
    container.addView(progress);
    final LinearLayout.LayoutParams messageParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    messageParams.gravity = Gravity.CENTER_VERTICAL;
    final TextView message = messageView = new TextView(context);
    message.setLayoutParams(messageParams);
    message.setId(android.R.id.message);
    container.addView(message);
    return root;
}
Also used : Context(android.content.Context) LayoutParams(android.view.ViewGroup.LayoutParams) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout)

Example 65 with ProgressBar

use of android.widget.ProgressBar in project Android-DialogFragments by wada811.

the class ProgressDialog method getHorizontalView.

protected View getHorizontalView() {
    final Context context = getContext();
    final float density = context.getResources().getDisplayMetrics().density;
    final RelativeLayout root = new RelativeLayout(context);
    root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    final int marginH = (int) (10 * density);
    final int marginT = (int) (12 * density);
    final RelativeLayout.LayoutParams progressParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    progressParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    progressParams.topMargin = marginT;
    progressParams.bottomMargin = (int) (density + 0.5f);
    progressParams.leftMargin = marginH;
    progressParams.rightMargin = marginH;
    final ProgressBar progress = progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    progress.setLayoutParams(progressParams);
    progress.setId(android.R.id.progress);
    root.addView(progress);
    final RelativeLayout.LayoutParams percentParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    percentParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    percentParams.addRule(RelativeLayout.BELOW, android.R.id.progress);
    percentParams.leftMargin = marginH;
    percentParams.rightMargin = marginH;
    final TextView percent = progressPercent = new TextView(context);
    percent.setLayoutParams(percentParams);
    root.addView(percent);
    final RelativeLayout.LayoutParams numberParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    numberParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    numberParams.addRule(RelativeLayout.BELOW, android.R.id.progress);
    numberParams.leftMargin = marginH;
    numberParams.rightMargin = marginH;
    final TextView number = progressNumber = new TextView(context);
    number.setLayoutParams(numberParams);
    root.addView(number);
    return root;
}
Also used : Context(android.content.Context) LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar)

Aggregations

ProgressBar (android.widget.ProgressBar)193 TextView (android.widget.TextView)66 View (android.view.View)63 ImageView (android.widget.ImageView)41 LinearLayout (android.widget.LinearLayout)30 Context (android.content.Context)18 ViewGroup (android.view.ViewGroup)16 WindowManager (android.view.WindowManager)14 FrameLayout (android.widget.FrameLayout)14 Drawable (android.graphics.drawable.Drawable)13 Dialog (android.app.Dialog)12 Button (android.widget.Button)12 RelativeLayout (android.widget.RelativeLayout)12 LayoutInflater (android.view.LayoutInflater)11 SuppressLint (android.annotation.SuppressLint)10 LayoutParams (android.widget.LinearLayout.LayoutParams)9 Intent (android.content.Intent)8 LayoutParams (android.view.ViewGroup.LayoutParams)8 AlertDialog (android.app.AlertDialog)7 TypedArray (android.content.res.TypedArray)7