第五週(1) Flag相關的功能設計

引言

不知不覺,我們的創新項目實訓已經過去了大半,按照我們事先商定好的計劃,這周的任務主要是安卓客戶端與後天有關具體的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();
            }

        }
    }

其主要功能是從服務器獲取數據後的回調函數,根據請求的成功或者失敗做出具體的響應。

總結

這一階段的過程還算順利,小組成員深刻體會到了前期需求討論的充分以及花費了大量的時間進行計劃的評估和修改,好讓我們的開發過程思路清晰明瞭,遇到的問題也會快速解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章