package com.pro;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.SpannableString;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
public class ProgressDialog1 extends AlertDialog {
public static final int STYLE_SPINNER = 0;
/** Creates a ProgressDialog1 with a horizontal progress bar.
*/
public static final int STYLE_HORIZONTAL = 1;
public static final int STYLE_DISMISS = -1;
private ProgressBar mProgress_h;
private int mProgressStyle = STYLE_SPINNER;
private TextView mProgressNumber_s,message_tv,message_ed_tv,message_center_tv,message_all_tv;
private int mMax;
private int mProgressVal;
private int mSecondaryProgressVal;
private int mIncrementBy;
private int mIncrementSecondaryBy;
private Drawable mProgressDrawable;
private Drawable mIndeterminateDrawable;
private CharSequence mMessage = "";
private boolean mIndeterminate;
private boolean mHasStarted;
private Handler mViewUpdateHandler;
private Context mContext;
private LinearLayout layout,layout_h,layout_s,layout_message_h;
private LinearLayout layout_progress_h,layout_progress_s;
private TextView message_h,number_ed,number_cen,number_all,progress_number2;
private ProgressBar progress_h,progress;
private SpannableString tmp;
public SpannableString getTmp() {
return tmp;
}
public void setTmp(SpannableString tmp) {
this.tmp = tmp;
}
public ProgressDialog1(Context context) {
this(context, android.R.style.Theme_Panel);
mContext = context;
}
public ProgressDialog1(Context context, int theme) {
super(context, theme);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message) {
return show(context, title, message, false);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message, boolean indeterminate) {
return show(context, title, message, indeterminate, false, null);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message, boolean indeterminate, boolean cancelable) {
return show(context, title, message, indeterminate, cancelable, null);
}
public static ProgressDialog1 show(Context context, CharSequence title,
CharSequence message, boolean indeterminate,
boolean cancelable, OnCancelListener cancelListener) {
ProgressDialog1 dialog = new ProgressDialog1(context);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setIndeterminate(indeterminate);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);
dialog.show();
return dialog;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (mProgressStyle == STYLE_HORIZONTAL)
{
/* Use a separate handler to update the text views as they
* must be updated on the same thread that created them.
*/
mViewUpdateHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
/* Update the number and percent */
int progress = mProgress_h.getProgress();
int max = mProgress_h.getMax();
message_tv.setText(getMessage());
message_ed_tv.setText(""+progress);
message_all_tv.setText(""+max);
}
};
View view = initLayout();
layout_progress_h = layout_h;
layout_progress_s = layout_s;
layout_progress_s.setVisibility(View.GONE);
mProgress_h = progress_h;
mProgressNumber_s = progress_number2;
message_tv = message_h;
message_ed_tv = number_ed;
message_center_tv = number_cen;
message_all_tv = number_all;
message_center_tv.setText("/");
setView(view);
}
if (mMax > 0) {
setMax(mMax);
}
if (mProgressVal > 0) {
setProgress(mProgressVal);
}
if (mSecondaryProgressVal > 0) {
setSecondaryProgress(mSecondaryProgressVal);
}
if (mIncrementBy > 0) {
incrementProgressBy(mIncrementBy);
}
if (mIncrementSecondaryBy > 0) {
incrementSecondaryProgressBy(mIncrementSecondaryBy);
}
if (mProgressDrawable != null) {
setProgressDrawable(mProgressDrawable);
}
if (mIndeterminateDrawable != null) {
setIndeterminateDrawable(mIndeterminateDrawable);
}
if (mMessage != null) {
setMessage(mMessage);
}
setIndeterminate(mIndeterminate);
onProgressChanged();
super.onCreate(savedInstanceState);
}
@Override
public void onStart() {
super.onStart();
mHasStarted = true;
}
@Override
protected void onStop() {
super.onStop();
mHasStarted = false;
}
public void setProgress(int value) {
if (mHasStarted) {
mProgress_h.setProgress(value);
onProgressChanged();
} else {
mProgressVal = value;
}
}
public void setSecondaryProgress(int secondaryProgress) {
if (mProgress_h != null) {
mProgress_h.setSecondaryProgress(secondaryProgress);
onProgressChanged();
} else {
mSecondaryProgressVal = secondaryProgress;
}
}
public int getProgress() {
if (mProgress_h != null) {
return mProgress_h.getProgress();
}
return mProgressVal;
}
public int getSecondaryProgress() {
if (mProgress_h != null) {
return mProgress_h.getSecondaryProgress();
}
return mSecondaryProgressVal;
}
public int getMax() {
if (mProgress_h != null) {
return mProgress_h.getMax();
}
return mMax;
}
public void setMax(int max) {
if (mProgress_h != null) {
mProgress_h.setMax(max);
onProgressChanged();
} else {
mMax = max;
}
}
public void incrementProgressBy(int diff) {
if (mProgress_h != null) {
mProgress_h.incrementProgressBy(diff);
onProgressChanged();
} else {
mIncrementBy += diff;
}
}
public void incrementSecondaryProgressBy(int diff) {
if (mProgress_h != null) {
mProgress_h.incrementSecondaryProgressBy(diff);
onProgressChanged();
} else {
mIncrementSecondaryBy += diff;
}
}
public void setProgressDrawable(Drawable d) {
if (mProgress_h != null) {
mProgress_h.setProgressDrawable(d);
} else {
mProgressDrawable = d;
}
}
public void setIndeterminateDrawable(Drawable d) {
if (mProgress_h != null) {
mProgress_h.setIndeterminateDrawable(d);
} else {
mIndeterminateDrawable = d;
}
}
public void setIndeterminate(b
荣华富贵8
- 粉丝: 218
- 资源: 7653
最新资源
- 基于Beego开发的问答系统详细文档+优秀项目+全部资料.zip
- 基于beego框架的接口在线文档管理系统详细文档+优秀项目+全部资料.zip
- 基于beego框架的cms系统详细文档+优秀项目+全部资料.zip
- 基于GF(Go Frame)的后台管理系统详细文档+优秀项目+全部资料.zip
- 基于Gin + Ant Design Pro的前后端分离管理系统的前后端模块详细文档+优秀项目+全部资料.zip
- 基于Excel VBA和Go语言的自动化考试系统详细文档+优秀项目+全部资料.zip
- 基于gin+websocket+mongodb实现 IM 即时聊天系统,基于WS连接的即时聊天,支持单聊,在线回复以及历史记录查询详细文档+优秀项目+全部资料.zip
- 基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了
- 基于gin+vue+element搭建的商城管理系统详细文档+优秀项目+全部资料.zip
- 基于Go + Vue开发的管理系统脚手架, 前后端分离, 仅包含项目开发的必需部分, 基于角色的访问控制(RBAC), 分包合理, 精简易于扩展。 后端Go包含
- 基于go micro + gin + kafka + etcd的分布式消息即时通信微服务系统详细文档+优秀项目+全部资料.zip
- 基于Go + Golang + Uniapp + Vue + ElementUi + Goframe框架的新零售社交电商系统(除了go商城系统外,还有java商
- 基于Go 标准库构建的博客系统、此项目非常适合作为 Go 新手的第一个上手项目详细文档+优秀项目+全部资料.zip
- 基于go,gin,JWT,权限管理系统详细文档+优秀项目+全部资料.zip
- 基于Go Web开发实战,基于Go语言,Beego框架开发的B2C模式的电商系统详细文档+优秀项目+全部资料.zip
- 基于go、gorm、gin、mysql及layui构建的人力资源管理系统。提供员工管理、考试管理、薪资考勤管理、权限管理及分公司分库数据隔离等功能详细文档+优秀项目+全部资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈