File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
app/src/main/java/com/platypii/baseline/views/bluetooth Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .platypii .baseline .views .bluetooth ;
2
2
3
+ import android .os .Handler ;
3
4
import androidx .annotation .NonNull ;
4
5
import com .platypii .baseline .Intents ;
5
6
import com .platypii .baseline .R ;
@@ -24,6 +25,16 @@ public class BluetoothActivity extends BaseActivity implements Subscriber<MLocat
24
25
25
26
private ActivityBluetoothBinding binding ;
26
27
28
+ // Periodic UI updates
29
+ private static final int signalUpdateInterval = 200 ; // milliseconds
30
+ private final Handler handler = new Handler ();
31
+ private final Runnable signalRunnable = new Runnable () {
32
+ public void run () {
33
+ updateViews ();
34
+ handler .postDelayed (this , signalUpdateInterval );
35
+ }
36
+ };
37
+
27
38
@ Override
28
39
protected void onCreate (Bundle savedInstanceState ) {
29
40
super .onCreate (savedInstanceState );
@@ -125,13 +136,16 @@ public void onResume() {
125
136
EventBus .getDefault ().register (this );
126
137
Services .location .locationUpdates .subscribeMain (this );
127
138
updateViews ();
139
+ // Start regular ui updates
140
+ handler .post (signalRunnable );
128
141
}
129
142
130
143
@ Override
131
144
public void onPause () {
132
145
super .onPause ();
133
146
EventBus .getDefault ().unregister (this );
134
147
Services .location .locationUpdates .unsubscribeMain (this );
148
+ handler .removeCallbacks (signalRunnable );
135
149
}
136
150
137
151
@ Subscribe (threadMode = ThreadMode .MAIN )
You can’t perform that action at this time.
0 commit comments