2020-08-25 10:08:00 +08:00
|
|
|
|
package com.fenghoo.seven.dialog;
|
2020-08-14 15:12:29 +08:00
|
|
|
|
|
|
|
|
|
|
import android.app.Dialog;
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
|
|
import android.widget.TextView;
|
2020-08-20 09:17:58 +08:00
|
|
|
|
|
2020-08-25 10:08:00 +08:00
|
|
|
|
import com.fenghoo.seven.R;
|
2020-08-14 15:12:29 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* on: 2018/11/2
|
|
|
|
|
|
* <p>
|
|
|
|
|
|
* 描述:加载中禁止用户手机关闭的对话框
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public class LoadingDialogy extends Dialog {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Context context;
|
|
|
|
|
|
private static LoadingDialogy dialog;
|
|
|
|
|
|
private ProgressBar ivProgress;
|
|
|
|
|
|
private String showContent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LoadingDialogy(Context context , String showContent) {
|
|
|
|
|
|
super(context);
|
|
|
|
|
|
this.context = context;
|
|
|
|
|
|
this.showContent = showContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LoadingDialogy(Context context, int themeResId, String showContent) {
|
|
|
|
|
|
super(context, themeResId);
|
|
|
|
|
|
this.context = context;
|
|
|
|
|
|
this.showContent = showContent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//显示dialog的方法
|
|
|
|
|
|
public static LoadingDialogy showDialog(Context context , String content){
|
|
|
|
|
|
dialog = new LoadingDialogy(context, R.style.loadingDialog ,content);//dialog样式
|
|
|
|
|
|
dialog.setContentView(R.layout.dialog_loading);//dialog布局文件
|
|
|
|
|
|
dialog.setCanceledOnTouchOutside(false);//点击外部不允许关闭dialog
|
|
|
|
|
|
return dialog;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onWindowFocusChanged(boolean hasFocus) {
|
|
|
|
|
|
super.onWindowFocusChanged(hasFocus);
|
|
|
|
|
|
if(hasFocus && dialog != null){
|
|
|
|
|
|
ivProgress = (ProgressBar) dialog.findViewById(R.id.ivProgress);
|
|
|
|
|
|
TextView textView = (TextView) dialog.findViewById(R.id.tv_content);
|
|
|
|
|
|
textView.setText(showContent);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|