Example usage for android.widget ProgressBar setProgress

List of usage examples for android.widget ProgressBar setProgress

Introduction

In this page you can find the example usage for android.widget ProgressBar setProgress.

Prototype

@android.view.RemotableViewMethod
public synchronized void setProgress(int progress) 

Source Link

Document

Sets the current progress to the specified value.

Usage

From source file:com.inovex.zabbixmobile.activities.fragments.BaseSeverityFilterListFragment.java

/**
 * Dismisses the progress bar.//  w ww.j a va 2 s .c o m
 */
public void dismissProgressBar() {
    mProgressBarVisible = false;
    if (getView() != null) {
        LinearLayout progressLayout = (LinearLayout) getView().findViewById(R.id.severity_list_progress_layout);
        if (progressLayout != null) {
            progressLayout.setVisibility(View.GONE);
        }
        ProgressBar listProgress = (ProgressBar) getView().findViewById(R.id.severity_list_progress);
        listProgress.setProgress(0);
    }
}

From source file:org.jared.synodroid.ds.adapter.DetailAdapter.java

/**
 * Bind torrent's data with widget for a DetailProgress instance
 * //  w  w  w.  j a  va2 s .  c om
 * @param viewP
 * @param torrentP
 */
private void bindDetailProgress(View viewP, final DetailProgress detailP) {
    // The label for the first progress
    TextView label = (TextView) viewP.findViewById(R.id.id_detail_value);
    label.setText(detailP.getLabel());
    // The value for the first progress
    ProgressBar value = (ProgressBar) viewP.findViewById(R.id.id_detail_progress);
    value.setProgress(detailP.getValue());
}

From source file:org.jared.synodroid.ds.adapter.DetailAdapter.java

/**
 * Bind torrent's data with widget for a Detail2Progress instance
 * /*from  w w w.  ja  v a 2 s  .c  o m*/
 * @param viewP
 * @param torrentP
 */
private void bindDetail2Progress(View viewP, final Detail2Progress detailP) {
    // The label for the first progress
    TextView label = (TextView) viewP.findViewById(R.id.id_detail_value1);
    label.setText(detailP.getLabel1());
    // The value for the first progress
    ProgressBar value = (ProgressBar) viewP.findViewById(R.id.id_detail_progress1);
    value.setProgress(detailP.getValue1());

    // The label for the second progress
    label = (TextView) viewP.findViewById(R.id.id_detail_value2);
    label.setText(detailP.getLabel2());
    // The value for the first progress
    value = (ProgressBar) viewP.findViewById(R.id.id_detail_progress2);
    value.setProgress(detailP.getValue2());
}

From source file:com.samknows.measurement.activity.SamKnowsActivating.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activating);
    Util.initializeFonts(this);
    Util.overrideFonts(this, findViewById(android.R.id.content));

    /*// w ww  .j  a  v  a  2  s. co  m
     * {"type":"mainprogress", "value":"42"} {"type":"activating"}
     * {"type":"download"} {"type":"inittests", "total":"24",
     * "finished":"21", "currentbest":"london", "besttime": "25 ms"}
     * {"type":"completed"}
     */

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            TextView tv;

            JSONObject message_json;
            if (msg.obj == null) {
                return;
            }
            message_json = (JSONObject) msg.obj;

            try {
                String type = message_json.getString(UIUpdate.JSON_TYPE);

                if (type == UIUpdate.JSON_MAINPROGRESS) {
                    String value = message_json.getString(UIUpdate.JSON_VALUE);
                    ProgressBar progressbar = (ProgressBar) findViewById(R.id.activation_progress);
                    int progress = Integer.parseInt(value);
                    progressbar.setProgress(progress);
                } else if (type == UIUpdate.JSON_ACTIVATED) {
                    ProgressBar pb = (ProgressBar) findViewById(R.id.activating_progress);
                    pb.setVisibility(View.GONE);
                    ImageView iv = (ImageView) findViewById(R.id.activating_complete);
                    iv.setVisibility(View.VISIBLE);
                } else if (type == UIUpdate.JSON_DOWNLOADED) {
                    ProgressBar pb = (ProgressBar) findViewById(R.id.download_progress);
                    pb.setVisibility(View.GONE);
                    ImageView iv = (ImageView) findViewById(R.id.download_complete);
                    iv.setVisibility(View.VISIBLE);
                } else if (type == UIUpdate.JSON_INITTESTS) {
                    String total = message_json.getString(UIUpdate.JSON_TOTAL);
                    String finished = message_json.getString(UIUpdate.JSON_FINISHED);
                    String currentbest = message_json.getString(UIUpdate.JSON_CURRENTBEST);
                    String besttime = message_json.getString(UIUpdate.JSON_BESTTIME);
                    tv = (TextView) findViewById(R.id.currentbest);
                    tv.setText(currentbest);
                    tv = (TextView) findViewById(R.id.besttime);
                    tv.setText(besttime);
                    tv = (TextView) findViewById(R.id.server_status);
                    tv.setText(finished + " " + getString(R.string.of) + " " + total);

                } else if (type == UIUpdate.JSON_COMPLETED) {
                    LoginHelper.openMainScreen(SamKnowsActivating.this);
                    SamKnowsActivating.this.finish();
                }

            } catch (JSONException e) {
                Logger.e(SamKnowsActivating.class, "Error in parsing JSONObject: " + e.getMessage());

            }

        }
    };
    if (MainService.registerHandler(handler)) {
        Logger.d(this, "handler registered");
    } else {
        Logger.d(this, "MainService is not executing");
        LoginHelper.openMainScreen(SamKnowsActivating.this);
        SamKnowsActivating.this.finish();

    }
}

From source file:com.ae.apps.messagecounter.fragments.SentCountFragment.java

private void setProgressInfo(int count, int limit, ProgressBar progressBar, TextView progressText,
        long animDelay) {
    if (limit > 0) {
        progressBar.setMax(limit);/*  www  .  ja  va 2 s .c  o m*/
        progressBar.setProgress(0);
        int progress = count;
        if (count >= limit) {
            // Don't want progress to be greater than limit
            progress = limit;
        }
        if (animDelay == 0) {
            progressBar.setProgress(progress);
        } else {
            setProgressWithAnimation(progressBar, progress, animDelay);
        }
        progressText.setText(count + " / " + limit);
    }
}

From source file:app.android.example.com.commontcents.ListContentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View recyclerView = inflater.inflate(R.layout.item_list, container, false);

    final ProgressBar progressBar = (ProgressBar) recyclerView.findViewById(R.id.progress_bar);
    progressBar.setScaleY(3f);//  w w  w  .ja v a2s  .  co m

    final Handler mHandler = new Handler();

    mHandler.post(new Runnable() {
        public void run() {
            progressBar.incrementProgressBy(10 * poolCounter.getCount());
            progressBar.setProgress(progressBar.getProgress());
        }
    });

    return recyclerView;
}

From source file:com.restswitch.controlpanel.MainActivity.java

public void setProgressBars(String pb1Text, int pb1Pos, String pb2Text, int pb2Pos) {
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar);
    pb.setProgress(pb1Pos);
    pb.setSecondaryProgress(pb2Pos);/* ww  w  .  j  a v a  2  s . c  o m*/

    TextView tv1 = (TextView) findViewById(R.id.progressBarText);
    tv1.setText(pb1Text);

    TextView tv2 = (TextView) findViewById(R.id.secondaryProgressBarText);
    tv2.setText(pb2Text);

    int pbwTot = pb.getWidth();
    int pbw1 = ((pbwTot * pb1Pos) / 100);
    tv1.setWidth(pbw1);

    pbw1 += 96;
    int pbw2 = (pbwTot - pbw1);
    ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) tv2.getLayoutParams();
    mlp.setMargins(pbw1, 2, 0, 0);
    tv2.setWidth(pbw2);
}

From source file:com.inovex.zabbixmobile.activities.fragments.ChecksApplicationsFragment.java

/**
 * Updates the progress bar.// w  w w.  j  a v  a2s.  c o  m
 * 
 * @param progress
 *            current progress
 */
public void updateProgress(int progress) {
    if (getView() != null) {
        ProgressBar listProgress = (ProgressBar) getView().findViewById(R.id.applications_progress);
        listProgress.setProgress(progress);
    }
}

From source file:com.inovex.zabbixmobile.activities.fragments.ChecksApplicationsFragment.java

/**
 * Dismisses the loading spinner view./* w w w . j av  a2 s  .c o  m*/
 * 
 * If the view has not yet been created, the status is saved and when the
 * view is created, the spinner will not be shown at all.
 */
public void dismissItemsLoadingSpinner() {
    mItemsLoadingSpinnerVisible = false;
    if (getView() != null) {
        LinearLayout progressLayout = (LinearLayout) getView().findViewById(R.id.items_progress_layout);
        if (progressLayout != null) {
            progressLayout.setVisibility(View.GONE);
        }
        ProgressBar listProgress = (ProgressBar) getView().findViewById(R.id.applications_progress);
        listProgress.setProgress(0);
    }

}

From source file:de.geeksfactory.opacclient.frontend.InfoFragment.java

@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override/*  w  w w . j ava2 s .c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    view = inflater.inflate(R.layout.fragment_info, container, false);
    app = (OpacClient) getActivity().getApplication();

    setHasOptionsMenu(true);

    load();

    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    wvInfo = (WebView) view.findViewById(R.id.wvInfo);

    wvInfo.getSettings().setSupportZoom(true);
    wvInfo.getSettings().setJavaScriptEnabled(true);
    wvInfo.getSettings().setAppCacheMaxSize(5 * 1024 * 1024);
    wvInfo.getSettings().setAppCacheEnabled(true);
    wvInfo.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);

    wvInfo.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView v, int progress) {
            ProgressBar Pbar = (ProgressBar) view.findViewById(R.id.pbWebProgress);
            if (progress < 100 && Pbar.getVisibility() == View.GONE) {
                Pbar.setVisibility(View.VISIBLE);
            }
            Pbar.setProgress(progress);
            if (progress == 100) {
                Pbar.setVisibility(View.GONE);
            }
        }

    });
    wvInfo.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains(app.getLibrary().getData().optString("webviewcontain", "NOPE"))) {
                return false;
            }
            if (getActivity() == null) {
                return false;
            }
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }

    });

    return view;
}