|
|
|
|
|
package com.rehome.meetingbook.weiget;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.Dialog;
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import android.view.Display;
|
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
import android.view.Window;
|
|
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
|
|
|
|
import com.rehome.meetingbook.R;
|
|
|
|
|
|
import com.rehome.meetingbook.databinding.DialogResultBinding;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Create By HuangWenFei
|
|
|
|
|
|
* 创建日期:2022-12-13 11:18
|
|
|
|
|
|
* 描述:
|
|
|
|
|
|
*/
|
|
|
|
|
|
public class ResultDialog extends Dialog {
|
|
|
|
|
|
protected View mView;
|
|
|
|
|
|
protected DialogResultBinding binding;
|
|
|
|
|
|
Context context;
|
|
|
|
|
|
private ResultDialogListener listener;
|
|
|
|
|
|
|
|
|
|
|
|
public ResultDialog(@NonNull Context context, String msg, ResultDialogListener listener) {
|
|
|
|
|
|
super(context);
|
|
|
|
|
|
this.context=context;
|
|
|
|
|
|
binding = DialogResultBinding.inflate(getLayoutInflater());
|
|
|
|
|
|
mView = binding.getRoot();
|
|
|
|
|
|
binding.tvMsg.setText(msg);
|
|
|
|
|
|
|
|
|
|
|
|
binding.bottomBtnView.dialogCommit.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
dismiss();
|
|
|
|
|
|
if (listener != null) {
|
|
|
|
|
|
listener.confirm();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.listener = listener;
|
|
|
|
|
|
setCancelable(false);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
setContentView(mView);
|
|
|
|
|
|
|
|
|
|
|
|
Window window = getWindow();
|
|
|
|
|
|
WindowManager.LayoutParams lp = window.getAttributes();
|
|
|
|
|
|
lp.width = (getScreenWidth(context)) / 4;
|
|
|
|
|
|
window.setGravity(Gravity.CENTER);
|
|
|
|
|
|
|
|
|
|
|
|
// Window window = this.getWindow();
|
|
|
|
|
|
// WindowManager.LayoutParams lp = window.getAttributes();
|
|
|
|
|
|
// Display d = window.getWindowManager().getDefaultDisplay();
|
|
|
|
|
|
// lp.width = (int) (d.getWidth() * 0.9F);
|
|
|
|
|
|
// window.setAttributes(lp);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setTvMsg(String msg) {
|
|
|
|
|
|
if (!TextUtils.isEmpty(msg)) {
|
|
|
|
|
|
binding.tvMsg.setText(msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取屏幕宽度
|
|
|
|
|
|
public static int getScreenWidth(Context context) {
|
|
|
|
|
|
WindowManager manager = (WindowManager) context
|
|
|
|
|
|
.getSystemService(Context.WINDOW_SERVICE);
|
|
|
|
|
|
Display display = manager.getDefaultDisplay();
|
|
|
|
|
|
return display.getWidth();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public interface ResultDialogListener {
|
|
|
|
|
|
void confirm();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|