Skip to content

Commit

Permalink
// fix #87#89#90
Browse files Browse the repository at this point in the history
  • Loading branch information
razerdp committed Oct 25, 2018
1 parent fdefa9b commit a3a36ab
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ defaultConfig {
更新日志([历史更新](https://github.com/razerdp/BasePopup/blob/master/UpdateLog.md))
---------------------------------------------------------------------------

* **2.0.8-alpha3**(2018/10/25)
* fixed [#87](https://github.com/razerdp/BasePopup/issues/87)[#89](https://github.com/razerdp/BasePopup/issues/89)[#90](https://github.com/razerdp/BasePopup/issues/90)

* **2.0.8-alpha2**(2018/10/19)
* 修复QuickPopupBuilder的click事件无响应问题,增加background方法
* 修复设置background(0)时无法找到资源而崩溃的问题
Expand Down
2 changes: 2 additions & 0 deletions UpdateLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
* BasePopup
* **2.0.8-alpha3**(2018/10/25)
* fixed [#87](https://github.com/razerdp/BasePopup/issues/87)[#89](https://github.com/razerdp/BasePopup/issues/89)[#90](https://github.com/razerdp/BasePopup/issues/90)

* **2.0.8-alpha2**(2018/10/19)
* 修复QuickPopupBuilder的click事件无响应问题,增加background方法
Expand Down
4 changes: 2 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 27
versionCode 23
versionName "2.0.8-alpha2"
versionName "2.0.8-alpha3"
}
buildTypes {
release {
Expand All @@ -34,7 +34,7 @@ def moduleName = 'BasePopup_Candy'


group = "com.github.razerdp"
version = "2.0.8-alpha2"
version = "2.0.8-alpha3"

install {
repositories.mavenInstaller {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/razerdp/basepopup/BasePopupWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ public BasePopupWindow setBackground(int drawableIds) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return setBackground(getContext().getDrawable(drawableIds));
} else {
return setBackground(getContext().getResources().getDrawable(drawableIds, getContext().getTheme()));
return setBackground(getContext().getResources().getDrawable(drawableIds));
}
}

Expand Down
29 changes: 17 additions & 12 deletions lib/src/main/java/razerdp/basepopup/HackWindowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public Display getDefaultDisplay() {

@Override
public void removeViewImmediate(View view) {
if (mWindowManager == null) return;
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.removeViewImmediate >>> " + (view == null ? null : view.getClass().getSimpleName()));
if (mWindowManager == null || view == null) return;
checkStatusBarHeight(view.getContext());
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.removeViewImmediate >>> " + view.getClass().getSimpleName());
if (isPopupInnerDecorView(view) && getHackPopupDecorView() != null) {
if (getMaskLayout() != null) {
try {
Expand All @@ -55,7 +55,7 @@ public void removeViewImmediate(View view) {
}
HackPopupDecorView hackPopupDecorView = getHackPopupDecorView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (!hackPopupDecorView.isAttachedToWindow())return;
if (!hackPopupDecorView.isAttachedToWindow()) return;
}
mWindowManager.removeViewImmediate(hackPopupDecorView);
mHackPopupDecorView.clear();
Expand All @@ -67,9 +67,9 @@ public void removeViewImmediate(View view) {

@Override
public void addView(View view, ViewGroup.LayoutParams params) {
if (mWindowManager == null) return;
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.addView >>> " + (view == null ? null : view.getClass().getSimpleName()));
if (mWindowManager == null || view == null) return;
checkStatusBarHeight(view.getContext());
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.addView >>> " + view.getClass().getSimpleName());
if (isPopupInnerDecorView(view)) {
/**
* 此时的params是WindowManager.LayoutParams,需要留意强转问题
Expand Down Expand Up @@ -106,6 +106,7 @@ public void onAttachtoWindow() {
private ViewGroup.LayoutParams fitLayoutParamsPosition(ViewGroup.LayoutParams params) {
if (params instanceof WindowManager.LayoutParams) {
WindowManager.LayoutParams p = (LayoutParams) params;
p.type = LayoutParams.TYPE_APPLICATION_SUB_PANEL;
BasePopupHelper helper = getBasePopupHelper();
if (helper != null && helper.isShowAsDropDown() && p.y <= helper.getAnchorY()) {
int y = helper.getAnchorY() + helper.getAnchorHeight() + helper.getInternalOffsetY();
Expand All @@ -117,9 +118,9 @@ private ViewGroup.LayoutParams fitLayoutParamsPosition(ViewGroup.LayoutParams pa

@Override
public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
if (mWindowManager == null) return;
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.updateViewLayout >>> " + (view == null ? null : view.getClass().getSimpleName()));
if (mWindowManager == null || view == null) return;
checkStatusBarHeight(view.getContext());
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.updateViewLayout >>> " + view.getClass().getSimpleName());
if (isPopupInnerDecorView(view) && getHackPopupDecorView() != null) {
HackPopupDecorView hackPopupDecorView = getHackPopupDecorView();
mWindowManager.updateViewLayout(hackPopupDecorView, fitLayoutParamsPosition(params));
Expand All @@ -130,15 +131,17 @@ public void updateViewLayout(View view, ViewGroup.LayoutParams params) {

@Override
public void removeView(View view) {
if (mWindowManager == null) return;
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.removeView >>> " + (view == null ? null : view.getClass().getSimpleName()));
if (mWindowManager == null || view == null) return;
checkStatusBarHeight(view.getContext());
PopupLogUtil.trace(LogTag.i, TAG, "WindowManager.removeView >>> " + view.getClass().getSimpleName());
if (isPopupInnerDecorView(view) && getHackPopupDecorView() != null) {
if (getMaskLayout() != null) {
try {
mWindowManager.removeView(getMaskLayout());
mMaskLayout.clear();
mMaskLayout = null;
if (mMaskLayout != null) {
mMaskLayout.clear();
mMaskLayout = null;
}
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -157,7 +160,9 @@ public void clear() {
removeViewImmediate(mHackPopupDecorView.get());
removeViewImmediate(getMaskLayout());
mHackPopupDecorView.clear();
mMaskLayout.clear();
if (mMaskLayout != null) {
mMaskLayout.clear();
}
} catch (Exception e) {
//no print
}
Expand Down

0 comments on commit a3a36ab

Please sign in to comment.