e83edf6f166624cbc4296a0be9eebbe58L131">131 149
132
    private void setListHolder(IViewHolder holder, final int position) {
133
134
        final ChatRecommendBean chatRecommendBean = chatRecommendBeans.get(position - 1);
135
        SimpleViewHolder simpleViewHolder = (SimpleViewHolder) holder;
136
        simpleViewHolder.index = position - 1;
137
        RelativeLayout.LayoutParams bgParams = (RelativeLayout.LayoutParams) simpleViewHolder.info_bg_icon.getLayoutParams();
138
        bgParams.width = talkItemWidth;
139
140
        if (chatRecommendBean.targetType == ChatRecommendBean.TARGET_TYPE_IMAGE_TOPIC) { // 话题
141
            bgParams.height = (int) (talkItemWidth * 365f / 480f);
142
            simpleViewHolder.bottom_view.setVisibility(View.GONE);
143
            simpleViewHolder.topic_back.setVisibility(View.VISIBLE);
144
            simpleViewHolder.recycler_view_title.setVisibility(View.GONE);
145
            simpleViewHolder.topic_title.setVisibility(View.VISIBLE);
146
147
            // 设置话题半透明层
148
            RelativeLayout.LayoutParams tbParams = (RelativeLayout.LayoutParams) simpleViewHolder.topic_back.getLayoutParams();
149
            tbParams.height = bgParams.height;
150
            tbParams.width = bgParams.width;
151
            simpleViewHolder.topic_back.setLayoutParams(tbParams);
152
            // 设置话题标题
153
            simpleViewHolder.topic_title.setText(chatRecommendBean.title);
154
150
    private void bindContentViewHolder(IViewHolder viewHolder, final int position) {
151
        final ChatRecommendBean bean = beanLab.beans().get(position - 1);
152
        TopicDetailAdapter.ContentViewHolder contentViewHolder = (TopicDetailAdapter.ContentViewHolder) viewHolder;
153
        ConstraintLayout.LayoutParams coverImageParams = (ConstraintLayout.LayoutParams) contentViewHolder.coverImage.getLayoutParams();
154
        coverImageParams.width = itemWidth;
155
156
        if (bean.targetType == ChatRecommendBean.TARGET_TYPE_IMAGE_TOPIC) {
157
            contentViewHolder.topic_item.setVisibility(View.VISIBLE);
158
            contentViewHolder.image_video_item.setVisibility(View.GONE);
159
            ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams)contentViewHolder.topicCoverImage.getLayoutParams();
160
            params.width = itemWidth;
161
            params.height = (int) (itemWidth * 365f / 480f);
162
            contentViewHolder.topicCoverImage.setLayoutParams(params);
163
            ImageDisplayUtils.dispalyImg(context, bean.coverImgUrl, contentViewHolder.topicCoverImage);
164
            contentViewHolder.topicTitle.setText(bean.title);
155 165
        } else {
156
            if (chatRecommendBean.coverImgW == 0 || chatRecommendBean.coverImgH == 0) {
157
                bgParams.height = (int) (talkItemWidth * 16f / 9f);
166
            contentViewHolder.topic_item.setVisibility(View.GONE);
167
            contentViewHolder.image_video_item.setVisibility(View.VISIBLE);
168
            if (bean.coverImgW == 0 || bean.coverImgH == 0) {
169
                coverImageParams.height = (int) (itemWidth * 16f / 9f);
158 170
            } else {
159
                if ((float) chatRecommendBean.coverImgH / chatRecommendBean.coverImgW > 16f / 9f) {
160
                    bgParams.height = (int) (talkItemWidth * 16f / 9f);
171
                if ((float) bean.coverImgH / bean.coverImgW > 16f / 9f) {
172
                    coverImageParams.height = (int) (itemWidth * 16f / 9f);
161 173
                } else {
162
                    bgParams.height = (int) ((float) talkItemWidth * chatRecommendBean.coverImgH / chatRecommendBean.coverImgW);
174
                    coverImageParams.height = (int) ((float) itemWidth * bean.coverImgH / bean.coverImgW);
163 175
                }
164 176
            }
165
            simpleViewHolder.bottom_view.setVisibility(View.VISIBLE);
166
            simpleViewHolder.topic_back.setVisibility(View.GONE);
167
            simpleViewHolder.recycler_view_title.setVisibility(View.VISIBLE);
168
            simpleViewHolder.topic_title.setVisibility(View.GONE);
169
            // 红心点赞
170
            if (chatRecommendBean.likeFlg == 0) {
171
                simpleViewHolder.recycler_view_zan_icon.setBackgroundResource(R.drawable.app_talk_main_list_zan_icon);
177
            contentViewHolder.coverImage.setLayoutParams(coverImageParams);
178
            ImageDisplayUtils.dispalyImg(context, bean.coverImgUrl, contentViewHolder.coverImage);
179
180
            contentViewHolder.videoIcon.setVisibility(bean.targetType == ChatRecommendBean.TARGET_TYPE_VIDEO ? View.VISIBLE : View.GONE);
181
            contentViewHolder.isTop.setVisibility(bean.isTop == 1 ? View.VISIBLE : View.GONE);
182
            if (TextUtils.isEmpty(bean.title)) {
183
                contentViewHolder.title.setText("分享内容");
172 184
            } else {
173
                simpleViewHolder.recycler_view_zan_icon.setBackgroundResource(R.drawable.app_talk_main_list_zan_red_icon);
185
                contentViewHolder.title.setText(bean.title);
174 186
            }
175
            // 标题设置
176
            if (TextUtils.isEmpty(chatRecommendBean.title)) {
177
                simpleViewHolder.recycler_view_title.setText("分享内容");
187
188
            if (TextUtils.isEmpty(bean.headImgUrl)) {
189
                Picasso.with(context)
190
                        .load(R.drawable.icon_face2_0)
191
                        .placeholder(R.drawable.icon_face2_0)
192
                        .error(R.drawable.icon_face2_0)
193
                        .transform(new CircleTransform())
194
                        .into(contentViewHolder.headImage);
178 195
            } else {
179
                simpleViewHolder.recycler_view_title.setText(chatRecommendBean.title);
196
                Picasso.with(context)
197
                        .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + bean.headImgUrl)
198
                        .placeholder(R.drawable.icon_face2_0)
199
                        .error(R.drawable.icon_face2_0)
200
                        .transform(new CircleTransform())
201
                        .into(contentViewHolder.headImage);
180 202
            }
181 203
182
            if (chatRecommendBean.likeNums == 0) {
183
                simpleViewHolder.recycler_view_zan.setVisibility(View.GONE);
184
                LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) simpleViewHolder.recycler_view_zan_icon.getLayoutParams();
185
                params.rightMargin = DensityUtil.dip2px(context, 10);
186
                simpleViewHolder.recycler_view_zan_icon.setLayoutParams(params);
187
            } else if (chatRecommendBean.likeNums > 999) {
188
                simpleViewHolder.recycler_view_zan.setVisibility(View.VISIBLE);
189
                simpleViewHolder.recycler_view_zan.setText("999+");
204
            contentViewHolder.nickName.setText(bean.nickName);
205
            contentViewHolder.likeInfo.setOnClickListener(new View.OnClickListener() {
206
                @Override
207
                public void onClick(View view) {
208
                    if (bean.likeFlg == 0) {
209
                        doLike(position);
210
                    }
211
                }
212
            });
213
214
            if (bean.likeFlg == 1) {
215
                contentViewHolder.likeIcon.setBackgroundResource(R.drawable.app_talk_main_list_zan_red_icon);
190 216
            } else {
191
                simpleViewHolder.recycler_view_zan.setVisibility(View.VISIBLE);
192
                simpleViewHolder.recycler_view_zan.setText(chatRecommendBean.likeNums + "");
217
                contentViewHolder.likeIcon.setBackgroundResource(R.drawable.app_talk_main_list_zan_icon);
193 218
            }
194 219
195
            simpleViewHolder.user_avater_name.setText(chatRecommendBean.nickName);
220
            int likeNum = bean.likeNums;
221
            if (likeNum > 0) {
222
                contentViewHolder.likeNum.setVisibility(View.VISIBLE);
223
                contentViewHolder.likeNum.setText(likeNum < 999 ? likeNum + "" : "999+");
224
            } else {
225
                contentViewHolder.likeNum.setVisibility(View.GONE);
226
            }
196 227
        }
197 228
198
        if (chatRecommendBean.isTop == 0) {
199
            simpleViewHolder.is_top_view.setVisibility(View.GONE);
200
        } else {
201
            simpleViewHolder.is_top_view.setBackgroundResource(R.drawable.corner_view);
202
            simpleViewHolder.is_top_view.setVisibility(View.VISIBLE);
203
        }
229
    }
204 230
205
        if (chatRecommendBean.targetType == ChatRecommendBean.TARGET_TYPE_VIDEO) {
206
            simpleViewHolder.info_id_video_icon.setVisibility(View.VISIBLE);
207
        } else {
208
            simpleViewHolder.info_id_video_icon.setVisibility(View.GONE);
209
        }
210
        simpleViewHolder.info_bg_icon.setLayoutParams(bgParams);
231
    /**
232
     * 点赞操作
233
     *
234
     * @param position
235
     */
236
    private void doLike(final int position) {
237
        final ChatRecommendBean bean = beanLab.beans().get(position - 1);
238
        String url = MainApplication.urlNew + "/topic/like.do";
239
        Map<String, String> map = new HashMap<>();
240
        map.put("targetId", bean.targetId + "");
241
        map.put("targetType", bean.targetType + "");
242
        map.put("flag", "1");
243
        map.put("authorId", bean.addUserId + "");
244
        CommonParams.addCommonParams(map);
245
246
        OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
247
            @Override
248
            public void onError(Call call, Exception e) {
249
                ToastUtil.showToast(context, "点赞失败,请重试", Toast.LENGTH_SHORT);
250
            }
251
252
            @Override
253
            public void onResponse(String res) {
254
                String code = JsonUtils.getKeyResult(res, "code");
255
                String desc = JsonUtils.getKeyResult(res, "desc");
256
                if ("1000".equals(code)) {
257
                    bean.likeFlg = 1;
258
                    bean.likeNums += 1;
259
                    notifyItemChanged(position);
260
                } else {
261
                    ToastUtil.showToast(context, desc, Toast.LENGTH_SHORT);
262
                }
263
            }
264
        });
265
    }
211 266
212
        ImageDisplayUtils.dispalyImg(context, chatRecommendBean.coverImgUrl, simpleViewHolder.info_bg_icon);
267
    private void bindFooterViewHolder(IViewHolder viewHolder, final int position) {
268
        TopicDetailAdapter.FooterViewHolder footerViewHolder = (TopicDetailAdapter.FooterViewHolder) viewHolder;
269
        StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) footerViewHolder.footerContainer.getLayoutParams();
270
        layoutParams.setFullSpan(true);
213 271
214
        if (TextUtils.isEmpty(chatRecommendBean.headImgUrl)) {
215
            Picasso.with(context)
216
                    .load(R.drawable.icon_face2_0)
217
                    .placeholder(R.drawable.icon_face2_0)
218
                    .error(R.drawable.icon_face2_0)
219
                    .transform(new CircleTransform())
220
                    .into(simpleViewHolder.user_avater);
272
        footerViewHolder.footerContainer.setVisibility(showFooter ? View.VISIBLE : View.GONE);
273
274
        ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) footerViewHolder.footerView.getLayoutParams();
275
276
        if (beanLab.beans().size() == 0) {
277
            params.height = DensityUtil.dip2px(context, 230);
278
            footerViewHolder.footTextView.setText("还没有任何内容哦,快来抢沙发~");
221 279
        } else {
222
            Picasso.with(context)
223
                    .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + chatRecommendBean.headImgUrl)
224
                    .placeholder(R.drawable.icon_face2_0)
225
                    .error(R.drawable.icon_face2_0)
226
                    .transform(new CircleTransform())
227
                    .into(simpleViewHolder.user_avater);
280
            footerViewHolder.footTextView.setText("已经全部加载完毕");
281
            params.height = DensityUtil.dip2px(context, 20);
228 282
        }
229
283
        footerViewHolder.footTextView.setLayoutParams(params);
230 284
    }
231 285
232
    private void setHeaderHolder(IViewHolder holder, int position) {
286
287
288
    private void bindHeaderViewHolder(IViewHolder holder, int position) {
233 289
        // 获取chat_header_linear_layout的布局属性,记住这里
234 290
        // 要是布局的最外层的控件的布局属性,如果是里层的会报cast错误
235 291
        SimpleHeaderViewHolder simpleHeaderViewHolder = (SimpleHeaderViewHolder) holder;
@ -258,104 +314,6 @@ public class ChatRecommendAdapter extends RecyclerView.Adapter<IViewHolder> {
258 314
        void onItemClick(View view);
259 315
    }
260 316
261
    class SimpleViewHolder extends IViewHolder {
262
        private int index;
263
        RelativeLayout card_view;
264
        TextView recycler_view_title;
265
        TextView recycler_view_zan;
266
        TextView user_avater_name;
267
        TextView is_top_view;
268
        ImageView user_avater;
269
        ImageView recycler_view_zan_icon;
270
        ImageView info_bg_icon;
271
        ImageView info_id_video_icon;
272
        RelativeLayout bottom_view;
273
        ImageView topic_back;
274
        TextView topic_title;
275
276
        public SimpleViewHolder(View view) {
277
            super(view);
278
            card_view = view.findViewById(R.id.card_view);
279
            recycler_view_title = (TextView) view.findViewById(R.id.recycler_view_title);
280
            user_avater_name = (TextView) view.findViewById(R.id.user_avater_name);
281
            is_top_view = (TextView) view.findViewById(R.id.is_top_view);
282
            recycler_view_zan = (TextView) view.findViewById(R.id.recycler_view_zan);
283
            user_avater = (ImageView) view.findViewById(R.id.user_avater);
284
            recycler_view_zan_icon = view.findViewById(R.id.recycler_view_zan_icon);
285
            info_bg_icon = (ImageView) view.findViewById(R.id.info_bg_icon);
286
            info_id_video_icon = (ImageView) view.findViewById(R.id.info_id_video_icon);
287
            bottom_view = view.findViewById(R.id.bottom_view);
288
            topic_back = view.findViewById(R.id.topic_back);
289
            topic_title = view.findViewById(R.id.topic_title);
290
291
            itemView.setOnClickListener(new View.OnClickListener() {
292
                @Override
293
                public void onClick(View view) {
294
                    if (onRecyclerItemClickListener != null) {
295
                        onRecyclerItemClickListener.onItemClickListener(getLayoutPosition(), 2);
296
                    }
297
                }
298
            });
299
            recycler_view_zan_icon.setOnClickListener(new View.OnClickListener() {
300
                @Override
301
                public void onClick(View view) { // 点赞操作
302
                    likeClick();
303
                }
304
            });
305
        }
306
307
        private void likeClick() {
308
            final ChatRecommendBean bean = chatRecommendBeans.get(index);
309
            if (bean.likeFlg == 1) { // 已点赞,无需再次点赞
310
                return;
311
            }
312
            String url = MainApplication.urlNew + "/topic/like.do";
313
            Map<String, String> map = new HashMap<>();
314
            CommonParams.addCommonParams(map);
315
            map.put("targetId", bean.targetId + "");
316
            map.put("targetType", bean.targetType + "");
317
            map.put("flag", "1");
318
            map.put("authorId", bean.addUserId + "");
319
            Log.d(TAG, "likeClick: " + map);
320
321
            OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
322
                @Override
323
                public void onError(Call call, Exception e) {
324
                    ToastUtil.showToast(context, "点赞失败,请重试", Toast.LENGTH_SHORT);
325
                }
326
327
                @Override
328
                public void onResponse(String response) {
329
                    String rtnCode = JsonUtils.getKeyResult(response, "code");
330
                    String desc = JsonUtils.getKeyResult(response, "desc");
331
                    if ("1000".equals(rtnCode)) {
332
                        recycler_view_zan_icon.setBackgroundResource(R.drawable.app_talk_main_list_zan_red_icon);
333
                        bean.likeNums++;
334
335
                        if (bean.likeNums > 999) {
336
                            recycler_view_zan.setText("999+");
337
                        } else {
338
                            recycler_view_zan.setText(bean.likeNums + "");
339
                        }
340
                        recycler_view_zan.setVisibility(View.VISIBLE);
341
                        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) recycler_view_zan_icon.getLayoutParams();
342
                        params.rightMargin = DensityUtil.dip2px(context, 5);
343
                        recycler_view_zan_icon.setLayoutParams(params);
344
                    } else {
345
                        ToastUtil.showToast(context, desc, Toast.LENGTH_SHORT);
346
                    }
347
                }
348
            });
349
        }
350
351
        public int getIndex() {
352
            return index;
353
        }
354
355
        public void setIndex(int index) {
356
            this.index = index;
357
        }
358
    }
359 317
360 318
    class SimpleHeaderViewHolder extends IViewHolder {
361 319
        LinearLayout chat_header_linear_layout;

+ 1 - 1
app/src/main/java/com/electric/chargingpile/adapter/LayoutAdapter.java

@ -59,7 +59,7 @@ public class LayoutAdapter extends RecyclerView.Adapter<IViewHolder> {
59 59
        talkRecommendBeans = new ArrayList<>();
60 60
        talkHeaderRecommendBeans = new ArrayList<>();
61 61
        screenWidth = ScreenUtils.getScreenWidth(context);
62
        talkItemWidth = (screenWidth - DensityUtil.dip2px(context, 10 * 2)) / 2;
62
        talkItemWidth = (screenWidth - DensityUtil.dip2px(context, 20 * 2)) / 2;
63 63
    }
64 64
65 65
    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {

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

@ -56,9 +56,6 @@ public class TopicDetailAdapter extends RecyclerView.Adapter<IViewHolder> {
56 56
    private RecyclerItemTypeClickListener onRecyclerItemClickListener;
57 57
    private ChooseTopicSortInterface chooseTopicSortInterface;
58 58
    private final int screenWidth;
59
    private final int screenHeight;
60
    private final int statusHeight;
61
    private final int headerHeight;
62 59
    private int itemWidth;
63 60
    private boolean showFooter = false;
64 61
@ -69,10 +66,7 @@ public class TopicDetailAdapter extends RecyclerView.Adapter<IViewHolder> {
69 66
        beanLab = TopicDetailBeanLab.get(context);
70 67
71 68
        screenWidth = ScreenUtils.getScreenWidth(context);
72
        screenHeight = ScreenUtils.getScreenHeight(context);
73
        statusHeight = ScreenUtils.getStatusHeight(context);
74
        headerHeight = DensityUtil.dip2px(context, 260);
75
        itemWidth = (screenWidth - DensityUtil.dip2px(context, 10 * 2)) / 2;
69
        itemWidth = (screenWidth - DensityUtil.dip2px(context, 20 * 2)) / 2;
76 70
    }
77 71
78 72
    @Override

+ 1 - 1
app/src/main/java/com/electric/chargingpile/adapter/UserPageAdapter.java

@ -54,7 +54,7 @@ public class UserPageAdapter extends RecyclerView.Adapter<IViewHolder> {
54 54
        beanLab = UserPageBeanLab.get(context);
55 55
56 56
        screenWidth = ScreenUtils.getScreenWidth(context);
57
        itemWidth = (screenWidth - DensityUtil.dip2px(context, 10 * 2)) / 2;
57
        itemWidth = (screenWidth - DensityUtil.dip2px(context, 20 * 2)) / 2;
58 58
    }
59 59
60 60
    @Override

+ 45 - 0
app/src/main/java/com/electric/chargingpile/data/ChatBeanLab.java

@ -0,0 +1,45 @@
1
package com.electric.chargingpile.data;
2
3
import android.content.Context;
4
5
import java.util.ArrayList;
6
import java.util.List;
7
8
public class ChatBeanLab {
9
    private static ChatBeanLab beanLab;
10
    private List<ChatRecommendBean> beans;
11
12
    public static ChatBeanLab get(Context context) {
13
        if (beanLab == null) {
14
            beanLab = new ChatBeanLab(context);
15
        }
16
17
        return beanLab;
18
    }
19
20
    private ChatBeanLab(Context context) {
21
        beans = new ArrayList<>();
22
    }
23
24
    public List<ChatRecommendBean> beans() {
25
        return beans;
26
    }
27
28
    public ChatRecommendBean bean(int topicId) {
29
        for (ChatRecommendBean bean : beans) {
30
            if (bean.topicId == topicId) {
31
                return bean;
32
            }
33
        }
34
        return null;
35
    }
36
37
    public void clear() {
38
        beans.clear();
39
    }
40
41
42
    public void add(List<ChatRecommendBean> list) {
43
        beans.addAll(list);
44
    }
45
}

+ 95 - 81
app/src/main/java/com/electric/chargingpile/fragment/ChatRecommendFragment.java

@ -21,13 +21,12 @@ import com.electric.chargingpile.activity.TopicDetailActivity;
21 21
import com.electric.chargingpile.activity.VideoDetaislActivity;
22 22
import com.electric.chargingpile.adapter.ChatRecommendAdapter;
23 23
import com.electric.chargingpile.adapter.ChatRecommendItemDecoration;
24
import com.electric.chargingpile.adapter.TopicDetailAdapter;
24 25
import com.electric.chargingpile.application.MainApplication;
25
import com.electric.chargingpile.data.AuthSignBean;
26
import com.electric.chargingpile.data.ChatBeanLab;
26 27
import com.electric.chargingpile.data.ChatRecommendBean;
27
import com.electric.chargingpile.data.TalkRecommendBean;
28 28
import com.electric.chargingpile.iview.RecyclerItemTypeClickListener;
29 29
import com.electric.chargingpile.manager.ProfileManager;
30
import com.electric.chargingpile.util.Bimp;
31 30
import com.electric.chargingpile.util.CommonParams;
32 31
import com.electric.chargingpile.util.JsonUtils;
33 32
import com.electric.chargingpile.util.LoadingDialog;
@ -36,27 +35,18 @@ import com.electric.chargingpile.util.ToastUtil;
36 35
import com.zhy.http.okhttp.OkHttpUtils;
37 36
import com.zhy.http.okhttp.callback.StringCallback;
38 37
39
import java.io.Serializable;
40 38
import java.util.ArrayList;
41 39
import java.util.HashMap;
42
import java.util.List;
43 40
import java.util.Map;
44
45
import io.reactivex.Observable;
46
import io.reactivex.android.schedulers.AndroidSchedulers;
47
import io.reactivex.disposables.Disposable;
48
import io.reactivex.functions.Consumer;
49
import io.reactivex.functions.Predicate;
50
import io.reactivex.schedulers.Schedulers;
51 41
import okhttp3.Call;
52 42
53 43
public class ChatRecommendFragment extends Fragment implements View.OnClickListener {
54 44
    private static final String TAG = "ChatRecommendFragment";
55 45
    public static final int CLICK_PUBLISH_BTN = 1010;
56 46
    private View view;
57
    private XRefreshView refreshView;
58
    private ImageView iv_ask;
47
    private XRefreshView xRefreshView;
59 48
    private RecyclerView recyclerView;
49
    private ImageView iv_ask;
60 50
    private ChatRecommendAdapter chatRecommendAdapter;
61 51
    private StaggeredGridLayoutManager layoutManager;
62 52
    private ImageView chat_share_info_remind;
@ -75,8 +65,8 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
75 65
    private void initViews() {
76 66
        loadingDialog = new LoadingDialog(getContext());
77 67
        loadingDialog.setCanceledOnTouchOutside(false);
78
        refreshView = view.findViewById(R.id.chat_x_refresh_view);
79
        refreshView.setPullLoadEnable(true);
68
        xRefreshView = view.findViewById(R.id.chat_x_refresh_view);
69
        xRefreshView.setPullLoadEnable(true);
80 70
        recyclerView = view.findViewById(R.id.recycler_view_test_rv);
81 71
        recyclerView.setHasFixedSize(true);
82 72
@ -96,13 +86,11 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
96 86
        layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
97 87
        recyclerView.setItemAnimator(null);
98 88
        recyclerView.setLayoutManager(layoutManager);
99
        recyclerView.addItemDecoration(new ChatRecommendItemDecoration()); // 设置边距
100
        // 静默加载模式不能设置footerview
89
        recyclerView.addItemDecoration(new TopicDetailAdapter.ContentViewDecoration()); // 设置边距
101 90
        recyclerView.setAdapter(chatRecommendAdapter);
102
        refreshView.setPinnedTime(0);
103
//        refreshView.setMoveForHorizontal(true);
91
        xRefreshView.setPinnedTime(0);
104 92
105
        refreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener() {
93
        xRefreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener() {
106 94
            @Override
107 95
            public void onRefresh(boolean isPullDown) {
108 96
                page = 1;
@ -116,9 +104,9 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
116 104
            }
117 105
        });
118 106
119
        refreshView.startRefresh();
107
        loadingDialog.show();
108
//        xRefreshView.startRefresh();
120 109
        requestHeaderData(); // 该页面数据发起请求起点
121
122 110
        chatRecommendAdapter.setOnRecyclerItemClickListener(new RecyclerItemTypeClickListener() {
123 111
            @Override
124 112
            public void onItemClickListener(final int position, int type) {
@ -128,48 +116,50 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
128 116
                }
129 117
130 118
                if (type == 2) {
131
                }
132
                final ArrayList<ChatRecommendBean> beans = chatRecommendAdapter.getCurrentData();
133
                ChatRecommendBean bean = beans.get(position - 1);
134
                if (bean.targetType == ChatRecommendBean.TARGET_TYPE_IMAGE_TOPIC) {
135
                    Intent intent = new Intent(getActivity(), TopicDetailActivity.class);
136
                    intent.putExtra("topicId", bean.targetId);
137
                    startActivity(intent);
138
                } else {
139
                    Disposable disposable = Observable
140
                            .fromIterable(beans)
141
                            .filter(new Predicate<ChatRecommendBean>() {
142
                                @Override
143
                                public boolean test(ChatRecommendBean chatRecommendBean) throws Exception {
144
                                    return chatRecommendBean.targetType != 25;
145
                                }
146
                            }).toList()
147
                            .subscribeOn(Schedulers.io())
148
                            .observeOn(AndroidSchedulers.mainThread())
149
                            .subscribe(new Consumer<List<ChatRecommendBean>>() {
150
                                @Override
151
                                public void accept(List<ChatRecommendBean> list) throws Exception {
152
                                    ChatRecommendBean chatRecommendBean = beans.get(position - 1);
153
154
                                    int index = 0;
155
                                    for (int i = 0; i < list.size(); i++) {
156
                                        ChatRecommendBean tmp = list.get(i);
157
                                        if (tmp.targetType == chatRecommendBean.targetType &&
158
                                                tmp.targetId == chatRecommendBean.targetId) {
159
                                            index = i;
160
                                            break;
161
                                        }
162
                                    }
163
164
                                    Intent intent = new Intent(getActivity(), VideoDetaislActivity.class);
165
                                    intent.putExtra("list", (Serializable) list);
166
                                    intent.putExtra("pos", index);
167
                                    startActivity(intent);
168
169
                                }
170
                            });
119
171 120
                }
172 121
122
//                final ArrayList<ChatRecommendBean> beans = chatRecommendAdapter.getCurrentData();
123
//                ChatRecommendBean bean = beans.get(position - 1);
124
//                if (bean.targetType == ChatRecommendBean.TARGET_TYPE_IMAGE_TOPIC) {
125
//                    Intent intent = new Intent(getActivity(), TopicDetailActivity.class);
126
//                    intent.putExtra("topicId", bean.targetId);
127
//                    startActivity(intent);
128
//                } else {
129
//                    Disposable disposable = Observable
130
//                            .fromIterable(beans)
131
//                            .filter(new Predicate<ChatRecommendBean>() {
132
//                                @Override
133
//                                public boolean test(ChatRecommendBean chatRecommendBean) throws Exception {
134
//                                    return chatRecommendBean.targetType != 25;
135
//                                }
136
//                            }).toList()
137
//                            .subscribeOn(Schedulers.io())
138
//                            .observeOn(AndroidSchedulers.mainThread())
139
//                            .subscribe(new Consumer<List<ChatRecommendBean>>() {
140
//                                @Override
141
//                                public void accept(List<ChatRecommendBean> list) throws Exception {
142
//                                    ChatRecommendBean chatRecommendBean = beans.get(position - 1);
143
//
144
//                                    int index = 0;
145
//                                    for (int i = 0; i < list.size(); i++) {
146
//                                        ChatRecommendBean tmp = list.get(i);
147
//                                        if (tmp.targetType == chatRecommendBean.targetType &&
148
//                                                tmp.targetId == chatRecommendBean.targetId) {
149
//                                            index = i;
150
//                                            break;
151
//                                        }
152
//                                    }
153
//
154
//                                    Intent intent = new Intent(getActivity(), VideoDetaislActivity.class);
155
//                                    intent.putExtra("list", (Serializable) list);
156
//                                    intent.putExtra("pos", index);
157
//                                    startActivity(intent);
158
//
159
//                                }
160
//                            });
161
//                }
162
173 163
                // TODO update by huyuguo
174 164
                Log.d(TAG, "onItemClickListener: position:" + position + ",type:" + type);
175 165
@ -253,11 +243,12 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
253 243
    }
254 244
255 245
    public void refreshList() {
256
        if (view == null)
257
            return;
258
        refreshView.startRefresh();
259
        page = 1;
260
        requestHeaderData();
246
//        if (view == null)
247
//            return;
248
//        ChatBeanLab.get(getContext()).clear();
249
//        xRefreshView.startRefresh();
250
//        page = 1;
251
//        requestHeaderData();
261 252
    }
262 253
263 254
    private void requestHeaderData() {
@ -270,10 +261,11 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
270 261
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
271 262
            @Override
272 263
            public void onError(Call call, Exception e) {
264
                loadingDialog.dismiss();
273 265
                if (page == 1) {
274
                    refreshView.stopRefresh();
266
                    xRefreshView.stopRefresh();
275 267
                } else {
276
                    refreshView.stopLoadMore();
268
                    xRefreshView.stopLoadMore();
277 269
                }
278 270
                if (getActivity() != null) {
279 271
                    ToastUtil.showToast(getActivity().getApplicationContext(), "加载失败,请重试:" + e.getMessage(), Toast.LENGTH_SHORT);
@ -290,6 +282,7 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
290 282
                    chatRecommendAdapter.setHeaderData(topicData);
291 283
                    requestData();
292 284
                } else {
285
                    loadingDialog.dismiss();
293 286
                    ToastUtil.showToast(getActivity().getApplicationContext(), desc, Toast.LENGTH_SHORT);
294 287
                }
295 288
            }
@ -306,22 +299,23 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
306 299
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
307 300
            @Override
308 301
            public void onError(Call call, Exception e) {
302
                loadingDialog.dismiss();
309 303
                if (page == 1) {
310
                    refreshView.stopRefresh();
304
                    xRefreshView.stopRefresh();
311 305
                } else {
312
                    refreshView.stopLoadMore();
306
                    xRefreshView.stopLoadMore();
313 307
                }
314 308
                ToastUtil.showToast(getActivity().getApplicationContext(), "加载失败,请重试:" + e.getMessage(), Toast.LENGTH_SHORT);
315 309
            }
316 310
317 311
            @Override
318 312
            public void onResponse(String response) {
313
                loadingDialog.dismiss();
319 314
                if (page == 1) {
320
                    refreshView.stopRefresh();
315
                    xRefreshView.stopRefresh();
321 316
                } else {
322
                    refreshView.stopLoadMore();
317
                    xRefreshView.stopLoadMore();
323 318
                }
324
//                Log.d(TAG, "onResponse: " + response);
325 319
326 320
                String code = JsonUtils.getKeyResult(response, "code");
327 321
                String desc = JsonUtils.getKeyResult(response, "desc");
@ -329,19 +323,39 @@ public class ChatRecommendFragment extends Fragment implements View.OnClickListe
329 323
                    String data = JsonUtils.getKeyResult(response, "data");
330 324
                    ArrayList<ChatRecommendBean> chatRecommendBeans = (ArrayList<ChatRecommendBean>) JsonUtils.parseToObjectList(data, ChatRecommendBean.class);
331 325
                    if (page == 1) {
332
                        refreshView.setLoadComplete(false);
326
                        xRefreshView.setLoadComplete(false);
333 327
                        chatRecommendAdapter.setData(chatRecommendBeans);
328
                        if (chatRecommendBeans.size() == 0) {
329
                            xRefreshView.setLoadComplete(true);
330
                            chatRecommendAdapter.setFooterData(true);
331
                        } else {
332
                            chatRecommendAdapter.setFooterData(false);
333
                        }
334 334
                    } else {
335
                        chatRecommendAdapter.addData(chatRecommendBeans);
336
                    }
337
338
                    if (chatRecommendBeans.size() == 0) {
339
                        refreshView.setLoadComplete(true);
335
                        if (chatRecommendBeans.size() == 0) {
336
                            xRefreshView.setLoadComplete(true);
337
                            chatRecommendAdapter.setFooterData(true);
338
                        } else {
339
                            chatRecommendAdapter.setFooterData(false);
340
                            chatRecommendAdapter.addData(chatRecommendBeans);
341
                        }
340 342
                    }
341 343
                } else {
344
                    if (page == 1) {
345
                        xRefreshView.stopRefresh();
346
                    } else {
347
                        page--;
348
                        xRefreshView.stopLoadMore();
349
                    }
342 350
                    ToastUtil.showToast(getActivity().getApplicationContext(), desc, Toast.LENGTH_SHORT);
343 351
                }
344 352
            }
345 353
        });
346 354
    }
355
356
    @Override
357
    public void onPause() {
358
        super.onPause();
359
        ChatBeanLab.get(getContext()).clear();
360
    }
347 361
}

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

@ -60,11 +60,11 @@
60 60
            android:id="@+id/title"
61 61
            android:layout_width="0dp"
62 62
            android:layout_height="wrap_content"
63
            android:paddingLeft="10dp"
64
            android:paddingRight="10dp"
65
            android:paddingTop="10dp"
66 63
            android:ellipsize="end"
67 64
            android:maxLines="3"
65
            android:paddingLeft="10dp"
66
            android:paddingTop="10dp"
67
            android:paddingRight="10dp"
68 68
            android:textColor="#222222"
69 69
            android:textSize="15sp"
70 70
            app:layout_constraintEnd_toEndOf="parent"
@ -182,6 +182,7 @@
182 182
            android:layout_width="0dp"
183 183
            android:layout_height="wrap_content"
184 184
            android:ellipsize="end"
185
            android:gravity="center"
185 186
            android:maxLines="3"
186 187
            android:paddingLeft="10dp"
187 188
            android:paddingRight="10dp"

+ 0 - 136
app/src/main/res/layout/view_chat_recommend.xml

@ -1,136 +0,0 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
4
    android:id="@+id/card_view"
5
    android:layout_width="match_parent"
6
    android:layout_height="wrap_content"
7
    android:layout_marginBottom="10dp"
8
    android:background="#ffffff"
9
    android:paddingBottom="5dp">
10
11
    <RelativeLayout
12
        android:id="@+id/info_bg_icon_bg"
13
        android:layout_width="wrap_content"
14
        android:layout_height="wrap_content"
15
        android:gravity="center">
16
17
        <ImageView
18
            android:id="@+id/info_bg_icon"
19
            android:layout_width="wrap_content"
20
            android:layout_height="wrap_content"
21
            android:scaleType="fitXY" />
22
23
        <ImageView
24
            android:id="@+id/info_id_video_icon"
25
            android:layout_width="wrap_content"
26
            android:layout_height="wrap_content"
27
            android:layout_centerInParent="true"
28
            android:src="@drawable/app_talk_video_icon" />
29
30
        <ImageView
31
            android:id="@+id/topic_back"
32
            android:layout_width="match_parent"
33
            android:layout_height="match_parent"
34
            android:alpha="0.5"
35
            android:background="@color/black" />
36
37
        <TextView
38
            android:id="@+id/topic_title"
39
            android:layout_width="wrap_content"
40
            android:layout_height="wrap_content"
41
            android:layout_centerInParent="true"
42
            android:textColor="@color/white"
43
            android:textSize="14sp" />
44
    </RelativeLayout>
45
46
    <TextView
47
        android:id="@+id/is_top_view"
48
        android:layout_width="wrap_content"
49
        android:layout_height="wrap_content"
50
        android:layout_alignRight="@+id/info_bg_icon_bg"
51
        android:layout_marginTop="10dp"
52
        android:layout_marginRight="10dp"
53
        android:background="@color/white"
54
        android:text="置顶"
55
        android:textColor="@color/color_fb9349"
56
        android:textSize="14sp" />
57
58
    <TextView
59
        android:id="@+id/recycler_view_title"
60
        android:layout_width="wrap_content"
61
        android:layout_height="wrap_content"
62
        android:layout_below="@+id/info_bg_icon_bg"
63
        android:layout_alignLeft="@+id/info_bg_icon_bg"
64
        android:layout_alignRight="@+id/info_bg_icon_bg"
65
        android:layout_marginBottom="16dp"
66
        android:ellipsize="end"
67
        android:maxLines="3"
68
        android:paddingLeft="10dp"
69
        android:paddingTop="11dp"
70
        android:paddingRight="10dp"
71
        android:text="123"
72
        android:textColor="@color/ui_62"
73
        android:textSize="15sp" />
74
75
    <RelativeLayout
76
        android:id="@+id/bottom_view"
77
        android:layout_width="wrap_content"
78
        android:layout_height="wrap_content"
79
        android:layout_below="@+id/recycler_view_title"
80
        android:layout_alignLeft="@+id/info_bg_icon_bg"
81
        android:layout_alignRight="@+id/info_bg_icon_bg">
82
83
        <LinearLayout
84
            android:id="@+id/recycler_view_zan_icon_view"
85
            android:layout_width="wrap_content"
86
            android:layout_height="wrap_content"
87
            android:layout_alignParentRight="true"
88
            android:layout_centerVertical="true"
89
            android:gravity="center_vertical"
90
            android:orientation="horizontal">
91
92
            <ImageView
93
                android:id="@+id/recycler_view_zan_icon"
94
                android:layout_width="16dp"
95
                android:layout_height="16dp"
96
                android:layout_centerVertical="true"
97
                android:layout_marginRight="5dp"
98
                android:layout_toLeftOf="@+id/recycler_view_zan"
99
                android:background="@drawable/app_talk_main_list_zan_icon" />
100
101
            <TextView
102
                android:id="@+id/recycler_view_zan"
103
                android:layout_width="wrap_content"
104
                android:layout_height="wrap_content"
105
                android:layout_centerVertical="true"
106
                android:layout_marginRight="10dp"
107
                android:text="456"
108
                android:textColor="@color/ui_68"
109
                android:textSize="13sp" />
110
111
        </LinearLayout>
112
113
        <ImageView
114
            android:id="@+id/user_avater"
115
            android:layout_width="20dp"
116
            android:layout_height="20dp"
117
            android:layout_centerVertical="true"
118
            android:layout_marginLeft="10dp" />
119
120
        <TextView
121
            android:id="@+id/user_avater_name"
122
            android:layout_width="match_parent"
123
            android:layout_height="wrap_content"
124
            android:layout_centerVertical="true"
125
            android:layout_toLeftOf="@+id/recycler_view_zan_icon_view"
126
            android:layout_toRightOf="@+id/user_avater"
127
            android:ellipsize="end"
128
            android:paddingLeft="5dp"
129
            android:singleLine="true"
130
            android:text="456"
131
            android:textColor="@color/ui_68"
132
            android:textSize="13sp" />
133
134
    </RelativeLayout>
135
136
</RelativeLayout>

cdzApp - Gogs: Go Git Service

充电桩app代码

gradlew 5.0KB

    #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >&- APP_HOME="`pwd -P`" cd "$SAVED" >&- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"