Sfoglia il codice sorgente

Update ChatContentListActivity.java

huyuguo 5 anni fa
parent
commit
f415dd417d

+ 80 - 0
app/src/main/java/com/electric/chargingpile/activity/ChatContentListActivity.java

1
package com.electric.chargingpile.activity;
1
package com.electric.chargingpile.activity;
2
2
3
import android.content.Intent;
3
import android.graphics.Color;
4
import android.graphics.Color;
4
import android.graphics.drawable.ColorDrawable;
5
import android.graphics.drawable.ColorDrawable;
5
import android.support.annotation.Nullable;
6
import android.support.annotation.Nullable;
145
        }
146
        }
146
147
147
        if (bean.targetType != ChatRecommendBean.TARGET_TYPE_VIDEO) {
148
        if (bean.targetType != ChatRecommendBean.TARGET_TYPE_VIDEO) {
149
            GSYVideoADManager.onPause();
150
            GSYVideoManager.onPause();
148
            return;
151
            return;
149
        }
152
        }
150
153
215
        private ImageView headImage;
218
        private ImageView headImage;
216
        private TextView nickName;
219
        private TextView nickName;
217
        private TextView addDate;
220
        private TextView addDate;
221
        private ConstraintLayout topicInfo;
222
        private ImageView closeUnfold;
223
        private TextView topicTitle;
224
        private ConstraintLayout userInfo;
218
225
219
        public static ChatContentFragment newInstance(int index, String from) {
226
        public static ChatContentFragment newInstance(int index, String from) {
220
            ChatContentFragment fragment = new ChatContentFragment();
227
            ChatContentFragment fragment = new ChatContentFragment();
265
            headImage = rootView.findViewById(R.id.headImage);
272
            headImage = rootView.findViewById(R.id.headImage);
266
            nickName = rootView.findViewById(R.id.nickName);
273
            nickName = rootView.findViewById(R.id.nickName);
267
            addDate = rootView.findViewById(R.id.addDate);
274
            addDate = rootView.findViewById(R.id.addDate);
275
            topicInfo = rootView.findViewById(R.id.topicInfo);
276
            closeUnfold = rootView.findViewById(R.id.closeUnfold);
277
            topicTitle = rootView.findViewById(R.id.topicTitle);
278
            userInfo = rootView.findViewById(R.id.userInfo);
268
            ConstraintLayout navBar = rootView.findViewById(R.id.navBar);
279
            ConstraintLayout navBar = rootView.findViewById(R.id.navBar);
269
280
270
            // 视频尺寸判断
281
            // 视频尺寸判断
374
                    Log.d(TAG, "onClick: " + msg.getLineCount());
385
                    Log.d(TAG, "onClick: " + msg.getLineCount());
375
                    int maxLines = msg.getMaxLines();
386
                    int maxLines = msg.getMaxLines();
376
                    if (maxLines == 3) {
387
                    if (maxLines == 3) {
388
                        closeUnfold.setVisibility(View.VISIBLE);
377
                        fold.setImageResource(R.drawable.unfold_icon);
389
                        fold.setImageResource(R.drawable.unfold_icon);
378
                        if (msgLines > 7) {
390
                        if (msgLines > 7) {
379
                            msg.setMaxLines(7);
391
                            msg.setMaxLines(7);
384
                        }
396
                        }
385
                        toolBar.setVisibility(View.GONE);
397
                        toolBar.setVisibility(View.GONE);
386
                    } else {
398
                    } else {
399
                        closeUnfold.setVisibility(View.GONE);
387
                        fold.setImageResource(R.drawable.fold_icon);
400
                        fold.setImageResource(R.drawable.fold_icon);
388
                        msg.setMovementMethod(null);
401
                        msg.setMovementMethod(null);
389
                        msg.setMaxLines(3);
402
                        msg.setMaxLines(3);
396
                }
409
                }
397
            });
410
            });
398
411
412
            closeUnfold.setOnClickListener(new View.OnClickListener() {
413
                @Override
414
                public void onClick(View view) {
415
                    closeUnfold.setVisibility(View.GONE);
416
                    fold.setImageResource(R.drawable.fold_icon);
417
                    msg.setMovementMethod(null);
418
                    msg.setMaxLines(3);
419
                    msg.setScrollbarFadingEnabled(true);
420
                    msg.setEllipsize(TextUtils.TruncateAt.END);
421
                    msg.setText(str);  // 重新赋值,解决...不出现的问题
422
423
                    toolBar.setVisibility(View.VISIBLE);
424
                }
425
            });
426
399
            if (TextUtils.isEmpty(bean.headImgUrl)) {
427
            if (TextUtils.isEmpty(bean.headImgUrl)) {
400
                Picasso.with(getContext())
428
                Picasso.with(getContext())
401
                        .load(R.drawable.icon_face2_0)
429
                        .load(R.drawable.icon_face2_0)
416
            addDate.setText(bean.addDate);
444
            addDate.setText(bean.addDate);
417
445
418
446
447
            if (bean.topicId == 0) {
448
                topicInfo.setVisibility(View.GONE);
449
            } else {
450
                topicTitle.setText(bean.topicName);
451
                topicInfo.setVisibility(View.VISIBLE);
452
            }
453
            topicInfo.setOnClickListener(new View.OnClickListener() {
454
                @Override
455
                public void onClick(View view) {
456
                    Intent intent = new Intent(getContext(), TopicDetailActivity.class);
457
                    intent.putExtra("topicId", bean.topicId);
458
                    getContext().startActivity(intent);
459
                }
460
            });
461
462
            userInfo.setOnClickListener(new View.OnClickListener() {
463
                @Override
464
                public void onClick(View view) {
465
                    Intent intent = new Intent(getContext(), UserPageActivity.class);
466
                    intent.putExtra("targetUserId", bean.addUserId + "");
467
                    getContext().startActivity(intent);
468
                }
469
            });
470
471
472
419
            rootView.findViewById(R.id.bottomView).setOnClickListener(new View.OnClickListener() {
473
            rootView.findViewById(R.id.bottomView).setOnClickListener(new View.OnClickListener() {
420
                @Override
474
                @Override
421
                public void onClick(View view) {
475
                public void onClick(View view) {
596
                }
650
                }
597
            });
651
            });
598
        }
652
        }
653
654
        @Override
655
        public void onPause() {
656
            super.onPause();
657
            if (videoPlayer != null) {
658
                videoPlayer.onVideoPause();
659
            }
660
            if (playIcon != null) {
661
                playIcon.setVisibility(View.VISIBLE);
662
            }
663
        }
664
665
        @Override
666
        public void onResume() {
667
            super.onResume();
668
//            if (videoPlayer != null) {
669
//                videoPlayer.onVideoResume();
670
//            }
671
        }
672
673
        @Override
674
        public void onDestroy() {
675
            super.onDestroy();
676
            GSYVideoManager.releaseAllVideos();
677
            GSYVideoADManager.releaseAllVideos();
678
        }
599
    }
679
    }
600
}
680
}