Browse Source

话题详情页面开发

huyuguo 5 years ago
parent
commit
548ae8a830

+ 42 - 40
app/src/main/java/com/electric/chargingpile/activity/PersonalPageActivity.java

@ -124,10 +124,11 @@ public class PersonalPageActivity extends Activity implements View.OnClickListen
124 124
                        haveLoadHeaderData = true;
125 125
                        initHeaderData(qadata);
126 126
                    }
127
                    if (page == 1)
128
                        waterFallAdapter.setData(qadata.list);
129
                    else
130
                        waterFallAdapter.addData(qadata.list);
127
                    // TODO by hyg
128
                    //if (page == 1)
129
                        //waterFallAdapter.setData(qadata.list);
130
                    //else
131
                        //waterFallAdapter.addData(qadata.list);
131 132
132 133
                    if ((page == 1 && null == qadata.list) || (page == 1 && qadata.list.size() == 0)) {
133 134
@ -145,43 +146,44 @@ public class PersonalPageActivity extends Activity implements View.OnClickListen
145 146
        });
146 147
    }
147 148
149
    // TODO by hyg
148 150
    private void initHeaderData(HomePageBean qadata) {
149
        if(qadata == null || qadata.userVo == null)
150
            return;
151
152
        chargingShareBean.setIcon(qadata.userVo.coverImgUrl);
153
        chargingShareBean.setTitle(qadata.userVo.nickName+"的个人主页");
154
        chargingShareBean.setUrl(qadata.userVo.shareUrl);
155
        chargingShareBean.setText("快来看看"+qadata.userVo.nickName+"都在分享什么吧。");
156
157
        username_text.setText(qadata.userVo.nickName+"");
158
        if(TextUtils.isEmpty(qadata.userVo.carName))
159
            username_content.setText("");
160
        else
161
            username_content.setText(qadata.userVo.carName+"");
162
        data_info.setText(qadata.userVo.topicNums + "");
163
        if (!"".equals(qadata.userVo.headImgUrl)) {
164
            Picasso.with(this)
165
                    .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + qadata.userVo.headImgUrl)
166
                    .into(new Target() {
167
                        @Override
168
                        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
169
                            iconPic.setImageBitmap(bitmap);
170
                        }
171
172
                        @Override
173
                        public void onBitmapFailed(Drawable drawable) {
174
175
                        }
176
177
                        @Override
178
                        public void onPrepareLoad(Drawable drawable) {
179
180
                        }
181
                    });
182
        } else {
183
            iconPic.setImageResource(R.drawable.icon_face2_0);
184
        }
151
//        if(qadata == null || qadata.topicBean == null)
152
//            return;
153
154
//        chargingShareBean.setIcon(qadata.userVo.coverImgUrl);
155
//        chargingShareBean.setTitle(qadata.userVo.nickName+"的个人主页");
156
//        chargingShareBean.setUrl(qadata.userVo.shareUrl);
157
//        chargingShareBean.setText("快来看看"+qadata.userVo.nickName+"都在分享什么吧。");
158
//
159
//        username_text.setText(qadata.userVo.nickName+"");
160
//        if(TextUtils.isEmpty(qadata.userVo.carName))
161
//            username_content.setText("");
162
//        else
163
//            username_content.setText(qadata.userVo.carName+"");
164
//        data_info.setText(qadata.userVo.topicNums + "");
165
//        if (!"".equals(qadata.userVo.headImgUrl)) {
166
//            Picasso.with(this)
167
//                    .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + qadata.userVo.headImgUrl)
168
//                    .into(new Target() {
169
//                        @Override
170
//                        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
171
//                            iconPic.setImageBitmap(bitmap);
172
//                        }
173
//
174
//                        @Override
175
//                        public void onBitmapFailed(Drawable drawable) {
176
//
177
//                        }
178
//
179
//                        @Override
180
//                        public void onPrepareLoad(Drawable drawable) {
181
//
182
//                        }
183
//                    });
184
//        } else {
185
//            iconPic.setImageResource(R.drawable.icon_face2_0);
186
//        }
185 187
    }
186 188
187 189
    private void initListener() {

+ 125 - 4
app/src/main/java/com/electric/chargingpile/activity/TopicDetailActivity.java

@ -4,33 +4,103 @@ import android.os.Bundle;
4 4
import android.support.annotation.Nullable;
5 5
import android.support.v7.app.AppCompatActivity;
6 6
import android.support.v7.widget.RecyclerView;
7
import android.support.v7.widget.StaggeredGridLayoutManager;
8
import android.util.Log;
7 9
import android.view.View;
8 10
import android.widget.TextView;
11
import android.widget.Toast;
9 12
10 13
import com.andview.refreshview.XRefreshView;
11 14
import com.electric.chargingpile.R;
15
import com.electric.chargingpile.adapter.TopicDetailAdapter;
16
import com.electric.chargingpile.application.MainApplication;
17
import com.electric.chargingpile.data.HomePageBean;
18
import com.electric.chargingpile.util.CommonParams;
19
import com.electric.chargingpile.util.JsonUtils;
20
import com.electric.chargingpile.util.NetUtil;
21
import com.electric.chargingpile.util.ToastUtil;
22
import com.zhy.http.okhttp.OkHttpUtils;
23
import com.zhy.http.okhttp.callback.StringCallback;
24
25
import java.util.HashMap;
26
import java.util.Map;
27
28
import okhttp3.Call;
12 29
13 30
/**
14 31
 * @desc 话题详情
15 32
 */
16 33
public class TopicDetailActivity extends AppCompatActivity implements View.OnClickListener {
17
34
    private static final String TAG = "TopicDetailActivity";
18 35
    private TextView titleTextView;
19 36
    private XRefreshView xRefreshView;
20 37
    private RecyclerView recyclerView;
21 38
39
    private int topicId;
40
    private String sort = "1";
41
    private int page = 1;
42
    private TopicDetailAdapter topicDetailAdapter;
43
    private StaggeredGridLayoutManager staggeredGridLayoutManager;
44
22 45
    @Override
23 46
    protected void onCreate(@Nullable Bundle savedInstanceState) {
24 47
        super.onCreate(savedInstanceState);
25 48
        setContentView(R.layout.activity_topic_detail);
26 49
        initView();
27 50
        initListener();
51
52
        if (NetUtil.CheckNetwork(this)) {
53
            xRefreshView.startRefresh();
54
            requestData();
55
        } else {
56
            // TODO by hyg
57
        }
28 58
    }
29 59
30 60
    private void initView() {
61
        topicId = getIntent().getIntExtra("topicId", 0);
31 62
        titleTextView = findViewById(R.id.titleTextView);
32 63
        xRefreshView = findViewById(R.id.xRefreshView);
64
        xRefreshView.setPullLoadEnable(true); // 允许加载更多
65
        xRefreshView.setPinnedTime(1000);
66
        xRefreshView.setMoveForHorizontal(true);
67
        xRefreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener(){
68
            @Override
69
            public void onRefresh(boolean isPullDown) {
70
                super.onRefresh(isPullDown);
71
                page = 1;
72
                requestData();
73
            }
74
75
            @Override
76
            public void onLoadMore(boolean isSilence) {
77
                super.onLoadMore(isSilence);
78
                page ++;
79
                requestData();
80
            }
81
        });
82
83
        staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
84
        staggeredGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
85
        topicDetailAdapter = new TopicDetailAdapter(getApplicationContext());
86
33 87
        recyclerView = findViewById(R.id.recyclerView);
88
        recyclerView.setHasFixedSize(true);
89
        recyclerView.setItemAnimator(null);
90
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
91
            @Override
92
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
93
                // TODO by hyg 发布功能
94
            }
95
96
            @Override
97
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
98
            }
99
        });
100
101
        recyclerView.setLayoutManager(staggeredGridLayoutManager);
102
        recyclerView.setAdapter(topicDetailAdapter);
103
//        topicDetailAdapter.setOn TODO by hyg 回调事件
34 104
    }
35 105
36 106
    private void initListener() {
@ -41,10 +111,10 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
41 111
    @Override
42 112
    public void onClick(View view) {
43 113
        switch (view.getId()) {
44
            case R.id.backImageView:
114
            case R.id.backImageView: // 左上角返回功能
45 115
                finish();
46 116
                break;
47
            case R.id.shareTextView:
117
            case R.id.shareTextView: // 右上角分享功能
48 118
                shareInfo();
49 119
                break;
50 120
        }
@ -52,6 +122,57 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
52 122
    }
53 123
54 124
    private void shareInfo() {
55
        // TODO by huyuguo share information
125
        // TODO by hyg share information
126
    }
127
128
    private void requestData() {
129
        String url = MainApplication.urlNew + "/topic/homepage.do";
130
        Map<String, String> map = new HashMap<>();
131
        map.put("topicId", topicId + "");
132
        map.put("sort", sort);              //   1:最新发布 2:最后回复 3:最热
133
        map.put("init", "1");            //   0:只返回话题下内容列表 1:返回话题名等信息
134
        map.put("page", page + "");
135
        map.put("limit", "20");
136
        CommonParams.addCommonParams(map);
137
138
        OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
139
            @Override
140
            public void onError(Call call, Exception e) {
141
142
                ToastUtil.showToast(getApplicationContext(), "数据获取失败:" + e.getMessage(), Toast.LENGTH_SHORT);
143
                if (page == 1) {
144
                    xRefreshView.stopRefresh();
145
                } else {
146
                    page--;
147
                    xRefreshView.stopLoadMore();
148
                }
149
            }
150
151
            @Override
152
            public void onResponse(String res) {
153
                // TODO by hyg no network
154
                String code = JsonUtils.getKeyResult(res, "code");
155
                String desc = JsonUtils.getKeyResult(res, "desc");
156
                if ("1000".equals(code)) {
157
                    String data = JsonUtils.getKeyResult(res, "data");
158
                    HomePageBean homePageBean = (HomePageBean)JsonUtils.parseToObjectBean(data, HomePageBean.class);
159
                    if (page == 1) {
160
                        xRefreshView.stopRefresh();
161
                        topicDetailAdapter.setHeaderData(homePageBean.topicVo);
162
                        topicDetailAdapter.setContentData(homePageBean.list);
163
                    } else {
164
                        xRefreshView.stopLoadMore();
165
                    }
166
                } else {
167
                    ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
168
                    if (page == 1) {
169
                        xRefreshView.stopRefresh();
170
                    } else {
171
                        page--;
172
                        xRefreshView.stopLoadMore();
173
                    }
174
                }
175
            }
176
        });
56 177
    }
57 178
}

+ 186 - 7
app/src/main/java/com/electric/chargingpile/adapter/TopicDetailAdapter.java

@ -1,26 +1,51 @@
1 1
package com.electric.chargingpile.adapter;
2 2
3 3
import android.content.Context;
4
import android.support.constraint.ConstraintLayout;
4 5
import android.support.v7.widget.RecyclerView;
6
import android.support.v7.widget.StaggeredGridLayoutManager;
7
import android.text.TextUtils;
8
import android.util.Log;
5 9
import android.view.LayoutInflater;
6 10
import android.view.View;
7 11
import android.view.ViewGroup;
8 12
import android.widget.ArrayAdapter;
13
import android.widget.ImageView;
14
import android.widget.TextView;
15
import android.widget.Toast;
9 16
10 17
import com.aspsine.irecyclerview.IViewHolder;
11 18
import com.electric.chargingpile.R;
19
import com.electric.chargingpile.application.MainApplication;
12 20
import com.electric.chargingpile.data.ChatRecommendBean;
21
import com.electric.chargingpile.data.HomePageBean;
22
import com.electric.chargingpile.data.TalkRecommendBean;
23
import com.electric.chargingpile.data.TopicDetailBean;
13 24
import com.electric.chargingpile.data.TopicDetailBeanLab;
25
import com.electric.chargingpile.util.CircleTransform;
26
import com.electric.chargingpile.util.CommonParams;
27
import com.electric.chargingpile.util.ImageDisplayUtils;
28
import com.electric.chargingpile.util.JsonUtils;
29
import com.electric.chargingpile.util.ToastUtil;
30
import com.squareup.picasso.Picasso;
31
import com.zhy.http.okhttp.OkHttpUtils;
32
import com.zhy.http.okhttp.callback.StringCallback;
14 33
15 34
import java.util.ArrayList;
35
import java.util.HashMap;
36
import java.util.List;
37
import java.util.Map;
38
39
import okhttp3.Call;
16 40
17 41
public class TopicDetailAdapter extends RecyclerView.Adapter<IViewHolder> {
42
    private static final String TAG = "TopicDetailAdapter";
18 43
    public static final int TOPIC_DETAIL_HEADER = 1;
19 44
    public static final int TOPIC_DETAIL_CONTENT = 2;
20 45
    private Context context;
21 46
    private LayoutInflater layoutInflater;
22 47
    private final TopicDetailBeanLab beanLab;
23
    private ChatRecommendBean topicDetailBean;
48
    private HomePageBean.HomePageTopicBean topicDetailBean;
24 49
25 50
    public TopicDetailAdapter(Context context) {
26 51
        this.context = context;
@ -68,14 +93,123 @@ public class TopicDetailAdapter extends RecyclerView.Adapter<IViewHolder> {
68 93
    }
69 94
70 95
    private void bindHeaderViewHolder(IViewHolder viewHolder, int position) {
71
        HeaderViewHolder headerViewHolder = (HeaderViewHolder)viewHolder;
96
        HeaderViewHolder headerViewHolder = (HeaderViewHolder) viewHolder;
97
        StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) headerViewHolder.topicDetailHeader.getLayoutParams();
98
        params.setFullSpan(true);
99
        if (topicDetailBean == null) {
100
            return;
101
        }
72 102
103
        ImageDisplayUtils.dispalyImg(context, topicDetailBean.coverImgUrl, headerViewHolder.headImage);
104
        headerViewHolder.name.setText(topicDetailBean.name);
105
        headerViewHolder.desc.setText(topicDetailBean.desc);
106
        int read = topicDetailBean.visitNums;
107
        headerViewHolder.read.setText(read < 10000 ? read + "" : String.format("%.1fW", read / 10000.0));
108
        int join = topicDetailBean.joinNums;
109
        headerViewHolder.join.setText(join < 10000 ? join + "" : String.format("%.1fW", join / 10000.0));
73 110
    }
74 111
75
    private void bindContentViewHolder(IViewHolder viewHolder, int position) {
112
    private void bindContentViewHolder(IViewHolder viewHolder, final int position) {
113
        List<ChatRecommendBean> beans = TopicDetailBeanLab.get(context).beans();
114
        if (beans.size() == 0 || position > beans.size()) {
115
            return;
116
        }
117
118
        final ChatRecommendBean bean = beans.get(position - 1);
119
        ContentViewHolder contentViewHolder = (ContentViewHolder) viewHolder;
120
        ImageDisplayUtils.dispalyImg(context, bean.coverImgUrl, contentViewHolder.coverImage);
121
        contentViewHolder.videoIcon.setVisibility(bean.targetType == ChatRecommendBean.TARGET_TYPE_VIDEO ? View.VISIBLE : View.GONE);
122
123
        contentViewHolder.isTop.setVisibility(bean.isTop == 1 ? View.VISIBLE : View.GONE);
124
        contentViewHolder.title.setText(bean.title);
125
        contentViewHolder.authorInfo.setOnClickListener(new View.OnClickListener() {
126
            @Override
127
            public void onClick(View view) {
128
                showAuthorInfo(position);
129
            }
130
        });
131
        if (TextUtils.isEmpty(bean.headImgUrl)) {
132
            Picasso.with(context)
133
                    .load(R.drawable.icon_face2_0)
134
                    .placeholder(R.drawable.icon_face2_0)
135
                    .error(R.drawable.icon_face2_0)
136
                    .transform(new CircleTransform())
137
                    .into(contentViewHolder.headImage);
138
        } else {
139
            Picasso.with(context)
140
                    .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + bean.headImgUrl)
141
                    .placeholder(R.drawable.icon_face2_0)
142
                    .error(R.drawable.icon_face2_0)
143
                    .transform(new CircleTransform())
144
                    .into(contentViewHolder.headImage);
145
        }
146
147
        contentViewHolder.nickName.setText(bean.nickName);
148
        contentViewHolder.likeInfo.setOnClickListener(new View.OnClickListener() {
149
            @Override
150
            public void onClick(View view) {
151
                if (bean.likeFlg == 0) {
152
                    doLike(position);
153
                }
154
            }
155
        });
76 156
157
        if (bean.likeFlg == 1) {
158
            contentViewHolder.likeIcon.setBackgroundResource(R.drawable.app_talk_main_list_zan_red_icon);
159
        } else {
160
            contentViewHolder.likeIcon.setBackgroundResource(R.drawable.app_talk_main_list_zan_icon);
161
        }
162
163
        int likeNum = bean.likeNums;
164
        if (likeNum > 0) {
165
            contentViewHolder.likeNum.setVisibility(View.VISIBLE);
166
            contentViewHolder.likeNum.setText(likeNum < 10000 ? likeNum + "" : String.format("%.1fW", likeNum / 10000.0));
167
        } else {
168
            contentViewHolder.likeNum.setVisibility(View.GONE);
169
        }
77 170
    }
78 171
172
    /**
173
     * 点赞操作
174
     *
175
     * @param position
176
     */
177
    private void doLike(final int position) {
178
        final ChatRecommendBean bean = TopicDetailBeanLab.get(context).beans().get(position - 1);
179
        String url = MainApplication.urlNew + "/topic/like.do";
180
        Map<String, String> map = new HashMap<>();
181
        map.put("targetId", bean.targetId + "");
182
        map.put("targetType", bean.targetType + "");
183
        map.put("flag", "1");
184
        map.put("authorId", bean.addUserId + "");
185
        CommonParams.addCommonParams(map);
186
187
        OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
188
            @Override
189
            public void onError(Call call, Exception e) {
190
                ToastUtil.showToast(context, "点赞失败,请重试", Toast.LENGTH_SHORT);
191
            }
192
193
            @Override
194
            public void onResponse(String res) {
195
                String code = JsonUtils.getKeyResult(res, "code");
196
                String desc = JsonUtils.getKeyResult(res, "desc");
197
                if ("1000".equals(code)) {
198
                    bean.likeFlg = 1;
199
                    bean.likeNums += 1;
200
                    notifyItemChanged(position);
201
                } else {
202
                    ToastUtil.showToast(context, desc, Toast.LENGTH_SHORT);
203
                }
204
            }
205
        });
206
    }
207
208
    private void showAuthorInfo(int position) {
209
        // TODO
210
    }
211
212
79 213
    public void setContentData(ArrayList<ChatRecommendBean> beans) {
80 214
        beanLab.clear();
81 215
        beanLab.add(beans);
@ -89,23 +223,68 @@ public class TopicDetailAdapter extends RecyclerView.Adapter<IViewHolder> {
89 223
        notifyItemRangeChanged(startSize, endSize);
90 224
    }
91 225
92
    public void setHeaderData(ChatRecommendBean bean) {
226
    public void setHeaderData(HomePageBean.HomePageTopicBean bean) {
93 227
        topicDetailBean = bean;
94 228
    }
95 229
96 230
    class HeaderViewHolder extends IViewHolder {
231
        ConstraintLayout topicDetailHeader;
232
        ImageView headImage;
233
        TextView name;
234
        TextView desc;
235
        TextView read;
236
        TextView join;
237
97 238
        public HeaderViewHolder(View itemView) {
98 239
            super(itemView);
240
            topicDetailHeader = itemView.findViewById(R.id.topicDetailHeader);
241
            headImage = itemView.findViewById(R.id.headImage);
242
            name = itemView.findViewById(R.id.name);
243
            desc = itemView.findViewById(R.id.desc);
244
            read = itemView.findViewById(R.id.read);
245
            join = itemView.findViewById(R.id.join);
99 246
        }
100 247
101 248
    }
102 249
103
    class ContentViewHolder extends IViewHolder {
250
    public class ContentViewHolder extends IViewHolder {
251
252
        ConstraintLayout image_video_item;
253
        ImageView coverImage;
254
        ImageView videoIcon;
255
        TextView isTop;
256
        TextView title;
257
        ConstraintLayout authorInfo;
258
        ImageView headImage;
259
        TextView nickName;
260
        ConstraintLayout likeInfo;
261
        ImageView likeIcon;
262
        TextView likeNum;
263
264
        ConstraintLayout topic_item;
265
        ImageView topicCoverImage;
266
        TextView topicTitle;
267
104 268
105 269
        public ContentViewHolder(View itemView) {
106 270
            super(itemView);
107
        }
108
    }
271
            image_video_item = itemView.findViewById(R.id.image_video_item);
272
            coverImage = itemView.findViewById(R.id.coverImage);
273
            videoIcon = itemView.findViewById(R.id.videoIcon);
274
            isTop = itemView.findViewById(R.id.isTop);
275
            title = itemView.findViewById(R.id.title);
276
            authorInfo = itemView.findViewById(R.id.authorInfo);
277
            headImage = itemView.findViewById(R.id.headImage);
278
            nickName = itemView.findViewById(R.id.nickName);
279
            likeInfo = itemView.findViewById(R.id.likeInfo);
280
            likeIcon = itemView.findViewById(R.id.likeIcon);
281
            likeNum = itemView.findViewById(R.id.likeNum);
109 282
283
            // 默认是隐藏的,只有在首页信息流里面插入的话题才会显示
284
            topic_item = itemView.findViewById(R.id.topic_item);
285
            topicCoverImage = itemView.findViewById(R.id.topicCoverImage);
286
            topicTitle = itemView.findViewById(R.id.topicTitle);
110 287
288
        }
289
    }
111 290
}

+ 4 - 4
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

@ -73,10 +73,10 @@ public class MainApplication extends MultiDexApplication {
73 73
    public static String firstPoint = "";
74 74
    public static Boolean firstSsyd;
75 75
    public static String password = "";
76
    public static String url = "http://59.110.68.162";// 充电桩测试环境
77
//    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
78
    public static String urlNew = "http://123.56.67.7:83/api/0200";// 一电测试环境
79
//    public static String urlNew = "https://api.touchev.com:83/api/0200";// 一电正式环境
76
//    public static String url = "http://59.110.68.162";// 充电桩测试环境
77
    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
78
//    public static String urlNew = "http://123.56.67.7:83/api/0200";// 一电测试环境
79
    public static String urlNew = "https://api.touchev.com:83/api/0200";// 一电正式环境
80 80
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
81 81
    //	public static String url = "https://cdz.d1ev.com";
82 82
    public static String build_flag = "0";

+ 28 - 22
app/src/main/java/com/electric/chargingpile/data/HomePageBean.java

@ -5,29 +5,35 @@ import java.util.ArrayList;
5 5
public class HomePageBean {
6 6
7 7
8
    public ArrayList<TalkRecommendBean> list;
9
    public HomePageuserVo userVo;
8
    public ArrayList<ChatRecommendBean> list; // 话题下的内容信息集合
9
    public HomePageTopicBean topicVo;
10 10
11
    public class HomePageuserVo {
12
        public String nickName;
13
        public String headImgUrl;
14
        public String carName;
15
        public int topicNums;
11
    public class HomePageTopicBean {
12
        public String topicId; // 话题ID
13
        public String name; // 话题名称
14
        public String coverImgUrl; // 话题封面图片
15
        public String desc; // 话题描述
16
        public int joinNums; // 参与该话题的人数(最多显示4位,超过4位,以千进位,显示1.1W,小数点后1位)
17
        public int visitNums; // 访问量
16 18
17
        public long targetId;
18
        public long addUserId;
19
        public int targetType;
20
        public String title;
21
        public String carSeriesName;
22
        public String topicName;
23
        public String coverImgUrl;
24
        public String shareUrl;
25
        public String[] imgUrls;
26
        public int topicId;
27
        public int likeNums;
28
        public int commentNums;
29
        public int isTop;
30
        public int likeFlg;
31
        public int source;
19
        @Override
20
        public String toString() {
21
            return "HomePageTopicBean{" +
22
                    "topicId='" + topicId + '\'' +
23
                    ", name='" + name + '\'' +
24
                    ", coverImgUrl='" + coverImgUrl + '\'' +
25
                    ", desc='" + desc + '\'' +
26
                    ", joinNums=" + joinNums +
27
                    ", visitNums=" + visitNums +
28
                    '}';
29
        }
30
    }
31
32
    @Override
33
    public String toString() {
34
        return "HomePageBean{" +
35
                "list=" + list +
36
                ", topicVo=" + topicVo +
37
                '}';
32 38
    }
33 39
}

+ 195 - 3
app/src/main/res/layout/activity_chat_content.xml

@ -1,6 +1,198 @@
1 1
<?xml version="1.0" encoding="utf-8"?>
2
<android.support.constraint.ConstraintLayout
3
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
4
    android:layout_height="match_parent">
2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="wrap_content"
6
    android:layout_height="wrap_content"
7
    android:layout_marginBottom="10dp"
8
    android:background="#ffffff">
9
10
    <android.support.constraint.ConstraintLayout
11
        android:id="@+id/image_video_item"
12
        android:layout_width="wrap_content"
13
        android:layout_height="wrap_content"
14
        app:layout_constraintBottom_toBottomOf="parent"
15
        app:layout_constraintEnd_toEndOf="parent"
16
        app:layout_constraintStart_toStartOf="parent"
17
        app:layout_constraintTop_toTopOf="parent">
18
19
        <ImageView
20
            android:id="@+id/coverImage"
21
            android:layout_width="168dp"
22
            android:layout_height="147dp"
23
            android:contentDescription="信息图片"
24
            app:layout_constraintEnd_toEndOf="parent"
25
            app:layout_constraintStart_toStartOf="parent"
26
            app:layout_constraintTop_toTopOf="parent"
27
            tools:srcCompat="@tools:sample/avatars[0]" />
28
29
        <ImageView
30
            android:id="@+id/videoIcon"
31
            android:layout_width="wrap_content"
32
            android:layout_height="wrap_content"
33
            android:src="@drawable/app_talk_video_icon"
34
            android:visibility="gone"
35
            app:layout_constraintBottom_toBottomOf="@+id/coverImage"
36
            app:layout_constraintLeft_toLeftOf="@+id/coverImage"
37
            app:layout_constraintRight_toRightOf="@+id/coverImage"
38
            app:layout_constraintTop_toTopOf="@+id/coverImage"
39
            tools:visibility="visible" />
40
41
        <TextView
42
            android:id="@+id/isTop"
43
            android:layout_width="wrap_content"
44
            android:layout_height="wrap_content"
45
            android:layout_marginTop="10dp"
46
            android:layout_marginRight="10dp"
47
            android:background="@color/white"
48
            android:paddingLeft="4dp"
49
            android:paddingRight="4dp"
50
            android:text="置顶"
51
            android:textColor="@color/color_fb9349"
52
            android:textSize="14sp"
53
            android:visibility="gone"
54
            app:layout_constraintRight_toRightOf="@+id/coverImage"
55
            app:layout_constraintTop_toTopOf="@+id/coverImage"
56
            tools:visibility="visible" />
57
58
        <TextView
59
            android:id="@+id/title"
60
            android:layout_width="0dp"
61
            android:layout_height="wrap_content"
62
            android:layout_marginLeft="10dp"
63
            android:layout_marginTop="10dp"
64
            android:layout_marginRight="10dp"
65
            android:ellipsize="end"
66
            android:maxLines="2"
67
            android:textColor="#222222"
68
            android:textSize="15sp"
69
            app:layout_constraintEnd_toEndOf="parent"
70
            app:layout_constraintStart_toStartOf="parent"
71
            app:layout_constraintTop_toBottomOf="@+id/coverImage"
72
            tools:text="汽车上的“保命油”到底该多久换一次?汽车上的“保命油”到底该多久换一次?" />
73
74
        <android.support.constraint.ConstraintLayout
75
            android:layout_width="0dp"
76
            android:layout_height="48dp"
77
            app:layout_constraintLeft_toLeftOf="parent"
78
            app:layout_constraintRight_toRightOf="parent"
79
            app:layout_constraintTop_toBottomOf="@+id/title">
80
81
            <android.support.constraint.ConstraintLayout
82
                android:id="@+id/authorInfo"
83
                android:layout_width="wrap_content"
84
                android:layout_height="0dp"
85
                android:paddingLeft="10dp"
86
                android:paddingRight="10dp"
87
                app:layout_constraintBottom_toBottomOf="parent"
88
                app:layout_constraintLeft_toLeftOf="parent"
89
                app:layout_constraintTop_toTopOf="parent">
90
91
                <ImageView
92
                    android:id="@+id/headImage"
93
                    android:layout_width="20dp"
94
                    android:layout_height="20dp"
95
                    app:layout_constraintBottom_toBottomOf="parent"
96
                    app:layout_constraintStart_toStartOf="parent"
97
                    app:layout_constraintTop_toTopOf="parent"
98
                    tools:srcCompat="@tools:sample/avatars[1]" />
99
100
                <TextView
101
                    android:id="@+id/nickName"
102
                    android:layout_width="wrap_content"
103
                    android:layout_height="wrap_content"
104
                    android:layout_marginStart="5dp"
105
                    android:textColor="#888888"
106
                    android:textSize="14sp"
107
                    app:layout_constraintBottom_toBottomOf="parent"
108
                    app:layout_constraintLeft_toRightOf="@+id/headImage"
109
                    app:layout_constraintTop_toTopOf="parent"
110
                    tools:text="妮妮" />
111
            </android.support.constraint.ConstraintLayout>
112
113
            <android.support.constraint.ConstraintLayout
114
                android:id="@+id/likeInfo"
115
                android:layout_width="wrap_content"
116
                android:layout_height="0dp"
117
                android:paddingLeft="10dp"
118
                android:paddingRight="10dp"
119
                app:layout_constraintBottom_toBottomOf="parent"
120
                app:layout_constraintRight_toRightOf="parent"
121
                app:layout_constraintTop_toTopOf="parent">
122
123
                <ImageView
124
                    android:id="@+id/likeIcon"
125
                    android:layout_width="16dp"
126
                    android:layout_height="16dp"
127
                    android:background="@drawable/app_talk_main_list_zan_icon"
128
                    android:contentDescription="点赞图片"
129
                    app:layout_constraintBottom_toBottomOf="parent"
130
                    app:layout_constraintRight_toLeftOf="@+id/likeNum"
131
                    app:layout_constraintTop_toTopOf="parent" />
132
133
                <TextView
134
                    android:id="@+id/likeNum"
135
                    android:layout_width="wrap_content"
136
                    android:layout_height="wrap_content"
137
                    android:paddingLeft="5dp"
138
                    android:textColor="#888888"
139
                    android:textSize="13sp"
140
                    app:layout_constraintBottom_toBottomOf="parent"
141
                    app:layout_constraintRight_toRightOf="parent"
142
                    app:layout_constraintTop_toTopOf="parent"
143
                    tools:text="11W" />
144
            </android.support.constraint.ConstraintLayout>
145
146
        </android.support.constraint.ConstraintLayout>
147
    </android.support.constraint.ConstraintLayout>
148
149
    <android.support.constraint.ConstraintLayout
150
        android:id="@+id/topic_item"
151
        android:layout_width="wrap_content"
152
        android:layout_height="wrap_content"
153
        android:visibility="gone"
154
        app:layout_constraintBottom_toBottomOf="parent"
155
        app:layout_constraintLeft_toLeftOf="parent"
156
        app:layout_constraintRight_toRightOf="parent"
157
        app:layout_constraintTop_toTopOf="parent">
158
159
        <ImageView
160
            android:id="@+id/topicCoverImage"
161
            android:layout_width="168dp"
162
            android:layout_height="147dp"
163
            android:contentDescription="话题图片"
164
            app:layout_constraintBottom_toBottomOf="parent"
165
            app:layout_constraintLeft_toLeftOf="parent"
166
            app:layout_constraintRight_toRightOf="parent"
167
            app:layout_constraintTop_toTopOf="parent"
168
            tools:srcCompat="@tools:sample/avatars[7]" />
169
170
        <ImageView
171
            android:layout_width="0dp"
172
            android:layout_height="0dp"
173
            android:alpha="0.5"
174
            android:background="#000000"
175
            android:contentDescription="话题遮罩"
176
            app:layout_constraintBottom_toBottomOf="@+id/topicCoverImage"
177
            app:layout_constraintLeft_toLeftOf="@+id/topicCoverImage"
178
            app:layout_constraintRight_toRightOf="@+id/topicCoverImage"
179
            app:layout_constraintTop_toTopOf="@id/topicCoverImage" />
180
181
        <TextView
182
            android:id="@+id/topicTitle"
183
            android:layout_width="0dp"
184
            android:layout_height="wrap_content"
185
            android:ellipsize="end"
186
            android:maxLines="3"
187
            android:paddingLeft="10dp"
188
            android:paddingRight="10dp"
189
            android:textColor="#ffffff"
190
            android:textSize="15sp"
191
            app:layout_constraintBottom_toBottomOf="@+id/topicCoverImage"
192
            app:layout_constraintLeft_toLeftOf="@+id/topicCoverImage"
193
            app:layout_constraintRight_toRightOf="@+id/topicCoverImage"
194
            app:layout_constraintTop_toTopOf="@id/topicCoverImage"
195
            tools:text="新能源汽车发展趋势" />
196
    </android.support.constraint.ConstraintLayout>
5 197
6 198
</android.support.constraint.ConstraintLayout>

+ 1 - 0
app/src/main/res/layout/activity_topic_detail.xml

@ -11,6 +11,7 @@
11 11
        android:id="@+id/navBar"
12 12
        android:layout_width="0dp"
13 13
        android:layout_height="44dp"
14
        android:background="#ffffff"
14 15
        app:layout_constraintEnd_toEndOf="parent"
15 16
        app:layout_constraintStart_toStartOf="parent"
16 17
        app:layout_constraintTop_toTopOf="parent">

+ 45 - 10
app/src/main/res/layout/activity_topic_detail_header.xml

@ -2,6 +2,7 @@
2 2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4 4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:id="@+id/topicDetailHeader"
5 6
    android:layout_width="match_parent"
6 7
    android:layout_height="260dp">
7 8
@ -24,7 +25,7 @@
24 25
            tools:srcCompat="@tools:sample/avatars" />
25 26
26 27
        <TextView
27
            android:id="@+id/title"
28
            android:id="@+id/name"
28 29
            android:layout_width="0dp"
29 30
            android:layout_height="0dp"
30 31
            android:layout_marginStart="5dp"
@ -49,6 +50,7 @@
49 50
            android:layout_marginStart="15dp"
50 51
            android:layout_marginTop="15dp"
51 52
            android:layout_marginEnd="15dp"
53
            android:ellipsize="end"
52 54
            android:maxLines="3"
53 55
            android:textColor="#555555"
54 56
            android:textSize="15sp"
@ -70,7 +72,7 @@
70 72
            app:layout_constraintStart_toStartOf="parent" />
71 73
72 74
        <TextView
73
            android:id="@+id/readTextView"
75
            android:id="@+id/read"
74 76
            android:layout_width="wrap_content"
75 77
            android:layout_height="wrap_content"
76 78
            android:layout_marginStart="5dp"
@ -90,17 +92,17 @@
90 92
            android:text="参与"
91 93
            android:textColor="#555555"
92 94
            android:textSize="12sp"
93
            app:layout_constraintBottom_toBottomOf="@+id/readTextView"
94
            app:layout_constraintStart_toEndOf="@+id/readTextView"
95
            app:layout_constraintTop_toTopOf="@+id/readTextView" />
95
            app:layout_constraintBottom_toBottomOf="@+id/read"
96
            app:layout_constraintStart_toEndOf="@+id/read"
97
            app:layout_constraintTop_toTopOf="@+id/read" />
96 98
97 99
        <TextView
98
            android:id="@+id/joinTextView"
100
            android:id="@+id/join"
99 101
            android:layout_width="wrap_content"
100 102
            android:layout_height="wrap_content"
101 103
            android:layout_marginStart="5dp"
102 104
            android:gravity="center_vertical"
103
            android:text="32"
105
            tools:text="32"
104 106
            android:textColor="#555555"
105 107
            android:textSize="12sp"
106 108
            app:layout_constraintBottom_toBottomOf="@+id/joinLabel"
@ -108,12 +110,45 @@
108 110
            app:layout_constraintTop_toTopOf="@+id/joinLabel" />
109 111
    </android.support.constraint.ConstraintLayout>
110 112
111
    <LinearLayout
113
    <android.support.constraint.ConstraintLayout
112 114
        android:layout_width="0dp"
113 115
        android:layout_height="50dp"
114
        android:background="#ff00ff"
116
        android:background="#ffffff"
115 117
        android:orientation="horizontal"
116 118
        app:layout_constraintBottom_toBottomOf="parent"
117 119
        app:layout_constraintEnd_toEndOf="parent"
118
        app:layout_constraintStart_toStartOf="parent"></LinearLayout>
120
        app:layout_constraintStart_toStartOf="parent">
121
122
        <android.support.constraint.ConstraintLayout
123
            android:layout_width="wrap_content"
124
            android:layout_height="0dp"
125
            android:paddingLeft="15dp"
126
            android:paddingRight="15dp"
127
            app:layout_constraintBottom_toBottomOf="parent"
128
            app:layout_constraintStart_toStartOf="parent"
129
            app:layout_constraintTop_toTopOf="parent">
130
131
            <TextView
132
                android:id="@+id/sortTextView"
133
                android:layout_width="wrap_content"
134
                android:layout_height="match_parent"
135
                android:layout_weight="1"
136
                android:gravity="center_vertical"
137
                android:text="最新发布"
138
                android:textColor="#02B637"
139
                android:textSize="12sp"
140
                app:layout_constraintBottom_toBottomOf="parent"
141
                app:layout_constraintStart_toStartOf="parent"
142
                app:layout_constraintTop_toTopOf="parent" />
143
144
            <ImageView
145
                android:id="@+id/sortCursor"
146
                android:layout_width="wrap_content"
147
                android:layout_height="wrap_content"
148
                android:src="@drawable/app_topic_detaic_popup_icon"
149
                app:layout_constraintBottom_toBottomOf="parent"
150
                app:layout_constraintLeft_toRightOf="@+id/sortTextView"
151
                app:layout_constraintTop_toTopOf="parent" />
152
        </android.support.constraint.ConstraintLayout>
153
    </android.support.constraint.ConstraintLayout>
119 154
</android.support.constraint.ConstraintLayout>

+ 1 - 4
build.gradle

@ -8,8 +8,7 @@ buildscript {
8 8
//        appKey = 'mnhwhy8jP7Fq2G6b' // 注册时分配的App Key
9 9
//    }
10 10
    repositories {
11
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
12
        maven{ url 'https://maven.aliyun.com/repository/google' }
11
13 12
        jcenter()
14 13
        google()
15 14
    }
@ -24,8 +23,6 @@ buildscript {
24 23
}
25 24
allprojects {
26 25
    repositories {
27
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/' }
28
        maven{ url 'https://maven.aliyun.com/repository/google' }
29 26
        jcenter()
30 27
        google()
31 28
        maven { url "https://jitpack.io" }