-<?xml version="1.0" encoding="UTF-8"?>\r
-<classpath>\r
- <classpathentry kind="src" path="src"/>\r
- <classpathentry kind="src" path="gen"/>\r
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>\r
- <classpathentry kind="output" path="bin"/>\r
-</classpath>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
</activity>
<activity android:name="MapMode">
<intent-filter>
- <action android:name="RunningRecord" />
+ <action android:name="NewRunningRecord" />
</intent-filter>
</activity>
<activity android:name="Config"></activity>
android:layout_width="fill_parent"
android:textColor="#7CFC00"
- android:layout_height="50dp">
+ android:layout_height="72dp">
</TextView>
<string name="contextmenu_deletethis">Delete this</string>
<string name="contextmenu_deleteall">Delete all</string>
+ <string name="contextmenu_save_gpx">Save as GPX file</string>
<string name="dialog_save_title">Save record</string>
<string name="dialog_save_message">Do you want to save the current record?</string>
import android.view.Menu;\r
\r
public class Constants {\r
- public static final int MENU_STOPWATCH = Menu.FIRST + 1;\r
- public static final int MENU_MAP = Menu.FIRST + 2;\r
- public static final int MENU_SETTING = Menu.FIRST + 3;\r
- public static final int MENU_SAVE = Menu.FIRST + 4;\r
- public static final int MENU_HISTORY = Menu.FIRST + 5;\r
+ public static final int MENU_SETTING = Menu.FIRST + 1;\r
+ public static final int MENU_HISTORY = Menu.FIRST + 2;\r
\r
- public static final int DIALOG_SAVE_ID = 4000;\r
public static final int DIALOG_EXIT_ID = 4001;\r
\r
public static final int REQUEST_CODE_SETTINGS = 1000;\r
private List<Overlay> m_mapOverlays;\r
private SplitPoints m_overlaySplitpoints;\r
private GeoPoint m_prevPoint = null;\r
+ private long m_startTime = 0;\r
\r
public class RunningRoute extends Overlay {\r
\r
\r
@Override\r
protected OverlayItem createItem(int idx) {\r
- Log.d(this.getClass().getName(), "createItem(): index: " + idx);\r
+// Log.d(this.getClass().getName(), "createItem(): index: " + idx);\r
return m_splitpoints.get(idx);\r
}\r
\r
+ public void clearItem() {\r
+ m_splitpoints.clear();\r
+ }\r
+ \r
@Override\r
public int size() {\r
return m_splitpoints.size();\r
private BroadcastReceiver m_runningRecordReceiver = new BroadcastReceiver() {\r
@Override\r
public void onReceive(Context context, Intent intent) {\r
- long recordDate = intent.getLongExtra("RunningRecord", 0);\r
+ String action = intent.getAction();\r
+ if (action.equals("NewRunningRecord")) {\r
+ long recordDate = intent.getLongExtra("RunningRecord", 0);\r
\r
- Record rec = TokyoRunners.getRecord(recordDate);\r
+ Record rec = TokyoRunners.getRecord(recordDate);\r
\r
- if (rec == null) {\r
- ExLog.put("No record: " + recordDate);\r
- return;\r
- }\r
- GeoPoint gp = new GeoPoint(rec.getLatitudeE6(), rec\r
- .getLongitudeE6());\r
- m_controller.animateTo(gp);\r
-\r
- // Route\r
- if (m_prevPoint != null) {\r
- RunningRoute route = new RunningRoute(m_prevPoint, gp);\r
- m_mapOverlays.add(route);\r
- }\r
- // Split point\r
- if (rec.getName().length() > 0) {\r
- drawSplitPoint(gp, rec.getName(), rec.getDate());\r
- }\r
+ if (rec == null) {\r
+ ExLog.put("No record: " + recordDate);\r
+ return;\r
+ }\r
+ \r
+ GeoPoint gp = new GeoPoint(rec.getLatitudeE6(), rec\r
+ .getLongitudeE6());\r
+ m_controller.animateTo(gp);\r
\r
- m_prevPoint = gp;\r
+ // Route\r
+ if (m_prevPoint != null) {\r
+ RunningRoute route = new RunningRoute(m_prevPoint, gp);\r
+ m_mapOverlays.add(route);\r
+ }\r
+ // Split point\r
+ if (rec.getName().length() > 0) {\r
+ drawSplitPoint(gp, rec.getName(), rec.getDate());\r
+ }\r
+ m_prevPoint = gp;\r
+ }\r
\r
}\r
};\r
Log.d(this.getClass().getName(), "onResume()");\r
super.onResume();\r
IntentFilter filter = new IntentFilter();\r
- filter.addAction("RunningRecord");\r
+ filter.addAction("NewRunningRecord");\r
\r
registerReceiver(m_runningRecordReceiver, filter);\r
\r
+ // 履歴が読み込まれた場合は再描画\r
+ Record rec = TokyoRunners.getRecord(m_startTime);\r
+ if (rec == null) {\r
+ MapView mapView = (MapView) findViewById(R.id.mapview);\r
+ drawOverlays(mapView);\r
+ }\r
+\r
+\r
}\r
\r
@Override\r
\r
setContentView(R.layout.map);\r
\r
- SharedPreferences prefs = PreferenceManager\r
- .getDefaultSharedPreferences(this);\r
-\r
- MapView m = (MapView) findViewById(R.id.mapview);\r
- m.setBuiltInZoomControls(true);\r
+ MapView mapView = (MapView) findViewById(R.id.mapview);\r
+ mapView.setBuiltInZoomControls(true);\r
\r
- m_controller = m.getController();\r
+ m_controller = mapView.getController();\r
m_controller.setZoom(16);\r
\r
- m_mapOverlays = m.getOverlays();\r
+ m_mapOverlays = mapView.getOverlays();\r
\r
Drawable runner = getResources().getDrawable(R.drawable.runner);\r
m_overlaySplitpoints = new SplitPoints(runner);\r
\r
- MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, m);\r
+ drawOverlays(mapView);\r
+ }\r
+ \r
+ private void drawOverlays(MapView mapView) {\r
+ \r
+ m_mapOverlays.clear();\r
+ \r
+ MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);\r
myLocationOverlay.enableMyLocation();\r
\r
m_mapOverlays.add(myLocationOverlay);\r
\r
- m.setOnLongClickListener(new OnLongClickListener() {\r
- @Override\r
- public boolean onLongClick(View v) {\r
- Log.d(this.getClass().getName(), "onLongClick():");\r
- finish();\r
- return false;\r
- }\r
- });\r
-\r
+ m_overlaySplitpoints.clearItem();\r
+ \r
long recTime = 0;\r
Record rec;\r
while ((rec = TokyoRunners.getNextRecord(recTime)) != null) {\r
}\r
}\r
recTime = rec.getDate().getTime();\r
+ if (m_startTime == 0) {\r
+ m_startTime = recTime;\r
+ }\r
}\r
+ \r
}\r
\r
private void drawSplitPoint(GeoPoint gp, String pointName, Date recDate) {\r
}\r
\r
@Override\r
- public boolean onPrepareOptionsMenu(Menu menu) {\r
- menu.removeItem(Constants.MENU_SAVE);\r
- menu.removeItem(Constants.MENU_HISTORY);\r
-\r
- return super.onPrepareOptionsMenu(menu);\r
- }\r
-\r
- @Override\r
public boolean onOptionsItemSelected(MenuItem item) {\r
Intent intent;\r
switch (item.getItemId()) {\r
package net.kazhik.android.tokyorunners;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
private static final int MENU_DELETE_THIS = Menu.FIRST + 200;
private static final int MENU_DELETE_ALL = Menu.FIRST + 201;
+ private static final int MENU_SAVE_GPX = Menu.FIRST + 202;
+
+ private final static String LOGDIR = Environment
+ .getExternalStorageDirectory().getPath()
+ + "/tokyorunners/";
@Override
public void onCreate(Bundle savedInstanceState) {
String sortOrder = RunningRecordProvider.CURRENT_TIME + " desc";
Cursor cursor = managedQuery(RunningRecordProvider.REC_URI, columns, null, null, sortOrder);
- if (cursor == null) {
+ if (cursor == null || cursor.getCount() == 0) {
return;
}
ArrayList<String> history = new ArrayList<String>();
while (cursor.moveToNext()) {
startTime = cursor.getLong(0);
distance = (float)cursor.getLong(1);
+// Log.d(this.getClass().getName(), "startTime:" + startTime + "; distance:" + distance);
+
if (startTime == prevStartTime) {
// I need "select distinct"!
continue;
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, MENU_DELETE_THIS, 0, R.string.contextmenu_deletethis);
menu.add(0, MENU_DELETE_ALL, 0, R.string.contextmenu_deleteall);
+ menu.add(0, MENU_SAVE_GPX, 0, R.string.contextmenu_save_gpx);
}
public boolean onContextItemSelected(MenuItem item) {
- AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
- ArrayAdapter<String> historyArray = (ArrayAdapter<String>)getListAdapter();
- int position = info.position;
+ AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
+ .getMenuInfo();
+ ArrayAdapter<String> historyArray = (ArrayAdapter<String>) getListAdapter();
+ int position = info.position;
+ String[] splitStr = historyArray.getItem(position).split(" ");
+ String dateStr = splitStr[0] + " " + splitStr[1];
+ long startTime = 0;
+ try {
+ startTime = m_startTimeFormatter.parse(dateStr).getTime();
+ startTime = m_startTimeMap.get(startTime);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
switch (item.getItemId()) {
case MENU_DELETE_THIS:
- try {
- String[] splitStr = historyArray.getItem(position).split(" ");
- String dateStr = splitStr[0] + " " + splitStr[1];
- Date startTime = m_startTimeFormatter.parse(dateStr);
-
- String selection = RunningRecordProvider.START_TIME + " = ?";
- String[] selectionArgs = {Long.toString(startTime.getTime())};
-
- getContentResolver().delete(RunningRecordProvider.REC_URI, selection, selectionArgs);
-
- historyArray.remove(historyArray.getItem(position));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return true;
+
+ String selection = RunningRecordProvider.START_TIME + " = ?";
+ String[] selectionArgs = { Long.toString(startTime) };
+
+ getContentResolver().delete(RunningRecordProvider.REC_URI,
+ selection, selectionArgs);
+
+ historyArray.remove(historyArray.getItem(position));
+ break;
case MENU_DELETE_ALL:
- getContentResolver().delete(RunningRecordProvider.REC_URI, null, null);
+ getContentResolver().delete(RunningRecordProvider.REC_URI, null,
+ null);
historyArray.clear();
- return true;
+ break;
+ case MENU_SAVE_GPX:
+ saveRecordAsGpxFile(startTime);
+ break;
default:
- return super.onContextItemSelected(item);
+ break;
+ }
+ return super.onContextItemSelected(item);
+ }
+
+ private void saveRecordAsGpxFile(long startTime) {
+ String[] columns = { RunningRecordProvider.CURRENT_TIME,
+ RunningRecordProvider.LATITUDE,
+ RunningRecordProvider.LONGITUDE,
+ RunningRecordProvider.POINT_NAME };
+ String selection = RunningRecordProvider.START_TIME + " = ?";
+ String[] selectionArgs = { Long.toString(startTime) };
+ String sortOrder = RunningRecordProvider.CURRENT_TIME + " asc";
+ Cursor cursor = managedQuery(RunningRecordProvider.REC_URI, columns,
+ selection, selectionArgs, sortOrder);
+ if (cursor == null) {
+ return;
+ }
+
+ SimpleDateFormat formatter = new SimpleDateFormat(
+ "yyyy-MM-dd_HH_mm_ss");
+ String gpxFilePath = LOGDIR + formatter.format(new Date(startTime)) + ".xml";
+ FileOutputStream gpxFile = null;
+ OutputStreamWriter stWriter = null;
+ try {
+ gpxFile = new FileOutputStream(gpxFilePath);
+ stWriter = new OutputStreamWriter(gpxFile);
+ stWriter
+ .write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<gpx\n"
+ + " version=\"1.0\"\n"
+ + "creator=\"Tokyo Runners\"\n"
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ + "xmlns=\"http://www.topografix.com/GPX/1/0\"\n"
+ + "xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">\n");
+
+ stWriter.write("<trk>\n" + "<trkseg>\n");
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
+
+ long currentTime = 0;
+ int latitude = 0;
+ int longitude = 0;
+ String pointName = "";
+
+ while (cursor.moveToNext()) {
+ currentTime = cursor.getLong(cursor
+ .getColumnIndex(RunningRecordProvider.CURRENT_TIME));
+ latitude = cursor.getInt(cursor
+ .getColumnIndex(RunningRecordProvider.LATITUDE));
+ longitude = cursor.getInt(cursor
+ .getColumnIndex(RunningRecordProvider.LONGITUDE));
+ pointName = cursor.getString(cursor
+ .getColumnIndex(RunningRecordProvider.POINT_NAME));
+
+ stWriter.write("<trkpt lat=\"" + (((float)latitude) / 1E6)
+ + "\" lon=\"" + (((float)longitude) / 1E6) + "\">\n" + "<time>"
+ + dateFormat.format(currentTime) + "T"
+ + timeFormat.format(currentTime) + "Z</time>\n"
+ + "<speed>" + 0 + "</speed>\n" + "<name>"
+ + pointName + "</name>\n" + "<fix>none</fix>\n"
+ + "</trkpt>\n");
+
+ }
+
+ stWriter.write("</trkseg>\n" + "</trk>\n" + "</gpx>\n");
+ stWriter.flush();
+
+ } catch (IOException e) {
+ } finally {
+ try {
+ if (stWriter != null) {
+ stWriter.close();
+ }
+ if (gpxFile != null) {
+ gpxFile.close();
+ }
+ } catch (IOException e) {
+ }
}
}
\r
import android.content.ContentResolver;\r
import android.content.ContentValues;\r
+import android.database.Cursor;\r
import android.location.Location;\r
import android.util.Log;\r
\r
private Location m_prevLocation = null;\r
private int m_splitInterval = 0;\r
private int m_lastSplit = 0;\r
+ private long m_startTime = 0;\r
private String m_distanceUnit = "km";\r
private ContentResolver m_contentResolver;\r
\r
public RunningRecord(ContentResolver contentResolver) {\r
m_contentResolver = contentResolver;\r
}\r
- public String addRecord(Date date, Location loc, String pointName) {\r
- if (loc != null) {\r
- Log.d(this.getClass().getName(), "Latitude:" + loc.getLatitude() + "; Longitude:" + loc.getLongitude());\r
- }\r
- \r
+ public String addRecord(Date date, Location loc, String pointName, boolean persistent) {\r
+ // これまでの走行距離を計算\r
if (m_prevLocation != null && loc != null) {\r
+ float distance = m_prevLocation.distanceTo(loc);\r
+ Log.d(this.getClass().getName(), "distance: " + distance);\r
m_distance += m_prevLocation.distanceTo(loc);\r
+ } else {\r
+ m_startTime = date.getTime();\r
}\r
+ m_prevLocation = loc;\r
\r
+ // スプリットポイントを通過した場合 \r
if (m_splitInterval > 0 && m_distance > m_lastSplit + m_splitInterval && pointName.length() == 0 ) {\r
pointName = getDistanceString() + m_distanceUnit;\r
m_lastSplit += m_splitInterval;\r
}\r
\r
- Record newRecord = new Record(date, loc, pointName);\r
+ // リストに記録を保持\r
+ Record newRecord = new Record(date, loc, m_distance, pointName);\r
m_recordList.add(newRecord);\r
\r
- m_prevLocation = loc;\r
+ // データベースに記録を保存\r
+ if (persistent) {\r
+ ContentValues values = new ContentValues();\r
+ values.put(RunningRecordProvider.START_TIME, m_startTime);\r
+ values.put(RunningRecordProvider.CURRENT_TIME, date.getTime());\r
+ values.put(RunningRecordProvider.POINT_NAME, pointName);\r
+ values.put(RunningRecordProvider.DISTANCE, (int)m_distance);\r
+ values.put(RunningRecordProvider.LATITUDE, newRecord.getLatitudeE6());\r
+ values.put(RunningRecordProvider.LONGITUDE, newRecord.getLongitudeE6());\r
+ \r
+ try {\r
+ m_contentResolver.insert(RunningRecordProvider.REC_URI, values);\r
+ } catch (IllegalArgumentException e) {\r
+ Log.e(this.getClass().getName(), e.getMessage());\r
+ }\r
+ \r
+ }\r
\r
return pointName;\r
+ \r
+ }\r
+ public String addRecord(Date date, Location loc, String pointName) {\r
+ return addRecord(date, loc, pointName, true);\r
}\r
public Location getPrevLocation() {\r
return m_prevLocation;\r
m_distance = 0;\r
m_lastSplit = 0;\r
m_prevLocation = null;\r
+ m_startTime = 0;\r
m_recordList.clear();\r
}\r
\r
}\r
\r
public String getDistanceString() {\r
+ // メートル以下を切り捨ててからキロメートルに変換\r
int distance_m = (int)m_distance;\r
return Float.toString((float)distance_m / 1000);\r
}\r
\r
}\r
public void save() {\r
- long startTime = m_recordList.get(0).getTime();\r
- Location prevLocation = null;\r
- int distance = 0;\r
\r
+ if (saved(m_startTime) == true) {\r
+ return;\r
+ }\r
+ \r
for (Iterator<Record> it = m_recordList.iterator(); it.hasNext();) {\r
Record rec = (Record)it.next();\r
ContentValues values = new ContentValues();\r
- values.put(RunningRecordProvider.START_TIME, startTime);\r
+ values.put(RunningRecordProvider.START_TIME, m_startTime);\r
values.put(RunningRecordProvider.CURRENT_TIME, rec.getTime());\r
values.put(RunningRecordProvider.POINT_NAME, rec.getName());\r
- if (rec.hasLocation()) {\r
- if (prevLocation != null) {\r
- distance += prevLocation.distanceTo(rec.getLocation());\r
- }\r
- values.put(RunningRecordProvider.DISTANCE, distance);\r
- }\r
+ values.put(RunningRecordProvider.DISTANCE, (int)rec.getDistance());\r
values.put(RunningRecordProvider.LATITUDE, rec.getLatitudeE6());\r
values.put(RunningRecordProvider.LONGITUDE, rec.getLongitudeE6());\r
\r
}\r
}\r
\r
+ private boolean saved(long startTime) {\r
+ String[] columns = { RunningRecordProvider.CURRENT_TIME };\r
+ String selection = RunningRecordProvider.START_TIME + " = ?";\r
+ String[] selectionArgs = { Long.toString(startTime) };\r
+ Cursor cursor = m_contentResolver.query(RunningRecordProvider.REC_URI, columns,\r
+ selection, selectionArgs, null);\r
+ \r
+ return (cursor != null && cursor.getCount() > 0);\r
+ \r
+ }\r
+ \r
}\r
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();\r
qb.setTables(TABLE_NAME);\r
Cursor c = qb.query(db, projection, selection, selectionArgs, null,\r
- null, null);\r
+ null, sortOrder);\r
return c;\r
}\r
\r
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.pm.ActivityInfo;
-import android.content.res.Resources;
import android.database.Cursor;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
-import android.os.Debug;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.format.DateUtils;
RunningRecordProvider.POINT_NAME };
String selection = RunningRecordProvider.START_TIME + " = ?";
String[] selectionArgs = { Long.toString(startTime) };
- String sortOrder = RunningRecordProvider.CURRENT_TIME + " desc";
+ String sortOrder = RunningRecordProvider.CURRENT_TIME + " asc";
Cursor cursor = managedQuery(RunningRecordProvider.REC_URI, columns,
selection, selectionArgs, sortOrder);
if (cursor == null) {
return;
}
+
+ Log.d(this.getClass().getName(), "row count:" + cursor.getCount());
reset();
+
ListView listLaptime = (ListView) findViewById(R.id.lap_history);
ArrayAdapter<String> lapHistory = (ArrayAdapter<String>) listLaptime
.getAdapter();
loc.setLatitude((double) (latitude / 1E6));
loc.setLongitude((double) (longitude / 1E6));
}
- m_runningRecord.addRecord(new Date(currentTime), loc, pointName);
+ m_runningRecord.addRecord(new Date(currentTime), loc, pointName, false);
+
if (pointName.length() == 0) {
} else if (currentTime != startTime) {
StringBuffer strBuff = new StringBuffer();
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(Menu.NONE, Constants.MENU_SAVE, Menu.NONE, R.string.menu_save)
- .setIcon(android.R.drawable.ic_menu_save);
menu.add(Menu.NONE, Constants.MENU_HISTORY, Menu.NONE,
R.string.menu_history).setIcon(R.drawable.history2);
menu.add(Menu.NONE, Constants.MENU_SETTING, Menu.NONE,
R.string.menu_setting).setIcon(
android.R.drawable.ic_menu_preferences);
-
return super.onCreateOptionsMenu(menu);
}
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ boolean enabled;
+ if (getTabHost().getCurrentTabTag().equals("stopwatch")) {
+ enabled = !m_running;
+ } else {
+ enabled = false;
+ }
+ menu.findItem(Constants.MENU_HISTORY).setEnabled(enabled);
+
+ return super.onPrepareOptionsMenu(menu);
+ }
@Override
public Dialog onCreateDialog(int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
switch (id) {
- case Constants.DIALOG_SAVE_ID:
- builder.setTitle(R.string.dialog_save_title);
- builder.setMessage(R.string.dialog_save_message);
- builder.setPositiveButton(R.string.dialog_yes,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- saveRecord();
-
- }
- });
- builder.setNegativeButton(R.string.dialog_no,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
-
- }
- });
-
- break;
case Constants.DIALOG_EXIT_ID:
builder.setTitle(R.string.dialog_exit_title);
builder.setMessage(R.string.dialog_exit_message);
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
- case Constants.MENU_SAVE:
- showDialog(Constants.DIALOG_SAVE_ID);
- break;
case Constants.MENU_HISTORY:
intent = new Intent(this, RunningHistory.class);
intent.setAction(Intent.ACTION_VIEW);
distanceView.setText(m_runningRecord.getDistanceString());
// MapModeに通知
- Intent intent = new Intent("RunningRecord");
+ Intent intent = new Intent("NewRunningRecord");
intent.putExtra("RunningRecord", location.getTime());
sendBroadcast(intent);
}
private void reset() {
+ m_runningRecord.clearRecord();
+
long elapsedRealTime = SystemClock.elapsedRealtime();
m_elapsedTime.setBase(elapsedRealTime);
m_lapTime.setBase(elapsedRealTime);
+ // 距離
+ TextView distanceView = (TextView) findViewById(R.id.distance);
+ distanceView.setText(m_runningRecord.getDistanceString());
+
ListView listLaptime = (ListView) findViewById(R.id.lap_history);
ArrayAdapter<String> lapHistory = (ArrayAdapter<String>) listLaptime
.getAdapter();
lapHistory.clear();
- m_runningRecord.clearRecord();
}
private String calculateSplitAndLap() {
}
- private void saveRecord() {
- if (m_running) {
- return;
- }
- m_runningRecord.save();
-
- }
-
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- Log.d(this.getClass().getName(), "dispatchKeyEvent():"
- + event.toString());
- /*
- * if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER &&
- * event.getAction() == KeyEvent.ACTION_DOWN) { if (m_running == true) {
- * stop(); } else { start(); } }
- */
return super.dispatchKeyEvent(event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- Log.d(this.getClass().getName(), "onKeyDown():" + keyCode);
if (keyCode == KeyEvent.KEYCODE_BACK) {
showDialog(Constants.DIALOG_EXIT_ID);
return true;