翰林优商.apk(点击下载) / FeedPortraitVideoView.java


package com.baidu.mobads.sdk.api;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import com.baidu.mobads.sdk.api.NativeResponse;
import com.baidu.mobads.sdk.internal.aj;
import com.baidu.mobads.sdk.internal.ay;
import com.baidu.mobads.sdk.internal.r;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.sigmob.sdk.base.mta.PointCategory;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class FeedPortraitVideoView extends RelativeLayout {
    private static final String FEED_CLICK = "pauseBtnClick";
    private static final String PLAY_END = "playCompletion";
    private static final String PLAY_ERROR = "playError";
    private static final String PLAY_PAUSE = "playPause";
    private static final String PLAY_RESUME = "playResume";
    private static final String PLAY_START = "playRenderingStart";
    private static final String TAG = "FeedPortraitVideoView";
    private View mAdView;
    private IFeedPortraitListener mFeedVideoListener;
    private ClassLoader mLoader;
    private String mRemoteClassName;
    private Context mViewContext;
    private boolean useDownloadFrame;

    public FeedPortraitVideoView(Context context) {
        this(context, null);
    }

    public FeedPortraitVideoView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public FeedPortraitVideoView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.mRemoteClassName = r.d;
        this.useDownloadFrame = false;
        init(context);
    }

    private void init(Context context) {
        this.mViewContext = context;
        Object[] objArr = {context};
        ClassLoader a = ay.a(context);
        this.mLoader = a;
        View view = (View) aj.a(this.mRemoteClassName, a, new Class[]{Context.class}, objArr);
        this.mAdView = view;
        if (view != null) {
            addView(view, new RelativeLayout.LayoutParams(-1, -1));
        }
    }

    public void setFeedPortraitListener(IFeedPortraitListener iFeedPortraitListener) {
        this.mFeedVideoListener = iFeedPortraitListener;
        try {
            Class<?> a = aj.a("com.component.feed.IFeedPortraitListener", this.mLoader);
            Object newProxyInstance = Proxy.newProxyInstance(a.getClassLoader(), new Class[]{a}, new InvocationHandlerImp());
            View view = this.mAdView;
            if (view != null) {
                aj.a(this.mRemoteClassName, view, this.mLoader, "setFeedPortraitListener", new Class[]{a}, newProxyInstance);
            }
        } catch (Throwable unused) {
        }
    }

    public void setAdData(AbstractData abstractData) {
        View view;
        if (abstractData != null && (view = this.mAdView) != null) {
            if (abstractData instanceof NativeCPUAdData) {
                aj.a(this.mRemoteClassName, view, this.mLoader, "setCpuAdData", new Class[]{Object.class}, abstractData);
                showFeedVideoCover(abstractData);
                return;
            }
            aj.a(this.mRemoteClassName, view, this.mLoader, "setAdData", new Class[]{Object.class}, abstractData);
            if (((XAdNativeResponse) abstractData).getMaterialType() == NativeResponse.MaterialType.VIDEO) {
                showFeedVideoCover(abstractData);
            }
        }
    }

    public void showNormalPic(AbstractData abstractData) {
        View view;
        if (abstractData != null && (view = this.mAdView) != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "showNormalPic", new Class[]{Object.class}, abstractData);
        }
    }

    public void play() {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, PointCategory.PLAY, new Class[0], new Object[0]);
        }
    }

    public void pause() {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, CampaignEx.JSON_NATIVE_VIDEO_PAUSE, new Class[0], new Object[0]);
        }
    }

    public void resume() {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, CampaignEx.JSON_NATIVE_VIDEO_RESUME, new Class[0], new Object[0]);
        }
    }

    public void stop() {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "stop", new Class[0], new Object[0]);
        }
    }

    public void setVideoMute(boolean z) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setVideoMute", new Class[]{Boolean.TYPE}, Boolean.valueOf(z));
        }
    }

    public void seekTo(int i) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "seekTo", new Class[]{Integer.TYPE}, Integer.valueOf(i));
        }
    }

    public void setPlayBackSpeed(float f) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setPlayBackSpeed", new Class[]{Float.TYPE}, Float.valueOf(f));
        }
    }

    public void showFeedVideoCover(AbstractData abstractData) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "showFeedVideoCover", new Class[]{Object.class}, abstractData);
        }
    }

    public void hideFeedPauseBtn(AbstractData abstractData) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "hidePauseBtn", new Class[]{Object.class}, abstractData);
        }
    }

    public void hideFeedCoverPic(AbstractData abstractData) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "hideFeedCoverPic", new Class[]{Object.class}, abstractData);
        }
    }

    public void handleFeedCover(AbstractData abstractData) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "handleCover", new Class[]{Object.class}, abstractData);
        }
    }

    public boolean isPlaying() {
        View view = this.mAdView;
        if (view != null) {
            return ((Boolean) aj.a(this.mRemoteClassName, view, this.mLoader, "isPlaying", new Class[0], new Object[0])).booleanValue();
        }
        return false;
    }

    public long getCurrentPosition() {
        View view = this.mAdView;
        if (view != null) {
            return ((Long) aj.a(this.mRemoteClassName, view, this.mLoader, "getCurrentPosition", new Class[0], new Object[0])).longValue();
        }
        return 0;
    }

    public long getDuration() {
        View view = this.mAdView;
        if (view != null) {
            return ((Long) aj.a(this.mRemoteClassName, view, this.mLoader, "getDuration", new Class[0], new Object[0])).longValue();
        }
        return 0;
    }

    public void setCanClickVideo(boolean z) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setCanClickVideo", new Class[]{Boolean.TYPE}, Boolean.valueOf(z));
        }
    }

    public boolean isShowEndFrame() {
        View view = this.mAdView;
        if (view != null) {
            return ((Boolean) aj.a(this.mRemoteClassName, view, this.mLoader, "isShowEndFrame", new Class[0], new Object[0])).booleanValue();
        }
        return false;
    }

    public void setShowProgress(boolean z) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setShowProgressBar", new Class[]{Boolean.TYPE}, Boolean.valueOf(z));
        }
    }

    public void setProgressBackgroundColor(int i) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setProgressBackgroundColor", new Class[]{Integer.TYPE}, Integer.valueOf(i));
        }
    }

    public void setProgressBarColor(int i) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setProgressBarColor", new Class[]{Integer.TYPE}, Integer.valueOf(i));
        }
    }

    public void setProgressHeightInDp(int i) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setProgressHeightDp", new Class[]{Integer.TYPE}, Integer.valueOf(i));
        }
    }

    class InvocationHandlerImp implements InvocationHandler {
        InvocationHandlerImp() {
        }

        @Override // java.lang.reflect.InvocationHandler
        public Object invoke(Object obj, Method method, Object[] objArr) {
            String name = method.getName();
            if (TextUtils.isEmpty(name)) {
                return null;
            }
            if (name.equals(FeedPortraitVideoView.PLAY_END)) {
                if (FeedPortraitVideoView.this.mFeedVideoListener != null) {
                    FeedPortraitVideoView.this.mFeedVideoListener.playCompletion();
                }
            } else if (name.equals(FeedPortraitVideoView.PLAY_ERROR)) {
                if (FeedPortraitVideoView.this.mFeedVideoListener != null) {
                    FeedPortraitVideoView.this.mFeedVideoListener.playError();
                }
            } else if (name.equals(FeedPortraitVideoView.PLAY_START)) {
                if (FeedPortraitVideoView.this.mFeedVideoListener != null) {
                    FeedPortraitVideoView.this.mFeedVideoListener.playRenderingStart();
                }
            } else if (name.equals(FeedPortraitVideoView.PLAY_PAUSE)) {
                if (FeedPortraitVideoView.this.mFeedVideoListener != null) {
                    FeedPortraitVideoView.this.mFeedVideoListener.playPause();
                }
            } else if (name.equals(FeedPortraitVideoView.PLAY_RESUME)) {
                if (FeedPortraitVideoView.this.mFeedVideoListener != null) {
                    FeedPortraitVideoView.this.mFeedVideoListener.playResume();
                }
            } else if (name.equals(FeedPortraitVideoView.FEED_CLICK) && FeedPortraitVideoView.this.mFeedVideoListener != null) {
                FeedPortraitVideoView.this.mFeedVideoListener.pauseBtnClick();
            }
            return null;
        }
    }

    public void setUseDownloadFrame(boolean z) {
        View view = this.mAdView;
        if (view != null) {
            aj.a(this.mRemoteClassName, view, this.mLoader, "setUseDownloadFrame", new Class[]{Boolean.TYPE}, Boolean.valueOf(z));
        }
    }
}