Example usage for android.widget ProgressBar setVisibility

List of usage examples for android.widget ProgressBar setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

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 .j  a va  2s .c  om*/
    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 ww .j  a  va2s . co  m
    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:org.getlantern.firetweet.util.ImageLoadingHandler.java

@Override
public void onLoadingFailed(final String imageUri, final View view, final FailReason reason) {
    if (view == null)
        return;// w  w w.ja va2  s  . co  m
    if (view instanceof ForegroundImageView) {
        ((ImageView) view).setImageDrawable(null);
        final Drawable foreground = ResourcesCompat.getDrawable(view.getResources(),
                R.drawable.image_preview_refresh, null);
        ((ForegroundImageView) view).setForeground(foreground);
    }
    mLoadingUris.remove(view);
    final ProgressBar progress = findProgressBar(view.getParent());
    if (progress != null) {
        progress.setVisibility(View.GONE);
    }
}

From source file:ua.boberproduction.bbr.notes.NoteEditorFragment.java

@Override
public void displayProgressbar(boolean show) {
    ProgressBar progressBar = (ProgressBar) getActivity().findViewById(R.id.progressBar);
    if (show)/*from w  w w  .  j a v  a 2 s.  c  o  m*/
        progressBar.setVisibility(View.VISIBLE);
    else
        progressBar.setVisibility(View.GONE);
}

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

    /*/*  ww  w . ja  v  a  2 s .com*/
     * {"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:fr.unix_experience.owncloud_sms.activities.remote_account.RestoreMessagesActivity.java

private void initInterface() {
    TextView tv_error = (TextView) findViewById(R.id.tv_error_default_smsapp);
    tv_error.setText(R.string.error_make_default_sms_app);
    findViewById(R.id.tv_restore_finished).setVisibility(View.INVISIBLE);
    findViewById(R.id.tv_progress_value).setVisibility(View.INVISIBLE);
    Button fix_button = (Button) findViewById(R.id.button_fix_permissions);
    Button launch_restore = (Button) findViewById(R.id.button_launch_restore);
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressbar_restore);
    pb.setVisibility(View.INVISIBLE);

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
        notifyIncompatibleVersion();/*from   w  w w. ja  v  a  2s. com*/
        return;
    }

    _defaultSmsApp = Telephony.Sms.getDefaultSmsPackage(this);
    if (!Telephony.Sms.getDefaultSmsPackage(this).equals(getPackageName())) {
        _defaultSmsApp = Telephony.Sms.getDefaultSmsPackage(getBaseContext());
        tv_error.setVisibility(View.VISIBLE);
        fix_button.setVisibility(View.VISIBLE);
        launch_restore.setVisibility(View.INVISIBLE);
    } else {
        tv_error.setVisibility(View.INVISIBLE);
        fix_button.setVisibility(View.INVISIBLE);
        launch_restore.setVisibility(View.VISIBLE);
    }
}

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;// w ww  .  j av  a  2s .  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:com.shafiq.mytwittle.view.ImageViewActivity.java

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

    if (Constant.ENABLE_CRASH_TRACKING) {
        Crittercism.init(getApplicationContext(), Constant.CRITTERCISM_APP_ID);
    }//from w w w . j a  v  a 2s . c o  m

    String imageUrl = getMediaUrl();
    if (imageUrl == null) {
        finish();
        return;
    }

    setContentView(R.layout.image_view);

    mZoomableImageView = (GestureImageView) findViewById(R.id.image_view);
    UrlImageViewHelper.setUrlDrawable(mZoomableImageView, imageUrl, new UrlImageViewCallback() {

        @Override
        public void onLoaded(ImageView imageView, Drawable loadedDrawable, String url,
                boolean loadedFromCache) {
            ProgressBar loadingView = (ProgressBar) findViewById(R.id.imageViewLoading);
            loadingView.setVisibility(View.GONE);
            if (loadedDrawable == null) {
                TextView errorTextView = (TextView) findViewById(R.id.errorTextView);
                errorTextView.setVisibility(View.VISIBLE);
            }

        }
    });

    getActionBar().setTitle("@" + getAuthorScreenName() + "'s image");
    getActionBar().setDisplayHomeAsUpEnabled(true);
}

From source file:com.hplasplas.weather.activitys.SearchPlaceActivity.java

private void setProgressBarState(ProgressBar progressBar, boolean mustVisible) {

    if (progressBar != null) {
        progressBar.setVisibility(mustVisible ? View.VISIBLE : View.INVISIBLE);
    }/*from  w  w w.  j  ava2  s .c o  m*/
}

From source file:com.quarterfull.newsAndroid.VersionInfoDialogFragment.java

/**
 * Loads changelog into the given view and hides progress bar when done.
 *//*from www. j  av a 2 s  .  c  om*/
private void loadChangeLog(ChangeLogFileListView clListView, final ProgressBar progressBar) {
    new DownloadChangelogTask(getContext(), clListView, new DownloadChangelogTask.Listener() {
        @Override
        public void onSuccess() {
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onError(IOException e) {
            progressBar.setVisibility(View.GONE);
            e.printStackTrace();
        }
    }).execute();
}