360手机助手 v5.2.50版本的 MD5 值为:087c008db9e518cd556c792742e6830c

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


package com.qihoo360.newssdk.view.impl;

import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.qihoo.appstore.install.InstallNotificationManager;
import com.qihoo.express.mini.model.EMessage;
import com.qihoo360.newssdk.a;
import com.qihoo360.newssdk.f.a.a.e;
import com.qihoo360.newssdk.g;
import com.qihoo360.newssdk.h;
import com.qihoo360.newssdk.i;
import com.qihoo360.newssdk.i.r;
import com.qihoo360.newssdk.i.u;
import com.qihoo360.newssdk.page.b.f;
import com.qihoo360.newssdk.video.net.b;
import com.qihoo360.newssdk.video.net.c;
import com.qihoo360.newssdk.video.net.d;
import com.qihoo360.newssdk.video.widget.ScreenVideoPlayer;
import com.qihoo360.newssdk.video.widget.p;
import com.qihoo360.newssdk.view.ContainerBase;
import com.qihoo360.newssdk.view.action.ActionJump;
import com.qihoo360.newssdk.view.utils.ContainerNewsUtil;
import com.tencent.open.SocialConstants;
import org.json.JSONObject;

public class ContainerNews9 extends ContainerBase implements View.OnClickListener, f {
    private static final boolean DEBUG = a.e();
    private static final String TAG = "ContainerNews9";
    public static ScreenVideoPlayer VIDEOPLAYER;
    private AsyncTask loadRelateVideoInfoTask;
    private TextView mComment;
    private boolean mCommentShow;
    private LinearLayout mDisplay;
    private TextView mFrom;
    private ImageView mFromIcon;
    private boolean mFromIconShow;
    private boolean mFromShow;
    private View mIngoreBtn;
    private ImageView mLargeImage;
    private e mNewsTemplate;
    protected ImageView mPlaybtn;
    protected SeekBar mProgressbar;
    protected TextView mReplay;
    private ViewGroup mRoot;
    protected TextView mScreenSwitch;
    private TextView mTime;
    private boolean mTimeShow;
    private TextView mTitle;
    private RelativeLayout mVideoContainer;
    protected TextView mVideoDuration;
    private com.qihoo360.newssdk.video.b.a mVideoInfo;
    private Rect rootContainerRect;
    private ViewTreeObserver.OnScrollChangedListener scrollListener;
    private View tipView;
    private Point videoOffset;
    private Rect videoRect;

    public ContainerNews9(Context context, com.qihoo360.newssdk.f.a.a aVar) {
        super(context, aVar);
        this.scrollListener = new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                if (ContainerNews9.this.mVideoContainer != null && ContainerNews9.VIDEOPLAYER != null) {
                    ContainerNews9.VIDEOPLAYER.a(ContainerNews9.this.mVideoContainer.getGlobalVisibleRect(ContainerNews9.this.videoRect, ContainerNews9.this.videoOffset), ContainerNews9.this.videoRect, ContainerNews9.this.videoOffset);
                }
            }
        };
    }

    public ContainerNews9(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.scrollListener = new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                if (ContainerNews9.this.mVideoContainer != null && ContainerNews9.VIDEOPLAYER != null) {
                    ContainerNews9.VIDEOPLAYER.a(ContainerNews9.this.mVideoContainer.getGlobalVisibleRect(ContainerNews9.this.videoRect, ContainerNews9.this.videoOffset), ContainerNews9.this.videoRect, ContainerNews9.this.videoOffset);
                }
            }
        };
    }

    public ContainerNews9(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.scrollListener = new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                if (ContainerNews9.this.mVideoContainer != null && ContainerNews9.VIDEOPLAYER != null) {
                    ContainerNews9.VIDEOPLAYER.a(ContainerNews9.this.mVideoContainer.getGlobalVisibleRect(ContainerNews9.this.videoRect, ContainerNews9.this.videoOffset), ContainerNews9.this.videoRect, ContainerNews9.this.videoOffset);
                }
            }
        };
    }

    @Override
    public void initView(com.qihoo360.newssdk.f.a.a aVar) {
        inflate(getContext(), i.newssdk_container_news_9, this);
        this.mRoot = (ViewGroup) findViewById(h.news_root_layout_9);
        this.mTitle = (TextView) findViewById(h.news_title_9);
        this.mLargeImage = (ImageView) findViewById(h.news_image_9A);
        this.mVideoDuration = (TextView) findViewById(h.news_video_duration);
        this.mPlaybtn = (ImageView) findViewById(h.news_video_playbtn);
        this.mReplay = (TextView) findViewById(h.news_video_replay);
        this.mScreenSwitch = (TextView) findViewById(h.news_video_screenswitch9);
        this.mProgressbar = (SeekBar) findViewById(h.news_video_progressbar);
        this.mDisplay = (LinearLayout) findViewById(h.news_display_9);
        this.mFromIcon = (ImageView) findViewById(h.news_fromicon_9);
        this.mFrom = (TextView) findViewById(h.news_source_9);
        this.mComment = (TextView) findViewById(h.news_comment_9);
        this.mTime = (TextView) findViewById(h.news_time_9);
        this.mIngoreBtn = findViewById(h.news_ignore_9);
        this.mPlaybtn.setOnClickListener(this);
        this.mVideoContainer = (RelativeLayout) findViewById(h.news_videocontainer_9);
        this.mVideoContainer.setOnClickListener(this);
        Drawable drawable = getContext().getResources().getDrawable(g.newssdk_ic_replay);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        this.mReplay.setCompoundDrawables(drawable, null, null, null);
        this.videoRect = new Rect();
        this.videoOffset = new Point();
    }

    @Override
    public void updateView(com.qihoo360.newssdk.f.a.a aVar) {
        if (aVar != null && (aVar instanceof e) && this.mNewsTemplate != aVar) {
            if (this.mNewsTemplate != null && !TextUtils.equals(this.mNewsTemplate.m, aVar.m)) {
                this.mVideoInfo = null;
                if (VIDEOPLAYER != null && (TextUtils.isEmpty(VIDEOPLAYER.getUniqueId()) || VIDEOPLAYER.a(this.mNewsTemplate.m))) {
                    VIDEOPLAYER.r();
                }
            }
            setVisibility(0);
            this.mNewsTemplate = (e) aVar;
            if (this.mNewsTemplate.R != null) {
                String optString = this.mNewsTemplate.R.optString("fromicon");
                if (!TextUtils.isEmpty(optString) && optString.equals("1")) {
                    this.mFromIconShow = true;
                } else {
                    this.mFromIconShow = false;
                }
                String optString2 = this.mNewsTemplate.R.optString(InstallNotificationManager.KEY_FROM);
                if (!TextUtils.isEmpty(optString2) && optString2.equals("1")) {
                    this.mFromShow = true;
                } else {
                    this.mFromShow = false;
                }
                String optString3 = this.mNewsTemplate.R.optString("time");
                if (!TextUtils.isEmpty(optString3) && optString3.equals("1")) {
                    this.mTimeShow = true;
                } else {
                    this.mTimeShow = false;
                }
                String optString4 = this.mNewsTemplate.R.optString("cmt");
                if (!TextUtils.isEmpty(optString4) && optString4.equals("1")) {
                    this.mCommentShow = true;
                } else {
                    this.mCommentShow = false;
                }
            } else {
                this.mFromIconShow = true;
                this.mFromShow = true;
                this.mTimeShow = true;
                this.mCommentShow = true;
            }
            ContainerNewsUtil.updateImage(this.mNewsTemplate, getContext(), this.mLargeImage);
            this.tipView = ContainerNewsUtil.updateDisplay(this.mNewsTemplate, getContext(), this.mDisplay, this.mFromIcon, this.mFrom, this.mTime, this.mComment, this.mFromIconShow, this.mFromShow, this.mTimeShow, this.mCommentShow, this.tipView);
            ContainerNewsUtil.updateTitle(this.mNewsTemplate, getContext(), this.mTitle, ContainerNewsUtil.getFillWidth(getContext(), null));
            ContainerNewsUtil.checkDisplayWidth(getContext(), this.mDisplay, this.mFrom, this.mIngoreBtn);
            ContainerNewsUtil.createJumpString(this.mNewsTemplate, 3, null);
            ContainerNewsUtil.initClick(this.mNewsTemplate, getContext(), this.mRoot, this.mIngoreBtn, this.mTitle, this);
            if (this.mVideoDuration != null) {
                if (this.mNewsTemplate != null && !TextUtils.isEmpty(this.mNewsTemplate.c())) {
                    try {
                        JSONObject jSONObject = new JSONObject(this.mNewsTemplate.c());
                        if (jSONObject != null) {
                            String optString5 = jSONObject.optString("totalTimeStr");
                            if (!TextUtils.isEmpty(optString5)) {
                                if (optString5.indexOf(":") == 1) {
                                    optString5 = "0" + optString5;
                                }
                                this.mVideoDuration.setText(optString5);
                                this.mVideoDuration.setVisibility(0);
                                return;
                            }
                            return;
                        }
                        return;
                    } catch (Throwable th) {
                        return;
                    }
                }
                this.mVideoDuration.setVisibility(8);
            }
        }
    }

    private boolean isSupportScreenPlayer() {
        Window window = getWindow(getContext());
        return (window == null || window.getDecorView() == null) ? false : true;
    }

    private boolean initScreenPlayer() {
        boolean z;
        boolean z2;
        if (VIDEOPLAYER != null && !VIDEOPLAYER.a(getTemplate().m)) {
            VIDEOPLAYER.r();
            VIDEOPLAYER = null;
        }
        if (this.rootContainerRect == null) {
            this.rootContainerRect = new Rect(0, com.qihoo360.newssdk.i.e.a(getContext(), 42.0f), com.qihoo360.newssdk.i.e.b(getContext()), com.qihoo360.newssdk.i.e.a(getContext()));
            for (ViewParent parent = getParent(); parent != null; parent = parent.getParent()) {
                if ((parent instanceof ScrollView) || (parent instanceof AbsListView)) {
                    ((ViewGroup) parent).getGlobalVisibleRect(this.rootContainerRect);
                    z2 = true;
                    break;
                }
            }
            z2 = false;
            z = z2;
        } else {
            z = true;
        }
        if (z && VIDEOPLAYER == null) {
            this.mVideoContainer.getGlobalVisibleRect(this.videoRect);
            ViewGroup viewGroup = (ViewGroup) getWindow(getContext()).getDecorView();
            if (this.videoRect.height() < this.mVideoContainer.getHeight()) {
                if (this.videoRect.top < this.rootContainerRect.top) {
                    this.videoRect.top = this.videoRect.bottom - this.mVideoContainer.getHeight();
                } else {
                    this.videoRect.bottom = this.videoRect.top + this.mVideoContainer.getHeight();
                }
            }
            Rect rect = new Rect();
            viewGroup.getGlobalVisibleRect(rect);
            VIDEOPLAYER = ScreenVideoPlayer.a(getContext(), this.videoRect, this.rootContainerRect, rect);
            VIDEOPLAYER.setPlayerPlace("list");
            VIDEOPLAYER.setAutoOrientationEnable(true);
            this.mVideoContainer.getViewTreeObserver().removeOnScrollChangedListener(this.scrollListener);
            this.mVideoContainer.getViewTreeObserver().addOnScrollChangedListener(this.scrollListener);
            VIDEOPLAYER.a(this.mVideoContainer.getViewTreeObserver(), this.scrollListener);
            VIDEOPLAYER.setUniqueId(getTemplate().m);
            VIDEOPLAYER.setOnShareClick(this);
            viewGroup.addView(VIDEOPLAYER);
            com.qihoo360.newssdk.page.b.i.a(this.mNewsTemplate.e, this.mNewsTemplate.f, ScreenVideoPlayer.class.getSimpleName(), this);
            com.qihoo360.newssdk.page.b.g.a(this.mNewsTemplate.e, this.mNewsTemplate.f, this.mNewsTemplate.m, this);
        }
        if (z && VIDEOPLAYER != null && this.mVideoContainer != null) {
            VIDEOPLAYER.a(this.mVideoContainer.getGlobalVisibleRect(this.videoRect, this.videoOffset), this.videoRect, this.videoOffset);
        }
        return z;
    }

    private Window getWindow(Context context) {
        ?? r1;
        if (context instanceof Activity) {
            return ((Activity) context).getWindow();
        }
        while (this != null) {
            Object parent = this.getParent();
            if (parent == null || !(parent instanceof View)) {
                r1 = 0;
            } else {
                Context context2 = ((View) parent).getContext();
                if (context2 != null && (context2 instanceof Activity)) {
                    return ((Activity) context2).getWindow();
                }
                r1 = (View) parent;
            }
            this = r1;
        }
        return null;
    }

    public void initVideoUrl() {
        p pVar = new p();
        pVar.a = this.mVideoInfo.u;
        pVar.b = r.a(this.mVideoInfo.o * 1000);
        pVar.c = this.mNewsTemplate.s;
        VIDEOPLAYER.setVideoData(pVar);
        VIDEOPLAYER.h();
    }

    private void loadVideoInfo(final String str) {
        c.a(true, this.loadRelateVideoInfoTask);
        this.loadRelateVideoInfoTask = new AsyncTask() {
            @Override
            public com.qihoo360.newssdk.video.b.a doInBackground(String... strArr) {
                com.qihoo360.newssdk.video.b.a b = d.b(str);
                if (b != null && b.a == 0) {
                    ContainerNews9.this.mVideoInfo = b;
                    try {
                        b.u = Uri.parse(new JSONObject(com.qihoo360.newssdk.video.net.a.a(b.j.replace("|", "%7C"), false)).optJSONObject("data").optString(SocialConstants.PARAM_URL));
                    } catch (Exception e) {
                        if (b.a) {
                            e.printStackTrace();
                        }
                    }
                }
                return b;
            }

            @Override
            protected void onPreExecute() {
                ContainerNews9.VIDEOPLAYER.i();
                super.onPreExecute();
            }

            @Override
            public void onPostExecute(com.qihoo360.newssdk.video.b.a aVar) {
                if (aVar != null) {
                    if (aVar.a == 0) {
                        ContainerNews9.this.mVideoInfo = aVar;
                        if (ContainerNews9.this.mVideoInfo.u != null) {
                            p pVar = new p();
                            pVar.a = ContainerNews9.this.mVideoInfo.u;
                            pVar.b = r.a(ContainerNews9.this.mVideoInfo.o * 1000);
                            ContainerNews9.VIDEOPLAYER.setVideoData(pVar);
                            ContainerNews9.VIDEOPLAYER.h();
                        }
                        super.onPostExecute((AnonymousClass2) aVar);
                    }
                }
                if (ContainerNews9.VIDEOPLAYER != null) {
                    ContainerNews9.VIDEOPLAYER.q();
                }
                Toast.makeText(ContainerNews9.this.getContext(), "视频播放失败", 0).show();
                super.onPostExecute((AnonymousClass2) aVar);
            }
        };
        this.loadRelateVideoInfoTask.execute("");
    }

    @Override
    public void onClick(View view) {
        try {
            if (view.getId() == h.news_video_playbtn || view.getId() == h.news_videocontainer_9) {
                try {
                    com.qihoo360.newssdk.f.a.a template = getTemplate();
                    if (a.M() && EMessage.FILETYPE_VIDEO.equals(template.h) && isSupportScreenPlayer()) {
                        if (initScreenPlayer()) {
                            if (this.mVideoInfo != null && this.mVideoInfo.u != null) {
                                p pVar = new p();
                                pVar.a = this.mVideoInfo.u;
                                pVar.b = r.a(this.mVideoInfo.o * 1000);
                                pVar.c = this.mNewsTemplate.s;
                                VIDEOPLAYER.setVideoData(pVar);
                                if (view.getId() == h.news_videocontainer_9) {
                                    VIDEOPLAYER.o();
                                } else if (VIDEOPLAYER.d()) {
                                    VIDEOPLAYER.o();
                                } else {
                                    VIDEOPLAYER.a();
                                }
                            } else {
                                loadVideoInfo(((e) template).I);
                            }
                        }
                        com.qihoo360.newssdk.f.e.a(getContext(), this.mNewsTemplate, "click", "", "http://api.look.360.cn/srv/c", "&where=list");
                        return;
                    }
                    this.mNewsTemplate.ad = 1;
                    com.qihoo360.newssdk.h.a.b.b(this.mNewsTemplate);
                    ContainerNewsUtil.updateTitleColor(this.mNewsTemplate, this.mTitle);
                    ActionJump.actionJumpVideoPage(getContext(), this.mNewsTemplate, (VIDEOPLAYER == null || !VIDEOPLAYER.a(getTemplate().m)) ? 0 : VIDEOPLAYER.getCurrentPosition());
                    com.qihoo360.newssdk.f.e.a(getContext(), this.mNewsTemplate, "click", "", "http://api.look.360.cn/srv/c", "&where=list");
                    return;
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }
            }
            if (view.getId() == h.vp_reshare) {
                String str = "?sign=" + a.b() + "&to=&sid=" + getContext().getPackageName() + "&wid=" + u.a(getContext());
                com.qihoo360.newssdk.g.a aVar = new com.qihoo360.newssdk.g.a();
                aVar.j = this.mNewsTemplate.s + str;
                aVar.e = aVar.j;
                aVar.a = this.mNewsTemplate.u;
                aVar.k = EMessage.FILETYPE_VIDEO;
                aVar.i = com.qihoo360.newssdk.g.b.a(this.mNewsTemplate.B);
                com.qihoo360.newssdk.f.c.b.b bVar = new com.qihoo360.newssdk.f.c.b.b();
                bVar.a = this.mNewsTemplate.e;
                bVar.b = this.mNewsTemplate.f;
                bVar.c = this.mNewsTemplate.i;
                bVar.d = this.mNewsTemplate.j;
                bVar.e = this.mNewsTemplate.k;
                aVar.l = bVar;
                aVar.m = "list";
                com.qihoo360.newssdk.g.h.a(getContext(), view, null, null, false).a(aVar);
            }
        } catch (Exception e2) {
        }
    }

    @Override
    public com.qihoo360.newssdk.f.a.a getTemplate() {
        return this.mNewsTemplate;
    }

    @Override
    public void onPause() {
        if (VIDEOPLAYER != null) {
            VIDEOPLAYER.v();
        }
    }

    @Override
    public void onResume() {
        if (VIDEOPLAYER != null) {
            VIDEOPLAYER.w();
        }
    }

    @Override
    public void onDestroy() {
    }

    @Override
    public boolean onBackPressed() {
        return VIDEOPLAYER != null && VIDEOPLAYER.u();
    }

    @Override
    public void onTimer() {
    }

    @Override
    public void onFocus(boolean z) {
        if (!z && VIDEOPLAYER != null) {
            VIDEOPLAYER.r();
        }
    }

    @Override
    public void onTabSelected(int i, String str) {
        if (VIDEOPLAYER != null) {
            VIDEOPLAYER.r();
        }
    }
}