Selaa lähdekoodia

消息列表,缺省页

316044749 7 vuotta sitten
vanhempi
commit
808f529f02

+ 54 - 3
app/src/main/java/com/ynstkz/shitu/android/activity/MessageListActivity.java

@@ -2,15 +2,22 @@ package com.ynstkz.shitu.android.activity;
 
 import android.os.Bundle;
 import android.support.annotation.Nullable;
+import android.view.View;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import com.common.library.okhttp.callback.Callback;
 import com.common.library.pulltorefresh.PullToRefreshListView;
+import com.google.gson.Gson;
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.base.TitleBarActivity;
+import com.ynstkz.shitu.android.bean.MessageListBean;
+import com.ynstkz.shitu.android.data.RequestGroup;
 
 import butterknife.Bind;
+import okhttp3.Call;
+import okhttp3.Response;
 
 /**
  * 作者:fuchangle on 2018/2/23 10:41
@@ -24,6 +31,12 @@ public class MessageListActivity extends TitleBarActivity {
     RelativeLayout viewTitle;
     @Bind(R.id.pullToRefresh)
     PullToRefreshListView pullToRefresh;
+    @Bind(R.id.iv_nodata_icon)
+    ImageView ivNodataIcon;
+    @Bind(R.id.tv_nodata_lab)
+    TextView tvNodataLab;
+    @Bind(R.id.rl_nodata)
+    RelativeLayout rlNodata;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -38,15 +51,53 @@ public class MessageListActivity extends TitleBarActivity {
         return R.layout.activity_message_list;
     }
 
-    private void initView(){
+    private void initView() {
         tvTitle.setText("系统通知");
     }
 
-    private void initData(){
+    private void initData() {
+        getMessageList();
+    }
+
+    private void setListener() {
 
     }
 
-    private void setListener(){
+    /**
+     * 获取通知列表
+     */
+    private void getMessageList() {
+
+        RequestGroup.getMessageList(new Callback() {
+            @Override
+            public Object parseNetworkResponse(Response response, int id) throws Exception {
+                return new Gson().fromJson(response.body().string(), MessageListBean.class);
+            }
+
+            @Override
+            public void onError(Call call, Exception e, int id) {
+                showNoData();
+            }
+
+            @Override
+            public void onResponse(Object response, int id) {
+                MessageListBean bean = (MessageListBean)response;
+                if(bean != null){
+
+                } else {
+                    showNoData();
+                }
+            }
+        });
+    }
 
+    /**
+     * 显示无数据
+     */
+    private void showNoData(){
+        pullToRefresh.setVisibility(View.GONE);
+        rlNodata.setVisibility(View.VISIBLE);
+        ivNodataIcon.setImageResource(R.drawable.nodata_msg);
+        tvNodataLab.setText(getString(R.string.nodata_msg));
     }
 }

+ 12 - 0
app/src/main/java/com/ynstkz/shitu/android/bean/MessageListBean.java

@@ -0,0 +1,12 @@
+package com.ynstkz.shitu.android.bean;
+
+import com.ynstkz.shitu.android.base.BaseBean;
+
+/**
+ * 作者:fuchangle on 2018/2/23 21:16
+ */
+
+public class MessageListBean extends BaseBean{
+
+
+}

+ 9 - 0
app/src/main/java/com/ynstkz/shitu/android/data/RequestGroup.java

@@ -1,5 +1,6 @@
 package com.ynstkz.shitu.android.data;
 
+import com.common.library.cache.Cache;
 import com.common.library.okhttp.OkHttpUtils;
 import com.common.library.okhttp.callback.Callback;
 import com.google.gson.Gson;
@@ -203,4 +204,12 @@ public class RequestGroup {
         params.put("userName", userName);
         OkHttpUtils.postString().url(UrlCat.URL_USER_RESET_USERNAME).content(new Gson().toJson(params)).build().execute(callback);
     }
+
+    /**
+     * 获取消息列表
+     */
+    public static void getMessageList(Callback callback){
+        Map<String, String> params = getSystemParams();
+        OkHttpUtils.get().url(UrlCat.URL_MESSAGE_LIST).params(params).build().execute(callback);
+    }
 }

+ 5 - 0
app/src/main/java/com/ynstkz/shitu/android/data/UrlCat.java

@@ -82,4 +82,9 @@ public class UrlCat {
      * 修改用户名
      */
     public static final String URL_USER_RESET_USERNAME = HOST + "api/user/reset/username";
+
+    /**
+     * 消息列表
+     */
+    public static final String URL_MESSAGE_LIST = HOST + "api/message/list";
 }

BIN
app/src/main/res/drawable-xxhdpi/error_icon.png


BIN
app/src/main/res/drawable-xxhdpi/nodata_apply.png


BIN
app/src/main/res/drawable-xxhdpi/nodata_collect.png


BIN
app/src/main/res/drawable-xxhdpi/nodata_common.png


BIN
app/src/main/res/drawable-xxhdpi/nodata_msg.png


BIN
app/src/main/res/drawable-xxhdpi/nodata_net.png


+ 9 - 0
app/src/main/res/layout/activity_message_list.xml

@@ -11,4 +11,13 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"/>
 
+    <RelativeLayout
+        android:id="@+id/rl_nodata"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <include layout="@layout/view_nodata"/>
+
+    </RelativeLayout>
+
 </LinearLayout>

+ 12 - 2
app/src/main/res/layout/activity_minecomment.xml

@@ -1,4 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
 
-</selector>
+    <include layout="@layout/view_title"/>
+
+    <com.common.library.pulltorefresh.PullToRefreshListView
+        android:id="@+id/pullToRefresh"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+
+</LinearLayout>

+ 30 - 0
app/src/main/res/layout/view_nodata.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_centerInParent="true">
+
+    <RelativeLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true">
+
+        <ImageView
+            android:id="@+id/iv_nodata_icon"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+
+        <TextView
+            android:id="@+id/tv_nodata_lab"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/iv_nodata_icon"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="@dimen/company_10dp"
+            android:textSize="@dimen/company_14sp"
+            android:textColor="@color/color_999"/>
+
+    </RelativeLayout>
+
+</RelativeLayout>

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -6,4 +6,7 @@
     <string name="error_msg">服务器连接失败,请稍后再试</string>
     <string name="empty_username">用户名不能为空</string>
     <string name="empty_verifyCode">验证码不能为空</string>
+
+    <string name="nodata_msg">亲,你还没有通知哦</string>
+
 </resources>