Commit 99345c3
committed
Refactor BatteryReceiver to improve reliability and efficiency
The `BatteryReceiver` has been refactored to be more robust and efficient.
It now takes the `FontAppCompatTextView` and `Prefs` as constructor parameters, removing the need to look up the view on each `onReceive` call. The battery level calculation has been improved to use `BatteryManager.BATTERY_PROPERTY_CAPACITY` as a fallback if the intent extras are not available.
In `HomeFragment`, the receiver is now registered with a sticky intent, allowing the battery UI to be updated immediately upon registration instead of waiting for the next battery change event.1 parent 2f64613 commit 99345c3
File tree
2 files changed
+33
-36
lines changed- app/src/main/java/com/github/codeworkscreativehub/mlauncher
- helper/receivers
- ui
2 files changed
+33
-36
lines changedLines changed: 24 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
| 10 | + | |
12 | 11 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
| 31 | + | |
27 | 32 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
43 | 36 | | |
44 | 37 | | |
45 | 38 | | |
| 39 | + | |
46 | 40 | | |
47 | | - | |
48 | | - | |
| 41 | + | |
49 | 42 | | |
50 | | - | |
51 | | - | |
| 43 | + | |
| 44 | + | |
52 | 45 | | |
53 | 46 | | |
54 | | - | |
| 47 | + | |
55 | 48 | | |
56 | 49 | | |
57 | 50 | | |
58 | 51 | | |
59 | | - | |
| 52 | + | |
60 | 53 | | |
61 | 54 | | |
62 | 55 | | |
63 | | - | |
64 | 56 | | |
65 | 57 | | |
66 | | - | |
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
193 | 199 | | |
194 | 200 | | |
195 | 201 | | |
| |||
0 commit comments