1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package cn.flightfeather.thirdapp.util;
 
import android.animation.Animator;
import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.view.View;
import android.view.animation.Animation;
 
import cn.flightfeather.thirdapp.R;
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();
    }
 
}