package cn.flightfeather.thirdappmodule.util;
|
|
import android.animation.Animator;
|
import android.content.Context;
|
import android.support.annotation.LayoutRes;
|
import android.view.View;
|
import android.view.animation.Animation;
|
|
import razerdp.basepopup.BasePopupWindow;
|
|
public class PopupGenerator extends BasePopupWindow {
|
|
private int layoutId;
|
|
public PopupGenerator(Context context, @LayoutRes int layoutId) {
|
super(context, true);
|
this.layoutId = layoutId;
|
delayInit();
|
}
|
|
/**
|
* <p>
|
* 返回一个contentView以作为PopupWindow的contentView
|
* </p>
|
* <br>
|
* <strong>强烈建议使用{@link BasePopupWindow#createPopupById(int)},该方法支持读取View的xml布局参数,否则可能会出现与布局不一样的展示从而必须手动传入宽高等参数</strong>
|
*/
|
@Override
|
public View onCreateContentView() {
|
return createPopupById(layoutId);
|
}
|
|
/**
|
* <p>
|
* 该方法决定您的PopupWindow将会以怎样的动画展示出来,可以返回为 {@code null}
|
* </p>
|
* <p>
|
* 本类提供一些简单的动画方法:
|
* <ul>
|
* <li>{@link #getDefaultAlphaAnimation()}:得到一个默认进入的渐变动画</li>
|
* <li>{@link #getDefaultScaleAnimation()}:得到一个默认的放大缩小动画</li>
|
* <li>{@link #getTranslateVerticalAnimation(float, float, int)} ()}:快速获取垂直方向的动画</li>
|
* </ul>
|
* <p>
|
* 如果需要用到属性动画,请覆写{@link #onCreateShowAnimator()}
|
*
|
* @return 返回显示PopupWindow的动画
|
*/
|
@Override
|
protected Animation onCreateShowAnimation() {
|
return super.onCreateShowAnimation();
|
}
|
|
/**
|
* <p>
|
* 该方法决定您的PopupWindow将会以怎样的动画展示出来(返回 {@link Animator}),可以返回为 {@code null}
|
* <br>
|
* <br>
|
* 功能详情请看{@link #onCreateShowAnimation()}
|
* </p>
|
*
|
* @return 返回显示PopupWindow的动画
|
*/
|
@Override
|
protected Animator onCreateShowAnimator() {
|
return super.onCreateShowAnimator();
|
}
|
|
}
|