@@ -49,7 +49,8 @@ public RoundedCornersTransformation(Context context, int radius, int margin) {
49
49
this (context , radius , margin , CornerType .ALL );
50
50
}
51
51
52
- public RoundedCornersTransformation (Context context , int radius , int margin , CornerType cornerType ) {
52
+ public RoundedCornersTransformation (Context context , int radius , int margin ,
53
+ CornerType cornerType ) {
53
54
mBitmapPool = Glide .get (context ).getBitmapPool ();
54
55
mRadius = radius ;
55
56
mDiameter = mRadius * 2 ;
@@ -134,89 +135,112 @@ private void drawRoundRect(Canvas canvas, Paint paint, float width, float height
134
135
}
135
136
136
137
private void drawTopLeftRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
137
- canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , mMargin + mDiameter ), mRadius , mRadius , paint );
138
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , mMargin + mDiameter ),
139
+ mRadius , mRadius , paint );
138
140
canvas .drawRect (new RectF (mMargin , mMargin + mRadius , mMargin + mRadius , bottom ), paint );
139
141
canvas .drawRect (new RectF (mMargin + mRadius , mMargin , right , bottom ), paint );
140
142
}
141
143
142
144
private void drawTopRightRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
143
- canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , mMargin + mDiameter ), mRadius , mRadius , paint );
145
+ canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , mMargin + mDiameter ), mRadius ,
146
+ mRadius , paint );
144
147
canvas .drawRect (new RectF (mMargin , mMargin , right - mRadius , bottom ), paint );
145
148
canvas .drawRect (new RectF (right - mRadius , mMargin + mRadius , right , bottom ), paint );
146
149
}
147
150
148
151
private void drawBottomLeftRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
149
- canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , mMargin + mDiameter , bottom ), mRadius , mRadius , paint );
152
+ canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , mMargin + mDiameter , bottom ),
153
+ mRadius , mRadius , paint );
150
154
canvas .drawRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom - mRadius ), paint );
151
155
canvas .drawRect (new RectF (mMargin + mRadius , mMargin , right , bottom ), paint );
152
156
}
153
157
154
158
private void drawBottomRightRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
155
- canvas .drawRoundRect (new RectF (right - mDiameter , bottom - mDiameter , right , bottom ), mRadius , mRadius , paint );
159
+ canvas .drawRoundRect (new RectF (right - mDiameter , bottom - mDiameter , right , bottom ), mRadius ,
160
+ mRadius , paint );
156
161
canvas .drawRect (new RectF (mMargin , mMargin , right - mRadius , bottom ), paint );
157
162
canvas .drawRect (new RectF (right - mRadius , mMargin , right , bottom - mRadius ), paint );
158
163
}
159
164
160
165
private void drawTopRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
161
- canvas .drawRoundRect (new RectF (mMargin , mMargin , right , mMargin + mDiameter ), mRadius , mRadius , paint );
166
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , right , mMargin + mDiameter ), mRadius , mRadius ,
167
+ paint );
162
168
canvas .drawRect (new RectF (mMargin , mMargin + mRadius , right , bottom ), paint );
163
169
}
164
170
165
171
private void drawBottomRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
166
- canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , right , bottom ), mRadius , mRadius , paint );
172
+ canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , right , bottom ), mRadius , mRadius ,
173
+ paint );
167
174
canvas .drawRect (new RectF (mMargin , mMargin , right , bottom - mRadius ), paint );
168
175
}
169
176
170
177
private void drawLeftRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
171
- canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom ), mRadius , mRadius , paint );
178
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom ), mRadius , mRadius ,
179
+ paint );
172
180
canvas .drawRect (new RectF (mMargin + mRadius , mMargin , right , bottom ), paint );
173
181
}
174
182
175
183
private void drawRightRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
176
- canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , bottom ), mRadius , mRadius , paint );
184
+ canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , bottom ), mRadius , mRadius ,
185
+ paint );
177
186
canvas .drawRect (new RectF (mMargin , mMargin , right - mRadius , bottom ), paint );
178
187
}
179
188
180
189
private void drawOtherTopLeftRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
181
- canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , right , bottom ), mRadius , mRadius , paint );
182
- canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , bottom ), mRadius , mRadius , paint );
190
+ canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , right , bottom ), mRadius , mRadius ,
191
+ paint );
192
+ canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , bottom ), mRadius , mRadius ,
193
+ paint );
183
194
canvas .drawRect (new RectF (mMargin , mMargin , right - mRadius , bottom - mRadius ), paint );
184
195
}
185
196
186
197
private void drawOtherTopRightRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
187
- canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom ), mRadius , mRadius , paint );
188
- canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , right , bottom ), mRadius , mRadius , paint );
198
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom ), mRadius , mRadius ,
199
+ paint );
200
+ canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , right , bottom ), mRadius , mRadius ,
201
+ paint );
189
202
canvas .drawRect (new RectF (mMargin + mRadius , mMargin , right , bottom - mRadius ), paint );
190
203
}
191
204
192
205
private void drawOtherBottomLeftRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
193
- canvas .drawRoundRect (new RectF (mMargin , mMargin , right , mMargin + mDiameter ), mRadius , mRadius , paint );
194
- canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , bottom ), mRadius , mRadius , paint );
206
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , right , mMargin + mDiameter ), mRadius , mRadius ,
207
+ paint );
208
+ canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , bottom ), mRadius , mRadius ,
209
+ paint );
195
210
canvas .drawRect (new RectF (mMargin , mMargin + mRadius , right - mRadius , bottom ), paint );
196
211
}
197
212
198
- private void drawOtherBottomRightRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
199
- canvas .drawRoundRect (new RectF (mMargin , mMargin , right , mMargin + mDiameter ), mRadius , mRadius , paint );
200
- canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom ), mRadius , mRadius , paint );
213
+ private void drawOtherBottomRightRoundRect (Canvas canvas , Paint paint , float right ,
214
+ float bottom ) {
215
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , right , mMargin + mDiameter ), mRadius , mRadius ,
216
+ paint );
217
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , bottom ), mRadius , mRadius ,
218
+ paint );
201
219
canvas .drawRect (new RectF (mMargin + mRadius , mMargin + mRadius , right , bottom ), paint );
202
220
}
203
221
204
- private void drawDiagonalFromTopLeftRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
205
- canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , mMargin + mDiameter ), mRadius , mRadius , paint );
206
- canvas .drawRoundRect (new RectF (right - mDiameter , bottom - mDiameter , right , bottom ), mRadius , mRadius , paint );
222
+ private void drawDiagonalFromTopLeftRoundRect (Canvas canvas , Paint paint , float right ,
223
+ float bottom ) {
224
+ canvas .drawRoundRect (new RectF (mMargin , mMargin , mMargin + mDiameter , mMargin + mDiameter ),
225
+ mRadius , mRadius , paint );
226
+ canvas .drawRoundRect (new RectF (right - mDiameter , bottom - mDiameter , right , bottom ), mRadius ,
227
+ mRadius , paint );
207
228
canvas .drawRect (new RectF (mMargin , mMargin + mRadius , right - mDiameter , bottom ), paint );
208
229
canvas .drawRect (new RectF (mMargin + mDiameter , mMargin , right , bottom - mRadius ), paint );
209
230
}
210
231
211
- private void drawDiagonalFromTopRightRoundRect (Canvas canvas , Paint paint , float right , float bottom ) {
212
- canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , mMargin + mDiameter ), mRadius , mRadius , paint );
213
- canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , mMargin + mDiameter , bottom ), mRadius , mRadius , paint );
232
+ private void drawDiagonalFromTopRightRoundRect (Canvas canvas , Paint paint , float right ,
233
+ float bottom ) {
234
+ canvas .drawRoundRect (new RectF (right - mDiameter , mMargin , right , mMargin + mDiameter ), mRadius ,
235
+ mRadius , paint );
236
+ canvas .drawRoundRect (new RectF (mMargin , bottom - mDiameter , mMargin + mDiameter , bottom ),
237
+ mRadius , mRadius , paint );
214
238
canvas .drawRect (new RectF (mMargin , mMargin , right - mRadius , bottom - mRadius ), paint );
215
239
canvas .drawRect (new RectF (mMargin + mRadius , mMargin + mRadius , right , bottom ), paint );
216
240
}
217
241
218
- @ Override
219
- public String getId () {
220
- return "RoundedTransformation(radius=" + mRadius + ", margin =" + mMargin + ")" ;
242
+ @ Override public String getId () {
243
+ return "RoundedTransformation(radius=" + mRadius + ", margin=" + mMargin + ", diameter="
244
+ + mDiameter + ", cornerType =" + mCornerType . name () + ")" ;
221
245
}
222
246
}
0 commit comments