|
@@ -51,6 +51,8 @@ public class FitSystemBarUtils {
|
|
|
|
|
|
private CallBack callBack;
|
|
|
|
|
|
+ private BaseDialog dialog;
|
|
|
+
|
|
|
/**
|
|
|
* 绑定到View
|
|
|
*
|
|
@@ -137,6 +139,9 @@ public class FitSystemBarUtils {
|
|
|
// view.setFitsSystemWindows(true);
|
|
|
contentView = view;
|
|
|
this.callBack = callBack;
|
|
|
+ if (view instanceof DialogXBaseRelativeLayout) {
|
|
|
+ dialog = ((DialogXBaseRelativeLayout) view).getParentDialog();
|
|
|
+ }
|
|
|
applyWindowInsets();
|
|
|
}
|
|
|
|
|
@@ -517,7 +522,7 @@ public class FitSystemBarUtils {
|
|
|
}
|
|
|
|
|
|
private boolean isFullScreen() {
|
|
|
- Activity activity = BaseDialog.getTopActivity();
|
|
|
+ Activity activity = getActivity();
|
|
|
if (activity == null) {
|
|
|
return false;
|
|
|
}
|
|
@@ -535,7 +540,7 @@ public class FitSystemBarUtils {
|
|
|
}
|
|
|
|
|
|
private int checkOrientationAndStatusBarSide() {
|
|
|
- Activity activity = BaseDialog.getTopActivity();
|
|
|
+ Activity activity = getActivity();
|
|
|
if (activity == null) {
|
|
|
return 0;
|
|
|
}
|
|
@@ -563,7 +568,7 @@ public class FitSystemBarUtils {
|
|
|
private ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener;
|
|
|
|
|
|
private View getDecorView() {
|
|
|
- Activity activity = BaseDialog.getTopActivity();
|
|
|
+ Activity activity = getActivity();
|
|
|
if (activity == null) {
|
|
|
return null;
|
|
|
}
|
|
@@ -612,4 +617,20 @@ public class FitSystemBarUtils {
|
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
|
+
|
|
|
+ private Activity getActivity() {
|
|
|
+ if (dialog == null) return BaseDialog.getTopActivity();
|
|
|
+ return dialog.getOwnActivity();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void recycle() {
|
|
|
+ View decorView = getDecorView();
|
|
|
+ if (decorView != null && onGlobalLayoutListener != null) {
|
|
|
+ decorView.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
|
|
|
+ }
|
|
|
+ onGlobalLayoutListener = null;
|
|
|
+ callBack = null;
|
|
|
+ contentView = null;
|
|
|
+ dialog = null;
|
|
|
+ }
|
|
|
}
|