Skip to content

Commit 3100506

Browse files
committed
Periodic UI updates on BluetoothActivity
1 parent db44a53 commit 3100506

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/src/main/java/com/platypii/baseline/views/bluetooth/BluetoothActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.platypii.baseline.views.bluetooth;
22

3+
import android.os.Handler;
34
import androidx.annotation.NonNull;
45
import com.platypii.baseline.Intents;
56
import 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)

0 commit comments

Comments
 (0)