From bb836cc5d5bc89a716dfc0209d1d096f3fd59cb6 Mon Sep 17 00:00:00 2001 From: dueeeke Date: Wed, 29 Aug 2018 19:59:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=96=E9=9F=B3demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/list/tiktok/TikTokActivity.java | 12 ++++++++---- .../com/dueeeke/dkplayer/adapter/TikTokAdapter.java | 1 + app/src/main/res/layout/layout_tiktok_controller.xml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/dueeeke/dkplayer/activity/list/tiktok/TikTokActivity.java b/app/src/main/java/com/dueeeke/dkplayer/activity/list/tiktok/TikTokActivity.java index 109a3ecd..e93d5a43 100644 --- a/app/src/main/java/com/dueeeke/dkplayer/activity/list/tiktok/TikTokActivity.java +++ b/app/src/main/java/com/dueeeke/dkplayer/activity/list/tiktok/TikTokActivity.java @@ -13,8 +13,8 @@ import android.view.ViewParent; import android.view.WindowInsets; import android.widget.FrameLayout; -import android.widget.ImageView; +import com.bumptech.glide.Glide; import com.dueeeke.dkplayer.R; import com.dueeeke.dkplayer.adapter.TikTokAdapter; import com.dueeeke.dkplayer.bean.VideoBean; @@ -74,7 +74,9 @@ public void onInitComplete() { @Override public void onPageRelease(boolean isNext, int position) { - mIjkVideoView.release(); + if (mCurrentPosition == position) { + mIjkVideoView.release(); + } } @Override @@ -93,8 +95,10 @@ public void onPageSelected(int position, boolean isBottom) { private void startPlay(int position) { View itemView = mRecyclerView.getChildAt(0); FrameLayout frameLayout = itemView.findViewById(R.id.container); - ImageView imageView = itemView.findViewById(R.id.thumb); - mTikTokController.getThumb().setImageDrawable(imageView.getDrawable()); + Glide.with(this) + .load(mVideoList.get(position).getThumb()) + .placeholder(android.R.color.white) + .into(mTikTokController.getThumb()); frameLayout.addView(mIjkVideoView); mIjkVideoView.setUrl(mVideoList.get(position).getUrl()); mIjkVideoView.setScreenScale(IjkVideoView.SCREEN_SCALE_CENTER_CROP); diff --git a/app/src/main/java/com/dueeeke/dkplayer/adapter/TikTokAdapter.java b/app/src/main/java/com/dueeeke/dkplayer/adapter/TikTokAdapter.java index 74a25aab..0d813811 100644 --- a/app/src/main/java/com/dueeeke/dkplayer/adapter/TikTokAdapter.java +++ b/app/src/main/java/com/dueeeke/dkplayer/adapter/TikTokAdapter.java @@ -36,6 +36,7 @@ public void onBindViewHolder(final VideoHolder holder, int position) { VideoBean videoBean = videos.get(position); Glide.with(context) .load(videoBean.getThumb()) + .placeholder(android.R.color.white) .into(holder.thumb); } diff --git a/app/src/main/res/layout/layout_tiktok_controller.xml b/app/src/main/res/layout/layout_tiktok_controller.xml index f96e4b56..3a0827ba 100644 --- a/app/src/main/res/layout/layout_tiktok_controller.xml +++ b/app/src/main/res/layout/layout_tiktok_controller.xml @@ -6,6 +6,6 @@ android:id="@+id/iv_thumb" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="fitXY"/> + android:scaleType="centerCrop"/> \ No newline at end of file