itemView.setOnClickListener(listener);
}
+ void setOnLongClickListener(View.OnLongClickListener listener)
+ {
+ itemView.setOnLongClickListener(listener);
+ }
+
void setLapCount(String message)
{
lapView.setText(message);
import android.util.Log;
import android.view.View;
+import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabase;
+import net.osdn.gokigen.joggingtimer.utilities.TimeStringConvert;
+
/**
*
*
public class DetailRecord implements View.OnClickListener, View.OnLongClickListener
{
private final String TAG = toString();
+ private final long indexId;
private final long dataId;
private final int recordType;
- private String lapCount;
- private String title;
- private String detail;
+ private final int lapCount;
+ private final IDetailEditor editorLauncher;
+ private long lapTime;
+ private long overallTime;
+ private long differenceTime;
/**
*
*/
- DetailRecord(long dataId, int recordType, String lapCount, String title, String detail)
+ DetailRecord(long indexId, long dataId, int recordType, int lapCount, long lapTime, long overallTime, long differenceTime, IDetailEditor editorLauncher)
{
+ this.indexId = indexId;
this.dataId = dataId;
this.recordType = recordType;
this.lapCount = lapCount;
- this.title = title;
- this.detail = detail;
+ this.lapTime = lapTime;
+ this.overallTime = overallTime;
+ this.differenceTime = differenceTime;
+ this.editorLauncher = editorLauncher;
}
String getLapCount()
{
- return (lapCount);
+ return ("" + lapCount);
}
String getTitle()
{
- return (title);
+ return (TimeStringConvert.getTimeString(lapTime).toString());
}
String getDetail()
{
- return (detail);
+ return (TimeStringConvert.getTimeString(overallTime).toString() + " (" + TimeStringConvert.getDiffTimeString(differenceTime).toString() +") ");
}
@Override
public void onClick(View v)
{
- Log.v(TAG, "Clicked : [" + dataId + "] (" + lapCount + ") " + title + " " + detail);
-
+ Log.v(TAG, "Clicked : [" + dataId + "] (" + lapCount + ") " + getTitle() + " " + getDetail());
}
@Override
public boolean onLongClick(View v)
{
- Log.v(TAG, "LONG Clicked : [" + dataId + "] (" + lapCount + ") " + title + " " + detail + " TYPE : " + recordType);
+ Log.v(TAG, "LONG Clicked : [" + dataId + "] (" + lapCount + ") " + getTitle() + " " + getDetail() + " TYPE : " + recordType);
+ if (recordType == ITimeEntryDatabase.EDITABLE_RECORD_TYPE)
+ {
+ // Edit Laptime Record...
+ editorLauncher.editDetailData(indexId, dataId, lapCount, lapTime);
+ }
return (false);
}
}
--- /dev/null
+package net.osdn.gokigen.joggingtimer.recorddetail;
+
+public interface IDetailEditor
+{
+ void editDetailData(long indexId, long dataId, int count, long defaultMillis);
+
+}
holder.setMainText(list.get(position).getTitle());
holder.setSubText(list.get(position).getDetail());
holder.setOnClickListener(list.get(position));
+ holder.setOnLongClickListener(list.get(position));
}
catch (Exception e)
{
import android.support.wearable.activity.WearableActivity;
import android.util.Log;
+import net.osdn.gokigen.joggingtimer.R;
import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabase;
import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabaseCallback;
import net.osdn.gokigen.joggingtimer.storage.TimeEntryDatabaseFactory;
*
*
*/
-public class RecordDetailSetup implements ITimeEntryDatabaseCallback
+public class RecordDetailSetup implements ITimeEntryDatabaseCallback, IDetailEditor
{
private final String TAG = toString();
private final WearableActivity activity;
callback.databaseSetupFinished(false);
return;
}
+ final IDetailEditor editor = this;
Thread thread = new Thread(new Runnable() {
@Override
public void run()
while (cursor.moveToNext())
{
long dataId = cursor.getLong(cursor.getColumnIndex(_ID));
+ long indexId = cursor.getLong(cursor.getColumnIndex(TimeEntryData.EntryData.COLUMN_NAME_INDEX_ID));
long entryTime = cursor.getLong(cursor.getColumnIndex(TimeEntryData.EntryData.COLUMN_NAME_TIME_ENTRY));
int recordType = cursor.getInt(cursor.getColumnIndex(TimeEntryData.EntryData.COLUMN_NAME_RECORD_TYPE));
long lapTime = entryTime - previousLapTime;
long overallTime = entryTime - startTime;
long differenceTime = (lapTime) - (previousLapTime - morePreviousTime);
- String lapCount = " " + index;
- String lapTimeString = TimeStringConvert.getTimeString(lapTime).toString();
- String overallTimeString = TimeStringConvert.getTimeString(overallTime).toString() + " (" + TimeStringConvert.getDiffTimeString(differenceTime).toString() +") ";
- operation.addRecord(new DetailRecord(dataId, recordType, lapCount, lapTimeString, overallTimeString));
+ operation.addRecord(new DetailRecord(indexId, dataId, recordType, index, lapTime, overallTime, differenceTime, editor));
morePreviousTime = previousLapTime;
previousLapTime = entryTime;
}
return (new CreateModelData(database));
}
+ @Override
+ public void editDetailData(final long indexId, final long dataId, final int count, final long defaultMillis)
+ {
+ activity.runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ CreateModelDataDialog dialog2 = new CreateModelDataDialog(activity);
+ dialog2.show(false, activity.getString(R.string.information_modify_time), getCreateModelDataCallback(), defaultMillis);
+ }
+ });
+ }
+
/**
*
*/
*/
public interface ITimeEntryDatabase
{
+ static final long DEFAULT_RECORD_TYPE = 0;
+ static final long EDITABLE_RECORD_TYPE = 1;
+
void prepare();
void close();
private static final int REFERENCE_ICON_ID = 2;
private static final int MODEL_DATA_ICON_ID = 4;
private static final int DEFAULT_ICON_ID = 0;
- private static final long DEFAULT_RECORD_TYPE = 0;
- private static final long EDITABLE_RECORD_TYPE = 1;
+
private SQLiteDatabase db = null;
//private SQLiteDatabase writeDb = null;
//private SQLiteDatabase readDb = null;
{
try
{
- database.createTimeEntryModelData(lap, hour, minute, second, "");
+ if (lap > 0)
+ {
+ database.createTimeEntryModelData(lap, hour, minute, second, "");
+ }
+ else
+ {
+ Log.v(TAG, "MODIFIED TO : " + hour + ":" + minute + ":" + second);
+ }
}
catch (Exception e)
{
final NumberPicker hour = alertView.findViewById(R.id.number_picker_hours);
final NumberPicker minute = alertView.findViewById(R.id.number_picker_minutes);
final NumberPicker second = alertView.findViewById(R.id.number_picker_seconds);
+
try
{
if (title != null)
lapStartText.setVisibility(View.GONE);
lapEndText.setVisibility(View.GONE);
}
+
hour.setMinValue(0);
hour.setMaxValue(72);
minute.setMinValue(0);
minute.setMaxValue(59);
second.setMinValue(0);
second.setMaxValue(59);
+ second.setValue((int) (defaultValue / 1000) % 60);
+ minute.setValue((int) ((defaultValue / (1000 * 60)) % 60));
+ hour.setValue((int) ((defaultValue / (1000 * 60 * 60)) % 24));
}
catch (Exception e)
{
try
{
Log.v(TAG, "ENTRY [" + lap.getValue() + "] " + hour.getValue() + ":" + minute.getValue() + ":" + second.getValue());
- callback.dataCreated(lap.getValue(), hour.getValue(), minute.getValue(), second.getValue());
- //callback.dataCreateCancelled();
+ int lapCount = (lap.getVisibility() == View.GONE) ? -1 : lap.getValue();
+ callback.dataCreated(lapCount, hour.getValue(), minute.getValue(), second.getValue());
}
catch (Exception e)
{
<string name="time_picker_minute_separator">:</string>
<string name="time_picker_second_separator"> </string>
<string name="information_time_picker">LAPと総時間を入力</string>
+ <string name="information_modify_time">目標ラップタイムを設定</string>
</resources>
\ No newline at end of file
<string name="time_picker_minute_separator">:</string>
<string name="time_picker_second_separator"> </string>
<string name="information_time_picker">Set LAP and total Time</string>
+ <string name="information_modify_time">Set Target LAP Time</string>
</resources>
<string name="time_picker_minute_separator">:</string>
<string name="time_picker_second_separator"> </string>
<string name="information_time_picker">Set LAP and total Time</string>
+ <string name="information_modify_time">Set Target LAP Time</string>
</resources>