|
@@ -1,16 +1,18 @@
|
|
package com.sheishuo.app.main.adapter;
|
|
package com.sheishuo.app.main.adapter;
|
|
|
|
|
|
|
|
+import android.content.Context;
|
|
import android.support.v7.widget.CardView;
|
|
import android.support.v7.widget.CardView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
|
+import android.text.Html;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
|
+import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.Glide;
|
|
-import com.netease.nim.uikit.robot.parser.elements.group.LinearLayout;
|
|
|
|
import com.netease.nimlib.sdk.NIMClient;
|
|
import com.netease.nimlib.sdk.NIMClient;
|
|
import com.netease.nimlib.sdk.RequestCallback;
|
|
import com.netease.nimlib.sdk.RequestCallback;
|
|
import com.netease.nimlib.sdk.uinfo.UserService;
|
|
import com.netease.nimlib.sdk.uinfo.UserService;
|
|
@@ -18,18 +20,19 @@ import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
|
import com.sheishuo.app.R;
|
|
import com.sheishuo.app.R;
|
|
import com.sheishuo.app.SheishuoApplication;
|
|
import com.sheishuo.app.SheishuoApplication;
|
|
import com.sheishuo.app.common.beans.CircleBean;
|
|
import com.sheishuo.app.common.beans.CircleBean;
|
|
-import com.sheishuo.app.common.beans.NearbyGroupsBean;
|
|
|
|
import com.sheishuo.app.common.util.img.ImgUtil;
|
|
import com.sheishuo.app.common.util.img.ImgUtil;
|
|
|
|
+import com.sheishuo.app.common.util.net.NetStatus;
|
|
import com.sheishuo.app.common.views.GridViewAdapter;
|
|
import com.sheishuo.app.common.views.GridViewAdapter;
|
|
import com.sheishuo.app.common.views.ImgGridView;
|
|
import com.sheishuo.app.common.views.ImgGridView;
|
|
|
|
+import com.sheishuo.app.main.fragment.CircleOfFriendsFragment;
|
|
|
|
+
|
|
|
|
+import org.w3c.dom.Text;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import static com.sheishuo.app.R.id.circle_comment_preview_item_tv;
|
|
import static com.sheishuo.app.R.id.circle_liked_user_tv;
|
|
import static com.sheishuo.app.R.id.circle_liked_user_tv;
|
|
-import static com.sheishuo.app.R.id.holder;
|
|
|
|
-import static com.sheishuo.app.R.id.layout_scr_bottom;
|
|
|
|
-import static com.sheishuo.app.R.id.name;
|
|
|
|
import static com.sheishuo.app.R.id.visit_num_tv;
|
|
import static com.sheishuo.app.R.id.visit_num_tv;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -40,10 +43,14 @@ public class CircleListAdapter extends RecyclerView.Adapter<CircleListAdapter.C
|
|
|
|
|
|
private List<CircleBean.DBean.ListBean> data;
|
|
private List<CircleBean.DBean.ListBean> data;
|
|
private OnCircleItemClickListener listener;
|
|
private OnCircleItemClickListener listener;
|
|
|
|
+ private Context context;
|
|
|
|
+ private CircleOfFriendsFragment circleFragment;
|
|
|
|
|
|
- public CircleListAdapter(CircleBean bean){
|
|
|
|
|
|
+ public CircleListAdapter(CircleOfFriendsFragment fragment,CircleBean bean){
|
|
data = new ArrayList<>();
|
|
data = new ArrayList<>();
|
|
this.addAll(bean);
|
|
this.addAll(bean);
|
|
|
|
+ this.context = fragment.getActivity();
|
|
|
|
+ this.circleFragment = fragment;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -158,11 +165,50 @@ public class CircleListAdapter extends RecyclerView.Adapter<CircleListAdapter.C
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //加载评论
|
|
|
|
+ if (bean.getComments_list().size() > 0){
|
|
|
|
+ holder.commentsLayout.setVisibility(View.VISIBLE);
|
|
|
|
+ for (CircleBean.DBean.ListBean.Comment comment : bean.getComments_list()){
|
|
|
|
+ View commentView = LayoutInflater.from(context).inflate(R.layout.circle_comment_preview_item,null);
|
|
|
|
+ ImageView imageView = (ImageView) commentView.findViewById(R.id.circle_comment_preview_item_img);
|
|
|
|
+ TextView textView = (TextView) commentView.findViewById(circle_comment_preview_item_tv);
|
|
|
|
+
|
|
|
|
+ String avatarUrl = NIMClient.getService(UserService.class).getUserInfo(comment.getUser_id()).getAvatar();
|
|
|
|
+ if (avatarUrl.equals("")){
|
|
|
|
+ Glide.with(context).load(R.drawable.user_account_icon).into(imageView);
|
|
|
|
+ }else {
|
|
|
|
+ Glide.with(context).load(avatarUrl).into(imageView);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- //加载两条评论
|
|
|
|
|
|
+ if (comment.getReply_id().equals("0")){
|
|
|
|
+ textView.setText(Html.fromHtml("<font color=\"#337a9b\">"
|
|
|
|
+ + getUserName(comment.getUser_id())
|
|
|
|
+ + "</font> "
|
|
|
|
+ + comment.getComment()));
|
|
|
|
+ System.out.println(comment.getComment());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ holder.commentsLayout.addView(commentView);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TextView moreCommentsTV = new TextView(context);
|
|
|
|
+ moreCommentsTV.setText(Html.fromHtml("<font color=\"#337a9b\"> 所有"
|
|
|
|
+ + bean.getComments()
|
|
|
|
+ + "条评论</font>"));
|
|
|
|
+ holder.commentsLayout.addView(moreCommentsTV);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //判断是否需要加载更多评论
|
|
|
|
+ //判断标志为缓存的Holder小于两个且最底部的Item ID不为"1"时则自动加载
|
|
|
|
+ if (position > data.size() - 2 && !data.get(data.size() - 1).getId().equals("1")) {
|
|
|
|
+ Log.e("CircleListAdapter",data.get(data.size() - 1).getId());
|
|
|
|
+ circleFragment.loadCircleListMore(data.get(data.size() - 1).getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -172,7 +218,12 @@ public class CircleListAdapter extends RecyclerView.Adapter<CircleListAdapter.C
|
|
super.onViewRecycled(holder);
|
|
super.onViewRecycled(holder);
|
|
//解决Glide不能使用添加了Tag的ImageView的问题
|
|
//解决Glide不能使用添加了Tag的ImageView的问题
|
|
holder.likedImg.setTag(null);
|
|
holder.likedImg.setTag(null);
|
|
|
|
+
|
|
|
|
+ //重置所有隐藏元素
|
|
holder.likedUserLayout.setVisibility(View.GONE);
|
|
holder.likedUserLayout.setVisibility(View.GONE);
|
|
|
|
+ holder.commentsLayout.setVisibility(View.GONE);
|
|
|
|
+ holder.commentsLayout.removeAllViews();
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -224,20 +275,27 @@ public class CircleListAdapter extends RecyclerView.Adapter<CircleListAdapter.C
|
|
|
|
|
|
class CircleListViewHolder extends RecyclerView.ViewHolder{
|
|
class CircleListViewHolder extends RecyclerView.ViewHolder{
|
|
private CardView layout;
|
|
private CardView layout;
|
|
|
|
+ private LinearLayout commentsLayout;
|
|
private TextView usernameTV
|
|
private TextView usernameTV
|
|
,contentTV
|
|
,contentTV
|
|
,locationTV
|
|
,locationTV
|
|
,dateTV
|
|
,dateTV
|
|
,visitNumTv
|
|
,visitNumTv
|
|
,likesNumTV
|
|
,likesNumTV
|
|
- ,likedUserTV;
|
|
|
|
|
|
+ ,likedUserTV
|
|
|
|
+ ,firstCommentTV
|
|
|
|
+ ,secondCommentTV;
|
|
private ImgGridView gridView;
|
|
private ImgGridView gridView;
|
|
- private ImageView avatar,likedImg;
|
|
|
|
|
|
+ private ImageView avatar
|
|
|
|
+ ,likedImg
|
|
|
|
+ ,firstCommentImg
|
|
|
|
+ ,secondCommentImg;
|
|
private View likedUserLayout;
|
|
private View likedUserLayout;
|
|
|
|
|
|
public CircleListViewHolder(View v) {
|
|
public CircleListViewHolder(View v) {
|
|
super(v);
|
|
super(v);
|
|
layout = (CardView) v.findViewById(R.id.circle_item_cardview);
|
|
layout = (CardView) v.findViewById(R.id.circle_item_cardview);
|
|
|
|
+ commentsLayout = (LinearLayout) v.findViewById(R.id.circle_two_comments_layout);
|
|
likedUserLayout = v.findViewById(R.id.circle_liked_user_layout);
|
|
likedUserLayout = v.findViewById(R.id.circle_liked_user_layout);
|
|
gridView = (ImgGridView) v.findViewById(R.id.gridview_imgs);
|
|
gridView = (ImgGridView) v.findViewById(R.id.gridview_imgs);
|
|
usernameTV = (TextView) v.findViewById(R.id.username_tv);
|
|
usernameTV = (TextView) v.findViewById(R.id.username_tv);
|
|
@@ -247,9 +305,13 @@ public class CircleListAdapter extends RecyclerView.Adapter<CircleListAdapter.C
|
|
visitNumTv = (TextView) v.findViewById(visit_num_tv);
|
|
visitNumTv = (TextView) v.findViewById(visit_num_tv);
|
|
likesNumTV = (TextView) v.findViewById(R.id.likes_num_tv);
|
|
likesNumTV = (TextView) v.findViewById(R.id.likes_num_tv);
|
|
likedUserTV = (TextView) v.findViewById(circle_liked_user_tv);
|
|
likedUserTV = (TextView) v.findViewById(circle_liked_user_tv);
|
|
|
|
+ //firstCommentTV = (TextView) v.findViewById(R.id.circle_comment_first_tv);
|
|
|
|
+ //secondCommentTV = (TextView) v.findViewById(R.id.circle_comment_second_tv);
|
|
|
|
|
|
avatar = (ImageView) v.findViewById(R.id.avatar_img);
|
|
avatar = (ImageView) v.findViewById(R.id.avatar_img);
|
|
likedImg = (ImageView) v.findViewById(R.id.liked_img);
|
|
likedImg = (ImageView) v.findViewById(R.id.liked_img);
|
|
|
|
+ //firstCommentImg = (ImageView) v.findViewById(R.id.circle_comment_first_img);
|
|
|
|
+ //secondCommentImg = (ImageView) v.findViewById(R.id.circle_comment_second_img);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|