引言
在这半周的工作中,我们小组仍然进行后台和客户端的代码编写工作,以及用户界面的优化,具体内容如下:
- 客户端 :修改密码和查看个人信息
- 后台:SuperviseDao的功能实现
- 界面:界面跳转关系与布局的优化
下面做一个详细的介绍。
一、客户端
在这半周中,客户端主要实现了两个功能,修改密码和查看个人信息,下面做一下详细介绍。
1、修改密码
(1)界面编写
在之前的界面设计中,已经完成了该界面的设计工作。根据分析,该界面并不复杂,在最外层使用一个LinearLayout,内部嵌套RelativeLayout或各种组件就可以实现了,部分代码如下所示:
根据编写的代码,生成的预览效果如下所示:
(2)内部逻辑实现
在之前的详细设计中,已经完成了这部分功能的设计。这部分的功能也并不复杂,只需要获取用户输入的原密码,新密码,密码重复,并判断长度是否符合要求,原密码与新密码是否相同,两次密码输入是否一致。通过这些检查之后,再次调用NetUtil类的相应方法,与服务器通信,并将返回的结果反馈给用户就可以了。
部分实现代码如下所示:
2、查看个人信息
(1)界面编写
在之前的界面设计中,已经完成了该界面的设计工作。根据分析,发现该界面与修改密码的界面类似,都不复杂,在最外层使用一个LinearLayout,内部嵌套RelativeLayout或各种组件就可以实现了,部分代码如下所示:
根据编写的代码,生成的预览效果如下所示:
(2)内部逻辑实现
这个界面的功能主要分为两个,一是获取用户的个人信息并显示在界面上,而是当用户点击编辑按钮时跳转到编辑界面。根据之前的详细设计,在跳转到这个界面之前,上一个界面就已经把用户的个人信息放在Intent中。也就是说,在该界面无需再访问服务器了,只需从Intent对象中获取就可。
部分实现代码如下所示:
在两个功能全部完成之后,我们进行了白盒测试,设计了多组测试用例进行测试,直到全部正确通过为止。
二、服务器
本次的主要认为是将SuperviseDao写了出来,共包含以下几个方法,
Invit()方法,invit方法的主要作用就是邀请别人监督自己的目标。当然,因为是创建的时候邀请的,所以邀请的是一个用户数组。
confirmAgreeSupervise(),同意监督
judge() 方法主要是对自己监督的目标做出评价,他首先判断目标是否存在,然后载进行插入,要注意的是,有可能判断目标失败,也有可能判断目标成功,无论如何。首先要写下评语,其次,要检查者这是否是最后一个评价,如果是最后一个评价的话,还有对这个目标是否完成做出评价。
JudgeFlag()这个方法的主要目的就是完成上述方法中的最后一步,评价目标。
getMySuperviseRequest(),这个方法主要是获取我的所欲的监督请求。
applySupervise()这个方法主要是用来申请监督
agreeApplySupervise这个方法主要是用来同意申请监督的请求
disagreeApplySupervise ,和上一个方法类似,这个是用来不同意申请监督的请求。
同时在这里更新了几个模型文件。
三、界面
在界面设计的方面,我们对前几天做的menupath的图标选取进行了修改,以及整体移植到myflag项目。初步移植的过程中遇到过不少问题,最棘手的问题是环境的不匹配与布局的合理性问题。
最重要的布局文件部分代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<carbon.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sat="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/activity_bg_gray"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.example.sdu.myflag.widget.CustomViewPager
android:id="@+id/main_view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/activity_bg_gray"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp">
</com.example.sdu.myflag.widget.CustomViewPager>
<com.example.sdu.myflag.menupath.SatelliteMenu
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_margin="8dp"
sat:satelliteDistance="100dp"
sat:mainImage="@drawable/ic_launcher"
sat:totalSpacingDegree="90"
sat:closeOnClick="true"
sat:expandDuration="500"
tools:layout_editor_absoluteX="0dp"
android:layout_alignParentBottom="true"
tools:layout_editor_absoluteY="444dp">
</com.example.sdu.myflag.menupath.SatelliteMenu>
</RelativeLayout>
<carbon.widget.LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp">
<carbon.widget.LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:onClick="onMainTabClick"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_main_img"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/main_page_default" />
<TextView
android:id="@+id/tab_main_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="首页"
android:textColor="@color/tab_text_color_gray"
android:textSize="14sp" />
</carbon.widget.LinearLayout>
<carbon.widget.LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:onClick="onCommunityTabClick"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_community_img"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/community_default" />
<TextView
android:id="@+id/tab_community_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="社区"
android:textColor="@color/tab_text_color_gray"
android:textSize="14sp" />
</carbon.widget.LinearLayout>
<carbon.widget.LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:onClick="onMySelfTabClick"
android:orientation="vertical">
<ImageView
android:id="@+id/tab_myself_img"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/myself_default" />
<TextView
android:id="@+id/tab_myself_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="我"
android:textColor="@color/tab_text_color_gray"
android:textSize="14sp" />
</carbon.widget.LinearLayout>
</carbon.widget.LinearLayout>
</carbon.widget.LinearLayout>
修改后的效果图如下所示,可以看到,界面美观度得到了明显改善。
总结
这一阶段的过程还算顺利,这得益于之前的工作做得到位,小组成员深刻体会到了前期需求讨论的充分以及花费了大量的时间进行计划的评估和修改,好让我们的开发过程思路清晰明了,遇到的问题也会快速解决。