result = new ArrayList<>();
result.add(new DemoMainItem(GuideActivity.class, "简介", GuideActivity.DESC, null));
diff --git a/app/src/main/java/razerdp/demo/base/baseactivity/BaseActivity.java b/app/src/main/java/razerdp/demo/base/baseactivity/BaseActivity.java
index 92694608..bea991ef 100644
--- a/app/src/main/java/razerdp/demo/base/baseactivity/BaseActivity.java
+++ b/app/src/main/java/razerdp/demo/base/baseactivity/BaseActivity.java
@@ -312,11 +312,7 @@ public void showLoadingDialog(boolean cancelable) {
}
mLoadingDialog.setCancelable(cancelable);
if (mLoadingDialog != null && !mLoadingDialog.isShowing()) {
- if (ToolUtil.isMainThread()) {
- mLoadingDialog.show();
- } else {
- runOnUiThread(() -> mLoadingDialog.show());
- }
+ runOnUiThread(() -> mLoadingDialog.show());
}
}
diff --git a/app/src/main/java/razerdp/demo/model/common/ScreenRotateActivityInfo.java b/app/src/main/java/razerdp/demo/model/common/ScreenRotateActivityInfo.java
new file mode 100644
index 00000000..feb96126
--- /dev/null
+++ b/app/src/main/java/razerdp/demo/model/common/ScreenRotateActivityInfo.java
@@ -0,0 +1,30 @@
+package razerdp.demo.model.common;
+
+import android.view.View;
+
+import razerdp.demo.model.DemoCommonUsageInfo;
+import razerdp.demo.ui.ActivityLauncher;
+import razerdp.demo.ui.ScreenRotateActivity;
+import razerdp.demo.utils.UIHelper;
+
+/**
+ * Created by 大灯泡 on 2020/05/17
+ *
+ * Description:屏幕旋转
+ */
+public class ScreenRotateActivityInfo extends DemoCommonUsageInfo {
+
+ public ScreenRotateActivityInfo() {
+ title = "屏幕旋转";
+ }
+
+ @Override
+ public void toShow(View v) {
+ ActivityLauncher.start(v.getContext(), ScreenRotateActivity.class);
+ }
+
+ @Override
+ public void toOption(View v) {
+ UIHelper.toast("这里啥都没有哦");
+ }
+}
diff --git a/app/src/main/java/razerdp/demo/popup/DemoPopup.java b/app/src/main/java/razerdp/demo/popup/DemoPopup.java
index bc6e4239..dd6ec305 100644
--- a/app/src/main/java/razerdp/demo/popup/DemoPopup.java
+++ b/app/src/main/java/razerdp/demo/popup/DemoPopup.java
@@ -25,14 +25,17 @@ public class DemoPopup extends BasePopupWindow {
public DemoPopup(Context context) {
super(context);
+ setContentView(R.layout.popup_demo);
}
public DemoPopup(Fragment fragment) {
super(fragment);
+ setContentView(R.layout.popup_demo);
}
public DemoPopup(Dialog dialog) {
super(dialog);
+ setContentView(R.layout.popup_demo);
}
@Override
@@ -54,10 +57,6 @@ protected Animation onCreateDismissAnimation() {
.toDismiss();
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_demo);
- }
public DemoPopup setText(CharSequence text) {
mTvDesc.setText(text);
diff --git a/app/src/main/java/razerdp/demo/popup/PopupAnimate.java b/app/src/main/java/razerdp/demo/popup/PopupAnimate.java
index 094fcc05..c944413c 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupAnimate.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupAnimate.java
@@ -14,10 +14,7 @@
public class PopupAnimate extends BasePopupWindow {
public PopupAnimate(Context context) {
super(context);
+ setContentView(R.layout.popup_animate);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_animate);
- }
}
diff --git a/app/src/main/java/razerdp/demo/popup/PopupArrow.java b/app/src/main/java/razerdp/demo/popup/PopupArrow.java
index 300d1c98..67a0243c 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupArrow.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupArrow.java
@@ -28,15 +28,11 @@ public class PopupArrow extends BasePopupWindow {
public PopupArrow(Context context) {
super(context);
+ setContentView(R.layout.popup_arrow);
ViewUtil.setViewPivotRatio(mIvArrow, 0.5f, 0.5f);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_arrow);
- }
-
@Override
public void onViewCreated(@NonNull View contentView) {
ButterKnifeUtil.bind(this, contentView);
diff --git a/app/src/main/java/razerdp/demo/popup/PopupDesc.java b/app/src/main/java/razerdp/demo/popup/PopupDesc.java
index 24a1c442..8ade5d3d 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupDesc.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupDesc.java
@@ -29,6 +29,7 @@ public class PopupDesc extends BasePopupWindow {
public PopupDesc(Context context) {
super(context);
+ setContentView(R.layout.popup_description);
setClipChildren(false);
}
@@ -51,10 +52,6 @@ protected Animation onCreateDismissAnimation() {
.toDismiss();
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_description);
- }
public PopupDesc setTitle(CharSequence title) {
mTvTitle.setText(title);
diff --git a/app/src/main/java/razerdp/demo/popup/PopupFriendCircle.java b/app/src/main/java/razerdp/demo/popup/PopupFriendCircle.java
index 1b33bdca..8a00b5ca 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupFriendCircle.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupFriendCircle.java
@@ -46,6 +46,7 @@ public class PopupFriendCircle extends BasePopupWindow {
public PopupFriendCircle(Context context) {
super(context);
+ setContentView(R.layout.popup_friend_circle_comment);
ViewUtil.setViewPivotRatio(ivStar, 0.5f, 0.5f);
setBackgroundColor(0);
}
@@ -55,10 +56,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_friend_circle_comment);
- }
@Override
public void showPopupWindow(View anchorView) {
diff --git a/app/src/main/java/razerdp/demo/popup/PopupInput.java b/app/src/main/java/razerdp/demo/popup/PopupInput.java
index a9f85249..d7396933 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupInput.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupInput.java
@@ -28,6 +28,7 @@ public class PopupInput extends BasePopupWindow {
public PopupInput(Context context) {
super(context);
+ setContentView(R.layout.popup_input);
mTvSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -42,10 +43,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_input);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/PopupShowOnCreate.java b/app/src/main/java/razerdp/demo/popup/PopupShowOnCreate.java
index 614c1033..7e3de5c2 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupShowOnCreate.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupShowOnCreate.java
@@ -17,6 +17,7 @@ public class PopupShowOnCreate extends BasePopupWindow {
public PopupShowOnCreate(Context context) {
super(context);
+ setContentView(R.layout.popup_show_on_create);
}
@Override
@@ -33,11 +34,6 @@ protected Animation onCreateDismissAnimation() {
.toDismiss();
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_show_on_create);
- }
-
@Override
protected void onLogInternal(String msg) {
diff --git a/app/src/main/java/razerdp/demo/popup/PopupSlide.java b/app/src/main/java/razerdp/demo/popup/PopupSlide.java
index 2e5ab896..7e5702de 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupSlide.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupSlide.java
@@ -27,15 +27,12 @@ public class PopupSlide extends BasePopupWindow {
public PopupSlide(Context context) {
super(context);
+ setContentView(R.layout.popup_slide);
}
@Override
public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_slide);
- }
@OnClick({R.id.tv_item_1, R.id.tv_item_2, R.id.tv_item_3})
void click(View v) {
diff --git a/app/src/main/java/razerdp/demo/popup/PopupSlideSmall.java b/app/src/main/java/razerdp/demo/popup/PopupSlideSmall.java
index 5223c0b7..fa8ca13b 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupSlideSmall.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupSlideSmall.java
@@ -28,6 +28,7 @@ public class PopupSlideSmall extends BasePopupWindow {
public PopupSlideSmall(Context context) {
super(context);
+ setContentView(R.layout.popup_slide_small);
}
@Override
@@ -35,10 +36,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_slide_small);
- }
@OnClick({R.id.tv_item_1, R.id.tv_item_2, R.id.tv_item_3})
void click(View v) {
diff --git a/app/src/main/java/razerdp/demo/popup/PopupUpdateTest.java b/app/src/main/java/razerdp/demo/popup/PopupUpdateTest.java
index 5590c4a1..979efa95 100644
--- a/app/src/main/java/razerdp/demo/popup/PopupUpdateTest.java
+++ b/app/src/main/java/razerdp/demo/popup/PopupUpdateTest.java
@@ -21,15 +21,18 @@
public class PopupUpdateTest extends BasePopupWindow {
@BindView(R.id.tv_change_view)
TextView tvChangeView;
+ @BindView(R.id.tv_change_size)
+ TextView tvChangeSize;
@BindView(R.id.tv_update)
TextView tvUpdate;
OnTvChangeViewClickCallback cb;
+ OnTvChangeViewSizeClickCallback sizeCb;
OnUpdateClickCallback updateCb;
public PopupUpdateTest(Context context) {
super(context);
-
+ setContentView(R.layout.popup_update_test);
setBackground(null);
setPopupGravity(Gravity.BOTTOM);
tvUpdate.setOnClickListener(new View.OnClickListener() {
@@ -48,6 +51,14 @@ public void onClick(View v) {
}
}
});
+ tvChangeSize.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (sizeCb != null) {
+ sizeCb.onClick();
+ }
+ }
+ });
}
@Override
@@ -69,12 +80,8 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_update_test);
- }
- public void OnUpdateClickCallback(OnUpdateClickCallback cb) {
+ public void setOnUpdateClickCallback(OnUpdateClickCallback cb) {
this.updateCb = cb;
}
@@ -82,6 +89,11 @@ public void setOnTvChangeViewClickCallback(OnTvChangeViewClickCallback cb) {
this.cb = cb;
}
+ public void setOnTvChangeViewSizeClickCallback(OnTvChangeViewSizeClickCallback cb) {
+ this.sizeCb = cb;
+ }
+
+
@Override
public void onDestroy() {
super.onDestroy();
@@ -93,6 +105,10 @@ public interface OnTvChangeViewClickCallback {
void onClick();
}
+ public interface OnTvChangeViewSizeClickCallback {
+ void onClick();
+ }
+
public interface OnUpdateClickCallback {
void onClick();
}
diff --git a/app/src/main/java/razerdp/demo/popup/common/SimpleSelectorPopup.java b/app/src/main/java/razerdp/demo/popup/common/SimpleSelectorPopup.java
index 5824e405..28ad4e2d 100644
--- a/app/src/main/java/razerdp/demo/popup/common/SimpleSelectorPopup.java
+++ b/app/src/main/java/razerdp/demo/popup/common/SimpleSelectorPopup.java
@@ -35,6 +35,7 @@ public class SimpleSelectorPopup extends BasePopupWindow {
public SimpleSelectorPopup(Context context) {
super(context);
+ setContentView(R.layout.popup_text_selector);
layoutContainer = findViewById(R.id.layout_container);
datas = new ArrayList<>();
setBlurBackgroundEnable(true);
@@ -70,11 +71,6 @@ public void onClick(View v) {
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_text_selector);
- }
-
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue210.java b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue210.java
index c980c005..6937edc4 100644
--- a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue210.java
+++ b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue210.java
@@ -23,6 +23,7 @@ public class PopupIssue210 extends BasePopupWindow {
public PopupIssue210(Context context) {
super(context);
+ setContentView(R.layout.popup_issue_210);
setPopupGravity(Gravity.BOTTOM);
}
@@ -31,10 +32,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_issue_210);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue224.java b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue224.java
index 4bb2ffb2..10561c78 100644
--- a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue224.java
+++ b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue224.java
@@ -34,6 +34,7 @@ public class PopupIssue224 extends BasePopupWindow {
public PopupIssue224(Context context) {
super(context);
+ setContentView(R.layout.popup_issue_224);
mIntegers = new ArrayList<>();
mAdapter = new SimpleRecyclerViewAdapter<>(context, mIntegers);
mAdapter.setHolder(ViewHolder.class);
@@ -46,10 +47,6 @@ public PopupIssue224(Context context) {
mRvContent.setAdapter(mAdapter);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_issue_224);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue230.java b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue230.java
index 1147103a..a47accce 100644
--- a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue230.java
+++ b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue230.java
@@ -37,6 +37,7 @@ public class PopupIssue230 extends BasePopupWindow {
public PopupIssue230(Context context) {
super(context);
+ setContentView(R.layout.popup_issue_230);
setPopupGravity(Gravity.CENTER);
setMaxHeight(UIHelper.getScreenHeight() >> 1);
setMaxWidth(UIHelper.getScreenWidth() >> 1);
@@ -57,10 +58,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_issue_230);
- }
void delItem(String which) {
mAdapter.remove(which);
diff --git a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue236.java b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue236.java
index 3f1ec68d..648d08ae 100644
--- a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue236.java
+++ b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue236.java
@@ -23,6 +23,7 @@ public class PopupIssue236 extends BasePopupWindow {
public PopupIssue236(Context context) {
super(context);
+ setContentView(R.layout.popup_issue_236);
setPopupGravity(Gravity.BOTTOM);
}
@@ -31,11 +32,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_issue_236);
- }
-
@Override
protected Animation onCreateShowAnimation() {
return AnimationHelper.asAnimation()
diff --git a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue238.java b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue238.java
index 0f0e3fbe..8978c946 100644
--- a/app/src/main/java/razerdp/demo/popup/issue/PopupIssue238.java
+++ b/app/src/main/java/razerdp/demo/popup/issue/PopupIssue238.java
@@ -7,7 +7,7 @@
import androidx.annotation.Nullable;
import butterknife.BindView;
-import razerdp.basepopup.BaseLazyPopupWindow;
+import razerdp.basepopup.BasePopupWindow;
import razerdp.basepopup.R;
import razerdp.demo.utils.ButterKnifeUtil;
import razerdp.demo.utils.UIHelper;
@@ -17,7 +17,7 @@
/**
* Created by 大灯泡 on 2020/02/26.
*/
-public class PopupIssue238 extends BaseLazyPopupWindow {
+public class PopupIssue238 extends BasePopupWindow {
private boolean isEdit;
@Nullable
@@ -27,6 +27,7 @@ public class PopupIssue238 extends BaseLazyPopupWindow {
public PopupIssue238(Context context, boolean isEdit) {
super(context);
this.isEdit = isEdit;
+ setContentView(isEdit ? R.layout.popup_issue_238_with_edittext : R.layout.popup_issue_238);
}
@Override
@@ -44,11 +45,6 @@ public void onClick(View v) {
}
}
- @Override
- public View onCreateContentView() {
- return createPopupById(isEdit ? R.layout.popup_issue_238_with_edittext : R.layout.popup_issue_238);
- }
-
@Override
protected Animation onCreateShowAnimation() {
return AnimationHelper.asAnimation()
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupAlignBackgroundOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupAlignBackgroundOption.java
index 60ce5b98..af158662 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupAlignBackgroundOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupAlignBackgroundOption.java
@@ -37,6 +37,7 @@ public class PopupAlignBackgroundOption extends BaseOptionPopup infos = new ArrayList<>();
infos.add(new Info(Gravity.LEFT, "Gravity.Left"));
@@ -70,10 +71,6 @@ public void onItemClick(View v, int position, Info data) {
rvContent.setAdapter(mAdapter);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_match);
- }
@OnClick(R.id.tv_go)
void apply() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupAnimateOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupAnimateOption.java
index f203bb2b..d588fe71 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupAnimateOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupAnimateOption.java
@@ -48,15 +48,12 @@ public class PopupAnimateOption extends BaseOptionPopup {
public PopupAnimateOption(Context context) {
super(context);
+ setContentView(R.layout.popup_option_animate);
checkClipchildren.setChecked(true);
setAutoLocatePopup(true);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_animate);
- }
@OnClick(R.id.layout_select_show)
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupAnyPosOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupAnyPosOption.java
index 951d67e7..333bb325 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupAnyPosOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupAnyPosOption.java
@@ -25,13 +25,10 @@ public class PopupAnyPosOption extends BaseOptionPopup {
public PopupAnyPosOption(Context context) {
super(context);
+ setContentView(R.layout.popup_option_anypos);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_anypos);
- }
@OnClick(R.id.tv_go)
void ok() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupArrowOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupArrowOption.java
index ab1cde55..4942b288 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupArrowOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupArrowOption.java
@@ -44,7 +44,7 @@ public class PopupArrowOption extends BaseOptionPopup {
public PopupArrowOption(Context context) {
super(context);
-
+ setContentView(R.layout.popup_option_arrow);
List infos = new ArrayList<>();
infos.add(new Info(Gravity.LEFT, "Gravity.Left"));
infos.add(new Info(Gravity.TOP, "Gravity.Top"));
@@ -69,10 +69,6 @@ public void onItemClick(View v, int position, Info data) {
rvContent.setAdapter(mAdapter);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_arrow);
- }
@OnClick(R.id.tv_go)
void apply() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupBackgroundOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupBackgroundOption.java
index 1b1e5328..3285c06d 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupBackgroundOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupBackgroundOption.java
@@ -64,6 +64,7 @@ public class PopupBackgroundOption extends BaseOptionPopup
public PopupBackgroundOption(Context context) {
super(context);
+ setContentView(R.layout.popup_option_background);
randomColors();
View.OnClickListener listener = new View.OnClickListener() {
@@ -158,10 +159,6 @@ protected Animation onCreateDismissAnimation() {
.toDismiss();
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_background);
- }
private int randomColor() {
Random random = new Random();
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupBarControllerOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupBarControllerOption.java
index caef16a7..6b644978 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupBarControllerOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupBarControllerOption.java
@@ -62,6 +62,7 @@ public class PopupBarControllerOption extends BaseOptionPopup infos = new ArrayList<>();
infos.add(new Info(Gravity.LEFT, "Gravity.Left"));
@@ -88,10 +89,6 @@ public void onItemClick(View v, int position, Info data) {
rvContent.setAdapter(mAdapter);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_control_bar);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupBlurDemoOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupBlurDemoOption.java
index 3eef6c1c..d3a49ef1 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupBlurDemoOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupBlurDemoOption.java
@@ -54,6 +54,7 @@ public class PopupBlurDemoOption extends BaseOptionPopup {
public PopupBlurDemoOption(Context context) {
super(context);
+ setContentView(R.layout.popup_option_blur);
init();
}
@@ -150,11 +151,6 @@ public void onViewCreated(View contentView) {
ButterKnifeUtil.bind(this, contentView);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_blur);
- }
-
@OnClick(R.id.tv_go)
void ok() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupCircleOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupCircleOption.java
index 0e723af5..9837ca38 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupCircleOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupCircleOption.java
@@ -29,12 +29,9 @@ public class PopupCircleOption extends BaseOptionPopup {
public PopupCircleOption(Context context) {
super(context);
+ setContentView(R.layout.popup_option_circle);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_circle);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupControlOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupControlOption.java
index a75654b1..b2dcffd1 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupControlOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupControlOption.java
@@ -33,11 +33,7 @@ public class PopupControlOption extends BaseOptionPopup {
public PopupControlOption(Context context) {
super(context);
- }
-
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_control);
+ setContentView(R.layout.popup_option_control);
}
@Override
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupInputOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupInputOption.java
index f8323ef5..1a993fbe 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupInputOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupInputOption.java
@@ -35,12 +35,9 @@ public class PopupInputOption extends BaseOptionPopup {
public PopupInputOption(Context context) {
super(context);
+ setContentView(R.layout.popup_option_input);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_input);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupSelectDismissAnimate.java b/app/src/main/java/razerdp/demo/popup/options/PopupSelectDismissAnimate.java
index 6f665b79..4e75c4fc 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupSelectDismissAnimate.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupSelectDismissAnimate.java
@@ -45,6 +45,7 @@ public class PopupSelectDismissAnimate extends BasePopupWindow {
public PopupSelectDismissAnimate(Context context) {
super(context);
+ setContentView(R.layout.popup_select_animate);
setMaxHeight(UIHelper.getScreenHeight() >> 1);
generateAnimation();
FillViewUtil.fillView(animations, layoutAnimation, R.layout.item_popup_animate, creator);
@@ -158,11 +159,6 @@ private void generateAnimation() {
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_select_animate);
- }
-
@Override
protected Animation onCreateShowAnimation() {
return AnimationHelper.asAnimation()
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupSelectShowAnimate.java b/app/src/main/java/razerdp/demo/popup/options/PopupSelectShowAnimate.java
index 640534ff..4d65ffe0 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupSelectShowAnimate.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupSelectShowAnimate.java
@@ -45,6 +45,7 @@ public class PopupSelectShowAnimate extends BasePopupWindow {
public PopupSelectShowAnimate(Context context) {
super(context);
+ setContentView(R.layout.popup_select_animate);
setMaxHeight(UIHelper.getScreenHeight() >> 1);
generateAnimation();
FillViewUtil.fillView(animations, layoutAnimation, R.layout.item_popup_animate, creator);
@@ -156,10 +157,6 @@ private void generateAnimation() {
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_select_animate);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/popup/options/PopupSlideOption.java b/app/src/main/java/razerdp/demo/popup/options/PopupSlideOption.java
index 110a3b4e..6f0296b4 100644
--- a/app/src/main/java/razerdp/demo/popup/options/PopupSlideOption.java
+++ b/app/src/main/java/razerdp/demo/popup/options/PopupSlideOption.java
@@ -49,7 +49,7 @@ public class PopupSlideOption extends BaseOptionPopup {
public PopupSlideOption(Context context) {
super(context);
-
+ setContentView(R.layout.popup_option_slide);
List infos = new ArrayList<>();
infos.add(new Info(Gravity.LEFT, "Gravity.Left"));
infos.add(new Info(Gravity.TOP, "Gravity.Top"));
@@ -75,10 +75,6 @@ public void onItemClick(View v, int position, Info data) {
rvContent.setAdapter(mAdapter);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_option_slide);
- }
@OnClick(R.id.tv_go)
void apply() {
diff --git a/app/src/main/java/razerdp/demo/ui/CommonUsageActivity.java b/app/src/main/java/razerdp/demo/ui/CommonUsageActivity.java
index fc5ba347..4cc7805a 100644
--- a/app/src/main/java/razerdp/demo/ui/CommonUsageActivity.java
+++ b/app/src/main/java/razerdp/demo/ui/CommonUsageActivity.java
@@ -39,6 +39,7 @@
import razerdp.demo.model.common.CommonRTLInfo;
import razerdp.demo.model.common.CommonSlideInfo;
import razerdp.demo.model.common.CommonUpdateInfo;
+import razerdp.demo.model.common.ScreenRotateActivityInfo;
import razerdp.demo.model.lifecycle.ShowInServiceInfo;
import razerdp.demo.model.lifecycle.ShowOnCreateInfo;
import razerdp.demo.utils.ButterKnifeUtil;
@@ -141,6 +142,7 @@ private List createItem() {
result.add(new CommonDialogActivityInfo());
result.add(new CommonRTLInfo());
result.add(new CommonUpdateInfo());
+ result.add(new ScreenRotateActivityInfo());
return result;
}
diff --git a/app/src/main/java/razerdp/demo/ui/GuideActivity.java b/app/src/main/java/razerdp/demo/ui/GuideActivity.java
index b33c980a..2bf4172c 100644
--- a/app/src/main/java/razerdp/demo/ui/GuideActivity.java
+++ b/app/src/main/java/razerdp/demo/ui/GuideActivity.java
@@ -117,12 +117,12 @@ private void setDependence() {
builder.append("BasePopup区分为Release版本和Candy版本,Candy版本相当于预览版,其更新较为频繁且可能会包含了新的想法和特性,就像糖果一样甜,但也可能会引起蛀牙。")
.append('\n')
.append(String.format(FORMAT, "如果商业用途,请使用Release版本"))
- .append(String.format(FORMAT, "如果希望体验新的特性和功能,请使用Candy版本"))
+ .append(String.format(FORMAT, "如果希望体验新的特性和功能,请使用Snapshot版本"))
.append('\n')
.append("自2.2.2版本开始,BasePopup将完全迁移至AndroidX,不再提供扩展组件了,BasePopup建议您尽早迁移到AndroidX");
SpanUtil.create(builder)
.append("Release").setTextStyle(Typeface.DEFAULT_BOLD).setTextColor(Color.BLACK)
- .append("Candy").setTextStyle(Typeface.DEFAULT_BOLD).setTextColor(Color.BLACK)
+ .append("Snapshot").setTextStyle(Typeface.DEFAULT_BOLD).setTextColor(Color.BLACK)
.append("自2.2.2版本开始,BasePopup将完全迁移至AndroidX,不再提供扩展组件了,BasePopup建议您尽早迁移到AndroidX").setTextColor(Color.RED).setTextStyle(Typeface.DEFAULT_BOLD)
.into(tvDependence);
@@ -133,17 +133,17 @@ private void setDependence() {
private void appendReleaseDependence() {
List infos = new ArrayList<>();
- infos.add(new DependenceInfo("https://api.bintray.com/packages/razerdp/maven/BasePopup/images/download.svg",
+ infos.add(new DependenceInfo("https://img.shields.io/maven-central/v/io.github.razerdp/BasePopup",
"基础库(必选)",
- "implementation 'com.github.razerdp:BasePopup:{$latestVersion}'"));
+ "implementation 'io.github.razerdp:BasePopup:{$latestVersion}'"));
FillViewUtil.fillView(infos, layoutDependenceRelease, R.layout.item_guide_denpendence, fillViewsListener);
}
private void appendCandyDependence() {
List infos = new ArrayList<>();
- infos.add(new DependenceInfo("https://api.bintray.com/packages/razerdp/maven/BasePopup_Candy/images/download.svg",
+ infos.add(new DependenceInfo("https://img.shields.io/nexus/s/io.github.razerdp/BasePopup?server=https%3A%2F%2Fs01.oss.sonatype.org%2F",
"基础库(必选)",
- "implementation 'com.github.razerdp:BasePopup_Candy:{$latestVersion}'"));
+ "implementation 'io.github.razerdp:BasePopup_Candy:{$latestVersion}'"));
FillViewUtil.fillView(infos, layoutDependenceCandy, R.layout.item_guide_denpendence, fillViewsListener);
}
diff --git a/app/src/main/java/razerdp/demo/ui/ScreenRotateActivity.java b/app/src/main/java/razerdp/demo/ui/ScreenRotateActivity.java
new file mode 100644
index 00000000..1f72dff7
--- /dev/null
+++ b/app/src/main/java/razerdp/demo/ui/ScreenRotateActivity.java
@@ -0,0 +1,46 @@
+package razerdp.demo.ui;
+
+import android.content.Intent;
+import android.view.View;
+import android.widget.TextView;
+
+import butterknife.BindView;
+import razerdp.basepopup.R;
+import razerdp.demo.base.baseactivity.BaseActivity;
+import razerdp.demo.model.common.CommonSlideInfo;
+import razerdp.demo.utils.DescBuilder;
+
+/**
+ * Created by 大灯泡 on 2021/5/10
+ *
+ * Description:
+ */
+public class ScreenRotateActivity extends BaseActivity {
+ public static final String DESC = DescBuilder.get()
+ .append("测试屏幕旋转")
+ .build();
+ @BindView(R.id.tv_show)
+ TextView tvShow;
+ @BindView(R.id.tv_setting)
+ TextView tvSetting;
+
+ CommonSlideInfo info;
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+
+ }
+
+ @Override
+ public int contentViewLayoutId() {
+ return R.layout.activity_rotate;
+ }
+
+ @Override
+ protected void onInitView(View decorView) {
+ info = new CommonSlideInfo();
+ tvShow.setOnClickListener(v -> info.toShow(v));
+ tvSetting.setOnClickListener(v -> info.toOption(v));
+ }
+
+}
diff --git a/app/src/main/java/razerdp/demo/ui/issuestest/Issue277TestActivity.java b/app/src/main/java/razerdp/demo/ui/issuestest/Issue277TestActivity.java
index a8ee2693..cf07a315 100644
--- a/app/src/main/java/razerdp/demo/ui/issuestest/Issue277TestActivity.java
+++ b/app/src/main/java/razerdp/demo/ui/issuestest/Issue277TestActivity.java
@@ -8,7 +8,7 @@
import butterknife.BindView;
import butterknife.OnClick;
-import razerdp.basepopup.BaseLazyPopupWindow;
+import razerdp.basepopup.BasePopupWindow;
import razerdp.basepopup.R;
import razerdp.demo.base.baseactivity.BaseActivity;
import razerdp.demo.widget.DPTextView;
@@ -46,10 +46,11 @@ public void onViewClicked() {
new Issue277Popup(this).showPopupWindow();
}
- class Issue277Popup extends BaseLazyPopupWindow {
+ class Issue277Popup extends BasePopupWindow {
public Issue277Popup(Context context) {
super(context);
+ setContentView(R.layout.popup_issue_277);
setPopupGravity(Gravity.BOTTOM);
setBlurBackgroundEnable(false);
setOutSideDismiss(false);
@@ -57,10 +58,6 @@ public Issue277Popup(Context context) {
setAdjustInputMode(R.id.feedbackTv, FLAG_KEYBOARD_ALIGN_TO_VIEW);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_issue_277);
- }
@Override
protected Animation onCreateShowAnimation() {
diff --git a/app/src/main/java/razerdp/demo/ui/issuestest/Issue358TestActivity.java b/app/src/main/java/razerdp/demo/ui/issuestest/Issue358TestActivity.java
index e5b03ce3..e3afb65b 100644
--- a/app/src/main/java/razerdp/demo/ui/issuestest/Issue358TestActivity.java
+++ b/app/src/main/java/razerdp/demo/ui/issuestest/Issue358TestActivity.java
@@ -72,6 +72,7 @@ static class Issue358Popup extends BasePopupWindow {
public Issue358Popup(Context context) {
super(context);
+ setContentView(R.layout.popup_issue_358);
rvContent.setLayoutManager(new LinearLayoutManager(context));
List data = new ArrayList<>();
@@ -83,10 +84,6 @@ public Issue358Popup(Context context) {
rvContent.setAdapter(adapter);
}
- @Override
- public View onCreateContentView() {
- return createPopupById(R.layout.popup_issue_358);
- }
@Override
public void onViewCreated(@NonNull View contentView) {
diff --git a/app/src/main/java/razerdp/demo/ui/issuestest/Issue369TestActivity.java b/app/src/main/java/razerdp/demo/ui/issuestest/Issue369TestActivity.java
new file mode 100644
index 00000000..bf2b3bd0
--- /dev/null
+++ b/app/src/main/java/razerdp/demo/ui/issuestest/Issue369TestActivity.java
@@ -0,0 +1,72 @@
+package razerdp.demo.ui.issuestest;
+
+import android.content.Intent;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.PopupWindow;
+
+import androidx.appcompat.widget.AppCompatCheckBox;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+import razerdp.basepopup.R;
+import razerdp.demo.base.baseactivity.BaseActivity;
+import razerdp.demo.popup.DemoPopup;
+import razerdp.demo.utils.UIHelper;
+import razerdp.demo.utils.ViewUtil;
+import razerdp.demo.widget.DPTextView;
+
+/**
+ * Created by 大灯泡 on 2021/5/27.
+ *
+ * https://github.com/razerdp/BasePopup/issues/369
+ */
+public class Issue369TestActivity extends BaseActivity {
+ @BindView(R.id.showPopBt)
+ DPTextView mShowPopBt;
+ @BindView(R.id.show_system_popup)
+ DPTextView mShowSystemPopup;
+ @BindView(R.id.check_hidekeyboard)
+ AppCompatCheckBox check_hidekeyboard;
+
+ DemoPopup demoPopup;
+ PopupWindow systemPopup;
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+
+ }
+
+ @Override
+ public int contentViewLayoutId() {
+ return R.layout.activity_issue_369;
+ }
+
+ @Override
+ protected void onInitView(View decorView) {
+
+ }
+
+
+ @OnClick(R.id.showPopBt)
+ public void onViewClicked() {
+ if (demoPopup == null) {
+ demoPopup = new DemoPopup(this);
+ }
+ demoPopup.hideKeyboardOnShow(check_hidekeyboard.isChecked());
+ demoPopup.showPopupWindow();
+ }
+
+ @OnClick(R.id.show_system_popup)
+ public void onSystemViewClicked(View v) {
+ if (systemPopup == null) {
+ systemPopup = new PopupWindow(this);
+ View contentView = ViewUtil.inflate(this, R.layout.popup_demo, null, false);
+ contentView.setOnClickListener(v1 -> systemPopup.dismiss());
+ systemPopup.setContentView(contentView);
+ systemPopup.setWidth(UIHelper.dip2px(150));
+ systemPopup.setHeight(UIHelper.dip2px(150));
+ }
+ systemPopup.showAtLocation(v, Gravity.CENTER, 0, 0);
+ }
+}
diff --git a/app/src/main/java/razerdp/demo/ui/issuestest/home/IssueHelper.java b/app/src/main/java/razerdp/demo/ui/issuestest/home/IssueHelper.java
index e72858ef..a7c0cdc7 100644
--- a/app/src/main/java/razerdp/demo/ui/issuestest/home/IssueHelper.java
+++ b/app/src/main/java/razerdp/demo/ui/issuestest/home/IssueHelper.java
@@ -13,6 +13,7 @@
import razerdp.demo.ui.issuestest.Issue242TestActivity;
import razerdp.demo.ui.issuestest.Issue277TestActivity;
import razerdp.demo.ui.issuestest.Issue358TestActivity;
+import razerdp.demo.ui.issuestest.Issue369TestActivity;
import razerdp.demo.utils.DescBuilder;
import razerdp.demo.utils.StringUtil;
@@ -31,6 +32,7 @@ static List addIssues(List result) {
add_242(result);
add_277(result);
add_358(result);
+ add_369(result);
sort(result);
@@ -45,6 +47,22 @@ private static void sort(List result) {
});
}
+ private static void add_369(List result) {
+ IssueInfo issue369 = new IssueInfo();
+ issue369.setActivityClass(Issue369TestActivity.class)
+ .setIssue("369")
+ .setFixed(true)
+ .setTitle("弹出popupwindow不收起键盘")
+ .setDesc(DescBuilder.get()
+ .append("系统版本:Unknown")
+ .append("库版本:2.2.9")
+ .append("键盘是已经打开的的时候,长按item会触发pop弹出,会影响键盘自动收起。\n" +
+ "使用原生的popwindow,宽高使用WRAP_CONTENT,弹出是不会影响的,希望此库也能支持。谢谢作者")
+ .build());
+
+ result.add(issue369);
+ }
+
private static void add_358(List result) {
IssueInfo issue358 = new IssueInfo();
issue358.setActivityClass(Issue358TestActivity.class)
diff --git a/app/src/main/java/razerdp/demo/ui/transition/ImageViewerTransition.java b/app/src/main/java/razerdp/demo/ui/transition/ImageViewerTransition.java
index 07f54d04..f3df4d67 100644
--- a/app/src/main/java/razerdp/demo/ui/transition/ImageViewerTransition.java
+++ b/app/src/main/java/razerdp/demo/ui/transition/ImageViewerTransition.java
@@ -26,6 +26,7 @@
import com.davemorrissey.labs.subscaleview.ImageViewState;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
+import com.github.chrisbanes.photoview.PhotoView;
import java.util.Map;
@@ -113,15 +114,18 @@ void captureValueForImageView(ImageView iv, TransitionValues transitionValues) {
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
if (startValues == null ||
- endValues == null ||
- !(startValues.view instanceof ImageViewer) ||
- !(endValues.view instanceof ImageViewer)) {
+ endValues == null) {
return null;
}
- boolean isLarge = ((ImageViewer) startValues.view).getShowingView() instanceof SubsamplingScaleImageView &&
- ((ImageViewer) endValues.view).getShowingView() instanceof SubsamplingScaleImageView;
- PopupLog.i(TAG, isLarge, ((ImageViewer) startValues.view).getShowingView(), ((ImageViewer) endValues.view)
- .getShowingView());
+ View startView = startValues.view;
+ View endView = endValues.view;
+ boolean isLarge = false;
+ if (startView instanceof ImageViewer) {
+ isLarge = ((ImageViewer) startView).getShowingView() instanceof SubsamplingScaleImageView;
+ }
+ if (endView instanceof ImageViewer) {
+ isLarge = ((ImageViewer) endView).getShowingView() instanceof SubsamplingScaleImageView;
+ }
if (isLarge) {
return SubsamplingScaleImageViewTransitionCreator.createAnimator(sceneRoot, startValues, endValues);
} else {
@@ -157,14 +161,14 @@ static Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues
if (isEntering) {
centerFrom = new PointF(imgSize.x / 2, imgSize.y / 2);
scaleFrom = getMinIfTrue(startSize.x / (float) imgSize.x, startSize.y / (float) imgSize.y,
- false);
+ false);
scaleTo = getMinIfTrue(imgSize.x / (float) endSize.x, imgSize.y / (float) endSize.y,
- false);
+ false);
} else {
centerFrom = subsamplingState.getCenter();
scaleFrom = subsamplingState.getScale();
scaleTo = getMinIfTrue(endSize.x / (float) imgSize.x, endSize.y / (float) imgSize.y,
- false);
+ false);
}
@@ -201,11 +205,13 @@ static class ImageViewTransitionCreator {
static Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
Rect startBounds = (Rect) startValues.values.get(BOUNDS);
Rect endBounds = (Rect) endValues.values.get(BOUNDS);
- final ImageView imageView = (ImageView) ((ImageViewer) endValues.view).getShowingView();
- if (startBounds == null || endBounds == null) {
- return null;
+ ImageView imageView = null;
+ if (endValues.view instanceof ImageViewer) {
+ imageView = (ImageView) ((ImageViewer) endValues.view).getShowingView();
+ } else if (endValues.view instanceof ImageView) {
+ imageView = (ImageView) endValues.view;
}
- if (startBounds.equals(endBounds)) {
+ if (imageView == null || startBounds == null || endBounds == null || startBounds.equals(endBounds)) {
return null;
}
return createMatrixAnimator(imageView, startValues, endValues);
@@ -357,7 +363,7 @@ static Matrix getImageViewMatrix(Rect bounds, ImageView.ScaleType scaleType, int
} else if (ImageView.ScaleType.CENTER == scaleType) {
// Center bitmap in view, no scaling.
matrix.setTranslate(Math.round((vwidth - dwidth) * 0.5f),
- Math.round((vheight - dheight) * 0.5f));
+ Math.round((vheight - dheight) * 0.5f));
} else if (ImageView.ScaleType.CENTER_CROP == scaleType) {
float scale;
@@ -383,7 +389,7 @@ static Matrix getImageViewMatrix(Rect bounds, ImageView.ScaleType scaleType, int
scale = 1.0f;
} else {
scale = Math.min((float) vwidth / (float) dwidth,
- (float) vheight / (float) dheight);
+ (float) vheight / (float) dheight);
}
dx = Math.round((vwidth - dwidth * scale) * 0.5f);
diff --git a/app/src/main/java/razerdp/demo/ui/updatetest/UpdateTestActivity.java b/app/src/main/java/razerdp/demo/ui/updatetest/UpdateTestActivity.java
index 5a25c91d..ea81aa3d 100644
--- a/app/src/main/java/razerdp/demo/ui/updatetest/UpdateTestActivity.java
+++ b/app/src/main/java/razerdp/demo/ui/updatetest/UpdateTestActivity.java
@@ -19,9 +19,11 @@ public class UpdateTestActivity extends BaseActivity {
@BindView(R.id.tv_test)
TextView tvTest;
-
PopupUpdateTest updateTest;
+ int popupWidth;
+ int popupHeight;
+
@Override
protected void onHandleIntent(Intent intent) {
@@ -38,7 +40,8 @@ protected void onInitView(View decorView) {
if (updateTest == null) {
updateTest = new PopupUpdateTest(self());
updateTest.setOnTvChangeViewClickCallback(UpdateTestActivity.this::randomViewPosition);
- updateTest.OnUpdateClickCallback(() -> updateTest.update(v));
+ updateTest.setOnUpdateClickCallback(() -> updateTest.update(v));
+ updateTest.setOnTvChangeViewSizeClickCallback(this::randomViewSize);
}
updateTest.showPopupWindow(v);
});
@@ -53,4 +56,16 @@ void randomViewPosition() {
tvTest.setTranslationY(y);
}
+ void randomViewSize() {
+ if (popupWidth == 0) {
+ popupWidth = updateTest.getWidth();
+ }
+ if (popupHeight == 0) {
+ popupHeight = updateTest.getHeight();
+ }
+ View decor = getWindow().getDecorView();
+ int width = RandomUtil.randomInt(popupWidth >> 1, decor.getWidth());
+ int height = RandomUtil.randomInt(popupHeight, decor.getHeight());
+ updateTest.update(width * 1.0f, height * 1.0f);
+ }
}
diff --git a/app/src/main/java/razerdp/demo/widget/bigimageviewer/view/ImageViewer.java b/app/src/main/java/razerdp/demo/widget/bigimageviewer/view/ImageViewer.java
index 9965c624..e0565917 100644
--- a/app/src/main/java/razerdp/demo/widget/bigimageviewer/view/ImageViewer.java
+++ b/app/src/main/java/razerdp/demo/widget/bigimageviewer/view/ImageViewer.java
@@ -61,6 +61,8 @@
@Keep
public class ImageViewer extends FrameLayout implements View.OnClickListener {
+ static final long PROGRESS_BAR_DELAY = 500;
+ static final long THUMBNAIL_BAR_DELAY = 500;
private PhotoView mNormalView;
private SubsamplingScaleImageView mLargeView;
private CircleProgressView mProgressView;
@@ -75,6 +77,8 @@ public class ImageViewer extends FrameLayout implements View.OnClickListener {
Runnable showLoadingRunnable;
+ private long thumbnailTime;
+
public ImageViewer(@NonNull Context context) {
this(context, null);
}
@@ -94,9 +98,9 @@ void init() {
mNormalView.setZoomTransitionDuration(350);
mNormalView.setOnClickListener(this);
addViewInLayout(mNormalView,
- -1,
- new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
- true);
+ -1,
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
+ true);
mProgressView = new CircleProgressView(getContext());
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(UIHelper.dip2px(80), UIHelper.dip2px(80));
p.gravity = Gravity.CENTER;
@@ -110,9 +114,9 @@ void initLargeView() {
if (mLargeView != null) {
if (mLargeView.getParent() == null) {
addViewInLayout(mLargeView,
- -1,
- new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
- true);
+ -1,
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
+ true);
}
return;
}
@@ -121,9 +125,9 @@ void initLargeView() {
mLargeView.setMinimumTileDpi(160);
mLargeView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
addViewInLayout(mLargeView,
- -1,
- new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
- true);
+ -1,
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
+ true);
}
@@ -133,64 +137,79 @@ public void loadImage(Uri pic, @Nullable Uri thumbnail) {
cb.onShowThumbnail();
}
GlideProgressManager.getsInstance()
- .loadImage(pic.hashCode(), pic, new ImageDownloadTarget(pic
- .toString()) {
- @Override
- public void onDownloadStart() {
- runOnUI(() -> {
- if (mProgressView != null) {
- mProgressView.start();
- }
- if (cb != null) {
- cb.onStart();
- }
- });
-
- }
-
- @Override
- public void onResourceReady(@NonNull File resource, Transition super File> transition) {
- super.onResourceReady(resource, transition);
- runOnUI(() -> {
- displayImage(resource);
- if (cb != null) {
- cb.onSuccess();
- }
- });
- }
-
-
- @Override
- public void onLoadFailed(Drawable errorDrawable) {
- super.onLoadFailed(errorDrawable);
- runOnUI(() -> {
- displayErrorDrawable();
- if (cb != null) {
- cb.onError();
- }
- });
- }
-
- @Override
- public void onProgress(int progress) {
- runOnUI(() -> {
- if (mProgressView == null) return;
- mProgressView.setProgress(progress);
- });
- }
-
- @Override
- public void onDownloadFinish() {
- runOnUI(() -> {
- if (mProgressView != null) {
- mProgressView.finish(true);
- }
- if (cb != null) {
- cb.onFinish();
- }
- });
- }
- });
+ .loadImage(pic.hashCode(), pic, new ImageDownloadTarget(pic
+ .toString()) {
+ @Override
+ public void onDownloadStart() {
+ if (mProgressView != null) {
+ showLoadingRunnable = () -> {
+ if (mProgressView != null) {
+ mProgressView.start();
+ }
+ showLoadingRunnable = null;
+ };
+ postDelayed(showLoadingRunnable, PROGRESS_BAR_DELAY);
+ }
+ runOnUI(() -> {
+ if (cb != null) {
+ cb.onStart();
+ }
+ });
+
+ }
+
+ @Override
+ public void onResourceReady(@NonNull File resource, Transition super File> transition) {
+ super.onResourceReady(resource, transition);
+ runOnUI(() -> {
+ if (showLoadingRunnable != null) {
+ removeCallbacks(showLoadingRunnable);
+ }
+ displayImage(resource);
+ if (cb != null) {
+ cb.onSuccess();
+ }
+ });
+ }
+
+
+ @Override
+ public void onLoadFailed(Drawable errorDrawable) {
+ super.onLoadFailed(errorDrawable);
+ runOnUI(() -> {
+ if (showLoadingRunnable != null) {
+ removeCallbacks(showLoadingRunnable);
+ }
+ displayErrorDrawable();
+ if (cb != null) {
+ cb.onError();
+ }
+ });
+ }
+
+ @Override
+ public void onProgress(int progress) {
+ runOnUI(() -> {
+ if (mProgressView == null) return;
+ mProgressView.setProgress(progress);
+ });
+ }
+
+ @Override
+ public void onDownloadFinish() {
+ runOnUI(() -> {
+ if (showLoadingRunnable != null) {
+ removeCallbacks(showLoadingRunnable);
+ }
+ if (mProgressView != null) {
+ mProgressView.finish(true);
+ }
+ if (cb != null) {
+ cb.onFinish();
+ }
+ });
+ }
+ });
}
void displayThumbnail(Uri thumbnail) {
@@ -200,9 +219,11 @@ void displayThumbnail(Uri thumbnail) {
ImageLoaderManager.INSTANCE
.loadImage(mNormalView, thumbnail);
showingView = mNormalView;
+ thumbnailTime=System.currentTimeMillis();
}
void displayImage(File image) {
+ boolean cacheHit = System.currentTimeMillis() - thumbnailTime <=THUMBNAIL_BAR_DELAY;
if (mProgressView != null) {
mProgressView.finish(true);
}
@@ -216,16 +237,23 @@ void displayImage(File image) {
if (mLargeView != null) {
removeViewInLayout(mLargeView);
}
+ if (cacheHit){
+ mNormalView.setScaleX(1f);
+ mNormalView.setScaleY(1f);
+ }
ImageLoaderManager
.INSTANCE
.option()
.setLoading(new ColorDrawable(Color.TRANSPARENT))
.loadImage(mNormalView, image);
showingView = mNormalView;
- mNormalView.animate()
- .scaleX(1f)
- .scaleY(1f)
- .start();
+ if (!cacheHit) {
+ mNormalView.animate()
+ .scaleX(1f)
+ .scaleY(1f)
+ .setStartDelay(300)
+ .start();
+ }
}
requestLayout();
}
@@ -236,9 +264,9 @@ void displayErrorDrawable() {
}
if (mNormalView.getParent() == null) {
addViewInLayout(mNormalView,
- -1,
- new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
- true);
+ -1,
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT),
+ true);
}
mNormalView.setScaleX(1);
mNormalView.setScaleY(1);
diff --git a/app/src/main/res/layout/activity_issue_369.xml b/app/src/main/res/layout/activity_issue_369.xml
new file mode 100644
index 00000000..3bc8ec5e
--- /dev/null
+++ b/app/src/main/res/layout/activity_issue_369.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_rotate.xml b/app/src/main/res/layout/activity_rotate.xml
new file mode 100644
index 00000000..08487731
--- /dev/null
+++ b/app/src/main/res/layout/activity_rotate.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_main_demo_header.xml b/app/src/main/res/layout/item_main_demo_header.xml
index 3e078320..7a8cc536 100644
--- a/app/src/main/res/layout/item_main_demo_header.xml
+++ b/app/src/main/res/layout/item_main_demo_header.xml
@@ -10,6 +10,6 @@
android:layout_height="200dp"
android:src="@drawable/logo" />
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_main_demo_version.xml b/app/src/main/res/layout/item_main_demo_version.xml
new file mode 100644
index 00000000..06c7ad93
--- /dev/null
+++ b/app/src/main/res/layout/item_main_demo_version.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/popup_update_test.xml b/app/src/main/res/layout/popup_update_test.xml
index e02d3fbe..b99c2c4d 100644
--- a/app/src/main/res/layout/popup_update_test.xml
+++ b/app/src/main/res/layout/popup_update_test.xml
@@ -22,6 +22,21 @@
android:layout_height="1dp"
android:background="@color/white" />
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index ff03e4ee..b8719230 100644
--- a/build.gradle
+++ b/build.gradle
@@ -38,8 +38,8 @@ ext {
minSdkVersion = 19
minLibSdkVersion = 16
targetSdkVersion = 30
- versionCode = 200
- versionName = '2.3.0'
+ versionCode = 302
+ versionName = '3.1.0-SNAPSHOT'
candy = false
group = 'io.github.razerdp'
diff --git a/lib/src/main/java/razerdp/basepopup/BaseLazyPopupWindow.java b/lib/src/main/java/razerdp/basepopup/BaseLazyPopupWindow.java
deleted file mode 100644
index efe526a5..00000000
--- a/lib/src/main/java/razerdp/basepopup/BaseLazyPopupWindow.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package razerdp.basepopup;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.util.Pair;
-import android.view.View;
-
-import androidx.fragment.app.Fragment;
-
-/**
- * Created by 大灯泡 on 2019/11/24.
- * 延迟初始化的BasePopup,该PopupWindow将会在您调用show方法的时候才会进行初始化
- */
-public abstract class BaseLazyPopupWindow extends BasePopupWindow {
- private boolean initImmediately = false;
- private Pair sizeCached;
-
- public BaseLazyPopupWindow(Context context) {
- super(context);
- }
-
- public BaseLazyPopupWindow(Context context, int width, int height) {
- super(context, width, height);
- }
-
- public BaseLazyPopupWindow(Fragment fragment) {
- super(fragment);
- }
-
- public BaseLazyPopupWindow(Fragment fragment, int width, int height) {
- super(fragment, width, height);
- }
-
- public BaseLazyPopupWindow(Dialog dialog) {
- super(dialog);
- }
-
- public BaseLazyPopupWindow(Dialog dialog, int width, int height) {
- super(dialog, width, height);
- }
-
- @Override
- void onCreateConstructor(Object ownerAnchorParent, int width, int height) {
- super.onCreateConstructor(ownerAnchorParent, width, height);
- sizeCached = Pair.create(width, height);
- }
-
- public final void initImmediately() {
- initImmediately = true;
- if (sizeCached != null) {
- initView(sizeCached.first, sizeCached.second);
- sizeCached = null;
- } else {
- initView(0, 0);
- }
- }
-
- @Override
- void initView(int width, int height) {
- if (!initImmediately) return;
- super.initView(width, height);
- }
-
- @Override
- void tryToShowPopup(View v, boolean positionMode) {
- if (!initImmediately) {
- initImmediately();
- }
- super.tryToShowPopup(v, positionMode);
- }
-}
diff --git a/lib/src/main/java/razerdp/basepopup/BasePopupHelper.java b/lib/src/main/java/razerdp/basepopup/BasePopupHelper.java
index 63b2ea59..0d81c2d1 100644
--- a/lib/src/main/java/razerdp/basepopup/BasePopupHelper.java
+++ b/lib/src/main/java/razerdp/basepopup/BasePopupHelper.java
@@ -171,12 +171,12 @@ enum ShowMode {
this.mMaskViewShowAnimation.setInterpolator(new DecelerateInterpolator());
this.mMaskViewShowAnimation.setDuration(Resources.getSystem()
.getInteger(android.R.integer.config_shortAnimTime));
- isDefaultMaskViewShowAnimation=true;
+ isDefaultMaskViewShowAnimation = true;
this.mMaskViewDismissAnimation.setFillAfter(true);
this.mMaskViewDismissAnimation.setInterpolator(new DecelerateInterpolator());
this.mMaskViewDismissAnimation.setDuration(Resources.getSystem()
.getInteger(android.R.integer.config_shortAnimTime));
- isDefaultMaskViewDismissAnimation=true;
+ isDefaultMaskViewDismissAnimation = true;
}
void observerEvent(Object who, BasePopupEvent.EventObserver observer) {
@@ -1014,20 +1014,16 @@ public void onKeyboardChange(Rect keyboardBounds, boolean isVisible) {
void update(View v, boolean positionMode) {
if (!mPopupWindow.isShowing() || mPopupWindow.mContentView == null) return;
+ if (v == null && mShowInfo != null) {
+ v = mShowInfo.mAnchorView;
+ }
prepare(v, positionMode);
mPopupWindow.mPopupWindowProxy.update();
}
- void onUpdate() {
- if (mShowInfo != null) {
- prepare(mShowInfo.mAnchorView == null ? null : mShowInfo.mAnchorView,
- mShowInfo.positionMode);
- }
- }
-
- void dispatchOutSideEvent(MotionEvent event, boolean touchInMask) {
+ void dispatchOutSideEvent(MotionEvent event, boolean touchInMask, boolean isMaskPressed) {
if (mPopupWindow != null) {
- mPopupWindow.dispatchOutSideEvent(event, touchInMask);
+ mPopupWindow.dispatchOutSideEvent(event, touchInMask, isMaskPressed);
}
}
diff --git a/lib/src/main/java/razerdp/basepopup/BasePopupWindow.java b/lib/src/main/java/razerdp/basepopup/BasePopupWindow.java
index 73fc1b40..bedfb428 100644
--- a/lib/src/main/java/razerdp/basepopup/BasePopupWindow.java
+++ b/lib/src/main/java/razerdp/basepopup/BasePopupWindow.java
@@ -217,6 +217,7 @@ file or class name and description of purpose be included on the
import android.os.Looper;
import android.os.Message;
import android.util.AndroidRuntimeException;
+import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -227,6 +228,7 @@ file or class name and description of purpose be included on the
import android.widget.EditText;
import android.widget.PopupWindow;
+import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
@@ -362,6 +364,8 @@ public enum GravityMode {
//popup视图
View mContentView;
View mDisplayAnimateView;
+ int initWidth;
+ int initHeight;
Runnable initRunnable;
@@ -417,16 +421,8 @@ public BasePopupWindow(Dialog dialog, int width, int height) {
this.ownerAnchorParent = ownerAnchorParent;
checkActivity();
mHelper = new BasePopupHelper(this);
- initRunnable = new Runnable() {
- @Override
- public void run() {
- onCreateConstructor(ownerAnchorParent, width, height);
- initView(width, height);
- }
- };
- if (getContext() == null) return;
- initRunnable.run();
- initRunnable = null;
+ initWidth = width;
+ initHeight = height;
}
private void checkActivity() {
@@ -445,7 +441,6 @@ private void checkActivity() {
mContext = act;
if (initRunnable != null) {
initRunnable.run();
- initRunnable = null;
}
}
@@ -474,25 +469,23 @@ public void onViewDetachedFromWindow(View v) {
});
}
- void onCreateConstructor(Object ownerAnchorParent, int width, int height) {
-
- }
-
- void initView(int width, int height) {
- mContentView = onCreateContentView();
+ void initView(View contentView) {
+ mContentView = contentView;
mHelper.setContentRootId(mContentView);
mDisplayAnimateView = onCreateAnimateView();
if (mDisplayAnimateView == null) {
mDisplayAnimateView = mContentView;
}
- setWidth(width);
- setHeight(height);
+ setWidth(initWidth);
+ setHeight(initHeight);
//默认占满全屏
- mPopupWindowProxy = new PopupWindowProxy(new PopupWindowProxy.BasePopupContextWrapper(
- getContext(),
- mHelper));
+ if (mPopupWindowProxy == null) {
+ mPopupWindowProxy = new PopupWindowProxy(new PopupWindowProxy.BasePopupContextWrapper(
+ getContext(),
+ mHelper));
+ }
mPopupWindowProxy.setContentView(mContentView);
mPopupWindowProxy.setOnDismissListener(this);
setPopupAnimationStyle(0);
@@ -510,15 +503,21 @@ public void onViewCreated(@NonNull View contentView) {
}
//------------------------------------------抽象-----------------------------------------------
+ public void setContentView(@LayoutRes int layoutResID) {
+ this.setContentView(createPopupById(layoutResID));
+ }
- /**
- *
- * 返回一个contentView以作为PopupWindow的contentView
- *
- *
- * 强烈建议使用{@link BasePopupWindow#createPopupById(int)},该方法支持读取View的xml布局参数,否则可能会出现与布局不一样的展示从而必须手动传入宽高等参数
- */
- public abstract View onCreateContentView();
+ public void setContentView(final View view) {
+ initRunnable = new Runnable() {
+ @Override
+ public void run() {
+ initRunnable = null;
+ initView(view);
+ }
+ };
+ if (getContext() == null) return;
+ initRunnable.run();
+ }
/**
*
@@ -901,8 +900,8 @@ private View getDecorView() {
return mAnchorDecorView;
}
- void dispatchOutSideEvent(MotionEvent event, boolean touchInMask) {
- if (onOutSideTouch(event, touchInMask)) {
+ void dispatchOutSideEvent(MotionEvent event, boolean touchInMask, boolean isMaskPressed) {
+ if (onOutSideTouch(event, touchInMask, isMaskPressed)) {
return;
}
if (mHelper.isOutSideTouchable()) {
@@ -947,18 +946,13 @@ public void onViewDetachedFromWindow(View v) {
/**
- *
- * PopupWindow是否需要自适应输入法,为输入法弹出让出区域
- *
+ * PopupWindow展示时是否收起键盘,默认收起
*
- * @param needAdjust
- * - true for "SOFT_INPUT_ADJUST_RESIZE" mode
- * - false for "SOFT_INPUT_ADJUST_NOTHING" mode
- *
- *
+ * @param dismiss
+ * @return
*/
- public BasePopupWindow setAdjustInputMethod(boolean needAdjust) {
- setAdjustInputMethod(needAdjust, WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+ public BasePopupWindow hideKeyboardOnShow(boolean dismiss) {
+ setAdjustInputMethod(dismiss ? true : false);
return this;
}
@@ -971,19 +965,14 @@ public BasePopupWindow setAdjustInputMethod(boolean needAdjust) {
* true for "SOFT_INPUT_ADJUST_RESIZE" mode
* false for "SOFT_INPUT_ADJUST_NOTHING" mode
*
- * @param flag The desired mode, see
- * {@link android.view.WindowManager.LayoutParams#softInputMode}
- * for the full list
+ *
*/
- public BasePopupWindow setAdjustInputMethod(boolean needAdjust, int flag) {
- if (needAdjust) {
- setSoftInputMode(flag);
- } else {
- setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
- }
+ public BasePopupWindow setAdjustInputMethod(boolean needAdjust) {
+ mHelper.mSoftInputMode = needAdjust ? WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE : WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED;
return this;
}
+
/**
*
* 设置PopupWindow适配输入法的适配模式
@@ -1071,18 +1060,6 @@ public BasePopupWindow setAutoShowInputMethod(EditText editText, boolean autoSho
return setAutoShowInputMethod(autoShow);
}
- /**
- * 设置是否适配输入法
- *
- * @param softInputMode The desired mode, see
- * {@link android.view.WindowManager.LayoutParams#softInputMode}
- * for the full list
- */
- @Deprecated
- public BasePopupWindow setSoftInputMode(int softInputMode) {
- mHelper.mSoftInputMode = softInputMode;
- return this;
- }
/**
* 设置输入法弹出延时
@@ -1130,6 +1107,7 @@ public T findViewById(int id) {
if (mContentView != null && id != 0) {
return (T) mContentView.findViewById(id);
}
+ Log.e(TAG, "contentView is null,please call setContentView() before findViewById()");
return null;
}
@@ -1593,8 +1571,8 @@ public BasePopupWindow setPopupGravity(int popupGravity) {
*
*
* @param mode - GravityMode.RELATIVE_TO_ANCHOR:该模式将会以Anchor作为参考点,表示Popup处于该Anchor的哪个位置
- * - GravityMode.ALIGN_TO_ANCHOR_SIDE:该模式将会以Anchor作为参考点,表示Popup对齐Anchor的哪条边
- *
+ * GravityMode.ALIGN_TO_ANCHOR_SIDE:该模式将会以Anchor作为参考点,表示Popup对齐Anchor的哪条边
+ *
*/
public BasePopupWindow setPopupGravity(GravityMode mode, int popupGravity) {
mHelper.setPopupGravity(mode, popupGravity);
@@ -1900,7 +1878,7 @@ public BasePopupWindow setFitSize(boolean canResize) {
*/
public BasePopupWindow setMaskViewShowAnimation(Animation animation) {
mHelper.mMaskViewShowAnimation = animation;
- mHelper.isDefaultMaskViewShowAnimation=false;
+ mHelper.isDefaultMaskViewShowAnimation = false;
return this;
}
@@ -1909,7 +1887,7 @@ public BasePopupWindow setMaskViewShowAnimation(Animation animation) {
*/
public BasePopupWindow setMaskViewDismissAnimation(Animation animation) {
mHelper.mMaskViewDismissAnimation = animation;
- mHelper.isDefaultMaskViewDismissAnimation=false;
+ mHelper.isDefaultMaskViewDismissAnimation = false;
return this;
}
@@ -2106,8 +2084,8 @@ public boolean onBackPressed() {
* @param touchInMask 是否在mask中触摸
* @return 返回True则意味着您消耗了该事件,该事件不再会被分发下去
*/
- public boolean onOutSideTouch(MotionEvent event, boolean touchInMask) {
- if (mHelper.isOutSideDismiss() && event.getAction() == MotionEvent.ACTION_UP) {
+ public boolean onOutSideTouch(MotionEvent event, boolean touchInMask, boolean isMaskPressed) {
+ if (mHelper.isOutSideDismiss() && event.getAction() == MotionEvent.ACTION_UP && isMaskPressed) {
dismiss();
return true;
}
diff --git a/lib/src/main/java/razerdp/basepopup/PopupDecorViewProxy.java b/lib/src/main/java/razerdp/basepopup/PopupDecorViewProxy.java
index 81e16895..86d71bc9 100644
--- a/lib/src/main/java/razerdp/basepopup/PopupDecorViewProxy.java
+++ b/lib/src/main/java/razerdp/basepopup/PopupDecorViewProxy.java
@@ -41,6 +41,8 @@ final class PopupDecorViewProxy extends ViewGroup implements KeyboardUtils.OnKey
private int childRightMargin;
private int childBottomMargin;
+ private boolean reMeasure;
+
private int[] location = new int[2];
private Rect lastKeyboardBounds = new Rect();
private OnClickListener emptyInterceptClickListener = new OnClickListener() {
@@ -92,6 +94,11 @@ public void wrapPopupDecorView(final View target, WindowManager.LayoutParams par
}
mTarget = target;
+ LayoutParams wp = setupViewSize(target, params);
+ addView(target, wp);
+ }
+
+ WindowManager.LayoutParams setupViewSize(View target, WindowManager.LayoutParams params) {
WindowManager.LayoutParams wp = new WindowManager.LayoutParams();
wp.copyFrom(params);
wp.x = 0;
@@ -99,9 +106,9 @@ public void wrapPopupDecorView(final View target, WindowManager.LayoutParams par
View contentView = target.findViewById(mHelper.contentRootId);
if (contentView != null) {
if (!contentView.hasOnClickListeners()) {
- mTarget.setOnClickListener(emptyInterceptClickListener);
+ target.setOnClickListener(emptyInterceptClickListener);
} else {
- mTarget.setOnClickListener(null);
+ target.setOnClickListener(null);
}
LayoutParams lp = contentView.getLayoutParams();
if (lp == null) {
@@ -162,7 +169,14 @@ public void wrapPopupDecorView(final View target, WindowManager.LayoutParams par
if (wp.height > 0) {
wp.height += childTopMargin + childBottomMargin;
}
- addView(target, wp);
+ return wp;
+ }
+
+
+ @Override
+ public void requestLayout() {
+ reMeasure = true;
+ super.requestLayout();
}
@Override
@@ -229,8 +243,10 @@ private void measureWrappedDecorView(View mTarget, int widthMeasureSpec, int hei
heightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, 0, lp.height);
- int widthSize = Math.max(mTarget.getMeasuredWidth(), MeasureSpec.getSize(widthMeasureSpec));
- int heightSize = Math.max(mTarget.getMeasuredHeight(), MeasureSpec.getSize(heightMeasureSpec));
+ int widthSize = reMeasure ? MeasureSpec.getSize(widthMeasureSpec) :
+ Math.max(mTarget.getMeasuredWidth(), MeasureSpec.getSize(widthMeasureSpec));
+ int heightSize = reMeasure ? MeasureSpec.getSize(heightMeasureSpec) :
+ Math.max(mTarget.getMeasuredHeight(), MeasureSpec.getSize(heightMeasureSpec));
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
@@ -581,6 +597,7 @@ private void layoutInternal(int l, int t, int r, int b) {
popupRect.set(contentRect);
mHelper.onPopupLayout(popupRect, anchorRect);
}
+ reMeasure = false;
}
}
}
@@ -666,13 +683,16 @@ public boolean shouldDelayChildPressedState() {
public void updateLayout() {
- if (mHelper != null) {
- mHelper.onUpdate();
- }
if (mMaskLayout != null) {
mMaskLayout.update();
}
- requestLayout();
+ if (mTarget != null) {
+ WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mTarget.getLayoutParams();
+ if (lp.width != mHelper.getLayoutParams().width || lp.height != mHelper.getLayoutParams().height) {
+ setupViewSize(mTarget, (WindowManager.LayoutParams) mTarget.getLayoutParams());
+ }
+ requestLayout();
+ }
}
diff --git a/lib/src/main/java/razerdp/basepopup/PopupMaskLayout.java b/lib/src/main/java/razerdp/basepopup/PopupMaskLayout.java
index 57b7ca06..16f8450e 100644
--- a/lib/src/main/java/razerdp/basepopup/PopupMaskLayout.java
+++ b/lib/src/main/java/razerdp/basepopup/PopupMaskLayout.java
@@ -47,6 +47,7 @@ private PopupMaskLayout(Context context, AttributeSet attrs, int defStyleAttr) {
private void init(Context context, BasePopupHelper mHelper) {
this.mPopupHelper = mHelper;
+ setClickable(true);
location = null;
maskRect = new RectF();
setLayoutAnimation(null);
@@ -185,7 +186,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
if (!mPopupHelper.isOverlayStatusbar()) {
ev.offsetLocation(0, PopupUiUtils.getStatusBarHeight());
}
- mPopupHelper.dispatchOutSideEvent(ev, maskRect.contains(ev.getRawX(), ev.getRawY()));
+ mPopupHelper.dispatchOutSideEvent(ev, maskRect.contains(ev.getRawX(), ev.getRawY()),isPressed());
}
return super.dispatchTouchEvent(ev);
}
diff --git a/lib/src/main/java/razerdp/util/KeyboardUtils.java b/lib/src/main/java/razerdp/util/KeyboardUtils.java
index 43af7191..28e0e40f 100644
--- a/lib/src/main/java/razerdp/util/KeyboardUtils.java
+++ b/lib/src/main/java/razerdp/util/KeyboardUtils.java
@@ -21,8 +21,11 @@ public class KeyboardUtils {
public static void open(View view) {
if (view == null) return;
if (!view.hasFocus()) {
- view.requestFocus();
- view = view.findFocus();
+ PopupUiUtils.requestFocus(view);
+ View focusedView = view.findFocus();
+ if (focusedView != null) {
+ view = focusedView;
+ }
}
InputMethodManager imm = (InputMethodManager) view.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
diff --git a/lib/src/main/java/razerdp/widget/QuickPopup.java b/lib/src/main/java/razerdp/widget/QuickPopup.java
index a4bb2583..d85b697f 100644
--- a/lib/src/main/java/razerdp/widget/QuickPopup.java
+++ b/lib/src/main/java/razerdp/widget/QuickPopup.java
@@ -13,8 +13,8 @@
import java.util.HashMap;
import java.util.Map;
-import razerdp.basepopup.BaseLazyPopupWindow;
import razerdp.basepopup.BasePopupFlag;
+import razerdp.basepopup.BasePopupWindow;
import razerdp.basepopup.QuickPopupConfig;
/**
@@ -22,7 +22,7 @@
*
* 快速popup
*/
-public class QuickPopup extends BaseLazyPopupWindow {
+public class QuickPopup extends BasePopupWindow {
private QuickPopupConfig mConfig;
@@ -32,6 +32,7 @@ public QuickPopup(Fragment fragment, int width, int height, QuickPopupConfig con
if (mConfig == null) {
throw new NullPointerException("QuickPopupConfig must be not null!");
}
+ setContentView(mConfig.getContentViewLayoutid());
}
public QuickPopup(Dialog dialog, int width, int height, QuickPopupConfig config) {
@@ -40,6 +41,7 @@ public QuickPopup(Dialog dialog, int width, int height, QuickPopupConfig config)
if (mConfig == null) {
throw new NullPointerException("QuickPopupConfig must be not null!");
}
+ setContentView(mConfig.getContentViewLayoutid());
}
public QuickPopup(Context context, int width, int height, QuickPopupConfig config) {
@@ -48,6 +50,7 @@ public QuickPopup(Context context, int width, int height, QuickPopupConfig confi
if (mConfig == null) {
throw new NullPointerException("QuickPopupConfig must be not null!");
}
+ setContentView(mConfig.getContentViewLayoutid());
}
@@ -155,12 +158,6 @@ protected Animator onCreateShowAnimator() {
return mConfig.getShowAnimator();
}
- @Override
- public View onCreateContentView() {
- if (isConfigDestroyed()) return null;
- return createPopupById(mConfig.getContentViewLayoutid());
- }
-
boolean isConfigDestroyed() {
return mConfig == null || mConfig.isDestroyed();
}