第五周(1) Flag相关的功能设计

来源:互联网 发布:2016农村金融数据报告 编辑:程序博客网 时间:2024/05/16 05:31

引言

不知不觉,我们的创新项目实训已经过去了大半,按照我们事先商定好的计划,这周的任务主要是安卓客户端与后天有关具体的Flag的功能的相关实现,计划能顺利实施,得益于我们前期花费大量时间的讨论以及对工作量的正确的评估。本周的主要任务有:

  • 客户端 :我的好友消息和Flag详情
  • 后台:DAO层的详细逻辑梳理架构
  • 客户端:客户端设计工作的细节调整以及界面优化
下面我就客户端的工作中我的工作进行介绍:


客户端

本次我的工作是编写我的好友消息功能,其中xml界面代码如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    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="?attr/actionBarSize"        android:background="@color/white"        android:padding="0dp">        <ImageButton            android:layout_width="?attr/actionBarSize"            android:layout_height="?attr/actionBarSize"            android:layout_alignParentLeft="true"            android:background="@drawable/toolbar_back_bg"            android:onClick="myMessageFriendBack"            android:src="?attr/homeAsUpIndicator" />        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerInParent="true"            android:text="我的好友消息"            android:textColor="@color/black"            android:textSize="19sp" />    </RelativeLayout>    <android.support.v4.widget.SwipeRefreshLayout        android:id="@+id/friend_msg_swipe_layout"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_marginTop="20dp">        <ListView            android:id="@+id/myMessageListView"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:layout_marginTop="20dp"            android:background="@color/white" />    </android.support.v4.widget.SwipeRefreshLayout></LinearLayout>


界面如下:


相对应的Activity相关的核心实现部分MyMessageFriendActivity核心代码块为;

public void onSuccess(Response response) {        if (response.isSuccessful()) {            try {                String res = response.body().string();                JSONObject request = new JSONObject(res);                JSONArray jsonArray = request.getJSONArray("request");                for (int i = 0; i < jsonArray.length(); i++) {                    JSONObject jsonObject = jsonArray.getJSONObject(i);                    String nickname = jsonObject.optString("nickname");                    String phone = jsonObject.optString("phone");                    String message = jsonObject.optString("message");                    String requestUid = jsonObject.optString("requestUid");                    String agree = jsonObject.optString("agree");                    int iconId = jsonObject.optInt("photo");                    list.add(new TempFriendBean(nickname, phone, message, requestUid, agree, iconId));                }                MyMessageFriendActivity.this.runOnUiThread(new Runnable() {                    @Override                    public void run() {                        friendMessageAdapter = new FriendMessageAdapter(MyMessageFriendActivity.this, list);                        listView.setAdapter(friendMessageAdapter);                    }                });            } catch (IOException e) {                e.printStackTrace();            } catch (JSONException e) {                e.printStackTrace();            }        }    }

其主要功能是从服务器获取数据后的回调函数,根据请求的成功或者失败做出具体的响应。

总结

这一阶段的过程还算顺利,小组成员深刻体会到了前期需求讨论的充分以及花费了大量的时间进行计划的评估和修改,好让我们的开发过程思路清晰明了,遇到的问题也会快速解决。