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 11package com .platypii .baseline .views .bluetooth ;
22
3+ import android .os .Handler ;
34import androidx .annotation .NonNull ;
45import com .platypii .baseline .Intents ;
56import com .platypii .baseline .R ;
@@ -24,6 +25,16 @@ public class BluetoothActivity extends BaseActivity implements Subscriber<MLocat
2425
2526 private ActivityBluetoothBinding binding ;
2627
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+
2738 @ Override
2839 protected void onCreate (Bundle savedInstanceState ) {
2940 super .onCreate (savedInstanceState );
@@ -125,13 +136,16 @@ public void onResume() {
125136 EventBus .getDefault ().register (this );
126137 Services .location .locationUpdates .subscribeMain (this );
127138 updateViews ();
139+ // Start regular ui updates
140+ handler .post (signalRunnable );
128141 }
129142
130143 @ Override
131144 public void onPause () {
132145 super .onPause ();
133146 EventBus .getDefault ().unregister (this );
134147 Services .location .locationUpdates .unsubscribeMain (this );
148+ handler .removeCallbacks (signalRunnable );
135149 }
136150
137151 @ Subscribe (threadMode = ThreadMode .MAIN )
You can’t perform that action at this time.
0 commit comments