Przeglądaj źródła

Update ChatContentListActivity.java

huyuguo 5 lat temu
rodzic
commit
f415dd417d

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

@ -1,5 +1,6 @@
1 1
package com.electric.chargingpile.activity;
2 2
3
import android.content.Intent;
3 4
import android.graphics.Color;
4 5
import android.graphics.drawable.ColorDrawable;
5 6
import android.support.annotation.Nullable;
@ -145,6 +146,8 @@ public class ChatContentListActivity extends AppCompatActivity {
145 146
        }
146 147
147 148
        if (bean.targetType != ChatRecommendBean.TARGET_TYPE_VIDEO) {
149
            GSYVideoADManager.onPause();
150
            GSYVideoManager.onPause();
148 151
            return;
149 152
        }
150 153
@ -215,6 +218,10 @@ public class ChatContentListActivity extends AppCompatActivity {
215 218
        private ImageView headImage;
216 219
        private TextView nickName;
217 220
        private TextView addDate;
221
        private ConstraintLayout topicInfo;
222
        private ImageView closeUnfold;
223
        private TextView topicTitle;
224
        private ConstraintLayout userInfo;
218 225
219 226
        public static ChatContentFragment newInstance(int index, String from) {
220 227
            ChatContentFragment fragment = new ChatContentFragment();
@ -265,6 +272,10 @@ public class ChatContentListActivity extends AppCompatActivity {
265 272
            headImage = rootView.findViewById(R.id.headImage);
266 273
            nickName = rootView.findViewById(R.id.nickName);
267 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 279
            ConstraintLayout navBar = rootView.findViewById(R.id.navBar);
269 280
270 281
            // 视频尺寸判断
@ -374,6 +385,7 @@ public class ChatContentListActivity extends AppCompatActivity {
374 385
                    Log.d(TAG, "onClick: " + msg.getLineCount());
375 386
                    int maxLines = msg.getMaxLines();
376 387
                    if (maxLines == 3) {
388
                        closeUnfold.setVisibility(View.VISIBLE);
377 389
                        fold.setImageResource(R.drawable.unfold_icon);
378 390
                        if (msgLines > 7) {
379 391
                            msg.setMaxLines(7);
@ -384,6 +396,7 @@ public class ChatContentListActivity extends AppCompatActivity {
384 396
                        }
385 397
                        toolBar.setVisibility(View.GONE);
386 398
                    } else {
399
                        closeUnfold.setVisibility(View.GONE);
387 400
                        fold.setImageResource(R.drawable.fold_icon);
388 401
                        msg.setMovementMethod(null);
389 402
                        msg.setMaxLines(3);
@ -396,6 +409,21 @@ public class ChatContentListActivity extends AppCompatActivity {
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 427
            if (TextUtils.isEmpty(bean.headImgUrl)) {
400 428
                Picasso.with(getContext())
401 429
                        .load(R.drawable.icon_face2_0)
@ -416,6 +444,32 @@ public class ChatContentListActivity extends AppCompatActivity {
416 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 473
            rootView.findViewById(R.id.bottomView).setOnClickListener(new View.OnClickListener() {
420 474
                @Override
421 475
                public void onClick(View view) {
@ -596,5 +650,31 @@ public class ChatContentListActivity extends AppCompatActivity {
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
}