setIndeterminate ( )源码实例Demo

android.widget.ProgressBar#setIndeterminate ( )源码实例Demo

下面列出了android.widget.ProgressBar#setIndeterminate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android   文件: MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  progressBar = (ProgressBar) findViewById(R.id.progress_bar);
  progressBar.setIndeterminate(true);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  configureListView();

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    checkRuntimePermissions();
  }
}
 
源代码2 项目: InviZible   文件: PleaseWaitProgressDialog.java
@Override
public AlertDialog.Builder assignBuilder() {

    if (getActivity() == null) {
        return null;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.CustomAlertDialogTheme);
    builder.setTitle(R.string.please_wait);
    builder.setPositiveButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());

    ProgressBar progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setBackgroundResource(R.drawable.background_10dp_padding);
    progressBar.setIndeterminate(true);
    builder.setView(progressBar);
    builder.setCancelable(false);
    return builder;
}
 
源代码3 项目: mage-android   文件: OfflineLayersAdapter.java
public void updateDownloadProgress(View view, Layer layer) {
    int progress = downloadManager.getProgress(layer);
    long size = layer.getFileSize();

    final ProgressBar progressBar = view.findViewById(R.id.layer_progress);
    final View download = view.findViewById(R.id.layer_download);

    if (progress <= 0) {
        String reason = downloadManager.isFailed(layer);
        if(!StringUtils.isEmpty(reason)) {
            Toast.makeText(context, reason, Toast.LENGTH_LONG).show();
            progressBar.setVisibility(View.GONE);
            download.setVisibility(View.VISIBLE);
        }
        return;
    }

    int currentProgress = (int) (progress / (float) size * 100);
    progressBar.setIndeterminate(false);
    progressBar.setProgress(currentProgress);

    TextView layerSize = view.findViewById(R.id.layer_size);
    layerSize.setText(String.format("Downloading: %s of %s",
            Formatter.formatFileSize(context, progress),
            Formatter.formatFileSize(context, size)));
}
 
源代码4 项目: appcan-android   文件: EBrowserProgress.java
public EBrowserProgress(Context context) {
    super(context);
    mProgress = new ProgressBar(context);
    mProgress.setIndeterminate(true);
    mMessege = new TextView(context);
    RelativeLayout.LayoutParams parmPro = new LayoutParams(-2, -2);
    parmPro.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mProgress.setLayoutParams(parmPro);

    RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
    parmMsg.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mMessege.setLayoutParams(parmMsg);
    mMessege.setTextColor(0xFFFF0000);
    mMessege.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    addView(mProgress);
    addView(mMessege);
    setOnClickListener(this);
}
 
源代码5 项目: panoramagl   文件: PLView.java
/**
 * This event is fired when GLSurfaceView is created
 *
 * @param glSurfaceView current GLSurfaceView
 */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView) {
    for (int i = 0; i < kMaxTouches; i++)
        mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
    mContentLayout = new RelativeLayout(this);
    mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.GONE);
    mContentLayout.addView(mProgressBar, progressBarLayoutParams);
    return this.onContentViewCreated(mContentLayout);
}
 
源代码6 项目: secrecy   文件: PhotoPagerAdapter.java
/**
 * The Fragment's UI is just a simple text view showing its
 * instance number.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final RelativeLayout relativeLayout = new RelativeLayout(container.getContext());
    final EncryptedFile encryptedFile = encryptedFiles.get(mNum);
    final PhotoView photoView = new PhotoView(container.getContext());
    relativeLayout.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    try {
        photoView.setImageBitmap(encryptedFile.getEncryptedThumbnail().getThumb(150));
    } catch (SecrecyFileException e) {
        Util.log("No bitmap available!");
    }
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    final ProgressBar pBar = new ProgressBar(container.getContext());
    pBar.setIndeterminate(false);
    relativeLayout.addView(pBar, layoutParams);
    imageLoadJob = new ImageLoadJob(mNum, encryptedFile, photoView, pBar);
    CustomApp.jobManager.addJobInBackground(imageLoadJob);
    return relativeLayout;
}
 
源代码7 项目: LoadingLayout   文件: LoadingLayout.java
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    // 事先保存子控件显示状态,并隐藏所有子控件
    for (int i = 0; i < getChildCount(); i++) {
        mVisibilityMap.put(getChildAt(i), getChildAt(i).getVisibility());
        if (!mAutoLoadingDebug) {
            getChildAt(i).setVisibility(GONE);
        }
    }

    mLoadingBar = new ProgressBar(getContext());
    mLoadingBar.setIndeterminate(true);
    if (mProgressDrawable != null) {
        mLoadingBar.setProgressDrawable(mProgressDrawable);
    }
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;

    addView(mLoadingBar, params);

    if (!mAutoLoadingDebug) {
        showLoading();
    }
}
 
源代码8 项目: YalpStore   文件: DetailsProgressListener.java
@Override
public void onProgress(long bytesDownloaded, long bytesTotal) {
    if (null == activityRef.get()) {
        return;
    }
    activityRef.get().findViewById(R.id.download_progress_container).setVisibility(View.VISIBLE);
    ((TextView) activityRef.get().findViewById(R.id.download_progress_size)).setText(activityRef.get().getString(
        R.string.notification_download_progress,
        Formatter.formatShortFileSize(activityRef.get(), bytesDownloaded),
        Formatter.formatShortFileSize(activityRef.get(), bytesTotal)
    ));
    activityRef.get().findViewById(R.id.download).setVisibility(View.GONE);
    ProgressBar progressBar = activityRef.get().findViewById(R.id.download_progress);
    progressBar.setIndeterminate(false);
    progressBar.setProgress((int) bytesDownloaded);
    progressBar.setMax((int) bytesTotal);
}
 
源代码9 项目: PanoramaGL   文件: PLView.java
/**
    * This event is fired when GLSurfaceView is created
    * @param glSurfaceView current GLSurfaceView
    */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView)
{
	for(int i = 0; i < kMaxTouches; i++)
		mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
	mContentLayout = new RelativeLayout(this);
	mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	mProgressBar = new ProgressBar(this);
	mProgressBar.setIndeterminate(true);
	mProgressBar.setVisibility(View.GONE);
	mContentLayout.addView(mProgressBar, progressBarLayoutParams);
	return this.onContentViewCreated(mContentLayout);
}
 
源代码10 项目: InviZible   文件: RootCheckingProgressDialog.java
public static AlertDialog.Builder getBuilder(Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.CustomAlertDialogTheme);
    builder.setTitle(R.string.root);
    builder.setMessage(R.string.root_available);
    builder.setIcon(R.drawable.ic_visibility_off_black_24dp);

    ProgressBar progressBar = new ProgressBar(context,null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setBackgroundResource(R.drawable.background_10dp_padding);
    progressBar.setIndeterminate(true);
    builder.setView(progressBar);
    builder.setCancelable(false);
    return builder;
}
 
@Override
public void onScanStepCompleted(int completedStep, int totalSteps) {
    ProgressBar progressBar = mChannelSetupStylist.getProgressBar();
    if (totalSteps > 0 && progressBar != null) {
        progressBar.setIndeterminate(false);
        progressBar.setMax(totalSteps);
        progressBar.setProgress(completedStep);
    }
}
 
源代码12 项目: leanback-extensions   文件: LoadingFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_loading, container, false);

	FrameLayout loadingContainer = (FrameLayout) view.findViewById(R.id.fragment_loading_container);
	loadingContainer.setBackgroundColor(backgroundColor);

	progressBar = new ProgressBar(container.getContext());
	if (container instanceof FrameLayout) {
		FrameLayout.LayoutParams layoutParams =
				new FrameLayout.LayoutParams(progressWidth, progressHeight, Gravity.CENTER);
		progressBar.setLayoutParams(layoutParams);
	}

	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		if (progressBar.getIndeterminateDrawable() != null) {
			progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(progressColor),
					PorterDuff.Mode.SRC_IN);
		}
	} else {
		ColorStateList stateList = ColorStateList.valueOf(progressColor);
		progressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
		progressBar.setIndeterminateTintList(stateList);
		progressBar.setProgressBackgroundTintMode(PorterDuff.Mode.SRC_IN);
		progressBar.setProgressBackgroundTintList(stateList);
		progressBar.setIndeterminate(true);
	}

	loadingContainer.addView(progressBar);

	return view;
}
 
源代码13 项目: Aurora   文件: CacheFragment.java
private void showDownload(int position) {
    VideoDownLoadInfo item = data.get(position);
    item.setDownLoading(true);
    adapter.setDownPosition(position);
    ProgressBar seekBar = (ProgressBar) adapter.getViewByPosition(position, R.id.sb_progress);
    TextView size = (TextView) adapter.getViewByPosition(position, R.id.tv_pause);
    size.setText(StringUtils.getPrintSize(item.getCurrentBytes() == null ? 0 : item.getCurrentBytes(), false) + "/" + StringUtils.getPrintSize(item.getContentLength() == null ? 0 : item.getContentLength(), true));
    seekBar.setVisibility(View.VISIBLE);
    seekBar.setIndeterminate(false);
    seekBar.setProgress(data.get(position).getPercent());
}
 
源代码14 项目: xipl   文件: ChannelSetupStepFragment.java
@Override
public void onStart() {
    super.onStart();
    ProgressBar progressBar = mChannelSetupStylist.getProgressBar();
    if (progressBar != null) {
        progressBar.setIndeterminate(true);
    }
    mSyncStatusChangedReceiver = new SyncStatusBroadcastReceiver(mInputId, this);
    LocalBroadcastManager.getInstance(getActivity())
            .registerReceiver(
                    mSyncStatusChangedReceiver,
                    new IntentFilter(EpgSyncJobService.ACTION_SYNC_STATUS_CHANGED));
    startScan();
}
 
源代码15 项目: xipl   文件: ChannelSetupStepFragment.java
@Override
public void onScanStepCompleted(int completedStep, int totalSteps) {
    ProgressBar progressBar = mChannelSetupStylist.getProgressBar();
    if (totalSteps > 0 && progressBar != null) {
        progressBar.setIndeterminate(false);
        progressBar.setMax(totalSteps);
        progressBar.setProgress(completedStep);
    }
}
 
源代码16 项目: ViewInspector   文件: ProfileProgressbar.java
@Inject public ProfileProgressbar(Context context) {
  super(context);
  inflate(context, R.layout.view_inspector_progressbar, this);
  mProgressbar = (ProgressBar) findViewById(R.id.progressbar);
  mProgressbar.setIndeterminate(false);
  mProgressbar.setMax(100);
  mPercentage = (TextView) findViewById(R.id.percentage);
}
 
源代码17 项目: appcan-android   文件: EBrowserToast.java
public EBrowserToast(Context context) {
    super(context);
    GradientDrawable grade = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
            new int[]{0x99000000, 0x99000000});
    grade.setCornerRadius(6);
    setBackgroundDrawable(grade);
    int pad = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            5, ESystemInfo.getIntence().mDisplayMetrics);
    setPadding(pad, pad, pad, pad);
    m_progress = new ProgressBar(context);
    m_progress.setId(0x1101);
    m_progress.setIndeterminate(true);
    m_msg = new TextView(context);
    m_msg.setId(0x1102);
    int use = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            20, ESystemInfo.getIntence().mDisplayMetrics);
    RelativeLayout.LayoutParams parmPro = new LayoutParams(use, use);
    parmPro.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    parmPro.addRule(RelativeLayout.CENTER_VERTICAL);
    m_progress.setLayoutParams(parmPro);
    m_progress.setMinimumHeight(10);

    RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
    parmMsg.addRule(RelativeLayout.RIGHT_OF, 0x1101);
    parmMsg.addRule(RelativeLayout.CENTER_VERTICAL);
    m_msg.setLayoutParams(parmMsg);
    m_msg.setTextColor(0xFFFFFFFF);
    m_msg.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    addView(m_progress);
    addView(m_msg);
}
 
源代码18 项目: document-viewer   文件: UIManagerAppCompat.java
public static void setProgressSpinnerVisible(AppCompatActivity activity, boolean visible) {
    ActionBar bar = activity.getSupportActionBar();

    if (bar.getCustomView() == null) {
        ProgressBar spinner = new ProgressBar(activity);
        spinner.setIndeterminate(true);
        bar.setCustomView(spinner);
    }

    bar.setDisplayShowCustomEnabled(visible);
}
 
/**
 * Called when a row view is being updated.
 *
 * @param board
 * @param rowView
 * @param entry
 */
public void onRowViewUpdate(NotificationBoard board, RowView rowView, NotificationEntry entry) {
    if (DBG) Log.v(TAG, "onRowViewUpdate - " + entry.ID);

    ImageView iconView = (ImageView) rowView.findViewById(R.id.icon);
    TextView titleView = (TextView) rowView.findViewById(R.id.title);
    TextView textView = (TextView) rowView.findViewById(R.id.text);
    TextView whenView = (TextView) rowView.findViewById(R.id.when);
    ProgressBar bar = (ProgressBar) rowView.findViewById(R.id.progress);

    if (entry.iconDrawable != null) {
        iconView.setImageDrawable(entry.iconDrawable);
    } else if (entry.smallIconRes != 0) {
        iconView.setImageResource(entry.smallIconRes);
    } else if (entry.largeIconBitmap != null) {
        iconView.setImageBitmap(entry.largeIconBitmap);
    }

    titleView.setText(entry.title);
    textView.setText(entry.text);

    if (entry.showWhen) {
        whenView.setText(entry.whenFormatted);
    }

    if (entry.progressMax != 0 || entry.progressIndeterminate) {
        bar.setVisibility(View.VISIBLE);
        bar.setIndeterminate(entry.progressIndeterminate);
        if (!entry.progressIndeterminate) {
            bar.setMax(entry.progressMax);
            bar.setProgress(entry.progress);
        }
    } else {
        bar.setVisibility(View.GONE);
    }

}
 
源代码20 项目: video-transcoder   文件: MainActivity.java
@Override
public void handleMessage(Message msg)
{
    final MainActivity mainActivity = activityRef.get();
    if (mainActivity == null)
    {
        // Activity is no longer available, exit.
        return;
    }

    MessageId messageId = MessageId.fromInt(msg.what);

    switch (MessageId.fromInt(msg.what))
    {
        /*
         * Receives callback from the service when a job has landed
         * on the app. Turns on indicator and sends a message to turn it off after
         * a second.
         */
        case JOB_START_MSG:
            Log.d(TAG, "JOB_START_MSG: " + msg.obj.toString());
            break;

        /*
         * Receives callback from the service when a job that previously landed on the
         * app must stop executing. Turns on indicator and sends a message to turn it
         * off after two seconds.
         */
        case JOB_PROGRESS_MSG:
            Integer percentComplete = (Integer)msg.obj;

            if(percentComplete != null && percentComplete > 0)
            {
                Log.d(TAG, "JOB_PROGRESS_MSG: " + percentComplete);

                ProgressBar progressBar = mainActivity.findViewById(R.id.encodeProgress);
                progressBar.setIndeterminate(false);
                progressBar.setProgress(percentComplete);
            }
            break;

        case JOB_SUCCEDED_MSG:
        case JOB_FAILED_MSG:
            boolean result = false;
            String outputFile = null;
            String mimetype = null;
            String message = null;

            if(messageId == MessageId.JOB_SUCCEDED_MSG)
            {
                result = true;
                outputFile = ((Bundle)msg.obj).getString(FFMPEG_OUTPUT_FILE);
                mimetype = ((Bundle)msg.obj).getString(OUTPUT_MIMETYPE);
            }
            else
            {
                message = ((Bundle)msg.obj).getString(FFMPEG_FAILURE_MSG);
            }

            Log.d(TAG, "Job complete, result: " + result);
            showEncodeCompleteDialog(mainActivity, result, message, outputFile, mimetype);
            break;

        case FFMPEG_UNSUPPORTED_MSG:
            Log.d(TAG, "FFMPEG_UNSUPPORTED_MSG");
            break;

        case UNKNOWN_MSG:
            Log.w(TAG, "UNKNOWN_MSG received");
            break;
    }
}