Skip to content

Commit 993885b

Browse files
committed
// save
1 parent 36bd387 commit 993885b

17 files changed

+125
-69
lines changed

app/src/main/java/razerdp/demo/fragment/other/LocatePopupFrag.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ public void onClick(View v) {
6464
QuickPopupBuilder.with(getContext())
6565
.contentView(R.layout.popup_menu_small)
6666
.config(new QuickPopupConfig()
67-
.alignBackground(true)
68-
.backgroundColor(Color.parseColor("#8F617D8A"))
67+
.clipChildren(true)
68+
.backgroundColor(Color.parseColor("#8C617D8A"))
6969
.withShowAnimation(enterAnimation)
7070
.withDismissAnimation(dismissAnimation)
71-
.alignBackground(true)
7271
.gravity(gravity)
7372
.blurBackground(true, new BasePopupWindow.OnBlurOptionInitListener() {
7473
@Override

app/src/main/java/razerdp/demo/popup/AutoLocatedRecyclerViewPopup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public AutoLocatedRecyclerViewPopup(Context context) {
3232
mRecyclerView = findViewById(R.id.rv_content);
3333
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
3434
List<String> data = new ArrayList<>();
35-
for (int i = 0; i < 10; i++) {
35+
for (int i = 0; i < 20; i++) {
3636
data.add("test" + String.valueOf(i));
3737
}
3838
mRecyclerView.setAdapter(new InnerAdapter(getContext(), data));
39-
setAutoLocatePopup(true);
39+
setAutoLocatePopup(false);
4040
bindEvent();
4141
}
4242

app/src/main/java/razerdp/demo/popup/CommentPopup.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public CommentPopup(Context context) {
4949

5050
buildAnima();
5151
setBackground(0);
52+
setClipChildren(true);
5253
setAllowDismissWhenTouchOutside(true);
5354
setPopupGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
5455
setBlurBackgroundEnable(true);

app/src/main/java/razerdp/demo/popup/DialogPopup.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package razerdp.demo.popup;
22

33
import android.content.Context;
4+
import android.view.Gravity;
45
import android.view.View;
56
import android.view.animation.Animation;
67
import android.view.animation.AnimationSet;
@@ -17,24 +18,25 @@
1718
* dialogpopup :)
1819
* 客串一下dialog
1920
*/
20-
public class DialogPopup extends BasePopupWindow implements View.OnClickListener{
21+
public class DialogPopup extends BasePopupWindow implements View.OnClickListener {
2122

2223
private TextView ok;
2324
private TextView cancel;
2425

2526
public DialogPopup(Context context) {
2627
super(context);
2728

28-
ok= (TextView) findViewById(R.id.ok);
29-
cancel= (TextView) findViewById(R.id.cancel);
29+
ok = (TextView) findViewById(R.id.ok);
30+
cancel = (TextView) findViewById(R.id.cancel);
3031

31-
setViewClickListener(this,ok,cancel);
32+
setViewClickListener(this, ok, cancel);
33+
setPopupGravity(Gravity.CENTER);
3234
}
3335

3436
@Override
3537
protected Animation onCreateShowAnimation() {
36-
AnimationSet set=new AnimationSet(false);
37-
Animation shakeAnima=new RotateAnimation(0,15,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
38+
AnimationSet set = new AnimationSet(false);
39+
Animation shakeAnima = new RotateAnimation(0, 15, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
3840
shakeAnima.setInterpolator(new CycleInterpolator(5));
3941
shakeAnima.setDuration(400);
4042
set.addAnimation(getDefaultAlphaAnimation());
@@ -54,12 +56,12 @@ public View onCreateContentView() {
5456

5557
@Override
5658
public void onClick(View v) {
57-
switch (v.getId()){
59+
switch (v.getId()) {
5860
case R.id.ok:
59-
Toast.makeText(getContext(),"click the ok button",Toast.LENGTH_SHORT).show();
61+
Toast.makeText(getContext(), "click the ok button", Toast.LENGTH_SHORT).show();
6062
break;
6163
case R.id.cancel:
62-
Toast.makeText(getContext(),"click the cancel button",Toast.LENGTH_SHORT).show();
64+
Toast.makeText(getContext(), "click the cancel button", Toast.LENGTH_SHORT).show();
6365
dismiss();
6466
break;
6567
default:

app/src/main/java/razerdp/demo/popup/InputPopup.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.animation.AnimatorSet;
55
import android.animation.ObjectAnimator;
66
import android.content.Context;
7+
import android.view.Gravity;
78
import android.view.View;
89
import android.view.animation.Animation;
910
import android.widget.Button;
@@ -28,7 +29,9 @@ public InputPopup(Context context) {
2829
mCompeleteButton = (Button) findViewById(R.id.btn_Compelete);
2930
mInputEdittext = (EditText) findViewById(R.id.ed_input);
3031

32+
setClipChildren(false);
3133
setAutoShowInputMethod(mInputEdittext, true);
34+
setPopupGravity(Gravity.CENTER);
3235
bindEvent();
3336
}
3437

app/src/main/java/razerdp/demo/popup/ListPopup.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.app.Activity;
77
import android.content.Context;
88
import android.support.annotation.NonNull;
9+
import android.view.Gravity;
910
import android.view.LayoutInflater;
1011
import android.view.View;
1112
import android.view.ViewGroup;
@@ -38,6 +39,7 @@ private ListPopup(Context context, Builder builder) {
3839
this(context);
3940
mListView = (ListView) findViewById(R.id.popup_list);
4041
setAdapter(context, builder);
42+
setPopupGravity(Gravity.CENTER);
4143
}
4244

4345
public static class Builder {
@@ -190,8 +192,8 @@ protected Animation onCreateDismissAnimation() {
190192
public Animator onCreateShowAnimator() {
191193
AnimatorSet set = new AnimatorSet();
192194
set.playTogether(ObjectAnimator.ofFloat(mDisplayAnimateView, "rotationX", 90f, 0f).setDuration(400),
193-
ObjectAnimator.ofFloat(mDisplayAnimateView, "translationY", 250f, 0f).setDuration(400),
194-
ObjectAnimator.ofFloat(mDisplayAnimateView, "alpha", 0f, 1f).setDuration(400 * 3 / 2));
195+
ObjectAnimator.ofFloat(mDisplayAnimateView, "translationY", 250f, 0f).setDuration(400),
196+
ObjectAnimator.ofFloat(mDisplayAnimateView, "alpha", 0f, 1f).setDuration(400 * 3 / 2));
195197
return set;
196198
}
197199

@@ -205,8 +207,8 @@ public View onCreateContentView() {
205207
public Animator onCreateDismissAnimator() {
206208
AnimatorSet set = new AnimatorSet();
207209
set.playTogether(ObjectAnimator.ofFloat(mDisplayAnimateView, "rotationX", 0f, 90f).setDuration(400),
208-
ObjectAnimator.ofFloat(mDisplayAnimateView, "translationY", 0f, 250f).setDuration(400),
209-
ObjectAnimator.ofFloat(mDisplayAnimateView, "alpha", 1f, 0f).setDuration(400 * 3 / 2));
210+
ObjectAnimator.ofFloat(mDisplayAnimateView, "translationY", 0f, 250f).setDuration(400),
211+
ObjectAnimator.ofFloat(mDisplayAnimateView, "alpha", 1f, 0f).setDuration(400 * 3 / 2));
210212
return set;
211213
}
212214

app/src/main/java/razerdp/demo/popup/SlideFromTopPopup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public class SlideFromTopPopup extends BasePopupWindow {
3333

3434
public SlideFromTopPopup(Context context) {
3535
super(context);
36-
setBackPressEnable(false);
37-
setAllowDismissWhenTouchOutside(true);
36+
setBackPressEnable(true);
3837
setAlignBackground(true);
38+
setClipChildren(true);
3939
testList = new ArrayList<>();
4040
for (int i = 0; i < 50; i++) {
4141
testList.add("position - " + i);

app/src/main/java/razerdp/demo/popup/SlideFromTopPopup2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
public class SlideFromTopPopup2 extends BasePopupWindow {
3232

3333
public SlideFromTopPopup2(Context context) {
34-
super(context);
34+
super(context, MATCH_PARENT, WRAP_CONTENT);
3535
setBackPressEnable(false);
36-
setAllowDismissWhenTouchOutside(true);
3736
setAlignBackground(true);
37+
setClipChildren(true);
3838
List<String> testList = new ArrayList<>();
3939
for (int i = 0; i < 5; i++) {
4040
testList.add("position - " + i);

app/src/main/res/layout/frag_dismiss_control_popup.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:layout_width="match_parent"
2323
android:layout_height="wrap_content"
2424
android:padding="8dp"
25-
android:text="点击外部dismiss(setDismissWhenTouchOutside)\n一般针对wrap_content的popup"
25+
android:text="点击外部dismiss(setAllowDismissWhenTouchOutside)"
2626
android:textColor="#666666"
2727
android:textSize="12sp"/>
2828

@@ -41,7 +41,7 @@
4141
android:layout_height="wrap_content"
4242
android:checked="true"
4343
android:padding="8dp"
44-
android:text="popup是否拦截事件(setInterceptTouchEvent)false时无法响应backpress"
44+
android:text="popup是否拦截事件(setInterceptTouchEvent),如果不拦截事件,则背景去除,因为背景存在的情况下,理解为无法穿透事件也是正常的。"
4545
android:textColor="#666666"
4646
android:textSize="12sp"/>
4747
</LinearLayout>

app/src/main/res/layout/popup_input.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:layout_width="wrap_content"
4+
android:layout_width="match_parent"
55
android:layout_height="wrap_content"
6-
android:layout_centerInParent="true"
6+
android:layout_marginLeft="25dp"
7+
android:layout_marginRight="25dp"
78
android:background="@android:color/white"
8-
android:orientation="vertical"
9-
android:paddingLeft="25dp"
10-
android:paddingRight="25dp">
9+
android:orientation="vertical">
1110

1211
<TextView
1312
android:layout_width="match_parent"

app/src/main/res/menu/menu_demo.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@
5757
android:orderInCategory="108"
5858
android:title="对话框Popup"
5959
app:showAsAction="never"/>
60-
<item
61-
android:id="@+id/id_custom_interpolator_popup"
62-
android:orderInCategory="109"
63-
android:title="动画插值器Popup"
64-
app:showAsAction="never"/>
6560
<item
6661
android:id="@+id/id_auto_located_popup"
6762
android:orderInCategory="110"

lib/src/main/java/razerdp/basepopup/BasePopupHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ final class BasePopupHelper implements PopupTouchController, PopupWindowActionLi
7676
private PopupWindowActionListener mActionListener;
7777
private PopupWindowLocationListener mLocationListener;
7878

79-
private boolean mClipChildren = true;
79+
private boolean mClipChildren = false;
8080
private boolean mClipToScreen = true;
8181

8282
BasePopupHelper(PopupTouchController controller) {

lib/src/main/java/razerdp/basepopup/BasePopupWindow.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ private void registerListener(BasePopupHelper helper) {
403403

404404
//针对match_parent的popup寻找点击消失区域
405405
private void hookContentViewDismissClick(int w, int h) {
406+
if (w != MATCH_PARENT || h != MATCH_PARENT) return;
406407
if (mContentView != null && !(mContentView instanceof AdapterView) && mContentView instanceof ViewGroup) {
407408
ViewGroup vp = ((ViewGroup) mContentView);
408409
final int childCount = vp.getChildCount();

0 commit comments

Comments
 (0)