Example usage for android.widget ProgressBar setMax

List of usage examples for android.widget ProgressBar setMax

Introduction

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

Prototype

@android.view.RemotableViewMethod
public synchronized void setMax(int max) 

Source Link

Document

Set the upper range of the progress bar max.

Usage

From source file:org.ligi.android.dubwise_uavtalk.dashboard.DownloadDashboardImagesStatusAlertDialog.java

/**
 * //from  w  w  w. jav a  2 s.c  o  m
 * @param activity
 * @param autoclose - if the alert should close when connection is established
 * 
 */
public static void show(Context activity, boolean autoclose, Intent after_connection_intent) {

    LinearLayout lin = new LinearLayout(activity);
    lin.setOrientation(LinearLayout.VERTICAL);

    ScrollView sv = new ScrollView(activity);
    TextView details_text_view = new TextView(activity);

    LinearLayout lin_in_scrollview = new LinearLayout(activity);
    lin_in_scrollview.setOrientation(LinearLayout.VERTICAL);
    sv.addView(lin_in_scrollview);
    lin_in_scrollview.addView(details_text_view);

    details_text_view.setText("no text");

    ProgressBar progress = new ProgressBar(activity, null, android.R.attr.progressBarStyleHorizontal);
    progress.setMax(img_lst.length);

    lin.addView(progress);
    lin.addView(sv);

    new AlertDialog.Builder(activity).setTitle("Download Status").setView(lin)
            .setPositiveButton("OK", new DialogDiscardingOnClickListener()).show();

    class AlertDialogUpdater implements Runnable {

        private Handler h = new Handler();
        private TextView myTextView;
        private ProgressBar myProgress;

        public AlertDialogUpdater(TextView ab, ProgressBar progress) {
            myTextView = ab;
            myProgress = progress;

        }

        public void run() {

            for (int i = 0; i < img_lst.length; i++) {
                class MsgUpdater implements Runnable {

                    private int i;

                    public MsgUpdater(int i) {
                        this.i = i;
                    }

                    public void run() {
                        myProgress.setProgress(i + 1);
                        if (i != img_lst.length - 1)
                            myTextView.setText("Downloading " + img_lst[i] + ".png");
                        else
                            myTextView.setText("Ready - please restart DUBwise to apply changes!");
                    }
                }
                h.post(new MsgUpdater(i));

                try {
                    URLConnection ucon = new URL(url_lst[i]).openConnection();
                    BufferedInputStream bis = new BufferedInputStream(ucon.getInputStream());

                    ByteArrayBuffer baf = new ByteArrayBuffer(50);
                    int current = 0;
                    while ((current = bis.read()) != -1)
                        baf.append((byte) current);

                    File path = new File(
                            Environment.getExternalStorageDirectory() + "/dubwise/images/dashboard");
                    path.mkdirs();

                    FileOutputStream fos = new FileOutputStream(
                            new File(path.getAbsolutePath() + "/" + img_lst[i] + ".png"));
                    fos.write(baf.toByteArray());
                    fos.close();
                } catch (Exception e) {
                }

                try {
                    Thread.sleep(199);
                } catch (InterruptedException e) {
                }

            }
        }
    }

    new Thread(new AlertDialogUpdater(details_text_view, progress)).start();
}

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  w  w. ja v 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:org.peterbaldwin.vlcremote.widget.TvShowsAdapter.java

private View populateShow(View convertView, Show show) {
    if (convertView == null || !convertView.getTag().equals("show")) {
        convertView = mInflater.inflate(R.layout.shows_list_item, null);
    }/*  w  w  w.  j a  v a2 s.c om*/
    TextView tv = (TextView) convertView.findViewById(R.id.show_name);
    tv.setText(show.getTitle());

    ProgressBar pb = (ProgressBar) convertView.findViewById(R.id.show_progress);
    pb.setProgress(show.getProgress());
    pb.setMax(show.getTotal());
    convertView.setTag("show");
    return convertView;
}

From source file:org.peterbaldwin.vlcremote.widget.TvShowsAdapter.java

private View populateSeason(View convertView, Season season) {
    if (convertView == null || !convertView.getTag().equals("season")) {
        convertView = mInflater.inflate(R.layout.seasons_list_item, null);
    }/*from   w w  w  .ja  va 2s  .co m*/

    TextView tv = (TextView) convertView.findViewById(R.id.season_num);
    tv.setText("S" + season.getNum());

    ProgressBar pb = (ProgressBar) convertView.findViewById(R.id.season_progress);
    pb.setProgress(season.getProgress());
    pb.setMax(season.getTotal());
    convertView.setTag("season");
    return convertView;
}

From source file:eu.cyberkat.h2owirelessbalancecheck.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Button button = (Button) this.findViewById(R.id.button1);
    final ProgressBar pb = getMyProgBar();
    pb.setMax(100);
    final AutoScaleTextView text1 = (AutoScaleTextView) this.findViewById(R.id.textView2);
    final TextView text2 = (TextView) this.findViewById(R.id.textView3);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        text1.setVisibility(View.VISIBLE);
        text2.setVisibility(View.GONE);
        Scaling = true;//from ww w .  j  a va  2  s  .c om
    } else {
        text1.setVisibility(View.GONE);
        text2.setVisibility(View.VISIBLE);
        Scaling = false;
    }
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            final EditText phonenum = getPhoneNum();
            String number = phonenum.getText().toString();
            new GrabTheBalance().execute(number);
        }
    });
}

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);
        progressBar.setProgress(0);//from w  w w.ja v a  2s. c o  m
        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:org.mariotaku.twidere.util.MediaLoadingHandler.java

@Override
public void onLoadingStarted(final String imageUri, final View view) {
    if (view == null || imageUri == null || imageUri.equals(mLoadingUris.get(view)))
        return;//from  w ww  .  ja v a  2s .c o  m
    ViewGroup parent = (ViewGroup) view.getParent();
    if (view instanceof ForegroundImageView) {
        ((ForegroundImageView) view).setForeground(null);
    }
    mLoadingUris.put(view, imageUri);
    final ProgressBar progress = findProgressBar(parent);
    if (progress != null) {
        progress.setVisibility(View.VISIBLE);
        progress.setIndeterminate(true);
        progress.setMax(100);
    }
}

From source file:org.getlantern.firetweet.util.ImageLoadingHandler.java

@Override
public void onLoadingStarted(final String imageUri, final View view) {
    if (view == null || imageUri == null || imageUri.equals(mLoadingUris.get(view)))
        return;/* w  w w .j a  v a 2s . com*/
    if (view instanceof ForegroundImageView) {
        ((ForegroundImageView) view).setForeground(null);
    }
    mLoadingUris.put(view, imageUri);
    final ProgressBar progress = findProgressBar(view.getParent());
    if (progress != null) {
        progress.setVisibility(View.VISIBLE);
        progress.setIndeterminate(true);
        progress.setMax(100);
    }
}

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;// www.  ja  v  a2  s  .  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:org.tomasdavid.vehicleroutingproblem.fragments.VrpFragment.java

/**
 * {@inheritDoc}/* w  ww .j  av  a2  s. c o  m*/
 */
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    MainActivity mainActivity = (MainActivity) getActivity();
    ((VrpView) mainActivity.findViewById(R.id.vrp_view)).setActualSolution(vrs);
    mainActivity.unlockDrawer();

    // adds left menu button for navigation drawer
    Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((DrawerLayout) getActivity().findViewById(R.id.drawer_layout)).openDrawer(Gravity.LEFT);
        }
    });

    // initialize progress bar
    ProgressBar pb = (ProgressBar) getActivity().findViewById(R.id.progress_bar);
    pb.setMax(timeLimitInSeconds);
    pb.getProgressDrawable().setColorFilter(getResources().getColor(R.color.dark_blue), PorterDuff.Mode.SRC_IN);
}