OSDN Git Service

LAPボタンのチャタリング防止をハードボタンでも適用するようにした。
[gokigen/JoggingTimer.git] / wear / src / main / java / net / osdn / gokigen / joggingtimer / stopwatch / MainActivity.java
index 8c52e52..36345f7 100644 (file)
@@ -6,16 +6,18 @@ import android.os.Bundle;
 import android.support.wear.widget.BoxInsetLayout;
 import android.support.wearable.activity.WearableActivity;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.View;
 import android.widget.ImageButton;
+import android.widget.ListView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import net.osdn.gokigen.joggingtimer.R;
 import net.osdn.gokigen.joggingtimer.recordlist.ListActivity;
+import net.osdn.gokigen.joggingtimer.stopwatch.graphview.LapTimeGraphView;
 import net.osdn.gokigen.joggingtimer.utilities.TimeStringConvert;
 
-
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
@@ -25,12 +27,16 @@ import java.util.Locale;
  *
  *
  */
-public class MainActivity extends WearableActivity implements IClickCallback, MyTimerTrigger.ITimeoutReceiver
+public class MainActivity extends WearableActivity implements IClickCallback, MyTimerTrigger.ITimeoutReceiver, MyTimerCounter.ICounterStatusNotify
 {
     private final String TAG = toString();
     private final IWearableActivityControl controller = new WearableActivityController();
     private MyTimerCounter counter = new MyTimerCounter();
-    private boolean isCounterLapTime = false;
+    private boolean isCounterLapTime = true;
+    private boolean isLaptimeView = true;
+    private boolean pendingStart = false;
+    private int currentLapCount = 0;
+    private ITimerStopTrigger stopTrigger = null;
 
     /**
      *
@@ -43,7 +49,7 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
 
         setContentView(R.layout.activity_main);
 
-        controller.setup(this, this);
+        controller.setup(this, this, counter);
 
         // Enables Always-on
         setAmbientEnabled();
@@ -53,30 +59,6 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
      *
      */
     @Override
-    protected void onSaveInstanceState(Bundle outState)
-    {
-        super.onSaveInstanceState(outState);
-
-        /* ここで状態を保存 */
-        outState.putParcelable("timerCounter", counter);
-    }
-
-    /**
-     *
-     */
-    @Override
-    protected void onRestoreInstanceState(Bundle savedInstanceState)
-    {
-        super.onRestoreInstanceState(savedInstanceState);
-
-        /* ここで保存した状態を読み出して設定 */
-        counter = savedInstanceState.getParcelable("timerCounter");
-    }
-
-    /**
-     *
-     */
-    @Override
     protected void onResume()
     {
         super.onResume();
@@ -102,10 +84,16 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
                 }
             }
         }
+        isLaptimeView = controller.getDisplayMode();
+        //Log.v(TAG, "isLaptimeView " + isLaptimeView);
+
+        controller.setupReferenceData();
+
         if (isStartTimer)
         {
             // start a timer!
-            startTimer();
+            //startTimer();
+            pendingStart = true;
         }
     }
 
@@ -128,6 +116,10 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
     {
         super.onStart();
         Log.v(TAG, "onStart()");
+
+        // データベースのセットアップ
+        counter.setCallback(this);
+        controller.setupDatabase(this, false);
     }
 
     /**
@@ -139,6 +131,10 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
     {
         super.onStop();
         Log.v(TAG, "onStop()");
+        if (stopTrigger != null)
+        {
+            stopTrigger.forceStop();
+        }
         controller.exitApplication(this);
     }
 
@@ -162,7 +158,7 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
     {
         super.onExitAmbient();
         Log.v(TAG, "onExitAmbient()");
-        updateTimerLabel();
+        //updateTimerLabel();
     }
 
     /**
@@ -179,100 +175,100 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
     /**
      *
      */
-    public void updateTimerLabel()
+    private void updateTimerLabel()
     {
         ITimerCounter timerCounter = counter;
-        if (timerCounter != null)
+        if (timerCounter == null)
         {
-            int bgColor;
-            BoxInsetLayout insetLayout = findViewById(R.id.box_inset_layout);
-            RelativeLayout layout = findViewById(R.id.relative_main_layout);
-
-            ImageButton btn1 = findViewById(R.id.btn1);
-            ImageButton btn2 = findViewById(R.id.btn2);
-            ImageButton btn3 = findViewById(R.id.btn3);
-
-            updateMainSubCounter();
-
-            if (timerCounter.isStarted())
-            {
-                bgColor = Color.BLACK;
-                insetLayout.setBackgroundColor(bgColor);
-                insetLayout.invalidate();
-
-                layout.setBackgroundColor(bgColor);
-                layout.invalidate();
-
-                btn1.setImageResource(R.drawable.ic_flag_black_24dp);
-                btn1.setBackgroundColor(bgColor);
-                btn1.setVisibility(View.VISIBLE);
-                btn1.invalidate();
-
-                btn2.setImageResource(R.drawable.ic_stop_black_24dp);
-                btn2.setBackgroundColor(bgColor);
-                btn2.setVisibility(View.VISIBLE);
-                btn2.invalidate();
-
-                btn3.setImageResource(R.drawable.ic_block_black_24dp);
-                btn3.setBackgroundColor(bgColor);
-                btn3.setVisibility(View.INVISIBLE);
-                btn3.invalidate();
-
-                updateElapsedTimes();
-            }
-            else if (timerCounter.isReset())
-            {
-                bgColor = Color.BLACK;
-                insetLayout.setBackgroundColor(bgColor);
-                insetLayout.invalidate();
-
-                layout.setBackgroundColor(bgColor);
-                layout.invalidate();
-
-                btn1.setImageResource(R.drawable.ic_play_arrow_black_24dp);
-                btn1.setBackgroundColor(bgColor);
-                btn1.setVisibility(View.VISIBLE);
-                btn1.invalidate();
-
-                btn2.setImageResource(R.drawable.ic_format_list_bulleted_black_24dp);
-                btn2.setBackgroundColor(bgColor);
-                btn2.setVisibility(View.VISIBLE);
-                btn2.invalidate();
-
-                btn3.setImageResource(R.drawable.ic_refresh_black_24dp);
-                btn3.setBackgroundColor(bgColor);
-                btn3.setVisibility(View.INVISIBLE);
-                btn3.invalidate();
-
-                updateElapsedTimes();
-            }
-            else
-            {
-                bgColor = Color.BLACK;
-                insetLayout.setBackgroundColor(bgColor);
-                insetLayout.invalidate();
-
-                layout.setBackgroundColor(bgColor);
-                layout.invalidate();
+            return;
+        }
 
-                btn1.setImageResource(R.drawable.ic_play_arrow_black_24dp);
-                btn1.setVisibility(View.VISIBLE);
-                btn1.setBackgroundColor(bgColor);
-                btn1.invalidate();
+        int bgColor;
+        BoxInsetLayout insetLayout = findViewById(R.id.box_inset_layout);
+        RelativeLayout layout = findViewById(R.id.relative_main_layout);
 
-                btn2.setImageResource(R.drawable.ic_format_list_bulleted_black_24dp);
-                btn2.setVisibility(View.VISIBLE);
-                btn2.setBackgroundColor(bgColor);
-                btn2.invalidate();
+        ImageButton btn1 = findViewById(R.id.btn1);
+        ImageButton btn2 = findViewById(R.id.btn2);
+        ImageButton btn3 = findViewById(R.id.btn3);
 
-                btn3.setImageResource(R.drawable.ic_refresh_black_24dp);
-                btn3.setVisibility(View.VISIBLE);
-                btn3.setBackgroundColor(bgColor);
-                btn3.invalidate();
+        updateMainSubCounter();
 
-                updateElapsedTimes();
-            }
+        if (timerCounter.isStarted())
+        {
+            bgColor = Color.BLACK;
+            insetLayout.setBackgroundColor(bgColor);
+            insetLayout.invalidate();
+
+            layout.setBackgroundColor(bgColor);
+            layout.invalidate();
+
+            btn1.setImageResource(R.drawable.ic_flag_black_24dp);
+            btn1.setBackgroundColor(bgColor);
+
+            // チャタリング防止(ラップタイムとして、3秒以内は記録しないようボタンを消しておく)
+            long currentElapsedTime = timerCounter.getCurrentElapsedTime();
+            btn1.setVisibility((currentElapsedTime > 3000) ? View.VISIBLE : View.INVISIBLE);
+            btn1.invalidate();
+
+            btn2.setImageResource(R.drawable.ic_stop_black_24dp);
+            btn2.setBackgroundColor(bgColor);
+            btn2.setVisibility(View.VISIBLE);
+            btn2.invalidate();
+
+            btn3.setImageResource(R.drawable.ic_block_black_24dp);
+            btn3.setBackgroundColor(bgColor);
+            btn3.setVisibility(View.INVISIBLE);
+            btn3.invalidate();
         }
+        else if (timerCounter.isReset())
+        {
+            bgColor = Color.BLACK;
+            insetLayout.setBackgroundColor(bgColor);
+            insetLayout.invalidate();
+
+            layout.setBackgroundColor(bgColor);
+            layout.invalidate();
+
+            btn1.setImageResource(R.drawable.ic_play_arrow_black_24dp);
+            btn1.setBackgroundColor(bgColor);
+            btn1.setVisibility(View.VISIBLE);
+            btn1.invalidate();
+
+            btn2.setImageResource(R.drawable.ic_format_list_bulleted_black_24dp);
+            btn2.setBackgroundColor(bgColor);
+            btn2.setVisibility(View.VISIBLE);
+            btn2.invalidate();
+
+            btn3.setImageResource(R.drawable.ic_refresh_black_24dp);
+            btn3.setBackgroundColor(bgColor);
+            btn3.setVisibility(View.INVISIBLE);
+            btn3.invalidate();
+        }
+        else
+        {
+            bgColor = Color.BLACK;
+            insetLayout.setBackgroundColor(bgColor);
+            insetLayout.invalidate();
+
+            layout.setBackgroundColor(bgColor);
+            layout.invalidate();
+
+            btn1.setImageResource(R.drawable.ic_play_arrow_black_24dp);
+            btn1.setVisibility(View.VISIBLE);
+            btn1.setBackgroundColor(bgColor);
+            btn1.invalidate();
+
+            btn2.setImageResource(R.drawable.ic_format_list_bulleted_black_24dp);
+            btn2.setVisibility(View.VISIBLE);
+            btn2.setBackgroundColor(bgColor);
+            btn2.invalidate();
+
+            btn3.setImageResource(R.drawable.ic_refresh_black_24dp);
+            btn3.setVisibility(View.VISIBLE);
+            btn3.setBackgroundColor(bgColor);
+            btn3.invalidate();
+        }
+        updateElapsedTimes();
     }
 
     @Override
@@ -302,29 +298,51 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
             ITimerCounter timerCounter = counter;
             if (timerCounter != null)
             {
+                LapTimeGraphView graphView = findViewById(R.id.graph_area);
                 if (timerCounter.isStarted())
                 {
                     Log.v(TAG, "startTimer() LAP TIME");
-                    // チャタリング防止(ラップタイムとして、3秒以内は記録しないようにする)
-                    if (timerCounter.getCurrentElapsedTime() > 3000)
+                    long currentElapsedTime = timerCounter.getCurrentElapsedTime();
+                    if (currentElapsedTime > 3000)  // チャタリング防止(ラップタイムとして、3秒以内は記録しないようにする)
                     {
+                        currentLapCount++;
                         long lapTime = timerCounter.timeStamp();
+                        long refLapTime = timerCounter.getReferenceLapTime(currentLapCount);
+                        long diffTime = (refLapTime == 0) ? 0 :  (currentElapsedTime - refLapTime);
                         controller.vibrate(50);
                         controller.getDataEntry().appendTimeData(lapTime);
+                        controller.addTimeStamp(currentLapCount, currentElapsedTime, diffTime);
+                        //Log.v(TAG, " [[[ " + currentLapCount + " lap: " + currentElapsedTime + " diff:" + diffTime + " (" + refLapTime + ") ]]]");
+
+                        if (graphView != null)
+                        {
+                            graphView.notifyLapTime();
+                        }
                     }
                 }
                 else
                 {
                     Log.v(TAG, "startTimer() START");
+                    controller.clearTimeStamp();
                     timerCounter.start();
                     MyTimerTrigger trigger = new MyTimerTrigger(this, 100, timerCounter);
                     trigger.startTimer();
+                    currentLapCount = 0;
+                    stopTrigger = trigger;
+                    controller.timerStarted(true);
                     controller.vibrate(120);
 
                     Date date = new Date();
                     SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
                     String title = sdf1.format(date);
-                    controller.getDataEntry().createIndex(title, "", 0, timerCounter.getStartTime());
+                    long startTime = timerCounter.getStartTime();
+                    controller.getDataEntry().createIndex(title, startTime);
+
+                    if (graphView != null)
+                    {
+                        graphView.notifyStarted(startTime);
+                    }
+
                 }
                 updateTimerLabel();
             }
@@ -350,9 +368,22 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
                 if (timerCounter.isStarted())
                 {
                     timerCounter.stop();
+                    controller.timerStarted(false);
                     controller.vibrate(120);
                     controller.getDataEntry().finishTimeData(timerCounter.getStartTime(), timerCounter.getStopTime());
+
+                    int lapCount = currentLapCount + 1;
+                    long currentElapsedTime = timerCounter.getLastElapsedTime() - timerCounter.getElapsedTime(currentLapCount);
+                    long refLapTime = timerCounter.getReferenceLapTime(lapCount);
+                    long diffTime = (refLapTime == 0) ? 0 :  (currentElapsedTime - refLapTime);
+                    controller.addTimeStamp(lapCount, currentElapsedTime, diffTime);
                     ret = true;
+
+                    LapTimeGraphView graphView = findViewById(R.id.graph_area);
+                    if (graphView != null)
+                    {
+                        graphView.notifyStopped();
+                    }
                 }
                 updateTimerLabel();
             }
@@ -398,12 +429,26 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
             {
                 timerCounter.reset();
                 controller.vibrate(50);
+                controller.clearTimeStamp();
+                currentLapCount = 0;
+                LapTimeGraphView graphView = findViewById(R.id.graph_area);
+                if (graphView != null)
+                {
+                    graphView.notifyReset();
+                }
             }
             updateTimerLabel();
         }
     }
 
     @Override
+    public void clickedArea()
+    {
+        Log.v(TAG, "clickedArea()");
+
+    }
+
+    @Override
     public boolean pushedBtn1()
     {
         return (false);
@@ -421,6 +466,17 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
         return (false);
     }
 
+    @Override
+    public boolean pushedArea()
+    {
+        isLaptimeView = !isLaptimeView;
+        controller.setDisplayMode(isLaptimeView);
+        Log.v(TAG, "pushedArea() : " + isLaptimeView);
+        changeGraphicView(isLaptimeView);
+        updateTimerLabel();
+        return (true);
+    }
+
     /**
      *
      *
@@ -457,7 +513,6 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
         {
             long time1 = timerCounter.getPastTime();
             CharSequence str1 = TimeStringConvert.getTimeString(time1);
-
             CharSequence str2 = "";
             if (timerCounter.isStarted())
             {
@@ -491,83 +546,199 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
      */
     private void updateElapsedTimes()
     {
-        String dummy = "";
-        TextView area1 = findViewById(R.id.sub_counter2);
-        TextView area2 = findViewById(R.id.sub_counter3);
-        TextView area3 = findViewById(R.id.sub_counter4);
+        if (isLaptimeView)
+        {
+           updateElapsedTimesGraph();
+        }
+        else
+        {
+            updateElapsedTimesText();
+        }
+    }
 
-        ITimerCounter timerCounter = counter;
-        if (timerCounter != null)
+    /**
+     *
+     *
+     */
+    private void updateElapsedTimesGraph()
+    {
+        //Log.v(TAG, "updateElapsedTimesGraph()");
+        LapTimeGraphView view = findViewById(R.id.graph_area);
+        view.invalidate();
+    }
+
+    /**
+     *
+     *
+     */
+    private void updateElapsedTimesText()
+    {
+        // Log.v(TAG, "updateElapsedTimesText()");
+    }
+
+    /**
+     *  Launch ListActivity
+     *
+     */
+    private void launchListActivity()
+    {
+        Log.v(TAG, "launchListActivity()");
+        try
         {
-            List<Long> elapsedTimes = timerCounter.getTimerList();
-            int indexSize = elapsedTimes.size();
-            if (indexSize <= 1)
+            Intent intent = new Intent(this, ListActivity.class);
+            startActivity(intent);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    protected void onUserLeaveHint()
+    {
+        Log.v(TAG, "onUserLeaveHint() " );
+        // ハードキー(ホームボタン)が押されたとき、これがひろえるが...
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event)
+    {
+        Log.v(TAG, "dispatchKeyEvent() : " + event.getAction() + " (" + event.getKeyCode() + ")");
+
+        return (super.dispatchKeyEvent(event));
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event)
+    {
+        Log.v(TAG, "onKeyDown() : " + event.getAction() + " (" + event.getKeyCode() + ")" + keyCode);
+        if (event.getRepeatCount() == 0)
+        {
+            if (keyCode == KeyEvent.KEYCODE_STEM_1)
             {
-                // ラップの記録がないので表示しません
-                area1.setText(dummy);
-                area1.invalidate();
-                area2.setText(dummy);
-                area2.invalidate();
-                area3.setText(dummy);
-                area3.invalidate();
-                return;
+                startTimer();
+                return (true);
             }
-            if (indexSize <= 2)
+            else if (keyCode == KeyEvent.KEYCODE_STEM_2)
             {
-                // ラップが1つとれた場合
-                long time = (elapsedTimes.get(indexSize - 1) - elapsedTimes.get(indexSize - 2));
-                String elapsedTime = "[" + (timerCounter.getElapsedCount() - 1) + "] " + TimeStringConvert.getTimeString(time);
-                area1.setText(elapsedTime);
-                area1.invalidate();
-                area2.setText(dummy);
-                area2.invalidate();
-                area3.setText(dummy);
-                area3.invalidate();
-                return;
+                startTimer();
+                return (true);
             }
-            if (indexSize <= 3)
+            else if (keyCode == KeyEvent.KEYCODE_STEM_3)
             {
-                // ラップが3つとれた場合
-                long time1 = (elapsedTimes.get(indexSize - 2) - elapsedTimes.get(indexSize - 3));
-                long time2 = (elapsedTimes.get(indexSize - 1) - elapsedTimes.get(indexSize - 2));
-                String elapsedTime1 = "[" +  (timerCounter.getElapsedCount() - 2) + "] " + TimeStringConvert.getTimeString(time1);
-                String elapsedTime2 = "[" +  (timerCounter.getElapsedCount() - 1) + "] " + TimeStringConvert.getTimeString(time2);
-                area1.setText(elapsedTime1);
-                area1.invalidate();
-                area2.setText(elapsedTime2);
-                area2.invalidate();
-                area3.setText(dummy);
-                area3.invalidate();
-                return;
+                startTimer();
+                return (true);
             }
+        }
+        return (super.onKeyDown(keyCode, event));
+    }
 
-            // ラップが4つ以上ある場合
-            long time1 = (elapsedTimes.get(indexSize - 3) - elapsedTimes.get(indexSize - 4));
-            long time2 = (elapsedTimes.get(indexSize - 2) - elapsedTimes.get(indexSize - 3));
-            long time3 = (elapsedTimes.get(indexSize - 1) - elapsedTimes.get(indexSize - 2));
-            String elapsedTime1 = "[" +  (timerCounter.getElapsedCount() - 3) + "] " + TimeStringConvert.getTimeString(time1);
-            String elapsedTime2 = "[" +  (timerCounter.getElapsedCount() - 2) + "] " + TimeStringConvert.getTimeString(time2);
-            String elapsedTime3 = "[" +  (timerCounter.getElapsedCount() - 1) + "] " + TimeStringConvert.getTimeString(time3);
-            area1.setText(elapsedTime1);
-            area1.invalidate();
-            area2.setText(elapsedTime2);
-            area2.invalidate();
-            area3.setText(elapsedTime3);
-            area3.invalidate();
+    /**
+     *
+     *
+     */
+    @Override
+    public void counterStatusChanged(final boolean forceStartTimer)
+    {
+        ITimerCounter timerCounter = counter;
+        if (forceStartTimer)
+        {
+            try
+            {
+                LapTimeGraphView graphView = findViewById(R.id.graph_area);
+                if (timerCounter != null)
+                {
+                    MyTimerTrigger trigger = new MyTimerTrigger(this, 100, timerCounter);
+                    trigger.startTimer();
+                    stopTrigger = trigger;
+                }
+                if (graphView != null)
+                {
+                    graphView.notifyLapTime();
+                }
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
         }
+
+        runOnUiThread(new Runnable()
+        {
+            @Override
+            public void run()
+            {
+
+                // 自動スタート時の処理。。
+                if (pendingStart)
+                {
+                    startTimer();
+                    pendingStart = false;
+                }
+
+                // ラップタイム表示状態の更新
+                reloadLapTimeList(forceStartTimer);
+
+                // 表示ビューの切り替え
+                changeGraphicView(isLaptimeView);
+
+                // 表示のボタン状態を変更
+                updateTimerLabel();
+            }
+        });
     }
 
     /**
-     *  Launch ListActivity
+     *
      *
      */
-    private void launchListActivity()
+    private void reloadLapTimeList(final boolean forceStartTimer)
     {
-        Log.v(TAG, "launchListActivity()");
+        ITimerCounter timerCounter = counter;
+        if ((!forceStartTimer)||(timerCounter == null))
+        {
+            return;
+        }
+
+        // Adapter と TimerCounterの整合性を確認
         try
         {
-            Intent intent = new Intent(this, ListActivity.class);
-            startActivity(intent);
+            List<Long> lapTimeList = timerCounter.getLapTimeList();
+            int lapCount = lapTimeList.size();
+            int listCount = controller.getLapTimeCount();
+            if (lapCount != listCount)
+            {
+                Log.v(TAG, "LAP COUNT IS MISMATCH!!! lap:" + lapCount + " vs list:" + listCount);
+                int index = 0;
+                controller.clearTimeStamp();
+                long prevTime = lapTimeList.get(0);
+                for (long lapTime : lapTimeList)
+                {
+                    index++;
+                    if (prevTime != lapTime)
+                    {
+                        long refLapTime = counter.getReferenceLapTime(index - 1);
+                        long curLapTime = lapTime - prevTime;
+                        long calcRefLapTime = (refLapTime == 0) ? 0 : (curLapTime - refLapTime);
+                        controller.addTimeStamp((index - 1), curLapTime, calcRefLapTime);
+                    }
+                    prevTime = lapTime;
+                }
+                currentLapCount = lapCount - 1;
+            }
         }
         catch (Exception e)
         {
@@ -575,24 +746,32 @@ public class MainActivity extends WearableActivity implements IClickCallback, My
         }
     }
 
-    /*
+    /**
      *
      *
      */
-/*
-    private String getElapsedTime()
+    private void changeGraphicView(boolean isGraphics)
     {
-        String elapsedTime = "";
-        ITimerCounter timerCounter = counter;
-        if (timerCounter != null)
+        try
         {
-            int count = timerCounter.getElapsedCount();
-            if (count > 0)
+            LapTimeGraphView graphView = findViewById(R.id.graph_area);
+            ListView listView = findViewById(R.id.laptime_list_area);
+            if (isGraphics)
+            {
+                graphView.setITimerCounter(counter);
+                graphView.setVisibility(View.VISIBLE);
+                listView.setVisibility(View.GONE);
+            }
+            else
             {
-                elapsedTime = "[" + timerCounter.getElapsedCount() + "] " + MyTimerCounter.getTimeString(timerCounter.getCurrentElapsedTime());
+                graphView.setVisibility(View.GONE);
+                listView.setVisibility(View.VISIBLE);
             }
+            //controller.vibrate(30);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
         }
-        return (elapsedTime);
     }
-*/
 }