146 lines
5.5 KiB
Java
146 lines
5.5 KiB
Java
package com.ubt.jimu.base.dialog;
|
|
|
|
import android.app.DialogFragment;
|
|
import android.content.Context;
|
|
import android.graphics.drawable.ColorDrawable;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
import com.ubt.jimu.R;
|
|
import com.ubtech.utils.DisplayUtil;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class SimpleQuestionDialog extends DialogFragment implements View.OnClickListener {
|
|
public static final int GRAVITY_CENTER = 2;
|
|
public static final int GRAVITY_LEFT = 1;
|
|
public static final String KEY_CANCELBUTTON = "cancel";
|
|
public static final String KEY_OK_BUTTON = "ok";
|
|
public static final String KEY_TIPS = "tips";
|
|
public static final String KEY_TIPS_GRAVITY = "tipsGravity";
|
|
public static final String KEY_TITLE = "title";
|
|
private TextView cancelBtn;
|
|
private String cancelButton;
|
|
private IDialogListener listener;
|
|
private TextView okBtn;
|
|
private String okButton;
|
|
private String tips;
|
|
private int tipsGravity;
|
|
private TextView tipsTxt;
|
|
private String title;
|
|
private TextView tvTitle;
|
|
|
|
public static SimpleQuestionDialog newInstance(String str) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(KEY_TIPS, str);
|
|
SimpleQuestionDialog simpleQuestionDialog = new SimpleQuestionDialog();
|
|
simpleQuestionDialog.setArguments(bundle);
|
|
return simpleQuestionDialog;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
if (view.getId() == R.id.simple_question_dialog_ok) {
|
|
IDialogListener iDialogListener = this.listener;
|
|
if (iDialogListener != null) {
|
|
iDialogListener.onOk();
|
|
}
|
|
dismiss();
|
|
return;
|
|
}
|
|
if (view.getId() == R.id.simple_question_dialog_cancel) {
|
|
IDialogListener iDialogListener2 = this.listener;
|
|
if (iDialogListener2 != null) {
|
|
iDialogListener2.onCancle();
|
|
}
|
|
dismiss();
|
|
}
|
|
}
|
|
|
|
@Override // android.app.DialogFragment, android.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
setCancelable(false);
|
|
Bundle arguments = getArguments();
|
|
if (arguments != null) {
|
|
this.title = arguments.getString("title");
|
|
this.tips = arguments.getString(KEY_TIPS);
|
|
this.okButton = arguments.getString(KEY_OK_BUTTON);
|
|
this.cancelButton = arguments.getString(KEY_CANCELBUTTON);
|
|
this.tipsGravity = arguments.getInt(KEY_TIPS_GRAVITY);
|
|
}
|
|
}
|
|
|
|
@Override // android.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
getDialog().requestWindowFeature(1);
|
|
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));
|
|
View inflate = layoutInflater.inflate(R.layout.dialog_simple_question, viewGroup);
|
|
this.tvTitle = (TextView) inflate.findViewById(R.id.simple_question_dialog_title);
|
|
this.tipsTxt = (TextView) inflate.findViewById(R.id.simple_question_dialog_info);
|
|
this.okBtn = (TextView) inflate.findViewById(R.id.simple_question_dialog_ok);
|
|
this.cancelBtn = (TextView) inflate.findViewById(R.id.simple_question_dialog_cancel);
|
|
this.okBtn.setOnClickListener(this);
|
|
this.cancelBtn.setOnClickListener(this);
|
|
this.tipsTxt.setText(this.tips + " ");
|
|
if (!TextUtils.isEmpty(this.okButton)) {
|
|
this.okBtn.setText(this.okButton);
|
|
}
|
|
if (!TextUtils.isEmpty(this.cancelButton)) {
|
|
this.cancelBtn.setText(this.cancelButton);
|
|
}
|
|
if (TextUtils.isEmpty(this.title)) {
|
|
int a = DisplayUtil.a((Context) getActivity(), 46.0f);
|
|
this.tipsTxt.setPadding(a, a, a, a);
|
|
this.tvTitle.setVisibility(8);
|
|
} else {
|
|
this.tvTitle.setVisibility(0);
|
|
this.tvTitle.setText(this.title);
|
|
}
|
|
int i = this.tipsGravity;
|
|
if (i > 0) {
|
|
setTextLeft(i);
|
|
}
|
|
return inflate;
|
|
}
|
|
|
|
public void setListener(IDialogListener iDialogListener) {
|
|
this.listener = iDialogListener;
|
|
}
|
|
|
|
public void setTextLeft(int i) {
|
|
TextView textView = this.tipsTxt;
|
|
if (textView != null) {
|
|
if (i == 1) {
|
|
textView.setGravity(3);
|
|
} else if (i == 2) {
|
|
textView.setGravity(17);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static SimpleQuestionDialog newInstance(String str, String str2, String str3) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(KEY_OK_BUTTON, str);
|
|
bundle.putString(KEY_CANCELBUTTON, str2);
|
|
bundle.putString(KEY_TIPS, str3);
|
|
SimpleQuestionDialog simpleQuestionDialog = new SimpleQuestionDialog();
|
|
simpleQuestionDialog.setArguments(bundle);
|
|
return simpleQuestionDialog;
|
|
}
|
|
|
|
public static SimpleQuestionDialog newInstance(String str, String str2, String str3, String str4, int i) {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("title", str);
|
|
bundle.putString(KEY_OK_BUTTON, str2);
|
|
bundle.putString(KEY_CANCELBUTTON, str3);
|
|
bundle.putString(KEY_TIPS, str4);
|
|
bundle.putInt(KEY_TIPS_GRAVITY, i);
|
|
SimpleQuestionDialog simpleQuestionDialog = new SimpleQuestionDialog();
|
|
simpleQuestionDialog.setArguments(bundle);
|
|
return simpleQuestionDialog;
|
|
}
|
|
}
|