Skip to content

Commit

Permalink
// update to 1.8.8 and fix #47
Browse files Browse the repository at this point in the history
  • Loading branch information
razerdp committed Dec 13, 2017
1 parent ffa1b91 commit 87fc892
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 80 deletions.
9 changes: 8 additions & 1 deletion ISSUE_TEMPLATE.md
Expand Up @@ -6,4 +6,11 @@



### 报错信息
### 报错信息/系统版本

```java

```


### 建议或优化点
11 changes: 7 additions & 4 deletions README.md
Expand Up @@ -13,8 +13,14 @@

## 更新日志:

#### 1.8.8(未发布,等到解决别的issue后一同发布)
#### 1.8.8
- `BasePopupWindowProxy``PopupWindowProxy`权限收拢,不暴露放开
- 优化`SimpleAnimUtil`,修改部分动画时间和插值器
- 增加`setOutsideTouchable()`方法,和`setDismissWhenTouchOutside()`搭配使用有奇效哦
- 增加`BasePopupHelper`优化`BasePopupWindow`代码可读性
- 动画方面修正`AnimaView.clearAnimation()`->`Animation.cancel()`
- 优化`showOnTop()`/`showOnDown()`方法。。。虽然可能没什么人用
- 【未解决】`setBackPressEnable()`在M以上依然未能解决,除非我hook掉(但是代价太大),详情请看[#33](https://github.com/razerdp/BasePopup/issues/33)/问题描述:[查看描述](https://github.com/razerdp/BasePopup/blob/master/%E5%85%B3%E4%BA%8EAndorid%20M%E4%BB%A5%E4%B8%8AsetBackPressEnable()%E5%A4%B1%E6%95%88%E7%9A%84%E9%97%AE%E9%A2%98%E7%9A%84%E5%88%86%E6%9E%90.md)

#### 1.8.7
- 抽取`PopupWindowProxy`->`BasePopupWindowProxy`
Expand All @@ -35,9 +41,6 @@
- 针对诸位提出的setBackPress在6.0以上失效的问题,请查看这份[MD](https://github.com/razerdp/BasePopup/blob/master/%E5%85%B3%E4%BA%8EAndorid%20M%E4%BB%A5%E4%B8%8AsetBackPressEnable()%E5%A4%B1%E6%95%88%E7%9A%84%E9%97%AE%E9%A2%98%E7%9A%84%E5%88%86%E6%9E%90.md)文件(没错,暂时无法修复)
- 删除`setRelativeToAnchorView()`方法,该方法本身就没有什么用处。。。

##### 1.8.4:
- 补充PopupWindowProxy的scanForActivity方法(不知明原因在merged后丢失了)


### 最低SDK版本要求 : API 11

Expand Down
20 changes: 12 additions & 8 deletions app/src/main/java/razerdp/demo/popup/ScalePopup.java
Expand Up @@ -4,6 +4,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;

import razerdp.basepopup.BasePopupWindow;
import razerdp.basepopup.R;
import razerdp.demo.utils.ToastUtils;
Expand All @@ -12,7 +13,7 @@
* Created by 大灯泡 on 2016/1/15.
* 普通的popup
*/
public class ScalePopup extends BasePopupWindow implements View.OnClickListener{
public class ScalePopup extends BasePopupWindow implements View.OnClickListener {

private View popupView;

Expand All @@ -22,12 +23,15 @@ public ScalePopup(Activity context) {
}



@Override
protected Animation initShowAnimation() {
return getDefaultScaleAnimation();
}

@Override
protected Animation initExitAnimation() {
return getDefaultScaleAnimation(false);
}

@Override
public View getClickToDismissView() {
Expand All @@ -36,7 +40,7 @@ public View getClickToDismissView() {

@Override
public View onCreatePopupView() {
popupView= LayoutInflater.from(getContext()).inflate(R.layout.popup_normal,null);
popupView = LayoutInflater.from(getContext()).inflate(R.layout.popup_normal, null);
return popupView;
}

Expand All @@ -46,7 +50,7 @@ public View initAnimaView() {
}

private void bindEvent() {
if (popupView!=null){
if (popupView != null) {
popupView.findViewById(R.id.tx_1).setOnClickListener(this);
popupView.findViewById(R.id.tx_2).setOnClickListener(this);
popupView.findViewById(R.id.tx_3).setOnClickListener(this);
Expand All @@ -56,15 +60,15 @@ private void bindEvent() {

@Override
public void onClick(View v) {
switch (v.getId()){
switch (v.getId()) {
case R.id.tx_1:
ToastUtils.ToastMessage(getContext(),"click tx_1");
ToastUtils.ToastMessage(getContext(), "click tx_1");
break;
case R.id.tx_2:
ToastUtils.ToastMessage(getContext(),"click tx_2");
ToastUtils.ToastMessage(getContext(), "click tx_2");
break;
case R.id.tx_3:
ToastUtils.ToastMessage(getContext(),"click tx_3");
ToastUtils.ToastMessage(getContext(), "click tx_3");
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Expand Up @@ -31,7 +31,7 @@ publish {
userOrg = 'razerdp'
groupId = 'com.github.razerdp'
artifactId = 'BasePopup'
publishVersion = '1.8.7'
publishVersion = '1.8.8'
desc = '打造一个通用的Popup'
website = 'https://github.com/razerdp/BasePopup'
}
Expand Down
15 changes: 9 additions & 6 deletions lib/src/main/java/razerdp/basepopup/BasePopupHelper.java
Expand Up @@ -44,7 +44,7 @@ final class BasePopupHelper {
//点击popup外部是否消失
private boolean dismissWhenTouchOutside;
//外部是否可用点击
private boolean mOutsideClickable;
private boolean mOutsideTouchable;
//是否需要淡入window动画
private volatile boolean needPopupFadeAnima = true;

Expand Down Expand Up @@ -235,16 +235,19 @@ public BasePopupHelper setDismissWhenTouchOutside(boolean dismissWhenTouchOutsid
outsideTouchable = false;
hasBackground = false;
}
if (outsideTouchable) {
focusable = false;
}
return this;
}

public boolean isOutsideClickable() {
return mOutsideClickable;
public boolean isOutsideTouchable() {
return mOutsideTouchable;
}

public BasePopupHelper setOutsideClickable(boolean outsideClickable) {
mOutsideClickable = outsideClickable;
focusable = true;
public BasePopupHelper setOutsideTouchable(boolean outsideClickable) {
mOutsideTouchable = outsideClickable;
focusable = false;
return this;
}

Expand Down
74 changes: 50 additions & 24 deletions lib/src/main/java/razerdp/basepopup/BasePopupWindow.java
Expand Up @@ -205,6 +205,7 @@ file or class name and description of purpose be included on the
package razerdp.basepopup;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.app.Activity;
import android.content.Context;
Expand All @@ -225,7 +226,7 @@ file or class name and description of purpose be included on the
import java.lang.reflect.Field;

import razerdp.util.InputMethodUtils;
import razerdp.util.SimpleAnimUtil;
import razerdp.util.SimpleAnimationUtils;

/**
* Created by 大灯泡 on 2016/1/14.
Expand Down Expand Up @@ -543,9 +544,9 @@ private int[] calculateOffset(View anchorView) {
final boolean onTop = (getScreenHeight() - (mHelper.getAnchorY() + offset[1]) < getHeight());
if (onTop) {
offset[1] = -anchorView.getHeight() - getHeight() - offset[1];
showOnTop(mPopupView);
showOnTop(mPopupView, anchorView);
} else {
showOnDown(mPopupView);
showOnDown(mPopupView, anchorView);
}
}
return offset;
Expand Down Expand Up @@ -824,8 +825,8 @@ public BasePopupWindow setDismissWhenTouchOutside(boolean dismissWhenTouchOutsid
return this;
}

public BasePopupWindow setOutsideClickable(boolean clickable) {
mHelper.setOutsideClickable(clickable);
public BasePopupWindow setOutsideTouchable(boolean touchable) {
mHelper.setOutsideTouchable(touchable);
return this;
}

Expand All @@ -834,7 +835,7 @@ public boolean isDismissWhenTouchOutside() {
}

public boolean isOutsideClickable() {
return mHelper.isOutsideClickable();
return mHelper.isOutsideTouchable();
}

//------------------------------------------状态控制-----------------------------------------------
Expand Down Expand Up @@ -915,7 +916,8 @@ private boolean checkPerformShow(View v) {

//------------------------------------------Anima-----------------------------------------------

private Animator.AnimatorListener mAnimatorListener = new Animator.AnimatorListener() {
private Animator.AnimatorListener mAnimatorListener = new AnimatorListenerAdapter() {

@Override
public void onAnimationStart(Animator animation) {
isExitAnimaPlaying = true;
Expand All @@ -932,13 +934,9 @@ public void onAnimationCancel(Animator animation) {
isExitAnimaPlaying = false;
}

@Override
public void onAnimationRepeat(Animator animation) {

}
};

private Animation.AnimationListener mAnimationListener = new Animation.AnimationListener() {
private Animation.AnimationListener mAnimationListener = new SimpleAnimationUtils.AnimationListenerAdapter() {
@Override
public void onAnimationStart(Animation animation) {
isExitAnimaPlaying = true;
Expand All @@ -949,11 +947,6 @@ public void onAnimationEnd(Animation animation) {
mPopupWindow.callSuperDismiss();
isExitAnimaPlaying = false;
}

@Override
public void onAnimationRepeat(Animation animation) {

}
};

/**
Expand All @@ -963,7 +956,7 @@ public void onAnimationRepeat(Animation animation) {
* @param start 初始位置
*/
protected Animation getTranslateAnimation(int start, int end, int durationMillis) {
return SimpleAnimUtil.getTranslateAnimation(start, end, durationMillis);
return SimpleAnimationUtils.getTranslateAnimation(start, end, durationMillis);
}

/**
Expand All @@ -979,28 +972,48 @@ protected Animation getScaleAnimation(float fromX,
float pivotXValue,
int pivotYType,
float pivotYValue) {
return SimpleAnimUtil.getScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue);
return SimpleAnimationUtils.getScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue);
}


/**
* 生成自定义ScaleAnimation
*/
protected Animation getDefaultScaleAnimation() {
return SimpleAnimUtil.getDefaultScaleAnimation();
return getDefaultScaleAnimation(true);
}

/**
* 生成自定义ScaleAnimation
*
* @param in true for scale in
*/
protected Animation getDefaultScaleAnimation(boolean in) {
return SimpleAnimationUtils.getDefaultScaleAnimation(in);
}


/**
* 生成默认的AlphaAnimation
*/
protected Animation getDefaultAlphaAnimation() {
return SimpleAnimUtil.getDefaultAlphaAnimation();
return getDefaultAlphaAnimation(true);
}

/**
* 生成默认的AlphaAnimation
*
* @param in true for alpha in
*/
protected Animation getDefaultAlphaAnimation(boolean in) {
return SimpleAnimationUtils.getDefaultAlphaAnimation(in);
}

/**
* 从下方滑动上来
*/
protected AnimatorSet getDefaultSlideFromBottomAnimationSet() {
return SimpleAnimUtil.getDefaultSlideFromBottomAnimationSet(mAnimaView);
return SimpleAnimationUtils.getDefaultSlideFromBottomAnimationSet(mAnimaView);
}

/**
Expand All @@ -1018,11 +1031,24 @@ public int getScreenWidth() {
}

//------------------------------------------callback-----------------------------------------------
protected void showOnTop(View mPopupView) {

/**
* 在anchorView上方显示,autoLocatePopup为true时适用
*
* @param mPopupView {@link #onCreatePopupView()}返回的View
* @param anchorView {@link #showPopupWindow(View)}传入的View
*/
protected void showOnTop(View mPopupView, View anchorView) {

}

protected void showOnDown(View mPopupView) {
/**
* 在anchorView下方显示,autoLocatePopup为true时适用
*
* @param mPopupView {@link #onCreatePopupView()}返回的View
* @param anchorView {@link #showPopupWindow(View)}传入的View
*/
protected void showOnDown(View mPopupView, View anchorView) {

}

Expand Down

0 comments on commit 87fc892

Please sign in to comment.