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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations