柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b

以下内容为反编译后的 AliyunListPlayerView.java 源代码,内容仅作参考


package net.duohuo.magappx.video.videoplay.view;

import android.content.Context;
import android.graphics.SurfaceTexture;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.aliyun.player.AliListPlayer;
import com.aliyun.player.AliPlayerFactory;
import com.aliyun.player.IPlayer;
import com.aliyun.player.aliyunplayer.listener.OnViewPagerListener;
import com.aliyun.player.aliyunplayer.util.ToastUtils;
import com.aliyun.player.bean.ErrorInfo;
import com.aliyun.player.bean.InfoBean;
import com.aliyun.player.bean.InfoCode;
import com.aliyun.player.nativeclass.PlayerConfig;
import com.aliyun.player.source.StsInfo;
import com.jianpuzhaitong.forum.R;
import java.util.List;
import net.duohuo.core.util.SafeJsonUtil;
import net.duohuo.magappx.video.adapter.AliyunRecyclerViewAdapter;
import net.duohuo.magappx.video.adapter.PagerLayoutManager;
import net.duohuo.magappx.video.model.VideoItem;
import net.duohuo.magappx.video.util.RecordSettings;

public class AliyunListPlayerView extends FrameLayout {
    private static final int DEFAULT_PRELOAD_NUMBER = 1;
    private boolean isEnd;
    private AliListPlayer mAliListPlayer;
    private int mCurrentPosition;
    private GestureDetector mGestureDetector;
    private boolean mIsLoadingData;
    private boolean mIsOnBackground;
    private boolean mIsPause;
    private int mLastStopPosition;
    private View mListPlayerContainer;
    private com.aliyun.player.aliyunplayer.view.recycler.RecyclerViewEmptySupport mListPlayerRecyclerView;
    private TextureView mListPlayerTextureView;
    private PagerLayoutManager mPagerLayoutManager;
    private ImageView mPlayIconImageView;
    private AliyunRecyclerViewAdapter mRecyclerViewAdapter;
    private TextView mRefreshTextView;
    private SparseArray<String> mSparseArray;
    private StsInfo mStsInfo;
    private List<VideoItem> mVideoListBean;
    public OnPageListener onPageListener;
    private OnRefreshDataListener onRefreshDataListener;

    public interface OnPageListener {
        void onPageSelected(int i);
    }

    public interface OnRefreshDataListener {
        void onLoadMore();

        void onRefresh();
    }

    private void clearNotShowVideo(List<VideoItem> list) {
    }

    public void hideRefresh() {
    }

    public void setScaleMode(IPlayer.ScaleMode scaleMode) {
    }

    public void showRefresh() {
    }

    public AliyunRecyclerViewAdapter getmRecyclerViewAdapter() {
        return this.mRecyclerViewAdapter;
    }

    public void setmRecyclerViewAdapter(AliyunRecyclerViewAdapter aliyunRecyclerViewAdapter) {
        this.mRecyclerViewAdapter = aliyunRecyclerViewAdapter;
    }

    public AliyunListPlayerView(Context context) {
        super(context);
        this.mLastStopPosition = -1;
        initVideoView();
    }

    public AliyunListPlayerView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.mLastStopPosition = -1;
        initVideoView();
    }

    public AliyunListPlayerView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.mLastStopPosition = -1;
        initVideoView();
    }

    private void initVideoView() {
        initListPlayer();
        initListPlayerView();
        initPagerLayoutManager();
        initRecyclerView();
    }

    private void initListPlayer() {
        AliListPlayer createAliListPlayer = AliPlayerFactory.createAliListPlayer(getContext());
        this.mAliListPlayer = createAliListPlayer;
        createAliListPlayer.setLoop(true);
        PlayerConfig config = this.mAliListPlayer.getConfig();
        config.mClearFrameWhenStop = true;
        config.mReferrer = "https://app.jpztong.com/";
        this.mAliListPlayer.setConfig(config);
        this.mAliListPlayer.setOnPreparedListener(new IPlayer.OnPreparedListener() {
            @Override
            public void onPrepared() {
                if (AliyunListPlayerView.this.mIsPause || AliyunListPlayerView.this.mIsOnBackground) {
                    return;
                }
                AliyunListPlayerView.this.mAliListPlayer.start();
            }
        });
        this.mAliListPlayer.setOnRenderingStartListener(new IPlayer.OnRenderingStartListener() {
            @Override
            public void onRenderingStart() {
                AliyunRecyclerViewAdapter.MyViewHolder myViewHolder;
                if (AliyunListPlayerView.this.mListPlayerRecyclerView == null || (myViewHolder = (AliyunRecyclerViewAdapter.MyViewHolder) AliyunListPlayerView.this.mListPlayerRecyclerView.findViewHolderForLayoutPosition(AliyunListPlayerView.this.mCurrentPosition)) == null) {
                    return;
                }
                myViewHolder.getCoverView().setVisibility(8);
                myViewHolder.getSeekBar().setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    @Override
                    public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
                    }

                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {
                        AliyunListPlayerView.this.mAliListPlayer.seekTo((AliyunListPlayerView.this.mAliListPlayer.getDuration() * seekBar.getProgress()) / 100);
                    }
                });
            }
        });
        this.mAliListPlayer.setOnInfoListener(new IPlayer.OnInfoListener() {
            @Override
            public void onInfo(InfoBean infoBean) {
                AliyunRecyclerViewAdapter.MyViewHolder myViewHolder;
                if (infoBean.getCode() == InfoCode.CurrentPosition) {
                    boolean z = AliyunListPlayerView.this.mAliListPlayer.getDuration() > RecordSettings.DEFAULT_MAX_RECORD_DURATION;
                    if (AliyunListPlayerView.this.mListPlayerRecyclerView == null || (myViewHolder = (AliyunRecyclerViewAdapter.MyViewHolder) AliyunListPlayerView.this.mListPlayerRecyclerView.findViewHolderForLayoutPosition(AliyunListPlayerView.this.mCurrentPosition)) == null || AliyunListPlayerView.this.mAliListPlayer.getDuration() <= 0) {
                        return;
                    }
                    myViewHolder.getSeekBar().setVisibility(z ? 0 : 8);
                    myViewHolder.getLoadingView().setVisibility(8);
                    int extraValue = (int) (((infoBean.getExtraValue() % AliyunListPlayerView.this.mAliListPlayer.getDuration()) * 100) / AliyunListPlayerView.this.mAliListPlayer.getDuration());
                    if (z) {
                        myViewHolder.getSeekBar().setProgress(extraValue);
                    } else {
                        myViewHolder.getVideoProgress().setProgress(extraValue);
                    }
                }
            }
        });
        this.mAliListPlayer.setOnErrorListener(new IPlayer.OnErrorListener() {
            @Override
            public void onError(ErrorInfo errorInfo) {
                ToastUtils.show(AliyunListPlayerView.this.getContext(), errorInfo.getCode() + " --- " + errorInfo.getMsg());
            }
        });
    }

    private void initListPlayerView() {
        View inflate = View.inflate(getContext(), R.layout.layout_list_player_view, null);
        this.mListPlayerContainer = inflate;
        this.mPlayIconImageView = (ImageView) inflate.findViewById(R.id.iv_play_icon);
        TextureView textureView = (TextureView) this.mListPlayerContainer.findViewById(R.id.list_player_textureview);
        this.mListPlayerTextureView = textureView;
        textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
            @Override
            public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
                return true;
            }

            @Override
            public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
            }

            @Override
            public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
                Surface surface = new Surface(surfaceTexture);
                if (AliyunListPlayerView.this.mAliListPlayer != null) {
                    AliyunListPlayerView.this.mAliListPlayer.setSurface(surface);
                    AliyunListPlayerView.this.mAliListPlayer.redraw();
                }
            }

            @Override
            public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
                if (AliyunListPlayerView.this.mAliListPlayer != null) {
                    AliyunListPlayerView.this.mAliListPlayer.redraw();
                }
            }
        });
    }

    private void initRecyclerView() {
        View inflate = LayoutInflater.from(getContext()).inflate(R.layout.layout_list_player_recyclerview, (ViewGroup) this, true);
        this.mListPlayerRecyclerView = (com.aliyun.player.aliyunplayer.view.recycler.RecyclerViewEmptySupport) inflate.findViewById(R.id.list_player_recyclerview);
        TextView textView = (TextView) inflate.findViewById(R.id.tv_refresh);
        this.mRefreshTextView = textView;
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (AliyunListPlayerView.this.onRefreshDataListener != null) {
                    AliyunListPlayerView.this.mIsLoadingData = true;
                    AliyunListPlayerView.this.onRefreshDataListener.onRefresh();
                }
            }
        });
        this.mListPlayerRecyclerView.setHasFixedSize(true);
        this.mListPlayerRecyclerView.setLayoutManager(this.mPagerLayoutManager);
        this.mListPlayerRecyclerView.setEmptyView(inflate.findViewById(R.id.rl_empty_view));
        AliyunRecyclerViewAdapter aliyunRecyclerViewAdapter = new AliyunRecyclerViewAdapter(getContext(), this);
        this.mRecyclerViewAdapter = aliyunRecyclerViewAdapter;
        this.mListPlayerRecyclerView.setAdapter(aliyunRecyclerViewAdapter);
    }

    private void initPagerLayoutManager() {
        if (this.mPagerLayoutManager == null) {
            PagerLayoutManager pagerLayoutManager = new PagerLayoutManager(getContext());
            this.mPagerLayoutManager = pagerLayoutManager;
            pagerLayoutManager.setItemPrefetchEnabled(true);
        }
        if (this.mPagerLayoutManager.viewPagerListenerIsNull()) {
            this.mPagerLayoutManager.setOnViewPagerListener(new OnViewPagerListener() {
                @Override
                public void onInitComplete() {
                    int findFirstVisibleItemPosition = AliyunListPlayerView.this.mPagerLayoutManager.findFirstVisibleItemPosition();
                    if (findFirstVisibleItemPosition != -1) {
                        AliyunListPlayerView.this.mCurrentPosition = findFirstVisibleItemPosition;
                    }
                    if (AliyunListPlayerView.this.mRecyclerViewAdapter.getItemCount() - findFirstVisibleItemPosition <= 1 && !AliyunListPlayerView.this.mIsLoadingData && !AliyunListPlayerView.this.isEnd) {
                        AliyunListPlayerView.this.mIsLoadingData = true;
                        AliyunListPlayerView.this.loadMore();
                    }
                    AliyunListPlayerView aliyunListPlayerView = AliyunListPlayerView.this;
                    aliyunListPlayerView.startPlay(aliyunListPlayerView.mCurrentPosition);
                    AliyunListPlayerView.this.mLastStopPosition = -1;
                    if (AliyunListPlayerView.this.mCurrentPosition != 0 || AliyunListPlayerView.this.onPageListener == null) {
                        return;
                    }
                    AliyunListPlayerView.this.onPageListener.onPageSelected(AliyunListPlayerView.this.mCurrentPosition);
                }

                @Override
                public void onPageRelease(boolean z, int i, View view) {
                    if (AliyunListPlayerView.this.mCurrentPosition == i) {
                        AliyunListPlayerView.this.mLastStopPosition = i;
                        AliyunListPlayerView.this.stopPlay();
                        AliyunRecyclerViewAdapter.MyViewHolder myViewHolder = (AliyunRecyclerViewAdapter.MyViewHolder) AliyunListPlayerView.this.mListPlayerRecyclerView.findViewHolderForLayoutPosition(i);
                        if (myViewHolder != null) {
                            myViewHolder.getCoverView().setVisibility(0);
                        }
                    }
                }

                @Override
                public void onPageSelected(int i, boolean z, View view) {
                    if (AliyunListPlayerView.this.onPageListener != null) {
                        AliyunListPlayerView.this.onPageListener.onPageSelected(i);
                    }
                    if (AliyunListPlayerView.this.mCurrentPosition != i || AliyunListPlayerView.this.mLastStopPosition == i) {
                        int itemCount = AliyunListPlayerView.this.mRecyclerViewAdapter.getItemCount();
                        if (itemCount == i + 1 && AliyunListPlayerView.this.isEnd) {
                            Toast.makeText(AliyunListPlayerView.this.getContext(), R.string.list_no_more, 0).show();
                        }
                        if (itemCount - i <= 1 && !AliyunListPlayerView.this.mIsLoadingData && !AliyunListPlayerView.this.isEnd) {
                            AliyunListPlayerView.this.mIsLoadingData = true;
                            AliyunListPlayerView.this.loadMore();
                        }
                        AliyunListPlayerView.this.startPlay(i);
                        AliyunListPlayerView.this.mCurrentPosition = i;
                    }
                }
            });
        }
    }

    public void setOnPageListener(OnPageListener onPageListener) {
        this.onPageListener = onPageListener;
    }

    public void loadMore() {
        OnRefreshDataListener onRefreshDataListener = this.onRefreshDataListener;
        if (onRefreshDataListener != null) {
            onRefreshDataListener.onLoadMore();
        }
    }

    public void startPlay(int i) {
        if (i < 0 || i > this.mVideoListBean.size()) {
            return;
        }
        this.mIsPause = false;
        this.mPlayIconImageView.setVisibility(8);
        AliyunRecyclerViewAdapter.MyViewHolder myViewHolder = (AliyunRecyclerViewAdapter.MyViewHolder) this.mListPlayerRecyclerView.findViewHolderForLayoutPosition(i);
        ViewParent parent = this.mListPlayerContainer.getParent();
        if (parent instanceof FrameLayout) {
            ((ViewGroup) parent).removeView(this.mListPlayerContainer);
        }
        if (myViewHolder != null) {
            myViewHolder.getContainerView().addView(this.mListPlayerContainer, 0);
        }
        if (this.mIsOnBackground) {
            return;
        }
        this.mAliListPlayer.moveTo(this.mSparseArray.get(i), this.mStsInfo);
    }

    public void onPauseClick() {
        if (this.mIsPause) {
            resumePlay();
        } else {
            pausePlay();
        }
    }

    public void setStsInfo(StsInfo stsInfo) {
        this.mStsInfo = stsInfo;
    }

    public void moveTo(String str) {
        AliListPlayer aliListPlayer = this.mAliListPlayer;
        if (aliListPlayer != null) {
            aliListPlayer.moveTo(str);
        }
    }

    public void moveTo(String str, StsInfo stsInfo) {
        AliListPlayer aliListPlayer = this.mAliListPlayer;
        if (aliListPlayer != null) {
            aliListPlayer.moveTo(str, stsInfo);
        }
    }

    public void addVid(String str, String str2) {
        AliListPlayer aliListPlayer = this.mAliListPlayer;
        if (aliListPlayer != null) {
            aliListPlayer.addVid(str, str2);
        }
    }

    public void addUrl(String str, String str2) {
        AliListPlayer aliListPlayer = this.mAliListPlayer;
        if (aliListPlayer != null) {
            aliListPlayer.addUrl(str, str2);
        }
    }

    public void setData(List<VideoItem> list) {
        clearNotShowVideo(list);
        this.isEnd = false;
        this.mIsLoadingData = false;
        AliyunRecyclerViewAdapter aliyunRecyclerViewAdapter = this.mRecyclerViewAdapter;
        if (aliyunRecyclerViewAdapter != null) {
            aliyunRecyclerViewAdapter.setData(list);
            this.mRecyclerViewAdapter.notifyDataSetChanged();
            this.mVideoListBean = list;
        }
    }

    public void addMoreData(List<VideoItem> list) {
        if (list == null || list.size() < 10) {
            this.isEnd = true;
            return;
        }
        this.isEnd = false;
        clearNotShowVideo(list);
        this.mIsLoadingData = false;
        AliyunRecyclerViewAdapter aliyunRecyclerViewAdapter = this.mRecyclerViewAdapter;
        if (aliyunRecyclerViewAdapter != null) {
            aliyunRecyclerViewAdapter.addMoreData(list);
        }
        hideRefresh();
    }

    public void setCorrelationTable(SparseArray<String> sparseArray) {
        this.mSparseArray = sparseArray;
    }

    public SparseArray<String> getCorrelationTable() {
        return this.mSparseArray;
    }

    public void stopPlay() {
        ViewParent parent = this.mListPlayerContainer.getParent();
        if (parent instanceof FrameLayout) {
            ((FrameLayout) parent).removeView(this.mListPlayerContainer);
        }
        this.mAliListPlayer.stop();
        this.mAliListPlayer.setSurface(null);
    }

    public void setOnBackground(boolean z) {
        this.mIsOnBackground = z;
        if (z) {
            pausePlay();
        } else {
            resumePlay();
        }
    }

    private void pausePlay() {
        this.mIsPause = true;
        this.mPlayIconImageView.setVisibility(0);
        this.mAliListPlayer.pause();
    }

    private void resumePlay() {
        this.mIsPause = false;
        this.mPlayIconImageView.setVisibility(8);
        this.mAliListPlayer.start();
    }

    public void destroy() {
        AliListPlayer aliListPlayer = this.mAliListPlayer;
        if (aliListPlayer != null) {
            aliListPlayer.stop();
            this.mAliListPlayer.release();
        }
    }

    public void setOnRefreshDataListener(OnRefreshDataListener onRefreshDataListener) {
        this.onRefreshDataListener = onRefreshDataListener;
    }

    public String getContentId(int i) {
        return (getmRecyclerViewAdapter() == null || getmRecyclerViewAdapter().getValues() == null || i >= getmRecyclerViewAdapter().getItemCount()) ? "" : SafeJsonUtil.getString(getmRecyclerViewAdapter().getValues().get(i).show, "id");
    }
}