Skip to content
This repository was archived by the owner on Mar 27, 2022. It is now read-only.

Commit 84a734c

Browse files
author
EGE
committed
quick fix for nullPointerException thrown by updatePadding
1 parent 8417110 commit 84a734c

File tree

2 files changed

+45
-44
lines changed

2 files changed

+45
-44
lines changed

library/src/main/java/co/ceryle/radiorealbutton/library/RadioRealButton.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,9 @@ private void updatePaddings() {
460460
}
461461

462462
private void updatePadding(View view, boolean hasOtherView) {
463+
if (null == view)
464+
return;
465+
463466
int[] paddings = {paddingLeft, paddingTop, paddingRight, paddingBottom};
464467

465468
if (hasOtherView) {

sample/src/main/res/layout/activity_main.xml

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
android:layout_width="match_parent"
5-
android:layout_height="match_parent"
6-
android:background="@color/grey_200">
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="@color/grey_200">
77

88
<LinearLayout
99
android:layout_width="match_parent"
@@ -55,7 +55,7 @@
5555
app:rrb_textColor="@color/white"
5656
app:rrb_textGravity="left"
5757
app:rrb_textSize="12sp"
58-
app:rrb_textTypefacePath="fonts/shaka_pow.ttf"/>
58+
app:rrb_textTypefacePath="fonts/shaka_pow.ttf" />
5959

6060
<co.ceryle.radiorealbutton.library.RadioRealButton
6161
android:layout_width="wrap_content"
@@ -67,11 +67,11 @@
6767
app:rrb_drawableTint="@color/white"
6868
app:rrb_drawableWidth="36dp"
6969
app:rrb_rippleColor="@color/blue_500"
70-
app:rrb_text="Clark is jealous of Batman"
70+
app:rrb_text="Clark is super jealous of Batman"
7171
app:rrb_textColor="@color/white"
7272
app:rrb_textGravity="center"
7373
app:rrb_textSize="12sp"
74-
app:rrb_textTypefacePath="fonts/shaka_pow.ttf"/>
74+
app:rrb_textTypefacePath="fonts/shaka_pow.ttf" />
7575

7676
<co.ceryle.radiorealbutton.library.RadioRealButton
7777
android:id="@+id/rrb_3"
@@ -89,7 +89,7 @@
8989
app:rrb_textFillSpace="true"
9090
app:rrb_textGravity="right"
9191
app:rrb_textSize="12sp"
92-
app:rrb_textTypefacePath="fonts/shaka_pow.ttf"/>
92+
app:rrb_textTypefacePath="fonts/shaka_pow.ttf" />
9393
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
9494

9595

@@ -105,7 +105,7 @@
105105
android:layout_height="wrap_content"
106106
android:layout_marginEnd="4dp"
107107
android:layout_marginRight="4dp"
108-
android:text="Position: 0"/>
108+
android:text="Position: 0" />
109109

110110
<co.ceryle.radiorealbutton.library.RadioRealButtonGroup
111111
android:id="@+id/radioRealButtonGroup_1"
@@ -137,7 +137,7 @@
137137
app:rrb_drawableWidth="48dp"
138138
app:rrb_text="Button 1"
139139
app:rrb_textStyle="italic"
140-
app:rrb_textTypeface="serif"/>
140+
app:rrb_textTypeface="serif" />
141141

142142
<co.ceryle.radiorealbutton.library.RadioRealButton
143143
android:layout_width="wrap_content"
@@ -146,7 +146,7 @@
146146
app:rrb_drawableWidth="36dp"
147147
app:rrb_text="Button 2"
148148
app:rrb_textStyle="italic"
149-
app:rrb_textTypeface="serif"/>
149+
app:rrb_textTypeface="serif" />
150150

151151
<co.ceryle.radiorealbutton.library.RadioRealButton
152152
android:layout_width="wrap_content"
@@ -155,7 +155,7 @@
155155
app:rrb_drawableWidth="24dp"
156156
app:rrb_text="Button 3"
157157
app:rrb_textStyle="italic"
158-
app:rrb_textTypeface="serif"/>
158+
app:rrb_textTypeface="serif" />
159159
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
160160
</LinearLayout>
161161

@@ -199,7 +199,7 @@
199199
app:rrb_rippleColor="@color/black"
200200
app:rrb_text="Bruce"
201201
app:rrb_textColor="@color/black"
202-
app:rrb_textTypefacePath="fonts/shaka_pow.ttf"/>
202+
app:rrb_textTypefacePath="fonts/shaka_pow.ttf" />
203203

204204
<co.ceryle.radiorealbutton.library.RadioRealButton
205205
android:layout_width="wrap_content"
@@ -212,7 +212,7 @@
212212
app:rrb_rippleColor="@color/blue_500"
213213
app:rrb_text="Clark"
214214
app:rrb_textColor="@color/black"
215-
app:rrb_textTypefacePath="fonts/shaka_pow.ttf"/>
215+
app:rrb_textTypefacePath="fonts/shaka_pow.ttf" />
216216

217217
<co.ceryle.radiorealbutton.library.RadioRealButton
218218
android:layout_width="wrap_content"
@@ -224,7 +224,7 @@
224224
app:rrb_rippleColor="@color/yellow_600"
225225
app:rrb_text="Diana"
226226
app:rrb_textColor="@color/black"
227-
app:rrb_textTypefacePath="fonts/shaka_pow.ttf"/>
227+
app:rrb_textTypefacePath="fonts/shaka_pow.ttf" />
228228
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
229229

230230

@@ -239,32 +239,30 @@
239239
android:layout_margin="4dp"
240240
android:layout_weight="1"
241241
android:elevation="2dp"
242-
app:rrbg_borderColor="@color/black"
242+
app:rrbg_borderColor="@color/teal_300"
243243
app:rrbg_borderSize="1dp"
244-
app:rrbg_bottomLineSize="0dp"
245244
app:rrbg_checkedPosition="0"
246-
app:rrbg_dividerColor="@color/black"
247-
app:rrbg_dividerPadding="0dp"
248-
app:rrbg_dividerSize="1dp"
249245
app:rrbg_radius="28dp"
250-
app:rrbg_selectorColor="@color/yellow_600"
251-
app:rrbg_selectorSize="6dp">
246+
app:rrbg_backgroundColor="@android:color/transparent"
247+
app:rrbg_selectorColor="@color/teal_300"
248+
app:rrbg_selectorFullSize="true"
249+
app:rrbg_selectorRadius="28dp">
252250

253251
<co.ceryle.radiorealbutton.library.RadioRealButton
254252
android:layout_width="wrap_content"
255253
android:layout_height="wrap_content"
256254
app:rrb_drawable="@drawable/b1"
257255
app:rrb_drawableHeight="36dp"
258256
app:rrb_drawableWidth="36dp"
259-
app:rrb_rippleColor="@color/DarkRed"/>
257+
app:rrb_ripple="false" />
260258

261259
<co.ceryle.radiorealbutton.library.RadioRealButton
262260
android:layout_width="wrap_content"
263261
android:layout_height="wrap_content"
264262
app:rrb_drawable="@drawable/b2"
265263
app:rrb_drawableHeight="36dp"
266264
app:rrb_drawableWidth="36dp"
267-
app:rrb_rippleColor="@color/blue_300"/>
265+
app:rrb_ripple="false" />
268266
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
269267

270268

@@ -291,15 +289,15 @@
291289
app:rrb_drawable="@drawable/b17"
292290
app:rrb_drawableHeight="36dp"
293291
app:rrb_drawableWidth="36dp"
294-
app:rrb_rippleColor="@color/black"/>
292+
app:rrb_rippleColor="@color/black" />
295293

296294
<co.ceryle.radiorealbutton.library.RadioRealButton
297295
android:layout_width="wrap_content"
298296
android:layout_height="wrap_content"
299297
app:rrb_drawable="@drawable/b6"
300298
app:rrb_drawableHeight="36dp"
301299
app:rrb_drawableWidth="36dp"
302-
app:rrb_rippleColor="@color/DarkRed"/>
300+
app:rrb_rippleColor="@color/DarkRed" />
303301
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
304302
</LinearLayout>
305303

@@ -335,35 +333,35 @@
335333
android:layout_height="wrap_content"
336334
app:rrb_drawable="@drawable/b9"
337335
app:rrb_drawableHeight="36dp"
338-
app:rrb_drawableWidth="36dp"/>
336+
app:rrb_drawableWidth="36dp" />
339337

340338
<co.ceryle.radiorealbutton.library.RadioRealButton
341339
android:layout_width="wrap_content"
342340
android:layout_height="wrap_content"
343341
app:rrb_drawable="@drawable/b8"
344342
app:rrb_drawableHeight="36dp"
345-
app:rrb_drawableWidth="36dp"/>
343+
app:rrb_drawableWidth="36dp" />
346344

347345
<co.ceryle.radiorealbutton.library.RadioRealButton
348346
android:layout_width="wrap_content"
349347
android:layout_height="wrap_content"
350348
app:rrb_drawable="@drawable/b11"
351349
app:rrb_drawableHeight="36dp"
352-
app:rrb_drawableWidth="36dp"/>
350+
app:rrb_drawableWidth="36dp" />
353351

354352
<co.ceryle.radiorealbutton.library.RadioRealButton
355353
android:layout_width="wrap_content"
356354
android:layout_height="wrap_content"
357355
app:rrb_drawable="@drawable/b13"
358356
app:rrb_drawableHeight="36dp"
359-
app:rrb_drawableWidth="36dp"/>
357+
app:rrb_drawableWidth="36dp" />
360358

361359
<co.ceryle.radiorealbutton.library.RadioRealButton
362360
android:layout_width="wrap_content"
363361
android:layout_height="wrap_content"
364362
app:rrb_drawable="@drawable/b12"
365363
app:rrb_drawableHeight="36dp"
366-
app:rrb_drawableWidth="36dp"/>
364+
app:rrb_drawableWidth="36dp" />
367365
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
368366

369367

@@ -393,45 +391,45 @@
393391
android:layout_height="wrap_content"
394392
app:rrb_drawable="@drawable/b7"
395393
app:rrb_drawableHeight="36dp"
396-
app:rrb_rippleColor="@color/white"
397394
app:rrb_drawableTint="@color/white"
398-
app:rrb_drawableWidth="36dp"/>
395+
app:rrb_drawableWidth="36dp"
396+
app:rrb_rippleColor="@color/white" />
399397

400398
<co.ceryle.radiorealbutton.library.RadioRealButton
401399
android:layout_width="wrap_content"
402400
android:layout_height="wrap_content"
403401
app:rrb_drawable="@drawable/b7"
404402
app:rrb_drawableHeight="36dp"
405-
app:rrb_rippleColor="@color/white"
406403
app:rrb_drawableTint="@color/white"
407-
app:rrb_drawableWidth="36dp"/>
404+
app:rrb_drawableWidth="36dp"
405+
app:rrb_rippleColor="@color/white" />
408406

409407
<co.ceryle.radiorealbutton.library.RadioRealButton
410408
android:layout_width="wrap_content"
411409
android:layout_height="wrap_content"
412410
app:rrb_drawable="@drawable/b7"
413411
app:rrb_drawableHeight="36dp"
414-
app:rrb_rippleColor="@color/white"
415412
app:rrb_drawableTint="@color/white"
416-
app:rrb_drawableWidth="36dp"/>
413+
app:rrb_drawableWidth="36dp"
414+
app:rrb_rippleColor="@color/white" />
417415

418416
<co.ceryle.radiorealbutton.library.RadioRealButton
419417
android:layout_width="wrap_content"
420418
android:layout_height="wrap_content"
421419
app:rrb_drawable="@drawable/b7"
422420
app:rrb_drawableHeight="36dp"
423-
app:rrb_rippleColor="@color/white"
424421
app:rrb_drawableTint="@color/white"
425-
app:rrb_drawableWidth="36dp"/>
422+
app:rrb_drawableWidth="36dp"
423+
app:rrb_rippleColor="@color/white" />
426424

427425
<co.ceryle.radiorealbutton.library.RadioRealButton
428426
android:layout_width="wrap_content"
429427
android:layout_height="wrap_content"
430428
app:rrb_drawable="@drawable/b7"
431429
app:rrb_drawableHeight="36dp"
432-
app:rrb_rippleColor="@color/white"
433430
app:rrb_drawableTint="@color/white"
434-
app:rrb_drawableWidth="36dp"/>
431+
app:rrb_drawableWidth="36dp"
432+
app:rrb_rippleColor="@color/white" />
435433
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
436434

437435
<co.ceryle.radiorealbutton.library.RadioRealButtonGroup
@@ -475,7 +473,7 @@
475473
app:rrb_text="Legolas"
476474
app:rrb_textColor="@color/black"
477475
app:rrb_textSize="12sp"
478-
app:rrb_textTypefacePath="fonts/aniron.ttf"/>
476+
app:rrb_textTypefacePath="fonts/aniron.ttf" />
479477

480478
<co.ceryle.radiorealbutton.library.RadioRealButton
481479
android:layout_width="wrap_content"
@@ -488,7 +486,7 @@
488486
app:rrb_text="Gimli"
489487
app:rrb_textColor="@color/black"
490488
app:rrb_textSize="12sp"
491-
app:rrb_textTypefacePath="fonts/aniron.ttf"/>
489+
app:rrb_textTypefacePath="fonts/aniron.ttf" />
492490

493491
<co.ceryle.radiorealbutton.library.RadioRealButton
494492
android:layout_width="wrap_content"
@@ -501,7 +499,7 @@
501499
app:rrb_text="Aragorn"
502500
app:rrb_textColor="@color/black"
503501
app:rrb_textSize="12sp"
504-
app:rrb_textTypefacePath="fonts/aniron.ttf"/>
502+
app:rrb_textTypefacePath="fonts/aniron.ttf" />
505503
</co.ceryle.radiorealbutton.library.RadioRealButtonGroup>
506504

507505
</LinearLayout>

0 commit comments

Comments
 (0)