|
|
@@ -4,6 +4,7 @@ import android.app.AlertDialog;
|
|
|
import android.app.Dialog;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
+import android.graphics.drawable.ColorDrawable;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.widget.LinearLayout;
|
|
|
@@ -11,6 +12,7 @@ import android.widget.TextView;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
+import com.coorchice.library.SuperTextView;
|
|
|
import com.mgtech.base_library.R;
|
|
|
/**
|
|
|
* @ProjectName: TUA
|
|
|
@@ -133,17 +135,20 @@ public class CustomDialog extends Dialog {
|
|
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
// instantiate the dialog with the custom Theme
|
|
|
final CustomDialog dialog = new CustomDialog(context, R.style.Theme_AppCompat_Light_Dialog_Alert);
|
|
|
- View layout = inflater.inflate(R.layout.dialog_ask, null);
|
|
|
- dialog.addContentView(layout, new LinearLayout.LayoutParams(
|
|
|
- LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
|
+ if (dialog.getWindow() != null)
|
|
|
+ dialog.getWindow().setBackgroundDrawableResource(R.color.transparent);
|
|
|
+ if (contentView == null)
|
|
|
+ contentView = inflater.inflate(R.layout.dialog_ask, null);
|
|
|
+// dialog.addContentView(layout, new LinearLayout.LayoutParams(
|
|
|
+// LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
|
// set the dialog title
|
|
|
- ((TextView) layout.findViewById(R.id.dialog_title)).setText(title);
|
|
|
+ ((TextView) contentView.findViewById(R.id.dialog_title)).setText(title);
|
|
|
// set the confirm button
|
|
|
if (positiveButtonText != null) {
|
|
|
- ((TextView) layout.findViewById(R.id.dialog_positive))
|
|
|
+ ((SuperTextView) contentView.findViewById(R.id.dialog_positive))
|
|
|
.setText(positiveButtonText);
|
|
|
if (positiveButtonClickListener != null) {
|
|
|
- layout.findViewById(R.id.dialog_positive)
|
|
|
+ contentView.findViewById(R.id.dialog_positive)
|
|
|
.setOnClickListener(new View.OnClickListener() {
|
|
|
public void onClick(View v) {
|
|
|
positiveButtonClickListener.onClick(dialog,
|
|
|
@@ -153,15 +158,15 @@ public class CustomDialog extends Dialog {
|
|
|
}
|
|
|
} else {
|
|
|
// if no confirm button just set the visibility to GONE
|
|
|
- layout.findViewById(R.id.dialog_positive).setVisibility(
|
|
|
+ contentView.findViewById(R.id.dialog_positive).setVisibility(
|
|
|
View.GONE);
|
|
|
}
|
|
|
// set the cancel button
|
|
|
if (negativeButtonText != null) {
|
|
|
- ((TextView) layout.findViewById(R.id.dialog_negative))
|
|
|
+ ((SuperTextView) contentView.findViewById(R.id.dialog_negative))
|
|
|
.setText(negativeButtonText);
|
|
|
if (negativeButtonClickListener != null) {
|
|
|
- layout.findViewById(R.id.dialog_negative)
|
|
|
+ contentView.findViewById(R.id.dialog_negative)
|
|
|
.setOnClickListener(new View.OnClickListener() {
|
|
|
public void onClick(View v) {
|
|
|
negativeButtonClickListener.onClick(dialog,
|
|
|
@@ -171,21 +176,22 @@ public class CustomDialog extends Dialog {
|
|
|
}
|
|
|
} else {
|
|
|
// if no confirm button just set the visibility to GONE
|
|
|
- layout.findViewById(R.id.dialog_negative).setVisibility(
|
|
|
+ contentView.findViewById(R.id.dialog_negative).setVisibility(
|
|
|
View.GONE);
|
|
|
}
|
|
|
// set the content message
|
|
|
if (message != null) {
|
|
|
- ((TextView) layout.findViewById(R.id.dialog_message)).setText(message);
|
|
|
- } else if (contentView != null) {
|
|
|
- // if no message set
|
|
|
- // add the contentView to the dialog body
|
|
|
- ((LinearLayout) layout.findViewById(R.id.content))
|
|
|
- .removeAllViews();
|
|
|
- ((LinearLayout) layout.findViewById(R.id.content))
|
|
|
- .addView(contentView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
|
+ ((TextView) contentView.findViewById(R.id.dialog_message)).setText(message);
|
|
|
}
|
|
|
- dialog.setContentView(layout,new LinearLayout.LayoutParams(
|
|
|
+// else if (contentView != null) {
|
|
|
+// // if no message set
|
|
|
+// // add the contentView to the dialog body
|
|
|
+// ((LinearLayout) layout.findViewById(R.id.content))
|
|
|
+// .removeAllViews();
|
|
|
+// ((LinearLayout) layout.findViewById(R.id.content))
|
|
|
+// .addView(contentView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
|
+// }
|
|
|
+ dialog.setContentView(contentView,new LinearLayout.LayoutParams(
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
|
return dialog;
|
|
|
}
|