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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
package com.bumptech.glide.load.engine.prefill;
import android.graphics.Bitmap;
/**
* A container for a set of options used to pre-fill a {@link com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool}
* with {@link Bitmap Bitmaps} of a single size and configuration.
*/
public final class PreFillBitmapAttribute {
// Visible for testing.
static final Bitmap.Config DEFAULT_CONFIG = Bitmap.Config.RGB_565;
private final int width;
private final int height;
private final Bitmap.Config config;
private final int weight;
/**
* Constructor for a single type of {@link android.graphics.Bitmap}.
*
* @see #PreFillBitmapAttribute(int, int, int)
* @see #PreFillBitmapAttribute(int, int, android.graphics.Bitmap.Config, int)
*
* @param width The width in pixels of the {@link android.graphics.Bitmap} to pre-fill.
* @param height The height in pixels of the {@link android.graphics.Bitmap} to pre-fill.
*/
public PreFillBitmapAttribute(int width, int height) {
this(width, height, 1);
}
/**
* Constructor for a single type of {@link android.graphics.Bitmap}.
*
* @see #PreFillBitmapAttribute(int, int)
* @see #PreFillBitmapAttribute(int, int, android.graphics.Bitmap.Config, int)
*
* @param width The width in pixels of the {@link android.graphics.Bitmap} to pre-fill.
* @param height The height in pixels of the {@link android.graphics.Bitmap} to pre-fill.
* @param weight An integer indicating how to balance pre-filling this size and configuration of
* {@link android.graphics.Bitmap} against any other sizes/configurations that may be being pre-filled.
*/
public PreFillBitmapAttribute(int width, int height, int weight) {
this(width, height, DEFAULT_CONFIG, weight);
}
/**
* Constructor for a single type of {@link android.graphics.Bitmap}.
*
* @see #PreFillBitmapAttribute(int, int)
* @see #PreFillBitmapAttribute(int, int, int)
*
* @param width The width in pixels of the {@link android.graphics.Bitmap Bitmaps} to
* pre-fill.
* @param height The height in pixels of the {@link android.graphics.Bitmap Bitmaps} to
* pre-fill.
* @param config The {@link android.graphics.Bitmap.Config} of the {@link android.graphics.Bitmap Bitmaps} to
* pre-fill.
* @param weight An integer indicating how to balance pre-filling this size and configuration of
* {@link android.graphics.Bitmap} against any other sizes/configurations that may be being pre-filled.
*/
public PreFillBitmapAttribute(int width, int height, Bitmap.Config config, int weight) {
this.width = width;
this.height = height;
this.config = config;
this.weight = weight;
}
/**
* Returns the width in pixels of the {@link android.graphics.Bitmap Bitmaps}.
*/
public int getWidth() {
return width;
}
/**
* Returns the height in pixels of the {@link android.graphics.Bitmap Bitmaps}.
*/
public int getHeight() {
return height;
}
/**
* Returns the {@link android.graphics.Bitmap.Config} of the {@link android.graphics.Bitmap Bitmaps}.
*/
public Bitmap.Config getConfig() {
return config;
}
/**
* Returns the weight of the {@link android.graphics.Bitmap Bitmaps} of this type.
*/
public int getWeight() {
return weight;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o == null || getClass() != o.getClass()) {
return false;
}
PreFillBitmapAttribute size = (PreFillBitmapAttribute) o;
return height == size.height
&& weight == size.weight
&& width == size.width
&& config == size.config;
}
@Override
public int hashCode() {
int result = width;
result = 31 * result + height;
result = 31 * result + config.hashCode();
result = 31 * result + weight;
return result;
}
@Override
public String toString() {
return "PreFillSize{"
+ "width=" + width
+ ", height=" + height
+ ", config=" + config
+ ", weight=" + weight
+ '}';
}
}
|