|
|
@@ -3,16 +3,12 @@
|
|
|
*/
|
|
|
package kr.co.zumo.app.lifeplus.view.dialog;
|
|
|
|
|
|
-import android.app.Dialog;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.StringRes;
|
|
|
+import android.support.constraint.ConstraintLayout;
|
|
|
+import android.support.constraint.ConstraintSet;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.TextView;
|
|
|
|
|
|
-import kr.co.zumo.app.R;
|
|
|
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
|
|
|
/**
|
|
|
@@ -25,85 +21,7 @@ import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
* @history 민효동 [2018. 9. 23.] [최초 작성]
|
|
|
* @since 2018. 9. 23.
|
|
|
*/
|
|
|
-public class AlertDialog extends TextDialog<ICustomDialogListener<AlertDialog>> {
|
|
|
-
|
|
|
- protected boolean isCancelable = true;
|
|
|
-
|
|
|
- protected boolean isTransparent;
|
|
|
-
|
|
|
- @StringRes
|
|
|
- protected int positiveButtonLabel = R.string.empty_string;
|
|
|
- @StringRes
|
|
|
- protected int titleStringId = R.string.empty_string;
|
|
|
-
|
|
|
- private TextView textViewPositiveButton;
|
|
|
-
|
|
|
- private boolean isVisibleCloseButton;
|
|
|
-
|
|
|
- /**
|
|
|
- * 표시할 positiveButtonLabel 지정
|
|
|
- *
|
|
|
- * @param stringId
|
|
|
- */
|
|
|
- public void setPositiveButtonLabelId(@StringRes int stringId) {
|
|
|
- this.positiveButtonLabel = stringId;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 표시할 title 지정
|
|
|
- *
|
|
|
- * @param stringId
|
|
|
- */
|
|
|
- public void setTitleId(@StringRes int stringId) {this.titleStringId = stringId;}
|
|
|
-
|
|
|
- /**
|
|
|
- * back key 가능 여부 설정
|
|
|
- *
|
|
|
- * @param cancelable
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void setCancelable(boolean cancelable) {
|
|
|
- super.setCancelable(cancelable);
|
|
|
- isCancelable = cancelable;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 닫기 버튼 표시
|
|
|
- *
|
|
|
- * @param isVisibleCloseButton
|
|
|
- */
|
|
|
- public void setVisibleCloseButton(boolean isVisibleCloseButton) {this.isVisibleCloseButton = isVisibleCloseButton;}
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * todo 배경 투명 설정?
|
|
|
- *
|
|
|
- * @param isTransparent
|
|
|
- */
|
|
|
- public void setTransparent(boolean isTransparent) {
|
|
|
- this.isTransparent = isTransparent;
|
|
|
- }
|
|
|
-
|
|
|
- @NonNull
|
|
|
- @Override
|
|
|
- public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
|
- // Use the Builder class for convenient dialog construction
|
|
|
- android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(getActivity(), R.style.DialogTheme);
|
|
|
- View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_alert, null);
|
|
|
- setupView(view);
|
|
|
- builder.setView(view);
|
|
|
- builder.setCancelable(isCancelable);
|
|
|
- Dialog dialog = builder.create();
|
|
|
- dialog.setCancelable(isCancelable);
|
|
|
- dialog.setCanceledOnTouchOutside(isCancelable);
|
|
|
- if (isTransparent) {
|
|
|
- dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
|
|
- }
|
|
|
- // Create the AlertDialog object and return it
|
|
|
- return dialog;
|
|
|
-
|
|
|
- }
|
|
|
+public class AlertDialog extends ConfirmBaseDialog<ICustomDialogListener<AlertDialog>> {
|
|
|
|
|
|
//onStart() is where dialog.show() is actually called on
|
|
|
//the underlying dialog, so we have to do it there or
|
|
|
@@ -112,17 +30,12 @@ public class AlertDialog extends TextDialog<ICustomDialogListener<AlertDialog>>
|
|
|
//environment that skips onStart then the dialog will still be functioning
|
|
|
//properly after a rotation.
|
|
|
@Override
|
|
|
- public void onResume() {
|
|
|
- super.onResume();
|
|
|
-
|
|
|
+ protected void attachEvent() {
|
|
|
final android.support.v7.app.AlertDialog d = (android.support.v7.app.AlertDialog) getDialog();
|
|
|
if (d != null) {
|
|
|
- textViewPositiveButton.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- if (null != getCustomListener()) {
|
|
|
- getCustomListener().onDialogResult(AlertDialog.this, new Event.Builder(Event.CONFIRM).build());
|
|
|
- }
|
|
|
+ textViewPositiveButton.setOnClickListener(v -> {
|
|
|
+ if (null != getCustomListener()) {
|
|
|
+ getCustomListener().onDialogResult(AlertDialog.this, new Event.Builder(Event.CONFIRM).build());
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -136,30 +49,19 @@ public class AlertDialog extends TextDialog<ICustomDialogListener<AlertDialog>>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void setupView(View view) {
|
|
|
- textViewPositiveButton = view.findViewById(R.id.text_view_write_app_review);
|
|
|
- TextView textViewTitle = view.findViewById(R.id.text_view_title);
|
|
|
- TextView textViewContents = view.findViewById(R.id.text_view_dialog_message);
|
|
|
- ImageView imageViewClose = view.findViewById(R.id.image_view_close);
|
|
|
+ @Override
|
|
|
+ protected void setupView(View view) {
|
|
|
+ super.setupView(view);
|
|
|
|
|
|
- imageViewClose.setVisibility(isVisibleCloseButton ? View.VISIBLE : View.GONE);
|
|
|
- textViewTitle.setVisibility(titleStringId == R.string.empty_string ? View.GONE : View.VISIBLE);
|
|
|
- textViewPositiveButton.setText(positiveButtonLabel == R.string.empty_string ? R.string.confirm : positiveButtonLabel);
|
|
|
+ //
|
|
|
+ textViewNegativeButton.setVisibility(View.GONE);
|
|
|
|
|
|
- if (titleStringId != R.string.empty_string) {
|
|
|
- textViewTitle.setText(titleStringId);
|
|
|
- }
|
|
|
+ ConstraintSet constraintSet = new ConstraintSet();
|
|
|
+ constraintSet.clone((ConstraintLayout) textViewPositiveButton.getParent());
|
|
|
|
|
|
- textViewContents.setText(text);
|
|
|
+ constraintSet.connect(textViewPositiveButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, ResourceUtil.dpToPx(10));
|
|
|
|
|
|
- //닫기버튼 클릭
|
|
|
- imageViewClose.setOnClickListener(view1 -> {
|
|
|
- getCustomListener().onDialogCanceled(AlertDialog.this);
|
|
|
- });
|
|
|
+ constraintSet.applyTo((ConstraintLayout) textViewPositiveButton.getParent());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onActivityCreatedInternal() {
|
|
|
-
|
|
|
- }
|
|
|
}
|