Skip to content

Commit 545347a

Browse files
committed
fix: restore TTSControlsView after git hard reset
1 parent 78078c2 commit 545347a

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

app/src/main/java/com/foobnix/tts/TTSControlsView.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class TTSControlsView extends FrameLayout {
5151
private ImageView ttsPrevTrack;
5252
private ImageView ttsNextTrack;
5353
private int colorTint;
54+
private TextView ttsPreloadStats;
5455
Runnable update = new Runnable() {
5556

5657
@Override
@@ -363,15 +364,27 @@ protected void onDetachedFromWindow() {
363364
EventBus.getDefault().unregister(this);
364365
handler.removeCallbacksAndMessages(null);
365366
}
367+
@Subscribe(threadMode = ThreadMode.MAIN)
368+
public void onTTSStatus(TtsStatus status) {
369+
if (ttsPlayPause != null) {
370+
handler.removeCallbacksAndMessages(null);
371+
handler.postDelayed(update, 200);
372+
}
373+
}
366374

367-
@Subscribe(threadMode = ThreadMode.MAIN)
368-
public void onTTSStatus(TtsStatus status) {
369-
if (ttsPlayPause != null) {
370-
handler.removeCallbacksAndMessages(null);
371-
handler.postDelayed(update, 200);
375+
@Subscribe(threadMode = ThreadMode.MAIN)
376+
public void onTtsPreloadStats(TtsPreloadStats stats) {
377+
if (ttsPreloadStats != null) {
378+
if (com.foobnix.model.AppState.get().ttsPrecomputeLines > 0) {
379+
ttsPreloadStats.setVisibility(View.VISIBLE);
380+
ttsPreloadStats.setText(String.format("Preload Buffer - Pending: %d | Ready: %d | Playing: %d", stats.pending, stats.synthesized, stats.playing));
381+
} else {
382+
ttsPreloadStats.setVisibility(View.GONE);
372383
}
373384
}
385+
}
374386

387+
public void reset() {
375388
@Subscribe(threadMode = ThreadMode.MAIN)
376389
public void onTtsPreloadStats(TtsPreloadStats stats) {
377390
if (ttsPreloadStats != null) {
@@ -391,3 +404,9 @@ public void reset() {
391404
}
392405

393406
}
407+
Get());
408+
update.run();
409+
410+
}
411+
412+
}

0 commit comments

Comments
 (0)