Skip to content

Commit

Permalink
优化抖音demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Doikki committed Aug 29, 2018
1 parent e7c5c07 commit bb836cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,7 +74,9 @@ public void onInitComplete() {

@Override
public void onPageRelease(boolean isNext, int position) {
mIjkVideoView.release();
if (mCurrentPosition == position) {
mIjkVideoView.release();
}
}

@Override
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/layout_tiktok_controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

</LinearLayout>

0 comments on commit bb836cc

Please sign in to comment.