List of usage examples for android.widget ProgressBar setProgress
@android.view.RemotableViewMethod public synchronized void setProgress(int progress)
From source file:com.cjones.taskforcemamba.activity.WebActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTitle = mDrawerTitle = getTitle();//w w w . ja va 2s.c o m //WebView Intent launchingIntent = getIntent(); // String content = launchingIntent.getData().toString(); String home = "http://www.tfmamba.com"; // Log.i(TAG, "Content = " + content + " . Home = " + home); // if(content == home){ // content = content + "&styleid=2"; // Log.i(TAG, "IF Statement - Content = " + content + " . Home = " + home); // } else { // Log.i(TAG, "Else Statement - Content = " + content + " . Home = " + home); // } // Log.i(TAG, "conte = " + content); myWebView = (WebView) findViewById(R.id.webview); // if(content == null){ myWebView.loadUrl(home); // }else { // myWebView.loadUrl(content); // } myWebView.setWebViewClient(new WebViewClient()); myWebView.getSettings().setBuiltInZoomControls(true); myWebView.getSettings().setJavaScriptEnabled(true); myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); final ProgressBar Pbar; Pbar = (ProgressBar) findViewById(R.id.pB1); myWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { if (progress < 100 && Pbar.getVisibility() == ProgressBar.GONE) { Pbar.setVisibility(ProgressBar.VISIBLE); } Pbar.setProgress(progress); if (progress == 100) { Pbar.setVisibility(ProgressBar.GONE); } } }); if (savedInstanceState != null) { myWebView.restoreState(savedInstanceState); } else { // if(content == null && !content.isEmpty()){ // myWebView.loadUrl("http://www.tfmamba.com"); } }
From source file:yet.another.hackernews.reader.ViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); menuBrowser = (WebView) getSherlockActivity().findViewById(R.id.view_webview); final ProgressBar progressBar = (ProgressBar) getSherlockActivity().findViewById(R.id.view_progress); webviewSettings();/* w w w . ja v a2 s . co m*/ menuBrowser.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { // Hide dialog on finished if (progress >= 100) { progressBar.setVisibility(View.GONE); } else { progressBar.setProgress(progress); } } }); menuBrowser.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { progressBar.setVisibility(View.GONE); Toast.makeText(getActivity().getApplicationContext(), R.string.error, Toast.LENGTH_SHORT).show(); } }); final Bundle recieveArgs = this.getSherlockActivity().getIntent().getExtras(); if (recieveArgs != null) { try { news = new News(new JSONObject(recieveArgs.getString("NewsObject"))); } catch (JSONException e) { } update(progressBar); } }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Sets the progress of a ProgressBar.//ww w . j a v a2 s . c o m * * @param viewId * The view id. * @param progress * The progress. * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setProgress(int viewId, int progress) { ProgressBar view = retrieveView(viewId); view.setProgress(progress); return this; }
From source file:com.somethoughts.chinmay.game.Dice.DiceFragment.java
void spin() { if (inProgress) { Toast.makeText(getActivity(), "Please Wait", Toast.LENGTH_SHORT).show(); return;// w ww. jav a 2 s .c o m } Typeface custom_font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/myfnt.ttf"); final TextView textView = (TextView) view.findViewById(R.id.dice_result_textview); final TextView textViewrun = (TextView) view.findViewById(R.id.result_textView_run); final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.dice_progressBar); progressBar.setIndeterminate(false); progressBar.setMax(3000); textView.setTypeface(custom_font); textViewrun.setTypeface(custom_font); progressBar.setVisibility(View.VISIBLE); countDownTimer = new CountDownTimer(3000, 250) { @Override public void onTick(long l) { inProgress = true; Random random = new Random(); progressBar.setProgress(3000 - (int) l); Log.v("Progress", Integer.toString(progressBar.getProgress())); textViewrun.setVisibility(View.VISIBLE); textViewrun.setText("Waiting"); textView.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); textView.setText(Integer.toString(random.nextInt(6) + 1)); } @Override public void onFinish() { inProgress = false; view.setBackgroundColor(getResources().getColor(R.color.colorWin)); textViewrun.setText("Here you go"); progressBar.setProgress(3000); return; } }.start(); }
From source file:com.amaze.filemanager.fragments.ProcessViewer.java
public void processResults(final DataPackage b) { if (!running) return;//from www . j a v a2 s .c o m if (getResources() == null) return; if (b != null) { int id = b.getId(); final Integer id1 = new Integer(id); if (!CancelledCopyIds.contains(id1)) { if (CopyIds.contains(id1)) { boolean completed = b.isCompleted(); View process = rootView.findViewWithTag("copy" + id); if (completed) { try { rootView.removeViewInLayout(process); CopyIds.remove(CopyIds.indexOf(id1)); } catch (Exception e) { e.printStackTrace(); } } else { String name = b.getName(); int p1 = b.getP1(); int p2 = b.getP2(); long total = b.getTotal(); long done = b.getDone(); boolean move = b.isMove(); String text = utils.getString(getActivity(), R.string.copying) + "\n" + name + "\n" + utils.readableFileSize(done) + "/" + utils.readableFileSize(total) + "\n" + p1 + "%"; if (move) { text = utils.getString(getActivity(), R.string.moving) + "\n" + name + "\n" + utils.readableFileSize(done) + "/" + utils.readableFileSize(total) + "\n" + p1 + "%"; } ((TextView) process.findViewById(R.id.progressText)).setText(text); ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1); p.setProgress(p1); p.setSecondaryProgress(p2); } } else { CardView root = (android.support.v7.widget.CardView) getActivity().getLayoutInflater() .inflate(R.layout.processrow, null); root.setTag("copy" + id); ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button); TextView progressText = (TextView) root.findViewById(R.id.progressText); Drawable icon = icons.getCopyDrawable(); boolean move = b.isMove(); if (move) { icon = icons.getCutDrawable(); } if (mainActivity.theme1 == 1) { cancel.setImageResource(R.drawable.ic_action_cancel); root.setCardBackgroundColor(R.color.cardView_foreground); root.setCardElevation(0f); progressText.setTextColor(Color.WHITE); } else { icon.setColorFilter(Color.parseColor("#666666"), PorterDuff.Mode.SRC_ATOP); progressText.setTextColor(Color.BLACK); } ((ImageView) root.findViewById(R.id.progressImage)).setImageDrawable(icon); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping), Toast.LENGTH_LONG).show(); Intent i = new Intent("copycancel"); i.putExtra("id", id1); getActivity().sendBroadcast(i); rootView.removeView(rootView.findViewWithTag("copy" + id1)); CopyIds.remove(CopyIds.indexOf(id1)); CancelledCopyIds.add(id1); // TODO: Implement this method } }); String name = b.getName(); int p1 = b.getP1(); int p2 = b.getP2(); String text = utils.getString(getActivity(), R.string.copying) + "\n" + name; if (move) { text = utils.getString(getActivity(), R.string.moving) + "\n" + name; } progressText.setText(text); ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1); p.setProgress(p1); p.setSecondaryProgress(p2); CopyIds.add(id1); rootView.addView(root); } } } }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Sets the progress and max of a ProgressBar. * /* w ww . j a va2 s .c om*/ * @param viewId * The view id. * @param progress * The progress. * @param max * The max value of a ProgressBar. * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setProgress(int viewId, int progress, int max) { ProgressBar view = retrieveView(viewId); view.setMax(max); view.setProgress(progress); return this; }
From source file:com.somethoughts.chinmay.game.Coin.CoinTossMainFragment.java
private void toss_it(final Boolean userChoice) { if (inProgress) { Toast.makeText(getActivity(), "Please Wait", Toast.LENGTH_SHORT).show(); return;/*from w ww. j a v a2s .c om*/ } final TextView textViewResult = (TextView) view.findViewById(R.id.coin_result_textview); final TextView textViewStatus = (TextView) view.findViewById(R.id.coin_status_textView); final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.coin_progressBar); Random random = new Random(); progressBar.setVisibility(View.VISIBLE); progressBar.setMax(2500); progressBar.setIndeterminate(false); final Boolean b = random.nextBoolean(); countDownTimer = new CountDownTimer(3000, 125) { @Override public void onTick(long l) { inProgress = true; Random random = new Random(); progressBar.setProgress(3000 - (int) l); Log.v("Progress", Integer.toString(progressBar.getProgress())); textViewStatus.setVisibility(View.VISIBLE); textViewStatus.setText(toss[random.nextInt(2)]); textViewResult.setText(getResources().getText(R.string.Waiting)); } @Override public void onFinish() { inProgress = false; if ((b && userChoice) || (!b && !userChoice)) { textViewStatus.setText(getResources().getText(R.string.Voila)); view.setBackgroundColor(getColor(getActivity().getBaseContext(), R.color.colorWin)); if (userChoice) textViewResult.setText(toss[0]); else textViewResult.setText(toss[1]); } else { textViewStatus.setText(getResources().getText(R.string.oops)); view.setBackgroundColor(getColor(getActivity().getBaseContext(), R.color.colorLose)); if (userChoice) textViewResult.setText(toss[1]); else textViewResult.setText(toss[0]); } progressBar.setProgress(3000); } }.start(); }
From source file:io.github.hidroh.materialistic.WebFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { if (mIsHackerNewsUrl) { return createLocalView(container, savedInstanceState); }//from w w w . j a v a2 s .c om final View view = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_web, container, false); mScrollView = (NestedScrollView) view.findViewById(R.id.nested_scroll_view); final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress); mWebView = (WebView) view.findViewById(R.id.web_view); mWebView.setBackgroundColor(Color.TRANSPARENT); mWebView.setWebViewClient(new WebViewClient()); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); if (newProgress == 100) { progressBar.setVisibility(View.GONE); mWebView.setBackgroundColor(Color.WHITE); mWebView.setVisibility(mExternalRequired ? View.GONE : View.VISIBLE); } } }); mWebView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { if (getActivity() == null) { return; } final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (intent.resolveActivity(getActivity().getPackageManager()) == null) { return; } mExternalRequired = true; mWebView.setVisibility(View.GONE); view.findViewById(R.id.empty).setVisibility(View.VISIBLE); view.findViewById(R.id.download_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(intent); } }); } }); mWebView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) { if (mWebView.canGoBack()) { mWebView.goBack(); return true; } } return false; } }); setWebViewSettings(mWebView.getSettings()); return view; }
From source file:com.autoparts.buyers.action_content.fragment.WebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from w w w . j a v a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.webview_fragment, container, false); final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress); viewContentWebView = (WebView) v.findViewById(R.id.webview); viewContentWebView.getSettings().setJavaScriptEnabled(true); viewContentWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return super.shouldOverrideUrlLoading(view, url); } }); viewContentWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { viewContentProgress.setProgress(newProgress); viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE); if (newProgress == 100 && resetHistory) { viewContentWebView.clearHistory(); resetHistory = false; } } }); return v; }
From source file:com.anxpp.blog.fragment.WebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override// w ww . ja va 2 s . co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.webview, container, false); final ProgressBar viewContentProgress = (ProgressBar) v.findViewById(R.id.progress); viewContentWebView = (WebView) v.findViewById(R.id.webview); viewContentWebView.getSettings().setJavaScriptEnabled(true); viewContentWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return super.shouldOverrideUrlLoading(view, url); } }); viewContentWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { viewContentProgress.setProgress(newProgress); viewContentProgress.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE); if (newProgress == 100 && resetHistory) { viewContentWebView.clearHistory(); resetHistory = false; } } }); return v; }