1.简介
本应用可以用来记录各时间节点,整体逻辑偏向简单
运用线程和广播可实现与其他功能的互动,本篇中不加以解释。
2.页面展示
初始页面
在初始页面下,三个按钮分别为暂停,继续/开始,结束
启动功能
当我们点下开始按钮后,钟表内部数字开始进行跳动
暂停功能
当我们点下结束按钮后,钟表内部数字清零,并且在下方留下时间节点
每个时间节点编号会自动增加
多条数据存储
当我们多次记录时间节点后,下方会有一个list容器存放各条数据
删除功能
每条记录旁边都会有一个减号按钮,它是用来删除本条记录的,如图所示,我们删除了第10条记录
3.页面代码
1.时钟页面
//最上方文字
<DirectionalLayout
ohos:height="50fp"
ohos:width="match_parent"
ohos:alignment="center">
<Text
ohos:height="match_content"
ohos:width="match_content"
ohos:text="专注计时"
ohos:text_color="#000000"
ohos:text_size="25fp"/>
</DirectionalLayout>
//中间部位的时钟和时间数字
<DirectionalLayout
ohos:height="300fp"
ohos:width="300fp"
ohos:alignment="center"
ohos:background_element="$media:clock"
ohos:layout_alignment="horizontal_center">
<Text
ohos:height="match_content"
ohos:width="match_content"
ohos:alignment="center"
ohos:text="00 : 00 : 00"
ohos:text_color="#000000"
ohos:text_size="50fp"/>
</DirectionalLayout>
//三个功能按钮
<DirectionalLayout
ohos:height="match_content"
ohos:width="match_parent"
ohos:alignment="center"
ohos:bottom_margin="10fp"
ohos:orientation="horizontal"
ohos:top_margin="10fp">
<Image
ohos:id="$+id:cancelTimeImage"
ohos:height="match_content"
ohos:width="50fp"
ohos:end_margin="60fp"
ohos:image_src="$media:cancel_time"/>
<Image
ohos:id="$+id:resumeTimeImage"
ohos:height="match_content"
ohos:width="50fp"
ohos:image_src="$media:resume_time"/>
<Image
ohos:id="$+id:completeTimeImage"
ohos:height="match_content"
ohos:width="60fp"
ohos:image_src="$media:complete_time"
ohos:start_margin="60fp"/>
</DirectionalLayout>
// list
<ListContainer
ohos:id="$+id:timeListView"
ohos:height="match_content"
ohos:width="match_parent"/>
2.item代码
<Text
ohos:id="$+id:itemTimeText"
ohos:height="match_content"
ohos:width="match_content"
ohos:text="TextView"
ohos:text_color="#000000"
ohos:text_size="20fp"/>
<Text
ohos:id="$+id:itemTimeDate"
ohos:height="match_content"
ohos:width="match_content"
ohos:align_parent_end="true"
ohos:right_margin="35fp"
ohos:text="TextView"
ohos:text_alignment="vertical_center|horizontal_center"
ohos:text_size="15fp"/>
<Image
ohos:id="$+id:deleteImage"
ohos:height="30fp"
ohos:width="30fp"
ohos:align_parent_end="true"
ohos:image_src="$media:delete_icon"/>
4.功能代码
在功能实现中,需要频繁对时间进行调整,setInterval很方便就能实现。其他的就是对于时间的动态更新,数据库的增删改查功能。
5.项目心得
项目整体并不庞大,但内部各功能直接的联系比较紧密,需要不断的进行调试,同时也要考虑很多功能方面的问题,比如在时间节点的暂停功能,是否需要考虑不计时也能点击暂停按键;在暂停状态下,是否可以直接点击结束按键;在删除记录时,是否能添加一个批量删除或者一键删除的按钮。整体来看,项目略有瑕疵,能正常运行但带给使用者的体验可能没有那么完美。