Skip to content

Commit 85c90c6

Browse files
Fix Actionbar hiding
Signed-off-by: Keith Conger <keith.conger@blackboxembedded.com>
1 parent 7de46f0 commit 85c90c6

5 files changed

Lines changed: 70 additions & 54 deletions

File tree

app/src/main/java/com/blackboxembedded/WunderLINQ/AccessoryActivity.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,29 +401,33 @@ private void updateDisplay(){
401401
}
402402
}
403403

404-
//start timer function
404+
//ActionBar Hiding start timer
405405
void startTimer() {
406406
if (sharedPrefs.getBoolean("prefHideNavBar", false)) {
407-
if (!timerRunning) {
408-
cTimer = new CountDownTimer(10000, 1000) {
409-
public void onTick(long millisUntilFinished) {
410-
}
407+
cancelTimer();
408+
cTimer = new CountDownTimer(10000, 1000) {
409+
public void onTick(long millisUntilFinished) {
410+
}
411411

412-
public void onFinish() {
412+
public void onFinish() {
413+
if (getSupportActionBar() != null) {
413414
getSupportActionBar().hide();
414-
timerRunning = false;
415415
}
416-
};
417-
timerRunning = true;
418-
cTimer.start();
419-
}
416+
timerRunning = false;
417+
}
418+
};
419+
timerRunning = true;
420+
cTimer.start();
420421
}
421422
}
422423

423-
//Cancel timer
424+
//ActionBar Hiding cancel timer
424425
void cancelTimer() {
425-
if(cTimer!=null)
426+
if (cTimer != null) {
426427
cTimer.cancel();
428+
cTimer = null;
429+
}
430+
timerRunning = false;
427431
}
428432

429433
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {

app/src/main/java/com/blackboxembedded/WunderLINQ/DashActivity.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -348,29 +348,33 @@ void prevInfoLine(){
348348
updateDisplay();
349349
}
350350

351-
//start timer function
351+
//ActionBar Hiding start timer
352352
void startTimer() {
353353
if (sharedPrefs.getBoolean("prefHideNavBar", false)) {
354-
if (!timerRunning) {
355-
cTimer = new CountDownTimer(10000, 1000) {
356-
public void onTick(long millisUntilFinished) {
357-
}
354+
cancelTimer();
355+
cTimer = new CountDownTimer(10000, 1000) {
356+
public void onTick(long millisUntilFinished) {
357+
}
358358

359-
public void onFinish() {
359+
public void onFinish() {
360+
if (getSupportActionBar() != null) {
360361
getSupportActionBar().hide();
361-
timerRunning = false;
362362
}
363-
};
364-
timerRunning = true;
365-
cTimer.start();
366-
}
363+
timerRunning = false;
364+
}
365+
};
366+
timerRunning = true;
367+
cTimer.start();
367368
}
368369
}
369370

370-
//cancel timer
371+
//ActionBar Hiding cancel timer
371372
void cancelTimer() {
372-
if(cTimer!=null)
373+
if (cTimer != null) {
373374
cTimer.cancel();
375+
cTimer = null;
376+
}
377+
timerRunning = false;
374378
}
375379

376380
private static IntentFilter makeGattUpdateIntentFilter() {

app/src/main/java/com/blackboxembedded/WunderLINQ/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ public static boolean isAccessibilityServiceEnabled(Context context, Class<?> ac
913913
return false;
914914
}
915915

916-
//start timer function
916+
//ActionBar Hiding start timer
917917
void startTimer() {
918918
if (sharedPrefs.getBoolean("prefHideNavBar", false)) {
919919
cancelTimer();
@@ -933,7 +933,7 @@ public void onFinish() {
933933
}
934934
}
935935

936-
//cancel timer
936+
//ActionBar Hiding cancel timer
937937
void cancelTimer() {
938938
if (cTimer != null) {
939939
cTimer.cancel();

app/src/main/java/com/blackboxembedded/WunderLINQ/MusicActivity.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -563,29 +563,33 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
563563
}
564564
}
565565

566-
//start timer function
566+
//ActionBar Hiding start timer
567567
void startTimer() {
568568
if (sharedPrefs.getBoolean("prefHideNavBar", false)) {
569-
if (!timerRunning) {
570-
cTimer = new CountDownTimer(10000, 1000) {
571-
public void onTick(long millisUntilFinished) {
572-
}
569+
cancelTimer();
570+
cTimer = new CountDownTimer(10000, 1000) {
571+
public void onTick(long millisUntilFinished) {
572+
}
573573

574-
public void onFinish() {
574+
public void onFinish() {
575+
if (getSupportActionBar() != null) {
575576
getSupportActionBar().hide();
576-
timerRunning = false;
577577
}
578-
};
579-
timerRunning = true;
580-
cTimer.start();
581-
}
578+
timerRunning = false;
579+
}
580+
};
581+
timerRunning = true;
582+
cTimer.start();
582583
}
583584
}
584585

585-
//cancel timer
586+
//ActionBar Hiding cancel timer
586587
void cancelTimer() {
587-
if(cTimer!=null)
588+
if (cTimer != null) {
588589
cTimer.cancel();
590+
cTimer = null;
591+
}
592+
timerRunning = false;
589593
}
590594

591595
// Handles various events fired by the Service.

app/src/main/java/com/blackboxembedded/WunderLINQ/TaskList/TaskActivity.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -378,29 +378,33 @@ private void updateDisplay() {
378378
}
379379
};
380380

381-
//Start Timer to hide the ActionBar
381+
//ActionBar Hiding start timer
382382
void startTimer() {
383383
if (sharedPrefs.getBoolean("prefHideNavBar", false)) {
384-
if (!timerRunning) {
385-
cTimer = new CountDownTimer(10000, 1000) {
386-
public void onTick(long millisUntilFinished) {
387-
}
384+
cancelTimer();
385+
cTimer = new CountDownTimer(10000, 1000) {
386+
public void onTick(long millisUntilFinished) {
387+
}
388388

389-
public void onFinish() {
389+
public void onFinish() {
390+
if (getSupportActionBar() != null) {
390391
getSupportActionBar().hide();
391-
timerRunning = false;
392392
}
393-
};
394-
timerRunning = true;
395-
cTimer.start();
396-
}
393+
timerRunning = false;
394+
}
395+
};
396+
timerRunning = true;
397+
cTimer.start();
397398
}
398399
}
399400

400-
//Cancel Timer to hide the ActionBar
401+
//ActionBar Hiding cancel timer
401402
void cancelTimer() {
402-
if(cTimer!=null)
403+
if (cTimer != null) {
403404
cTimer.cancel();
405+
cTimer = null;
406+
}
407+
timerRunning = false;
404408
}
405409

406410
//Go to next screen

0 commit comments

Comments
 (0)