package com.hdl.photovoltaic.widget;
|
|
import android.content.Context;
|
import android.os.Bundle;
|
import android.text.TextUtils;
|
import android.view.WindowManager;
|
import android.widget.ImageView;
|
import android.widget.TextView;
|
|
|
import com.bumptech.glide.Glide;
|
import com.hdl.photovoltaic.R;
|
import com.hdl.photovoltaic.base.BaseDialog;
|
|
public class LoadingDialog extends BaseDialog {
|
private TextView content;
|
|
public LoadingDialog(Context context, int theme) {
|
super(context, theme);
|
init(context);
|
}
|
|
@Override
|
protected void onCreate(Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
}
|
|
private void init(Context context) {
|
setCancelable(true);//系统后退可以取消
|
setCanceledOnTouchOutside(false);
|
setContentView(R.layout.loading_alert);
|
content = (TextView) findViewById(R.id.load_content_tv);
|
ImageView imageView = (ImageView) findViewById(R.id.load_pb);
|
WindowManager.LayoutParams params = getWindow().getAttributes();
|
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
getWindow().setAttributes(params);
|
Glide.with(context)
|
// .asBitmap() // 强制作为静态图片加载
|
.load(R.drawable.loading_gif)
|
.into(imageView);
|
// content.setText(R.string.device_加载中);
|
}
|
|
public void setText(String mes) {
|
if (content != null && !TextUtils.isEmpty(mes)) {
|
content.setText(mes);
|
}
|
}
|
|
public String getTest() {
|
return content.getText().toString().trim();
|
}
|
|
public void start() {
|
if (!this.isShowing()) {
|
this.show();
|
}
|
}
|
|
//点击外部不关闭
|
public void startTouchNotGone() {
|
if (!this.isShowing()) {
|
this.show();
|
setCancelable(true);
|
setCanceledOnTouchOutside(false);
|
}
|
}
|
|
public void stop() {
|
this.dismiss();
|
this.cancel();
|
}
|
|
}
|