a
554325746@qq.com
2019-12-24 570a73851c26d810c2597596a8acc8a8d4cde211
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.obsez.android.lib.filechooser.internals;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
public class WrappedDrawable extends Drawable {
    private final Drawable _drawable;
    protected Drawable getDrawable() {
        return _drawable;
    }
    public WrappedDrawable(Drawable drawable) {
        super();
        _drawable = drawable;
    }
    public WrappedDrawable(Drawable drawable, float widthInDp, float heightInDp) {
        super();
        _drawable = drawable;
        setBounds(0, 0, (int) UiUtil.dip2px(widthInDp), (int) UiUtil.dip2px(heightInDp));
    }
    @Override
    public void setBounds(int left, int top, int right, int bottom) {
        //update bounds to get correctly
        super.setBounds(left, top, right, bottom);
        Drawable drawable = getDrawable();
        if (drawable != null) {
            drawable.setBounds(left, top, right, bottom);
        }
    }
    public void setBoundsInDp(float left, float top, float right, float bottom) {
        //update bounds to get correctly
        super.setBounds((int) UiUtil.dip2px(left),
            (int) UiUtil.dip2px(top),
            (int) UiUtil.dip2px(right),
            (int) UiUtil.dip2px(bottom));
        Drawable drawable = getDrawable();
        if (drawable != null) {
            drawable.setBounds((int) UiUtil.dip2px(left),
                (int) UiUtil.dip2px(top),
                (int) UiUtil.dip2px(right),
                (int) UiUtil.dip2px(bottom));
        }
    }
    @Override
    public void setAlpha(int alpha) {
        Drawable drawable = getDrawable();
        if (drawable != null) {
            drawable.setAlpha(alpha);
        }
    }
    @Override
    public void setColorFilter(ColorFilter colorFilter) {
        Drawable drawable = getDrawable();
        if (drawable != null) {
            drawable.setColorFilter(colorFilter);
        }
    }
    @Override
    public int getOpacity() {
        Drawable drawable = getDrawable();
        return drawable != null
            ? drawable.getOpacity()
            : PixelFormat.UNKNOWN;
    }
    @Override
    public void draw(Canvas canvas) {
        Drawable drawable = getDrawable();
        if (drawable != null) {
            drawable.draw(canvas);
        }
    }
    @Override
    public int getIntrinsicWidth() {
        Drawable drawable = getDrawable();
        return drawable != null
            ? drawable.getBounds().width()
            : 0;
    }
    @Override
    public int getIntrinsicHeight() {
        Drawable drawable = getDrawable();
        return drawable != null ?
            drawable.getBounds().height()
            : 0;
    }
}