Example usage for android.widget ProgressBar setIndeterminate

List of usage examples for android.widget ProgressBar setIndeterminate

Introduction

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

Prototype

@android.view.RemotableViewMethod
public synchronized void setIndeterminate(boolean indeterminate) 

Source Link

Document

Change the indeterminate mode for this progress bar.

Usage

From source file:Main.java

public static ProgressBar createProgress(Context context) {
    ProgressBar p = new ProgressBar(context);
    p.setIndeterminate(true);
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(40, 40);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    p.setLayoutParams(lp);//from ww  w  . ja  v a  2  s  .  co  m
    return p;
}

From source file:Main.java

public static ProgressBar createProgress(final Context context) {
    final ProgressBar p = new ProgressBar(context);
    p.setIndeterminate(true);
    final RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(40, 40);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    p.setLayoutParams(lp);//from www . java  2  s.  co  m
    return p;
}

From source file:org.onebusaway.android.report.ui.BaseReportActivity.java

protected void setUpProgressBar() {
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.END;/*from w ww  .  ja va 2  s .  c o m*/

    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setIndeterminate(true);
    progressBar.setVisibility(View.GONE);
    progressBar.setIndeterminate(true);
    progressBar.setLayoutParams(params);
    progressBar.getIndeterminateDrawable().setColorFilter(Color.WHITE,
            android.graphics.PorterDuff.Mode.MULTIPLY);

    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setDisplayShowCustomEnabled(true);
        ab.setCustomView(progressBar);
    }
}

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  .  j  a  v a  2s.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:ua.naiksoftware.chars.Sender.java

@Override
protected void onPreExecute() {
    Log.d(tag, "onPreExecute begin");

    ProgressBar progressBar = new ProgressBar(EngineActivity.CONTEXT);
    progressBar.setIndeterminate(true);

    AlertDialog.Builder builder = new AlertDialog.Builder(EngineActivity.CONTEXT);
    builder.setCustomTitle(progressBar);
    builder.setIcon(android.R.drawable.ic_menu_upload);
    builder.setMessage(R.string.send_record);
    builder.setCancelable(false);/*  w ww .  ja va 2 s. c om*/
    dialog = builder.create();
    dialog.show();
    Log.d(tag, "onPreExecute end");
}

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

@Override
public void onProgressUpdate(final String imageUri, final View view, final int current, final int total) {
    if (total == 0 || view == null)
        return;//from   ww  w  .  jav a  2s . c om
    final ProgressBar progress = findProgressBar(view.getParent());
    if (progress != null) {
        progress.setIndeterminate(false);
        progress.setProgress(100 * current / total);
    }
}

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;/*  ww  w . j  a v  a2s.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 2 s.  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:com.facebook.notifications.internal.activity.CardActivity.java

private void beginLoadingContent() {
    if (assetManager == null || contentManager == null) {
        Log.e(LOG_TAG, "Asset & content manager should be available!");
        return;/*  www.  ja v a2  s .  co m*/
    }

    if (configurationPayload == null) {
        Log.e(LOG_TAG, "No card payload is available!");
        return;
    }

    ProgressBar loadingView = new ProgressBar(this);
    loadingView.setIndeterminate(true);

    int backgroundColor = ColorAssetHandler.fromRGBAHex(configurationPayload.optString("backdropColor"));

    FrameLayout loadingViewFrame = new FrameLayout(this);
    loadingViewFrame.setBackgroundColor(backgroundColor);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    loadingViewFrame.addView(loadingView, layoutParams);

    setContentView(loadingViewFrame);

    final Handler handler = new Handler();
    if (configurationPayload == null) {
        return;
    }

    assetManager.cachePayload(configurationPayload, new AssetManager.CacheCompletionCallback() {
        @Override
        public void onCacheCompleted(@NonNull JSONObject payload) {
            final CardConfiguration configuration;
            try {
                configuration = new CardConfiguration(configurationPayload, assetManager, contentManager);
            } catch (JSONException ex) {
                Log.e(LOG_TAG, "Error while parsing JSON", ex);
                return;
            }

            handler.post(new Runnable() {
                @Override
                public void run() {
                    displayConfiguration(configuration);
                }
            });
        }
    });
}

From source file:com.ymt.demo1.plates.hub.FireHubMainFragment.java

protected void initView(View view) {
    //??/*w  ww  .j  av  a  2 s  . c  om*/
    ExpandableListView expandableListView = (ExpandableListView) view.findViewById(R.id.hub_list_view);
    //?
    ProgressBar progressBar = new ProgressBar(getActivity());
    progressBar.setIndeterminate(true);
    expandableListView.setEmptyView(progressBar);

    hubPlateAdapter = new HubPlateAdapter(getActivity());
    expandableListView.setAdapter(hubPlateAdapter);

    //item
    expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            //???
            Intent intent = new Intent(getActivity(), SubjectsActivity.class);
            intent.putExtra("plate", childList.get(groupPosition).get(childPosition));
            intent.putExtra("group_name", parentList.get(groupPosition).getName());
            startActivity(intent);
            getActivity().overridePendingTransition(android.R.anim.slide_in_left,
                    android.R.anim.slide_out_right);
            return true;
        }
    });

    ImageView doPostView = (ImageView) view.findViewById(R.id.hub_act_post);
    //        ImageView topPostView = (ImageView) view.findViewById(R.id.hub_act_top);
    ImageView newPostView = (ImageView) view.findViewById(R.id.hub_act_new);
    ImageView hotPostView = (ImageView) view.findViewById(R.id.hub_act_hot);
    ImageView myPostView = (ImageView) view.findViewById(R.id.hub_act_my);

    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.hub_act_post: //?
                Intent intent1 = new Intent(getActivity(), DoPostActivity.class);
                ArrayList<HubPlate> parents = new ArrayList<>();
                for (HubPlate plate : parentList) {
                    parents.add(plate);
                }
                ArrayList<HubPlate> childs = new ArrayList<>();
                for (List<HubPlate> pList : childList) {
                    for (HubPlate plate : pList) {
                        childs.add(plate);
                    }
                }
                intent1.putParcelableArrayListExtra("parent", parents);
                intent1.putParcelableArrayListExtra("child", childs);
                getActivity().startActivity(intent1);
                getActivity().overridePendingTransition(android.R.anim.slide_in_left,
                        android.R.anim.slide_out_right);
                break;
            //                    case R.id.hub_act_top:                                          //??
            //
            //                        break;
            case R.id.hub_act_new: //?
                Intent intentN = new Intent(getActivity(), HotNewPostActivity.class);
                intentN.putExtra("type", HotNewPostActivity.TYPE_NEW);
                startActivity(intentN);
                getActivity().overridePendingTransition(android.R.anim.slide_in_left,
                        android.R.anim.slide_out_right);
                break;
            case R.id.hub_act_hot: //?
                Intent intentH = new Intent(getActivity(), HotNewPostActivity.class);
                intentH.putExtra("type", HotNewPostActivity.TYPE_HOT);
                startActivity(intentH);
                getActivity().overridePendingTransition(android.R.anim.slide_in_left,
                        android.R.anim.slide_out_right);
                break;
            case R.id.hub_act_my: //?
                startActivity(new Intent(getActivity(), MyHubTabActivity.class));
                getActivity().overridePendingTransition(android.R.anim.slide_in_left,
                        android.R.anim.slide_out_right);
                break;
            }
        }
    };
    doPostView.setOnClickListener(onClickListener);
    //        topPostView.setOnClickListener(onClickListener);
    newPostView.setOnClickListener(onClickListener);
    hotPostView.setOnClickListener(onClickListener);
    myPostView.setOnClickListener(onClickListener);

}