@@ -393,6 +393,36 @@ public void onTimestampNs(long timestampNs) {
393
393
394
394
/* Set up UI controls and listeners based on if device is currently a leader of client. */
395
395
private void setLeaderClientControls (boolean isLeader ) {
396
+ getPeriodButton .setOnClickListener (
397
+ view -> {
398
+ Log .d (TAG , "Calculating frames period." );
399
+
400
+ FutureTask <Integer > periodTask = new FutureTask <Integer >(
401
+ () -> {
402
+ try {
403
+ long periodNs = periodCalculator .getPeriodNs ();
404
+ Log .d (TAG , "Calculated period: " + periodNs );
405
+ if (latestToast != null ) {
406
+ latestToast .cancel ();
407
+ }
408
+ latestToast =
409
+ Toast .makeText (
410
+ this ,
411
+ "Calculated period: " + periodNs ,
412
+ Toast .LENGTH_LONG );
413
+ latestToast .show ();
414
+ phaseAlignController .setPeriodNs (periodNs );
415
+ } catch (InterruptedException e ) {
416
+ Log .d (TAG , "Failed calculating period" );
417
+ e .printStackTrace ();
418
+ }
419
+ return 0 ;
420
+ }
421
+ );
422
+ periodTask .run ();
423
+ }
424
+ );
425
+
396
426
if (isLeader ) {
397
427
// Leader, all controls visible and set.
398
428
captureStillButton .setVisibility (View .VISIBLE );
@@ -444,36 +474,6 @@ private void setLeaderClientControls(boolean isLeader) {
444
474
String.valueOf(futureTimestamp));*/
445
475
});
446
476
447
- getPeriodButton .setOnClickListener (
448
- view -> {
449
- Log .d (TAG , "Calculating frames period." );
450
-
451
- FutureTask <Integer > periodTask = new FutureTask <Integer >(
452
- () -> {
453
- try {
454
- long periodNs = periodCalculator .getPeriodNs ();
455
- Log .d (TAG , "Calculated period: " + periodNs );
456
- if (latestToast != null ) {
457
- latestToast .cancel ();
458
- }
459
- latestToast =
460
- Toast .makeText (
461
- this ,
462
- "Calculated period: " + periodNs ,
463
- Toast .LENGTH_LONG );
464
- latestToast .show ();
465
- phaseAlignController .setPeriodNs (periodNs );
466
- } catch (InterruptedException e ) {
467
- Log .d (TAG , "Failed calculating period" );
468
- e .printStackTrace ();
469
- }
470
- return 0 ;
471
- }
472
- );
473
- periodTask .run ();
474
- }
475
- );
476
-
477
477
phaseAlignButton .setOnClickListener (
478
478
view -> {
479
479
Log .d (TAG , "Broadcasting phase alignment request." );
@@ -544,7 +544,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
544
544
// Client. All controls invisible.
545
545
captureStillButton .setVisibility (View .INVISIBLE );
546
546
phaseAlignButton .setVisibility (View .INVISIBLE );
547
- getPeriodButton .setVisibility (View .INVISIBLE );
547
+ getPeriodButton .setVisibility (View .VISIBLE );
548
548
exposureSeekBar .setVisibility (View .INVISIBLE );
549
549
sensitivitySeekBar .setVisibility (View .INVISIBLE );
550
550
0 commit comments