Browse Source

增加新的自定义控件BaseToolbar和ImgGridView。完成朋友圈首页

Junqin Wang 8 years ago
parent
commit
c0f899c662
47 changed files with 958 additions and 47 deletions
  1. 1 0
      app/app.iml
  2. 5 0
      app/build.gradle
  3. BIN
      app/res/drawable-hdpi/circe_likes_user.png
  4. BIN
      app/res/drawable-hdpi/circle_comments.png
  5. BIN
      app/res/drawable-hdpi/circle_eye.png
  6. BIN
      app/res/drawable-hdpi/circle_liked.png
  7. BIN
      app/res/drawable-hdpi/circle_likes.png
  8. BIN
      app/res/drawable-mdpi/circe_likes_user.png
  9. BIN
      app/res/drawable-mdpi/circle_comments.png
  10. BIN
      app/res/drawable-mdpi/circle_eye.png
  11. BIN
      app/res/drawable-mdpi/circle_liked.png
  12. BIN
      app/res/drawable-mdpi/circle_likes.png
  13. BIN
      app/res/drawable-xhdpi/circe_likes_user.png
  14. BIN
      app/res/drawable-xhdpi/circle_comments.png
  15. BIN
      app/res/drawable-xhdpi/circle_eye.png
  16. BIN
      app/res/drawable-xhdpi/circle_liked.png
  17. BIN
      app/res/drawable-xhdpi/circle_likes.png
  18. BIN
      app/res/drawable-xxhdpi/circe_likes_user.png
  19. BIN
      app/res/drawable-xxhdpi/circle_comments.png
  20. BIN
      app/res/drawable-xxhdpi/circle_eye.png
  21. BIN
      app/res/drawable-xxhdpi/circle_liked.png
  22. BIN
      app/res/drawable-xxhdpi/circle_likes.png
  23. BIN
      app/res/drawable-xxxhdpi/circe_likes_user.png
  24. BIN
      app/res/drawable-xxxhdpi/circle_comments.png
  25. BIN
      app/res/drawable-xxxhdpi/circle_eye.png
  26. BIN
      app/res/drawable-xxxhdpi/circle_liked.png
  27. BIN
      app/res/drawable-xxxhdpi/circle_likes.png
  28. 45 0
      app/res/layout/base_toolbar.xml
  29. 153 0
      app/res/layout/circle_item.xml
  30. 25 16
      app/res/layout/circle_of_friends_fragment.xml
  31. 0 6
      app/res/layout/circle_toolbar.xml
  32. 9 0
      app/res/values/attrs.xml
  33. 5 0
      app/res/values/style.xml
  34. 7 0
      app/src/com/sheishuo/app/SheishuoApplication.java
  35. 92 15
      app/src/com/sheishuo/app/common/beans/CircleBean.java
  36. 37 0
      app/src/com/sheishuo/app/common/util/img/ImgUtil.java
  37. 1 0
      app/src/com/sheishuo/app/common/util/net/NetInfo.java
  38. 72 0
      app/src/com/sheishuo/app/common/views/BaseToolbar.java
  39. 95 0
      app/src/com/sheishuo/app/common/views/GridViewAdapter.java
  40. 62 0
      app/src/com/sheishuo/app/common/views/ImgGridView.java
  41. 170 0
      app/src/com/sheishuo/app/main/adapter/CircleListAdapter.java
  42. 55 2
      app/src/com/sheishuo/app/main/fragment/CircleOfFriendsFragment.java
  43. 62 0
      app/src/com/sheishuo/app/main/model/CircleModel.java
  44. 16 0
      app/src/com/sheishuo/app/main/model/ICircle.java
  45. 38 0
      app/src/com/sheishuo/app/main/presenter/CirclePresenter.java
  46. 1 1
      uikit/src/com/netease/nim/uikit/common/fragment/TFragment.java
  47. 7 7
      uikit/uikit.iml

+ 1 - 0
app/app.iml

@@ -107,6 +107,7 @@
     <orderEntry type="library" exported="" name="video_effect" level="project" />
     <orderEntry type="library" exported="" name="design-25.3.1" level="project" />
     <orderEntry type="library" exported="" name="support-core-ui-25.3.1" level="project" />
+    <orderEntry type="library" exported="" name="cardview-v7-25.1.1" level="project" />
     <orderEntry type="library" exported="" name="rxandroid-2.0.1" level="project" />
     <orderEntry type="library" exported="" name="HMS-SDK-2.4.0.300-" level="project" />
     <orderEntry type="library" exported="" name="jsbridge-1.3.1" level="project" />

+ 5 - 0
app/build.gradle

@@ -118,6 +118,11 @@ dependencies {
     //debugCompile project(':plugins:sf')
 
 
+    //CardView
+    compile 'com.android.support:cardview-v7:25.1.1'
+
+
+
 
 
 }

BIN
app/res/drawable-hdpi/circe_likes_user.png


BIN
app/res/drawable-hdpi/circle_comments.png


BIN
app/res/drawable-hdpi/circle_eye.png


BIN
app/res/drawable-hdpi/circle_liked.png


BIN
app/res/drawable-hdpi/circle_likes.png


BIN
app/res/drawable-mdpi/circe_likes_user.png


BIN
app/res/drawable-mdpi/circle_comments.png


BIN
app/res/drawable-mdpi/circle_eye.png


BIN
app/res/drawable-mdpi/circle_liked.png


BIN
app/res/drawable-mdpi/circle_likes.png


BIN
app/res/drawable-xhdpi/circe_likes_user.png


BIN
app/res/drawable-xhdpi/circle_comments.png


BIN
app/res/drawable-xhdpi/circle_eye.png


BIN
app/res/drawable-xhdpi/circle_liked.png


BIN
app/res/drawable-xhdpi/circle_likes.png


BIN
app/res/drawable-xxhdpi/circe_likes_user.png


BIN
app/res/drawable-xxhdpi/circle_comments.png


BIN
app/res/drawable-xxhdpi/circle_eye.png


BIN
app/res/drawable-xxhdpi/circle_liked.png


BIN
app/res/drawable-xxhdpi/circle_likes.png


BIN
app/res/drawable-xxxhdpi/circe_likes_user.png


BIN
app/res/drawable-xxxhdpi/circle_comments.png


BIN
app/res/drawable-xxxhdpi/circle_eye.png


BIN
app/res/drawable-xxxhdpi/circle_liked.png


BIN
app/res/drawable-xxxhdpi/circle_likes.png


+ 45 - 0
app/res/layout/base_toolbar.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    style="@style/fullToolbarStyle">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="?attr/actionBarSize"
+            android:background="@color/colorPrimary"
+            android:gravity="center"
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/toolbar_left"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="2"
+                android:gravity="center"
+                android:textColor="@color/white"
+                android:textSize="16sp" />
+
+            <TextView
+                android:id="@+id/toolbar_title"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="6"
+                android:gravity="center"
+                android:text="朋友圈"
+                android:textColor="@color/white"
+                android:textSize="18sp"
+                android:textStyle="bold" />
+
+            <TextView
+                android:id="@+id/toolbar_right"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="2"
+                android:gravity="center"
+                android:text="发表"
+                android:textColor="@color/white"
+                android:textSize="16sp" />
+
+        </LinearLayout>
+</android.support.v7.widget.Toolbar>

+ 153 - 0
app/res/layout/circle_item.xml

@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@android:color/white"
+    android:orientation="vertical"
+    android:paddingLeft="10dp"
+    android:paddingRight="10dp"
+    android:paddingTop="5dp"
+    android:paddingBottom="5dp">
+
+
+    <android.support.v7.widget.CardView
+        android:id="@+id/circle_item_cardview"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        app:cardBackgroundColor="@android:color/white">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:padding="15dp">
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content">
+
+                <ImageView
+                    android:id="@+id/avatar_img"
+                    android:layout_width="48dp"
+                    android:layout_height="48dp"
+                    android:src="@drawable/nim_avatar_default" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:layout_marginLeft="15dp"
+                android:layout_marginStart="15dp">
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical">
+
+                    <TextView
+                        android:id="@+id/username_tv"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textColor="@android:color/holo_blue_dark" />
+
+                    <TextView
+                        android:id="@+id/user_content_tv"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textColor="@android:color/darker_gray"
+                        android:minHeight="50dp"
+                        android:gravity="center_vertical"/>
+                </LinearLayout>
+
+                <com.sheishuo.app.common.views.ImgGridView
+                    android:id="@+id/gridview_imgs"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:scrollbars="none"
+                    android:numColumns="2"
+                    android:horizontalSpacing="5dp" />
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="horizontal">
+
+                    <LinearLayout
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:orientation="vertical">
+
+                        <TextView
+                            android:id="@+id/location_tv"
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:text="地点"
+                            android:textColor="@android:color/darker_gray"
+                            android:textSize="10sp"/>
+
+                        <TextView
+                            android:id="@+id/date_tv"
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:text="发布日期"
+                            android:textColor="@android:color/darker_gray"
+                            android:textSize="10sp"/>
+                    </LinearLayout>
+
+                    <LinearLayout
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:gravity="end">
+
+                        <ImageView
+                            android:layout_width="30dp"
+                            android:layout_height="match_parent"
+                            android:src="@drawable/circle_eye" />
+
+                        <TextView
+                            android:id="@+id/visit_num_tv"
+                            android:layout_width="wrap_content"
+                            android:layout_height="match_parent"
+                            android:gravity="center"
+                            android:text="浏览数"
+                            android:textColor="@android:color/darker_gray"/>
+
+                        <ImageView
+                            android:id="@+id/liked_img"
+                            android:layout_width="30dp"
+                            android:layout_height="match_parent"
+                            android:src="@drawable/circle_likes" />
+
+                        <TextView
+                            android:id="@+id/likes_num_tv"
+                            android:layout_width="wrap_content"
+                            android:layout_height="match_parent"
+                            android:gravity="center"
+                            android:text="喜欢数"
+                            android:textColor="@android:color/darker_gray"/>
+
+                        <ImageView
+                            android:layout_width="30dp"
+                            android:layout_height="match_parent"
+                            android:src="@drawable/circle_comments" />
+
+                        <TextView
+                            android:id="@+id/comment_num_tv"
+                            android:layout_width="wrap_content"
+                            android:layout_height="match_parent"
+                            android:gravity="center"
+                            android:text="评论"
+                            android:textColor="@android:color/darker_gray"/>
+
+                    </LinearLayout>
+                </LinearLayout>
+
+            </LinearLayout>
+        </LinearLayout>
+    </android.support.v7.widget.CardView>
+
+    <View style="@style/horizontal_light_thin_divider" />
+
+</LinearLayout>

+ 25 - 16
app/res/layout/circle_of_friends_fragment.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:my="http://schemas.android.com/tools"
     android:id="@+id/main_content"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
@@ -19,7 +20,9 @@
             android:fitsSystemWindows="true"
             app:contentScrim="?attr/colorPrimary"
             app:expandedTitleMarginStart="48dp"
-            app:expandedTitleMarginEnd="64dp">
+            app:expandedTitleMarginEnd="64dp"
+            android:minHeight="?attr/actionBarSize">
+
 
 
 
@@ -32,7 +35,8 @@
                 <ImageView
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
-                    android:scaleType="centerCrop"/>
+                    android:scaleType="centerCrop"
+                    android:src="@drawable/ico_01_fujinqun"/>
 
                 <LinearLayout
                     android:layout_width="wrap_content"
@@ -60,11 +64,16 @@
 
             </RelativeLayout>
 
-            <!--<android.support.v7.widget.Toolbar-->
-                <!--android:id="@+id/toolbar_details"-->
-                <!--android:layout_width="match_parent"-->
-                <!--android:layout_height="?attr/actionBarSize"-->
-                <!--app:layout_collapseMode="pin" />-->
+
+            <com.sheishuo.app.common.views.BaseToolbar
+                android:id="@+id/circle_toolbar"
+                android:layout_width="match_parent"
+                android:layout_height="?attr/actionBarSize"
+                app:layout_collapseMode="pin"
+                app:title="朋友圈"
+                app:right_text="发表"
+                style="@style/fullToolbarStyle"/>
+
         </android.support.design.widget.CollapsingToolbarLayout>
 
     </android.support.design.widget.AppBarLayout>
@@ -84,14 +93,14 @@
             android:layout_height="match_parent"/>
     </LinearLayout>
 
-    <android.support.design.widget.FloatingActionButton
-        android:id="@+id/circle_fab"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        app:layout_anchor="@id/appbar"
-        app:layout_anchorGravity="bottom|right|end"
-        android:src="@drawable/ic_add_friends"
-        android:layout_margin="24dp"
-        android:clickable="true"/>
+    <!--<android.support.design.widget.FloatingActionButton-->
+        <!--android:id="@+id/circle_fab"-->
+        <!--android:layout_height="wrap_content"-->
+        <!--android:layout_width="wrap_content"-->
+        <!--app:layout_anchor="@id/appbar"-->
+        <!--app:layout_anchorGravity="bottom|right|end"-->
+        <!--android:src="@drawable/ic_add_friends"-->
+        <!--android:layout_margin="24dp"-->
+        <!--android:clickable="true"/>-->
 
 </android.support.design.widget.CoordinatorLayout>

+ 0 - 6
app/res/layout/circle_toolbar.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical" android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-</LinearLayout>

+ 9 - 0
app/res/values/attrs.xml

@@ -1,5 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
+
+    <!--BaseToolbar-->
+    <declare-styleable name="BaseToolbar">
+        <attr name="left_text" format="string"/>
+        <attr name="title" format="string"/>
+        <attr name="right_text" format="string"/>
+    </declare-styleable>
+
+
     <!--PartlyHighlightTextView-->
     <declare-styleable name="PartlyHighLightTextView">
         <attr name="normal_str" format="string"/>

+ 5 - 0
app/res/values/style.xml

@@ -15,4 +15,9 @@
         <item name="android:textColor">@color/white</item>
     </style>
 
+
+    <style name="fullToolbarStyle" parent="Widget.AppCompat.Toolbar">
+        <item name="contentInsetStart">0dp</item><!-- 设置该属性解决空白部分-->
+    </style>
+
 </resources>

+ 7 - 0
app/src/com/sheishuo/app/SheishuoApplication.java

@@ -68,6 +68,9 @@ public class SheishuoApplication extends Application {
 
     public void onCreate() {
         super.onCreate();
+
+        context = this;
+
         SheishuoCache.setContext(this);
         // 注册小米推送appID 、appKey 以及在云信管理后台添加的小米推送证书名称,该逻辑放在 NIMClient init 之前
         NIMPushClient.registerMiPush(this, "DEMO_MI_PUSH", "2882303761517502883", "5671750254883");
@@ -108,6 +111,10 @@ public class SheishuoApplication extends Application {
         }
     }
 
+    public static Context getContext(){
+        return context;
+    }
+
     private LoginInfo getLoginInfo() {
         String account = Preferences.getUserAccount();
         String token = Preferences.getUserToken();

+ 92 - 15
app/src/com/sheishuo/app/common/beans/CircleBean.java

@@ -34,8 +34,8 @@ public class CircleBean implements Serializable{
         this.d = d;
     }
 
-    private class DBean {
-        private List<ListBean> list;
+    public class DBean {
+        public List<ListBean> list;
 
         public List<ListBean> getList() {
             return list;
@@ -45,7 +45,7 @@ public class CircleBean implements Serializable{
             this.list = list;
         }
 
-        class ListBean {
+        public class ListBean {
             /**
              * id : 23
              * user_id : 200028
@@ -75,10 +75,10 @@ public class CircleBean implements Serializable{
             private String longitude;
             private String latitude;
             private String inputtime;
-            private List<?> pics;
-            private List<?> thumbs;
-            private List<?> like_users;
-            private List<?> comments_list;
+            private List<String> pics;
+            private List<String> thumbs;
+            private List<String> like_users;
+            private List<Comment> comments_list;
 
             public String getId() {
                 return id;
@@ -168,37 +168,114 @@ public class CircleBean implements Serializable{
                 this.inputtime = inputtime;
             }
 
-            public List<?> getPics() {
+            public List<String> getPics() {
                 return pics;
             }
 
-            public void setPics(List<?> pics) {
+            public void setPics(List<String> pics) {
                 this.pics = pics;
             }
 
-            public List<?> getThumbs() {
+            public List<String> getThumbs() {
                 return thumbs;
             }
 
-            public void setThumbs(List<?> thumbs) {
+            public void setThumbs(List<String> thumbs) {
                 this.thumbs = thumbs;
             }
 
-            public List<?> getLike_users() {
+            public List<String> getLike_users() {
                 return like_users;
             }
 
-            public void setLike_users(List<?> like_users) {
+            public void setLike_users(List<String> like_users) {
                 this.like_users = like_users;
             }
 
-            public List<?> getComments_list() {
+            public List<Comment> getComments_list() {
                 return comments_list;
             }
 
-            public void setComments_list(List<?> comments_list) {
+            public void setComments_list(List<Comment> comments_list) {
                 this.comments_list = comments_list;
             }
+
+            public class Comment{
+
+                /**
+                 * id : 28
+                 * type : 0
+                 * user_id : 200028
+                 * social_id : 22
+                 * reply_id : 0
+                 * comment : 帅
+                 * inputtime : 2017年07月14日
+                 */
+
+                private String id;
+                private String type;
+                private String user_id;
+                private String social_id;
+                private String reply_id;
+                private String comment;
+                private String inputtime;
+
+                public String getId() {
+                    return id;
+                }
+
+                public void setId(String id) {
+                    this.id = id;
+                }
+
+                public String getType() {
+                    return type;
+                }
+
+                public void setType(String type) {
+                    this.type = type;
+                }
+
+                public String getUser_id() {
+                    return user_id;
+                }
+
+                public void setUser_id(String user_id) {
+                    this.user_id = user_id;
+                }
+
+                public String getSocial_id() {
+                    return social_id;
+                }
+
+                public void setSocial_id(String social_id) {
+                    this.social_id = social_id;
+                }
+
+                public String getReply_id() {
+                    return reply_id;
+                }
+
+                public void setReply_id(String reply_id) {
+                    this.reply_id = reply_id;
+                }
+
+                public String getComment() {
+                    return comment;
+                }
+
+                public void setComment(String comment) {
+                    this.comment = comment;
+                }
+
+                public String getInputtime() {
+                    return inputtime;
+                }
+
+                public void setInputtime(String inputtime) {
+                    this.inputtime = inputtime;
+                }
+            }
         }
     }
 }

+ 37 - 0
app/src/com/sheishuo/app/common/util/img/ImgUtil.java

@@ -0,0 +1,37 @@
+package com.sheishuo.app.common.util.img;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.DisplayMetrics;
+import android.widget.ImageView;
+
+import com.bumptech.glide.Glide;
+import com.sheishuo.app.SheishuoApplication;
+
+/**
+ * Created by KN on 2017/7/7.
+ */
+
+public class ImgUtil {
+    public static ImageView getImageFromNet( Context context,String imgUrl){
+        ImageView imageView = new ImageView(context);
+        Glide.with(SheishuoApplication.getContext()).load(imgUrl).into(imageView);
+        return imageView;
+    }
+
+
+    public static float convertDpToPixel(float dp, Context context){
+        Resources resources = context.getResources();
+        DisplayMetrics metrics = resources.getDisplayMetrics();
+        float px = dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
+        return px;
+    }
+
+
+    public static float convertPixelsToDp(float px, Context context){
+        Resources resources = context.getResources();
+        DisplayMetrics metrics = resources.getDisplayMetrics();
+        float dp = px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
+        return dp;
+    }
+}

+ 1 - 0
app/src/com/sheishuo/app/common/util/net/NetInfo.java

@@ -9,4 +9,5 @@ public class NetInfo {
     public final static String LOGIN_URL = "?m=who&c=index&a=login";
     public final static String REG_URL = "?m=who&c=index&a=login";
     public final static String GET_NEARBY_GROUP = "?m=who&c=index&a=near_room";
+    public final static String CIRCLE_LIST = "?m=who&c=social&a=lists";
 }

+ 72 - 0
app/src/com/sheishuo/app/common/views/BaseToolbar.java

@@ -0,0 +1,72 @@
+package com.sheishuo.app.common.views;
+
+import android.content.Context;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.Toolbar;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.sheishuo.app.R;
+
+/**
+ * Created by KN on 2017/7/20.
+ */
+
+public class BaseToolbar extends Toolbar {
+
+    private final String TITLE = "title",LEFT_TEXT = "left_text",RIGHT_TEXT = "right_text";
+    private String titleStr = "",leftStr = "",rightStr = "";
+    private TextView titleTV,leftTV,rightTV;
+
+
+    public BaseToolbar(Context context, @Nullable AttributeSet attrs) {
+        super(context, attrs);
+        View view = LayoutInflater.from(context).inflate(R.layout.base_toolbar,this,true);
+        findViews(view);
+        assert attrs != null;
+        int count = attrs.getAttributeCount();
+        for (int index = 0; index < count; index++) {
+            String attributeName = attrs.getAttributeName(index);
+            switch (attributeName){
+                case TITLE:
+                    if (attrs.getAttributeValue(index) != null)
+                        titleTV.setText(titleStr = attrs.getAttributeValue(index));
+                    break;
+                case LEFT_TEXT:
+                    if (attrs.getAttributeValue(index) != null)
+                        leftTV.setText(leftStr = attrs.getAttributeValue(index));
+                    break;
+                case RIGHT_TEXT:
+                    if (attrs.getAttributeValue(index) != null)
+                        rightTV.setText(rightStr = attrs.getAttributeValue(index));
+                    break;
+
+            }
+        }
+
+
+    }
+
+
+    private void findViews(View view){
+        titleTV = (TextView) view.findViewById(R.id.toolbar_title);
+        leftTV = (TextView) view.findViewById(R.id.toolbar_left);
+        rightTV = (TextView) view.findViewById(R.id.toolbar_right);
+    }
+
+
+    public TextView getTitleTV() {
+        return titleTV;
+    }
+
+    public TextView getLeftTV() {
+        return leftTV;
+    }
+
+    public TextView getRightTV() {
+        return rightTV;
+    }
+}

+ 95 - 0
app/src/com/sheishuo/app/common/views/GridViewAdapter.java

@@ -0,0 +1,95 @@
+package com.sheishuo.app.common.views;
+
+import android.database.DataSetObserver;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+
+import com.sheishuo.app.SheishuoApplication;
+import com.sheishuo.app.common.util.img.ImgUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Created by KN on 2017/7/7.
+ */
+
+public class GridViewAdapter implements ListAdapter {
+    List<String> imgUrl = new ArrayList<>();
+
+    public  GridViewAdapter(List<String> imgUrl) {
+        this.imgUrl = imgUrl;
+    }
+
+    @Override
+    public boolean areAllItemsEnabled() {
+        return false;
+    }
+
+    @Override
+    public boolean isEnabled(int position) {
+        return false;
+    }
+
+    @Override
+    public void registerDataSetObserver(DataSetObserver observer) {
+
+    }
+
+    @Override
+    public void unregisterDataSetObserver(DataSetObserver observer) {
+
+    }
+
+    @Override
+    public int getCount() {
+        return imgUrl.size();
+    }
+
+    @Override
+    public Object getItem(int position) {
+        return null;
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return position;
+    }
+
+    @Override
+    public boolean hasStableIds() {
+        return false;
+    }
+
+    @Override
+    public View getView(int position, View convertView, ViewGroup parent) {
+        ImageView imageView = ImgUtil.getImageFromNet(SheishuoApplication.getContext(),imgUrl.get(position));
+        if (getCount() >= 5){
+            imageView.setMinimumHeight((int) ImgUtil.convertDpToPixel(96,SheishuoApplication.getContext()));
+            imageView.setMinimumWidth((int) ImgUtil.convertDpToPixel(96,SheishuoApplication.getContext()));
+        }else {
+            imageView.setMinimumHeight((int) ImgUtil.convertDpToPixel(128,SheishuoApplication.getContext()));
+            imageView.setMinimumWidth((int) ImgUtil.convertDpToPixel(128,SheishuoApplication.getContext()));
+        }
+
+        return imageView;
+    }
+
+    @Override
+    public int getItemViewType(int position) {
+        return 1;
+    }
+
+    @Override
+    public int getViewTypeCount() {
+        return 1;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return false;
+    }
+}

+ 62 - 0
app/src/com/sheishuo/app/common/views/ImgGridView.java

@@ -0,0 +1,62 @@
+package com.sheishuo.app.common.views;
+
+/**
+ * Created by KN on 2017/7/7.
+ */
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.GridView;
+
+
+public class ImgGridView extends GridView {
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        //防止MyGridView拦截事件
+        return false;
+    }
+
+    public ImgGridView(Context context) {
+        super(context);
+    }
+
+
+    public ImgGridView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+
+    public ImgGridView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+
+    @Override
+
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+
+        int heightSpec,widthSpec;
+
+
+        if (getLayoutParams().height == LayoutParams.WRAP_CONTENT) {
+            heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
+        } else {
+            heightSpec = heightMeasureSpec;
+        }
+
+
+//        int childCount = this.getChildCount();
+//        if (childCount >= 5){
+//            widthSpec = 128 * 3;
+//        }else {
+//            widthSpec = 128 * 2;
+//        }
+
+
+        super.onMeasure(widthMeasureSpec, heightSpec);
+
+    }
+
+}

+ 170 - 0
app/src/com/sheishuo/app/main/adapter/CircleListAdapter.java

@@ -0,0 +1,170 @@
+package com.sheishuo.app.main.adapter;
+
+import android.support.v7.widget.CardView;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.netease.nimlib.sdk.NIMClient;
+import com.netease.nimlib.sdk.RequestCallback;
+import com.netease.nimlib.sdk.uinfo.UserService;
+import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
+import com.sheishuo.app.R;
+import com.sheishuo.app.common.beans.CircleBean;
+import com.sheishuo.app.common.beans.NearbyGroupsBean;
+import com.sheishuo.app.common.views.GridViewAdapter;
+import com.sheishuo.app.common.views.ImgGridView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.sheishuo.app.R.id.layout_scr_bottom;
+import static com.sheishuo.app.R.id.visit_num_tv;
+
+/**
+ * Created by KN on 2017/7/20.
+ */
+
+public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.CircleListViewHolder> implements View.OnClickListener{
+
+    private List<CircleBean.DBean.ListBean> data;
+    private OnItemClickListener listener;
+
+    public CircleListAdapter(CircleBean bean){
+        data = new ArrayList<>();
+        data.addAll(bean.getD().getList());
+    }
+
+    @Override
+    public CircleListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.circle_item,null);
+        return new CircleListViewHolder(view);
+    }
+
+    @Override
+    public void onBindViewHolder(final CircleListViewHolder holder, int position) {
+        final CircleBean.DBean.ListBean bean = data.get(position);
+        holder.layout.setTag(bean);
+        holder.layout.setOnClickListener(this);
+        holder.contentTV.setText(bean.getMsg());
+        holder.locationTV.setText(bean.getLocal());
+        holder.dateTV.setText(bean.getInputtime());
+        holder.likesNumTV.setText(bean.getLikes());
+        holder.visitNumTv.setText(bean.getViews());
+
+
+        //获取此朋友圈中的所有用户id
+        List<String> userList = new ArrayList<>();
+        //添加此朋友圈发布者id
+        userList.add(bean.getUser_id());
+        //添加此朋友圈喜欢用户的id
+        for (String likedUser : bean.getLike_users()){
+            if (!userList.contains(likedUser))
+                userList.add(likedUser);
+        }
+        //添加次朋友圈评论用户的id
+        for (CircleBean.DBean.ListBean.Comment comment : bean.getComments_list()){
+            if (!userList.contains(comment.getUser_id()))
+                userList.add(comment.getUser_id());
+        }
+
+        //使用NIM SDK更新用户信息并将用户信息显示出来
+        NIMClient.getService(UserService.class).fetchUserInfo(userList).setCallback(new RequestCallback<List<NimUserInfo>>() {
+            @Override
+            public void onSuccess(List<NimUserInfo> user) {
+
+                //有用户名显示用户名,无用户名显示用户ID
+                if (getUserName(bean.getUser_id()).trim().equals("")){
+                    holder.usernameTV.setText(bean.getUser_id());
+                }else {
+                    holder.usernameTV.setText(getUserName(bean.getUser_id()));
+
+                }
+
+                String allLikedUser = "";
+                for (String likedUser:bean.getLike_users()){
+                    allLikedUser += (getUserName(likedUser) + ",");
+                }
+
+                Log.e("CommentsTAG","以下用户赞了" + allLikedUser);
+
+
+            }
+
+            @Override
+            public void onFailed(int i) {
+
+            }
+
+            @Override
+            public void onException(Throwable throwable) {
+
+            }
+        });
+
+
+        //加载thumbs
+        GridViewAdapter gridViewAdapter = new GridViewAdapter(bean.getThumbs());
+        if (bean.getThumbs().size() > 4){
+            //默认为两列,如果超过4张图则显示为3列
+            holder.gridView.setNumColumns(3);
+        }
+
+        holder.gridView.setAdapter(gridViewAdapter);
+
+    }
+
+    @Override
+    public int getItemCount() {
+        return data.size();
+    }
+
+    private String getUserName(String userId){
+        return NIMClient.getService(UserService.class).getUserInfo(userId).getName();
+    }
+
+    public void setOnItemClickListener(OnItemClickListener listener){
+        this.listener = listener;
+    }
+
+    public void addAll(CircleBean bean){
+        this.data.addAll(bean.getD().getList());
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (listener != null) listener.onItemClick(v);
+    }
+
+    class CircleListViewHolder extends RecyclerView.ViewHolder{
+        private CardView layout;
+        private TextView usernameTV
+                ,contentTV
+                ,locationTV
+                ,dateTV
+                ,visitNumTv
+                ,likesNumTV;
+        private ImgGridView gridView;
+        private ImageView avatar,likedImg;
+
+        public CircleListViewHolder(View v) {
+            super(v);
+            layout = (CardView) v.findViewById(R.id.circle_item_cardview);
+            gridView = (ImgGridView) v.findViewById(R.id.gridview_imgs);
+            usernameTV = (TextView) v.findViewById(R.id.username_tv);
+            contentTV = (TextView) v.findViewById(R.id.user_content_tv);
+            locationTV = (TextView) v.findViewById(R.id.location_tv);
+            dateTV = (TextView) v.findViewById(R.id.date_tv);
+            visitNumTv = (TextView) v.findViewById(visit_num_tv);
+            likesNumTV = (TextView) v.findViewById(R.id.likes_num_tv);
+
+            avatar = (ImageView) v.findViewById(R.id.avatar_img);
+            likedImg = (ImageView) v.findViewById(R.id.liked_img);
+
+        }
+    }
+}

+ 55 - 2
app/src/com/sheishuo/app/main/fragment/CircleOfFriendsFragment.java

@@ -1,14 +1,27 @@
 package com.sheishuo.app.main.fragment;
 
+import android.content.Context;
 import android.os.Bundle;
+import android.os.Handler;
+import android.support.design.widget.CollapsingToolbarLayout;
 import android.support.design.widget.FloatingActionButton;
+import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.Toolbar;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.Toast;
 
+import com.netease.nimlib.sdk.NIMClient;
+import com.netease.nimlib.sdk.uinfo.UserService;
+import com.sheishuo.app.AccountCache;
 import com.sheishuo.app.R;
+import com.sheishuo.app.common.beans.CircleBean;
+import com.sheishuo.app.common.views.BaseToolbar;
+import com.sheishuo.app.main.adapter.CircleListAdapter;
 import com.sheishuo.app.main.model.MainTab;
+import com.sheishuo.app.main.presenter.CirclePresenter;
 
 
 /**
@@ -17,8 +30,20 @@ import com.sheishuo.app.main.model.MainTab;
 
 public class CircleOfFriendsFragment extends MainTabFragment {
 
-    private FloatingActionButton fab;
+    private Context context = getActivity();
+    private CirclePresenter presenter = new CirclePresenter(this);
+
+
     private RecyclerView recyclerView;
+    private BaseToolbar toolbar;
+    private CollapsingToolbarLayout toolbarLayout;
+
+    private CircleListAdapter adapter;
+
+    private LinearLayoutManager layoutManager = new LinearLayoutManager(context);
+
+    private Handler handler = getHandler();
+
 
 
     public CircleOfFriendsFragment(){
@@ -27,13 +52,41 @@ public class CircleOfFriendsFragment extends MainTabFragment {
     @Override
     protected void onInit() {
         findViews();
+        presenter.loadCircleList(AccountCache.getAccount().getId(),"0");
 
     }
 
     void findViews(){
-        fab = (FloatingActionButton) getView().findViewById(R.id.circle_fab);
         recyclerView = (RecyclerView) getView().findViewById(R.id.circle_recyclerview);
+        toolbar = (BaseToolbar) getView().findViewById(R.id.circle_toolbar);
+        toolbarLayout = (CollapsingToolbarLayout) getView().findViewById(R.id.collapsing_toolbar);
+    }
+
+
+    public void showToast(String str){
+        Toast.makeText(getActivity(),str,Toast.LENGTH_SHORT).show();
+    }
+
+
+
+    public void onCircleListLoaded(final CircleBean bean){
+        handler.post(new Runnable() {
+            @Override
+            public void run() {
+                if (adapter == null){
+                    adapter = new CircleListAdapter(bean);
+                    recyclerView.setLayoutManager(layoutManager);
+                    recyclerView.setAdapter(adapter);
+                }else {
+                    adapter.addAll(bean);
+                    adapter.notifyDataSetChanged();
+                }
+            }
+        });
     }
 
 
+
+
+
 }

+ 62 - 0
app/src/com/sheishuo/app/main/model/CircleModel.java

@@ -0,0 +1,62 @@
+package com.sheishuo.app.main.model;
+
+import com.google.gson.Gson;
+import com.sheishuo.app.common.beans.CircleBean;
+import com.sheishuo.app.common.util.net.INet;
+import com.sheishuo.app.common.util.net.NetImpl;
+import com.sheishuo.app.common.util.net.NetInfo;
+import com.sheishuo.app.common.util.net.ResponseCallback;
+import com.sheishuo.app.main.presenter.CirclePresenter;
+
+import okhttp3.FormBody;
+
+/**
+ * Created by KN on 2017/7/20.
+ */
+
+public class CircleModel implements ICircle {
+
+    private INet net = new NetImpl();
+    private CircleBean circleListBean = new CircleBean();
+    private CirclePresenter presenter;
+
+    public CircleModel(CirclePresenter presenter){
+        this.presenter = presenter;
+    }
+
+
+    @Override
+    public void getCircleList(final String user_id, final String last_id) {
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+
+                String url = NetInfo.INDEX + NetInfo.CIRCLE_LIST;
+                FormBody body = new FormBody.Builder()
+                        .add("user_id",user_id)
+                        .add("last_id",last_id)
+                        .build();
+
+                net.post(url, body, new ResponseCallback() {
+                    @Override
+                    public void onSuccess(Object object) {
+                        String result = (String)object;
+                        circleListBean = new Gson().fromJson(result,CircleBean.class);
+                        if (circleListBean.getC() == 0){
+                            presenter.onCircleListLoaded(circleListBean);
+                        }else {
+                            onFailed();
+                        }
+                    }
+
+                    @Override
+                    public void onFailed() {
+                        presenter.showToast("加载失败,请检查网络");
+                    }
+                });
+
+            }
+        }).start();
+
+    }
+}

+ 16 - 0
app/src/com/sheishuo/app/main/model/ICircle.java

@@ -0,0 +1,16 @@
+package com.sheishuo.app.main.model;
+
+/**
+ * Created by KN on 2017/7/20.
+ */
+
+public interface ICircle {
+    /**
+     * 获取最新朋友圈
+     * @param user_id   用户ID
+     * @param last_id   最后一条朋友圈消息ID
+     */
+    void getCircleList(String user_id,String last_id);
+
+
+}

+ 38 - 0
app/src/com/sheishuo/app/main/presenter/CirclePresenter.java

@@ -0,0 +1,38 @@
+package com.sheishuo.app.main.presenter;
+
+import android.content.Context;
+import android.os.Handler;
+import android.widget.Toast;
+
+import com.sheishuo.app.common.beans.CircleBean;
+import com.sheishuo.app.main.fragment.CircleOfFriendsFragment;
+import com.sheishuo.app.main.model.CircleModel;
+
+/**
+ * Created by KN on 2017/7/20.
+ */
+
+public class CirclePresenter {
+    Context context;
+    CircleOfFriendsFragment fragment;
+    CircleModel model;
+    public CirclePresenter(CircleOfFriendsFragment fragment){
+        this.fragment = fragment;
+        model = new CircleModel(this);
+        context = fragment.getActivity();
+    }
+
+
+    public void showToast(String str){
+        fragment.showToast(str);
+    }
+
+    public void loadCircleList(String user_id,String last_id){
+        model.getCircleList(user_id,last_id);
+    }
+
+    public void onCircleListLoaded(CircleBean bean){
+        fragment.onCircleListLoaded(bean);
+    }
+
+}

+ 1 - 1
uikit/src/com/netease/nim/uikit/common/fragment/TFragment.java

@@ -46,7 +46,7 @@ public abstract class TFragment extends Fragment {
         destroyed = true;
     }
 
-    protected final Handler getHandler() {
+    public final Handler getHandler() {
         return handler;
     }
 

+ 7 - 7
uikit/uikit.iml

@@ -59,13 +59,6 @@
       <sourceFolder url="file://$MODULE_DIR$/assets" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
@@ -73,6 +66,13 @@
       <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />