引言
在这半周的工作中,我们小组仍然进行后台和客户端的代码编写工作,以及用户界面的优化,具体内容如下:
- 客户端 :修改密码和查看个人信息
- 后台:SuperviseDao的功能实现
- 界面:界面跳转关系与布局的优化
下面做一个详细的介绍。
一、客户端
在这半周中,客户端主要实现了两个功能,设置和编辑个人头像,下面做一下详细介绍。
1、设置
(1)界面编写
在之前的界面设计中,已经完成了该界面的设计工作。根据分析,该界面并不复杂,在最外层使用一个LinearLayout,内部嵌套RelativeLayout或各种组件就可以实现了,部分代码如下所示:
生成的预览效果如下所示:
(2)内部逻辑实现
该界面的内部逻辑并不复杂,重点在于处理用户的按钮点击事件。当用户点击不同的按钮时,触发不同的事件进行处理就可以,如启动一个新的Activity。
部分实现代码如下所示:
2、编辑个人头像
在目前版本,用户可以从提供的9个头像中选择一个作为自己的头像,暂不支持用户上传图片作为头像的功能,该功能可以在以后版本中在进行完善。
(1)界面编写
在之前的界面设计中,已经完成了该界面的设计工作。根据分析,该界面并不复杂,在最外层使用一个LinearLayout,内部嵌套RelativeLayout或各种组件就可以实现了,部分代码如下所示:
生成的预览效果如下所示:
(2)内部逻辑实现
该界面的内部逻辑并不复杂,重点在于处理用户的按钮点击事件。当用户确认按钮时,获取用户选择的头像,将结果返回就可以。如果用户点击了左上角的返回按钮,那么取消换头像的操作就好。
部分实现代码如下所示:
public void afterCreate(Bundle savedInstanceState) { head_icon_check = new ImageView[9]; head_icon_check[0] = (ImageView) findViewById(R.id.head_icon_check1); head_icon_check[1] = (ImageView) findViewById(R.id.head_icon_check2); head_icon_check[2] = (ImageView) findViewById(R.id.head_icon_check3); head_icon_check[3] = (ImageView) findViewById(R.id.head_icon_check4); head_icon_check[4] = (ImageView) findViewById(R.id.head_icon_check5); head_icon_check[5] = (ImageView) findViewById(R.id.head_icon_check6); head_icon_check[6] = (ImageView) findViewById(R.id.head_icon_check7); head_icon_check[7] = (ImageView) findViewById(R.id.head_icon_check8); head_icon_check[8] = (ImageView) findViewById(R.id.head_icon_check9); } public void editIconBack(View view) { setResult(RESULT_CANCELED); this.finish(); } // 确认修改按钮点击事件 public void confirmChangeIcon(View view) { if(select == 0) Toast.makeText(EditHeadIconActivity.this, "未选择头像!", Toast.LENGTH_SHORT).show(); else { setResult(select); this.finish(); } } public void onClick_head_icon1(View view) { for(int i = 0; i < 9; i++){ if(i == 0) head_icon_check[i].setVisibility(View.VISIBLE); else head_icon_check[i].setVisibility(View.GONE); } select = 1; }
二、服务器
本次完成的内容主要是对supservise的剩余部分的完成以及部分接口的编写。主要的内容有getMyApplySupervise 获取我申请监督别人的flag,isSuperviseFull判断目前监督的人数是否已经达到最大监督人数要求,true代表已经达到最大人数,false代表未达到最大人数 未确定和已同意都算已监督人数。
Connection conn=ConnectionPool.getConnection();
PreparedStatement ptmt1=null;
PreparedStatement ptmt2=null;
int maxSupervise=0;
int nowSupervise=0;
ResultSet rs1=null;
ResultSet rs2=null;
String sql1="select maxSupervise from fg_flag where fid=? " ;
String sql2="select count(*) as nowSupervise from fg_supervise where fid=? and agree!=1";
try {
conn.setAutoCommit(false);
ptmt1=conn.prepareStatement(sql1);
ptmt2=conn.prepareStatement(sql2);
ptmt1.setInt(1, fid);
rs1=ptmt1.executeQuery();
ptmt2.setInt(1, fid);
rs2=ptmt2.executeQuery();
conn.commit();
if(rs1.next()){
maxSupervise=rs1.getInt("maxSupervise");
}
if(rs2.next()){
nowSupervise=rs2.getInt("nowSupervise");
}
写到这里,基本上所有的内容已经完成,剩下的就是对接口的编写。
int success=0;
try {
int fid=Integer.parseInt(request.getParameter("fid"));
int uid=Integer.parseInt(request.getParameter("uid"));
SuperviseDao sd=new SuperviseDao();
int agree=Integer.parseInt(request.getParameter("agree"));
boolean temp=sd.confirmAgreeSupervise(fid, uid, agree);
if(temp)
success=1;
总结
本周的工作进行的比较顺利,这得益于我们默契的配合和完美的计划,总是达到我们预期的目标。