-package net.osdn.gokigen.joggingtimer.presentation.ui.list
+package net.osdn.gokigen.joggingtimer
data class ResultListData(val indexId: Long, val title: String, val memo: String, val iconId: Int, val startTime: Long, val duration: Long)
import android.content.Context
import android.text.format.DateFormat
+import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.Text
import androidx.wear.compose.material.TimeText
import androidx.wear.compose.material.TimeTextDefaults
+import net.osdn.gokigen.joggingtimer.AppSingleton
import net.osdn.gokigen.joggingtimer.R
import java.util.Locale
@Composable
fun DetailRecordScreen(context: Context, navController: NavHostController, id: Int)
{
+ val dataItem = AppSingleton.controller.getRecordItem(id)
+ val lapTimeList = AppSingleton.controller.getLapTimeList(id)
+ val lapCount = if (lapTimeList.isEmpty()) { 0 } else if (lapTimeList.size < 2) { 0 } else { lapTimeList.size - 1 }
+
Scaffold(
timeText = {
TimeText(
)
},
) {
- Column(
- modifier = Modifier
- .fillMaxSize()
- .padding(
- PaddingValues(
- top = 25.dp
- )
- ),
- //verticalArrangement = Arrangement.Center,
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- Text(
- modifier = Modifier.fillMaxWidth(),
- textAlign = TextAlign.Center,
- color = MaterialTheme.colors.primary,
- fontSize = 12.sp,
- text = "${stringResource(R.string.result_detail)} : $id "
- )
+ if ((dataItem.indexId <= 0)||(lapTimeList.isEmpty()))
+ {
+ // 「詳細データの取得に失敗」を表示する
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(
+ PaddingValues(
+ top = 25.dp
+ )
+ ),
+ verticalArrangement = Arrangement.Center,
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Text(
+ modifier = Modifier.fillMaxWidth(),
+ textAlign = TextAlign.Center,
+ color = MaterialTheme.colors.primary,
+ fontSize = 14.sp,
+ text = stringResource(R.string.failed_to_get_details)
+ )
+ }
+
+ }
+ else
+ {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(
+ PaddingValues(
+ top = 30.dp
+ )
+ ),
+ //verticalArrangement = Arrangement.Center,
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Text(
+ modifier = Modifier.fillMaxWidth(),
+ textAlign = TextAlign.Center,
+ color = Color.White,
+ fontSize = 12.sp,
+ text = stringResource(id = R.string.result_detail)
+ )
+ Text(
+ modifier = Modifier.fillMaxWidth(),
+ textAlign = TextAlign.Center,
+ color = MaterialTheme.colors.primary,
+ fontSize = 12.sp,
+ text = dataItem.title
+ )
+ Text(
+ modifier = Modifier.fillMaxWidth(),
+ textAlign = TextAlign.Center,
+ color = MaterialTheme.colors.primary,
+ fontSize = 10.sp,
+ text = "Lap : $lapCount"
+ )
+ }
}
}
}
-package net.osdn.gokigen.joggingtimer.presentation.ui.list
+package net.osdn.gokigen.joggingtimer.presentation.ui.detail
-import androidx.compose.foundation.focusable
-import androidx.compose.foundation.gestures.scrollBy
import androidx.compose.foundation.layout.Arrangement
-import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.input.rotary.onRotaryScrollEvent
-import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.items
-import androidx.wear.compose.material.MaterialTheme
-import androidx.wear.compose.material.Text
-import kotlinx.coroutines.launch
-import net.osdn.gokigen.joggingtimer.AppSingleton
-import net.osdn.gokigen.joggingtimer.R
+import net.osdn.gokigen.joggingtimer.ResultListData
+import net.osdn.gokigen.joggingtimer.presentation.ui.list.ResultListItem
@Composable
-fun ResultList(navController: NavHostController, recordList: List<ResultListData>)
+fun RecordDetailList(navController: NavHostController, recordList: List<ResultListData>)
{
ScalingLazyColumn(
modifier = Modifier
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.Icon
import androidx.wear.compose.material.Text
+import net.osdn.gokigen.joggingtimer.ResultListData
import net.osdn.gokigen.joggingtimer.utilities.IconIdProvider
import net.osdn.ja.gokigen.wearos.timerapp.counter.TimeStringConvert
Text(
text = dataItem.title,
fontSize = 12.sp,
- //maxLines = 3,
overflow = TextOverflow.Ellipsis
)
},
enabled = true,
) {
Icon(
- painter = painterResource(id = R.drawable.baseline_list_24),
+ painter = painterResource(id = R.drawable.baseline_post_add_24),
contentDescription = "CreateReference",
tint = Color.White
)
package net.osdn.gokigen.joggingtimer.stopwatch
import androidx.activity.ComponentActivity
-import net.osdn.gokigen.joggingtimer.presentation.ui.list.ResultListData
+import net.osdn.gokigen.joggingtimer.ResultListData
/**
*
fun setReferenceTimerSelection(id: Int)
fun setupReferenceData()
fun getCounterRecordList(): List<ResultListData>
+ fun getRecordItem(id: Int): ResultListData
+ fun getLapTimeList(id: Int): List<Long>
fun launchNotify(isShow: Boolean)
import net.osdn.gokigen.joggingtimer.MainActivity
import net.osdn.gokigen.joggingtimer.MainActivity.Companion.CHANNEL_ID
import net.osdn.gokigen.joggingtimer.R
-import net.osdn.gokigen.joggingtimer.presentation.ui.list.ResultListData
+import net.osdn.gokigen.joggingtimer.ResultListData
import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabase
import net.osdn.gokigen.joggingtimer.storage.ITimeEntryDatabaseCallback
import net.osdn.gokigen.joggingtimer.storage.TimeEntryDatabaseFactory
val startTime = cursor.getLong(startTimeNumber)
val durationTime = cursor.getLong(durationNumber)
- Log.v(TAG, " Record ($indexId, $title, $memo, $iconId : [$startTime][$durationTime])")
+ //Log.v(TAG, " Record ($indexId, $title, $memo, $iconId : [$startTime][$durationTime])")
recordList.add(ResultListData(indexId, title, memo, iconId, startTime, durationTime))
}
return (recordList)
}
+ override fun getRecordItem(id: Int): ResultListData
+ {
+ try
+ {
+ //Log.v(TAG, " GET Record ($id)")
+ val cursor = database?.getIndexdata(id.toLong())
+ if (cursor != null)
+ {
+ while (cursor.moveToNext())
+ {
+ val indexIdNumber = cursor.getColumnIndex(TimeEntryIndex.EntryIndex._ID)
+ val titleNumber =
+ cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_TITLE)
+ val memoNumber =
+ cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_MEMO)
+ val iconIdNumber =
+ cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_ICON_ID)
+ val startTimeNumber =
+ cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_START_TIME)
+ val durationNumber =
+ cursor.getColumnIndex(TimeEntryIndex.EntryIndex.COLUMN_NAME_TIME_DURATION)
+
+ val indexId = cursor.getLong(indexIdNumber)
+ val title = cursor.getString(titleNumber)
+ val memo = cursor.getString(memoNumber)
+ val iconId = cursor.getInt(iconIdNumber)
+ val startTime = cursor.getLong(startTimeNumber)
+ val durationTime = cursor.getLong(durationNumber)
+ return (ResultListData(indexId, title, memo, iconId, startTime, durationTime))
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (ResultListData(indexId = -1, title = "", memo = "", iconId = 0, startTime = 0, duration = 0))
+ }
+
+ override fun getLapTimeList(id: Int): List<Long>
+ {
+ val lapTimeList = ArrayList<Long>()
+ try
+ {
+ val cursor = database?.getAllDetailData(id.toLong())
+ if (cursor != null)
+ {
+ while (cursor.moveToNext())
+ {
+ val lapTimeId = cursor.getColumnIndex(TimeEntryData.EntryData.COLUMN_NAME_TIME_ENTRY)
+ val lapTime = cursor.getLong(lapTimeId)
+ lapTimeList.add(lapTime)
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (lapTimeList)
+ }
+
@SuppressLint("Range")
private fun loadReferenceData()
{
--- /dev/null
+<vector android:height="24dp" android:tint="#EEEEEE"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M17,19.22H5V7h7V5H5C3.9,5 3,5.9 3,7v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2v-7h-2V19.22z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M19,2h-2v3h-3c0.01,0.01 0,2 0,2h3v2.99c0.01,0.01 2,0 2,0V7h3V5h-3V2z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M7,9h8v2h-8z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M7,12l0,2l8,0l0,-2l-3,0z"/>
+ <path android:fillColor="@android:color/white" android:pathData="M7,15h8v2h-8z"/>
+</vector>
<string name="channel_description">Running</string>
<string name="record_data_empty">記録データはありません。</string>
<string name="notification_description">計測中</string>
+ <string name="failed_to_get_details">記録データの取得に失敗しました。</string>
</resources>
\ No newline at end of file
<string name="channel_description">Running</string>
<string name="record_data_empty">Record data is none.</string>
<string name="notification_description">Timer active</string>
+ <string name="failed_to_get_details">Failed to get details.</string>
</resources>