Java Code Examples for android.widget.ProgressBar#setProgressDrawable()

The following examples show how to use android.widget.ProgressBar#setProgressDrawable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressWebView.java    From tysq-android with GNU General Public License v3.0 6 votes vote down vote up
private void initView() {
    mProgressbar = new ProgressBar(
            getContext(),
            null,
            android.R.attr.progressBarStyleHorizontal
    );
    mProgressbar.setProgressDrawable(ResourcesCompat
            .getDrawable(getResources(),
                    R.drawable.j_process_horizontal,
                    null)
    );
    mProgressbar.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    UIUtils.dip2px(getContext(), 3),
                    0,
                    0)
    );

    addView(mProgressbar);
    setWebChromeClient(new WebChromeClient());
}
 
Example 2
Source File: ProgressWebView.java    From Bailan with Apache License 2.0 6 votes vote down vote up
public ProgressWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    progressbar = new ProgressBar(context, null,
            android.R.attr.progressBarStyleHorizontal);
    progressbar.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            10, 0, 0));

    Drawable drawable = context.getResources().getDrawable(R.drawable.progress_bar_states);
    progressbar.setProgressDrawable(drawable);
    addView(progressbar);
    // setWebViewClient(new WebViewClient(){});
    setWebChromeClient(new WebChromeClient());
    //是否可以缩放
    getSettings().setSupportZoom(true);
    getSettings().setBuiltInZoomControls(true); 
}
 
Example 3
Source File: FormNavigationUI.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private static void setDoneState(ImageButton nextButton,
                                 Context context,
                                 final ClippingFrame finishButton,
                                 FormNavigationController.NavigationDetails details,
                                 ProgressBar progressBar) {
    if (nextButton.getTag() == null) {
        setFinishVisible(finishButton);
    } else if (!FormEntryConstants.NAV_STATE_DONE.equals(nextButton.getTag())) {
        nextButton.setTag(FormEntryConstants.NAV_STATE_DONE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            expandAndShowFinishButton(context, finishButton);
        } else {
            setFinishVisible(finishButton);
        }
    }

    progressBar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_full));
    progressBar.setProgress(details.totalQuestions);

    Log.i("Questions", "Form complete");
}
 
Example 4
Source File: ProgressWebView.java    From Bailan with Apache License 2.0 6 votes vote down vote up
public ProgressWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    progressbar = new ProgressBar(context, null,
            android.R.attr.progressBarStyleHorizontal);
    progressbar.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            10, 0, 0));

    Drawable drawable = context.getResources().getDrawable(R.drawable.progress_bar_states);
    progressbar.setProgressDrawable(drawable);
    addView(progressbar);
    // setWebViewClient(new WebViewClient(){});
    setWebChromeClient(new WebChromeClient());
    //是否可以缩放
    getSettings().setSupportZoom(true);
    getSettings().setBuiltInZoomControls(true); 
}
 
Example 5
Source File: ConnectingProcessWorkerTask.java    From spark-setup-android with Apache License 2.0 6 votes vote down vote up
private void updateProgress(StepProgress progress, View progressStepContainer) {
    ProgressBar progBar = Ui.findView(progressStepContainer, R.id.spinner);
    ImageView checkmark = Ui.findView(progressStepContainer, R.id.checkbox);

    // don't show the spinner again if we've already shown the checkmark,
    // regardless of the underlying state that might hide
    if (checkmark.getVisibility() == View.VISIBLE) {
        return;
    }

    progressStepContainer.setVisibility(View.VISIBLE);

    if (progress.status == StepProgress.STARTING) {
        checkmark.setVisibility(View.GONE);

        progBar.setProgressDrawable(tintedSpinner);
        progBar.setVisibility(View.VISIBLE);

    } else {
        progBar.setVisibility(View.GONE);

        checkmark.setImageDrawable(tintedCheckmark);
        checkmark.setVisibility(View.VISIBLE);
    }
}
 
Example 6
Source File: LoadingLayout.java    From LoadingLayout with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example 7
Source File: ConnectingProcessWorkerTask.java    From particle-android with Apache License 2.0 6 votes vote down vote up
private void updateProgress(StepProgress progress, View progressStepContainer) {
    ProgressBar progBar = Ui.findView(progressStepContainer, R.id.spinner);
    ImageView checkmark = Ui.findView(progressStepContainer, R.id.checkbox);

    // don't show the spinner again if we've already shown the checkmark,
    // regardless of the underlying state that might hide
    if (checkmark.getVisibility() == View.VISIBLE) {
        return;
    }

    progressStepContainer.setVisibility(View.VISIBLE);

    if (progress.status == StepProgress.STARTING) {
        checkmark.setVisibility(View.GONE);

        progBar.setProgressDrawable(tintedSpinner);
        progBar.setVisibility(View.VISIBLE);

    } else {
        progBar.setVisibility(View.GONE);

        checkmark.setImageDrawable(tintedCheckmark);
        checkmark.setVisibility(View.VISIBLE);
    }
}
 
Example 8
Source File: PageFactory.java    From BookReader with Apache License 2.0 6 votes vote down vote up
public void convertBetteryBitmap() {
    batteryView = (ProgressBar) LayoutInflater.from(mContext).inflate(R.layout.layout_battery_progress, null);
    batteryView.setProgressDrawable(ContextCompat.getDrawable(mContext,
            SettingManager.getInstance().getReadTheme() < 4 ?
                    R.drawable.seekbar_battery_bg : R.drawable.seekbar_battery_night_bg));
    batteryView.setProgress(battery);
    batteryView.setDrawingCacheEnabled(true);
    batteryView.measure(View.MeasureSpec.makeMeasureSpec(ScreenUtils.dpToPxInt(26), View.MeasureSpec.EXACTLY),
            View.MeasureSpec.makeMeasureSpec(ScreenUtils.dpToPxInt(14), View.MeasureSpec.EXACTLY));
    batteryView.layout(0, 0, batteryView.getMeasuredWidth(), batteryView.getMeasuredHeight());
    batteryView.buildDrawingCache();
    //batteryBitmap = batteryView.getDrawingCache();
    // tips: @link{https://github.com/JustWayward/BookReader/issues/109}
    batteryBitmap = Bitmap.createBitmap(batteryView.getDrawingCache());
    batteryView.setDrawingCacheEnabled(false);
    batteryView.destroyDrawingCache();
}
 
Example 9
Source File: ProgressBarWrapper.java    From Man-Man with GNU General Public License v3.0 5 votes vote down vote up
private ProgressBar createProgressBar() {
    ProgressBar pb = (ProgressBar) View.inflate(mActivity, R.layout.actionbar_progressbar, null);
    ShapeDrawable shape = new ShapeDrawable();
    shape.setShape(new RectShape());
    shape.getPaint().setColor(Color.parseColor("#FF33B5E5"));
    ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);
    pb.setProgressDrawable(clipDrawable);
    return pb;
}
 
Example 10
Source File: FiscalizacaoAdapter.java    From vocefiscal-android with Apache License 2.0 5 votes vote down vote up
private void refreshItemParaEnvioInProgress(final Fiscalizacao fiscalizacao, final ProgressBar upload_progress, final ImageView status_envio, final TextView porcentagem_envio) 
{
	status_envio.setImageResource(StatusEnvioEnum.getImageResource(fiscalizacao.getStatusDoEnvio()));

	int numeroTotalDeFotos = 0;
	int numeroDeFotosEnviadas = 0;
	int porcentagemEnviado = 0;

	if(fiscalizacao.getPicturePathList()!=null)
		numeroTotalDeFotos = fiscalizacao.getPicturePathList().size();

	if(fiscalizacao.getPictureURLList()!=null)
		numeroDeFotosEnviadas = fiscalizacao.getPictureURLList().size();

	if(numeroTotalDeFotos>0)
		porcentagemEnviado = (int) ((numeroDeFotosEnviadas / (numeroTotalDeFotos*1.0f)) * 100);	

	if(porcentagemEnviado>=100)
		porcentagemEnviado = 99;

	porcentagem_envio.setText(porcentagemEnviado+"%");
	upload_progress.setProgress(porcentagemEnviado);

	if(fiscalizacao.getStatusDoEnvio().equals(StatusEnvioEnum.PAUSADO.ordinal()))
	{
		porcentagem_envio.setTextColor(mContext.getResources().getColor(R.color.azul_vocefiscal));
		upload_progress.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progress_horizontal_vocefical));
		upload_progress.setVisibility(View.INVISIBLE);		
	}else
	{
		porcentagem_envio.setTextColor(mContext.getResources().getColor(R.color.amarelo_envio));
		upload_progress.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progress_horizontal_upload_vocefical));
		upload_progress.setVisibility(View.VISIBLE);		
	}
		
	porcentagem_envio.setVisibility(View.VISIBLE);		
}
 
Example 11
Source File: FormNavigationUI.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private static void setMoreQuestionsState(ImageButton nextButton,
                                          Context context,
                                          ClippingFrame finishButton,
                                          FormNavigationController.NavigationDetails details,
                                          ProgressBar progressBar) {
    if (!FormEntryConstants.NAV_STATE_NEXT.equals(nextButton.getTag())) {
        nextButton.setTag(FormEntryConstants.NAV_STATE_NEXT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            finishButton.setVisibility(View.GONE);
        }
    }

    progressBar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_modern));
    progressBar.setProgress(details.completedQuestions);
}
 
Example 12
Source File: ProcessWebView.java    From easyweather with MIT License 5 votes vote down vote up
public ProcessWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mProgressBar = new ProgressBar(context, null,
            android.R.attr.progressBarStyleHorizontal);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, 8);
    mProgressBar.setLayoutParams(layoutParams);

    Drawable drawable = context.getResources().getDrawable(
            R.drawable.web_progress_bar_states);
    mProgressBar.setProgressDrawable(drawable);
    addView(mProgressBar);
    setWebChromeClient(new WebChromeClient());
}
 
Example 13
Source File: ProgressWebView.java    From LQRWeChat with MIT License 5 votes vote down vote up
public ProgressWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 8, 0, 0));

    Drawable drawable = context.getResources().getDrawable(R.drawable.progressbar_webview);
    mProgressBar.setProgressDrawable(drawable);
    addView(mProgressBar);
    setWebChromeClient(new WebChromeClient());
    //是否可以缩放
    getSettings().setSupportZoom(true);
    getSettings().setBuiltInZoomControls(true);
}
 
Example 14
Source File: ProgressWebView.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProgressWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 10, 0, 0));
    Drawable drawable = ContextCompat.getDrawable(context, R.drawable.web_view_progress_bar);
    progressBar.setProgressDrawable(drawable);
    addView(progressBar);
    //滚动条样式
    setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    initSettings();
    setWebChromeClient(new ProgressWebChromeClient());

}
 
Example 15
Source File: PageFactory.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
public void convertBetteryBitmap() {
    batteryView = (ProgressBar) LayoutInflater.from(mContext).inflate(R.layout.layout_battery_progress, null);
    batteryView.setProgressDrawable(ContextCompat.getDrawable(mContext,
            SettingManager.getInstance().getReadTheme() < 4 ?
                    R.drawable.seekbar_battery_bg : R.drawable.seekbar_battery_night_bg));
    batteryView.setProgress(battery);
    batteryView.setDrawingCacheEnabled(true);
    batteryView.measure(View.MeasureSpec.makeMeasureSpec(ScreenUtils.dpToPxInt(26), View.MeasureSpec.EXACTLY),
            View.MeasureSpec.makeMeasureSpec(ScreenUtils.dpToPxInt(14), View.MeasureSpec.EXACTLY));
    batteryView.layout(0, 0, batteryView.getMeasuredWidth(), batteryView.getMeasuredHeight());
    batteryView.buildDrawingCache();
    batteryBitmap = batteryView.getDrawingCache();
}
 
Example 16
Source File: StoryStatusView.java    From StatusStories with Apache License 2.0 4 votes vote down vote up
private ProgressBar createProgressBar() {
    ProgressBar p = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleHorizontal);
    p.setLayoutParams(new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
    p.setProgressDrawable(ContextCompat.getDrawable(getContext(), R.drawable.progress_bg));
    return p;
}
 
Example 17
Source File: WebViewDialog.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
/***
 * 初始化需要的控件
 * @param context
 */
@JavascriptInterface
private void initView(final Context context) {
    //父控件
    mParent = new FrameLayout(context);
    //设置背景
    mParent.setBackgroundColor(Color.parseColor("#F0F0F0"));
    //大小参数
    FrameLayout.LayoutParams mParentParams =
            new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT);
    //设置参数
    mParent.setLayoutParams(mParentParams);
    //添加子控件
    FrameLayout mTopLayout = new FrameLayout(context);
    //设置背景
    mTopLayout.setBackgroundColor(Color.parseColor("#2b2b2b"));
    int mTopHight = VenvyUIUtil.dip2px(context, 45);
    //大小参数
    FrameLayout.LayoutParams mTopParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mTopHight);
    //TOP区域添加返回按钮
    ImageButton mBackView = new ImageButton(context);
    //设置点击事件
    mBackView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    //设置本地图片
    mBackView.setBackgroundResource(VenvyResourceUtil.getDrawableOrmipmapId(
            context, "venvy_os_outside_link_back"));
    //
    mBackView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    //大小参数
    FrameLayout.LayoutParams mBackParams = new FrameLayout.LayoutParams(mTopHight, mTopHight);
    mTopLayout.addView(mBackView, mBackParams);
    //进度条区域
    final ProgressBar mProBarView = new ProgressBar(context, null,
            android.R.attr.progressBarStyleHorizontal);
    //进度清空
    mProBarView.setProgress(0);
    //设置加载进度的颜色
    mProBarView.setProgressDrawable(context.getResources().getDrawable(
            VenvyResourceUtil.getDrawableId(context,
                    "venvy_library_webview_load_bg")));// 设置
    //大小参数
    FrameLayout.LayoutParams mBarParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, VenvyUIUtil.dip2px(context, 3));
    //顶部位置
    mBarParams.topMargin = mTopHight;
    //创建WebView控件
    mWebView = WebViewFactory.createWebView(context);
    //大小参数
    final FrameLayout.LayoutParams mWebParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    //距离顶部位置
    mWebParams.topMargin = mTopHight;
    //加载监听
    mWebView.setWebChromeClient(new IVenvyWebChromeClient() {
        @Override
        public void onProgressChanged(View view, int newProgress) {
            if (newProgress >= 100) {
                mParent.removeView(mProBarView);
            } else {
                mProBarView.setProgress(newProgress);
            }
        }
    });

    mParent.addView(mTopLayout, mTopParams);
    if (mWebView instanceof View) {
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        ((View) mWebView).setLayoutParams(params);
        mParent.addView((View) mWebView);
    }
    //添加进度条
    mParent.addView(mProBarView, mBarParams);
    //加载布局
    setContentView(mParent);
}