|
@@ -45,6 +45,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
|
|
private BaseDialog parentDialog;
|
|
private BaseDialog parentDialog;
|
|
private boolean autoUnsafePlacePadding = true;
|
|
private boolean autoUnsafePlacePadding = true;
|
|
private boolean focusable = true;
|
|
private boolean focusable = true;
|
|
|
|
+ private boolean interceptBack = true;
|
|
|
|
|
|
private OnLifecycleCallBack onLifecycleCallBack;
|
|
private OnLifecycleCallBack onLifecycleCallBack;
|
|
private OnBackPressedListener onBackPressedListener;
|
|
private OnBackPressedListener onBackPressedListener;
|
|
@@ -75,6 +76,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
|
|
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DialogXBaseRelativeLayout);
|
|
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DialogXBaseRelativeLayout);
|
|
focusable = a.getBoolean(R.styleable.DialogXBaseRelativeLayout_baseFocusable, true);
|
|
focusable = a.getBoolean(R.styleable.DialogXBaseRelativeLayout_baseFocusable, true);
|
|
autoUnsafePlacePadding = a.getBoolean(R.styleable.DialogXBaseRelativeLayout_autoSafeArea, true);
|
|
autoUnsafePlacePadding = a.getBoolean(R.styleable.DialogXBaseRelativeLayout_autoSafeArea, true);
|
|
|
|
+ interceptBack = a.getBoolean(R.styleable.DialogXBaseRelativeLayout_interceptBack, true);
|
|
a.recycle();
|
|
a.recycle();
|
|
isInited = true;
|
|
isInited = true;
|
|
}
|
|
}
|
|
@@ -121,7 +123,7 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
- if (isAttachedToWindow() && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
|
|
|
|
|
+ if (isAttachedToWindow() && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_BACK && interceptBack) {
|
|
if (onBackPressedListener != null) {
|
|
if (onBackPressedListener != null) {
|
|
onBackPressedListener.onBackPressed();
|
|
onBackPressedListener.onBackPressed();
|
|
}
|
|
}
|
|
@@ -307,4 +309,13 @@ public class DialogXBaseRelativeLayout extends RelativeLayout {
|
|
public boolean isBaseFocusable() {
|
|
public boolean isBaseFocusable() {
|
|
return focusable;
|
|
return focusable;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean isInterceptBack() {
|
|
|
|
+ return interceptBack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public DialogXBaseRelativeLayout setInterceptBack(boolean interceptBack) {
|
|
|
|
+ this.interceptBack = interceptBack;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
}
|
|
}
|