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

以下内容为反编译后的 ContainerNews21.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.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.h;
import com.qihoo360.newssdk.i;
import com.qihoo360.newssdk.i.m;
import com.qihoo360.newssdk.i.r;
import com.qihoo360.newssdk.i.u;
import com.qihoo360.newssdk.j;
import com.qihoo360.newssdk.page.b.f;
import com.qihoo360.newssdk.page.b.g;
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 ContainerNews21 extends ContainerBase implements View.OnClickListener, f {
    private static final boolean DEBUG = a.e();
    private static final String TAG = "ContainerNews21";
    private AsyncTask loadRelateVideoInfoTask;
    private TextView mComment;
    protected ImageView mCommentBtn;
    private boolean mCommentShow;
    private LinearLayout mDisplay;
    private TextView mFrom;
    private ImageView mFromIcon;
    private boolean mFromIconShow;
    private boolean mFromShow;
    private ImageView mLargeImage;
    private e mNewsTemplate;
    protected ImageView mPlaybtn;
    protected SeekBar mProgressbar;
    protected TextView mReplay;
    protected TextView mScreenSwitch;
    protected LinearLayout mShare;
    private TextView mTime;
    private boolean mTimeShow;
    protected TextView mTimesWatched;
    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 ContainerNews21(Context context, com.qihoo360.newssdk.f.a.a aVar) {
        super(context, aVar);
        this.scrollListener = new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                if (ContainerNews21.this.mVideoContainer != null && ContainerNews9.VIDEOPLAYER != null) {
                    ContainerNews9.VIDEOPLAYER.a(ContainerNews21.this.mVideoContainer.getGlobalVisibleRect(ContainerNews21.this.videoRect, ContainerNews21.this.videoOffset), ContainerNews21.this.videoRect, ContainerNews21.this.videoOffset);
                }
            }
        };
    }

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

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

    @Override
    public void initView(com.qihoo360.newssdk.f.a.a aVar) {
        inflate(getContext(), i.newssdk_container_news_21, this);
        this.mTitle = (TextView) findViewById(h.news_title_21);
        this.mTitle.getBackground().setAlpha(210);
        this.mLargeImage = (ImageView) findViewById(h.news_image_21A);
        this.mVideoDuration = (TextView) findViewById(h.news_video_duration_21);
        this.mPlaybtn = (ImageView) findViewById(h.news_video_playbtn_21);
        this.mReplay = (TextView) findViewById(h.news_video_replay_21);
        this.mScreenSwitch = (TextView) findViewById(h.news_video_screenswitch_21);
        this.mProgressbar = (SeekBar) findViewById(h.news_video_progressbar_21);
        this.mDisplay = (LinearLayout) findViewById(h.news_display_21);
        this.mFromIcon = (ImageView) findViewById(h.news_fromicon_21);
        this.mFrom = (TextView) findViewById(h.news_source_21);
        this.mTimesWatched = (TextView) findViewById(h.news_times_watched_21);
        this.mComment = (TextView) findViewById(h.news_commentNum_21);
        this.mCommentBtn = (ImageView) findViewById(h.news_commentBtn_21);
        this.mShare = (LinearLayout) findViewById(h.newssdk_share_21);
        this.mVideoContainer = (RelativeLayout) findViewById(h.news_videocontainer_21);
        this.mVideoContainer.setOnClickListener(this);
        this.mPlaybtn.setOnClickListener(this);
        this.mDisplay.setOnClickListener(this);
        this.mShare.setOnClickListener(this);
        this.videoRect = new Rect();
        this.videoOffset = new Point();
    }

    @Override
    public void updateView(com.qihoo360.newssdk.f.a.a aVar) {
        String substring;
        if (aVar != null && (aVar instanceof e) && this.mNewsTemplate != aVar) {
            if (this.mNewsTemplate != null && !TextUtils.equals(this.mNewsTemplate.m, aVar.m)) {
                this.mVideoInfo = null;
                if (ContainerNews9.VIDEOPLAYER != null && (TextUtils.isEmpty(ContainerNews9.VIDEOPLAYER.getUniqueId()) || ContainerNews9.VIDEOPLAYER.a(this.mNewsTemplate.m))) {
                    ContainerNews9.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);
            if (this.mTitle != null && !TextUtils.isEmpty(this.mNewsTemplate.u)) {
                this.mTitle.setText(this.mNewsTemplate.u);
            }
            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("timeStr")) {
                                this.mVideoDuration.setText(optString5);
                                this.mVideoDuration.setVisibility(0);
                            }
                        }
                    } catch (Throwable th) {
                    }
                } else {
                    this.mVideoDuration.setVisibility(8);
                }
            }
            if (this.mTimesWatched != null) {
                if (this.mNewsTemplate != null && !TextUtils.isEmpty(this.mNewsTemplate.c())) {
                    try {
                        JSONObject jSONObject2 = new JSONObject(this.mNewsTemplate.c());
                        if (jSONObject2 != null) {
                            String optString6 = jSONObject2.optString("playCnt");
                            if (!TextUtils.isEmpty("timesWatchedStr")) {
                                if (optString6.length() > 4) {
                                    if (optString6.charAt(optString6.length() - 4) != '0') {
                                        substring = optString6.substring(0, optString6.length() - 4) + "." + optString6.charAt(optString6.length() - 4);
                                    } else {
                                        substring = optString6.substring(0, optString6.length() - 4);
                                    }
                                    optString6 = substring + getContext().getString(j.news_wan);
                                }
                                this.mTimesWatched.setText(getContext().getString(j.video_timeswatched, optString6));
                                this.mTimesWatched.setVisibility(0);
                                return;
                            }
                            return;
                        }
                        return;
                    } catch (Throwable th2) {
                        return;
                    }
                }
                this.mTimesWatched.setVisibility(8);
            }
        }
    }

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

    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;
    }

    private boolean initScreenPlayer() {
        boolean z;
        boolean z2;
        if (ContainerNews9.VIDEOPLAYER != null && !ContainerNews9.VIDEOPLAYER.a(getTemplate().m)) {
            ContainerNews9.VIDEOPLAYER.r();
            ContainerNews9.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 && ContainerNews9.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);
            ContainerNews9.VIDEOPLAYER = ScreenVideoPlayer.a(getContext(), this.videoRect, this.rootContainerRect, rect);
            ContainerNews9.VIDEOPLAYER.setPlayerPlace("v_list");
            ContainerNews9.VIDEOPLAYER.setAutoOrientationEnable(true);
            this.mVideoContainer.getViewTreeObserver().removeOnScrollChangedListener(this.scrollListener);
            this.mVideoContainer.getViewTreeObserver().addOnScrollChangedListener(this.scrollListener);
            ContainerNews9.VIDEOPLAYER.a(this.mVideoContainer.getViewTreeObserver(), this.scrollListener);
            ContainerNews9.VIDEOPLAYER.setUniqueId(getTemplate().m);
            ContainerNews9.VIDEOPLAYER.setOnShareClick(this);
            viewGroup.addView(ContainerNews9.VIDEOPLAYER);
            com.qihoo360.newssdk.page.b.i.a(this.mNewsTemplate.e, this.mNewsTemplate.f, ScreenVideoPlayer.class.getSimpleName(), this);
            g.a(this.mNewsTemplate.e, this.mNewsTemplate.f, this.mNewsTemplate.m, this);
        }
        if (z && ContainerNews9.VIDEOPLAYER != null && this.mVideoContainer != null) {
            ContainerNews9.VIDEOPLAYER.a(this.mVideoContainer.getGlobalVisibleRect(this.videoRect, this.videoOffset), this.videoRect, this.videoOffset);
        }
        return z;
    }

    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;
        ContainerNews9.VIDEOPLAYER.setVideoData(pVar);
        ContainerNews9.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) {
                    ContainerNews21.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) {
                        ContainerNews21.this.mVideoInfo = aVar;
                        if (ContainerNews21.this.mVideoInfo.u != null) {
                            p pVar = new p();
                            pVar.a = ContainerNews21.this.mVideoInfo.u;
                            pVar.b = r.a(ContainerNews21.this.mVideoInfo.o * 1000);
                            ContainerNews9.VIDEOPLAYER.setVideoData(pVar);
                            ContainerNews9.VIDEOPLAYER.h();
                        }
                        super.onPostExecute((AnonymousClass2) aVar);
                    }
                }
                if (ContainerNews9.VIDEOPLAYER != null) {
                    ContainerNews9.VIDEOPLAYER.q();
                }
                Toast.makeText(ContainerNews21.this.getContext(), "视频播放失败", 0).show();
                super.onPostExecute((AnonymousClass2) aVar);
            }
        };
        this.loadRelateVideoInfoTask.execute("");
    }

    @Override
    public void onClick(View view) {
        int i = 0;
        if (view.getId() == h.news_video_playbtn_21 || view.getId() == h.news_videocontainer_21) {
            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;
                            ContainerNews9.VIDEOPLAYER.setVideoData(pVar);
                            if (view.getId() == h.news_videocontainer_9) {
                                ContainerNews9.VIDEOPLAYER.o();
                            } else if (ContainerNews9.VIDEOPLAYER.d()) {
                                ContainerNews9.VIDEOPLAYER.o();
                            } else {
                                ContainerNews9.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=v_list");
                    return;
                }
                if (ContainerNews9.VIDEOPLAYER != null && ContainerNews9.VIDEOPLAYER.a(getTemplate().m)) {
                    i = ContainerNews9.VIDEOPLAYER.getCurrentPosition();
                }
                ActionJump.actionJumpVideoPage(getContext(), this.mNewsTemplate, i);
                com.qihoo360.newssdk.f.e.a(getContext(), this.mNewsTemplate, "click", "", "http://api.look.360.cn/srv/c", "&where=v_list");
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
        }
        if (view.getId() == h.news_title_21 || view.getId() == h.news_display_21 || view.getId() == h.news_commentBtn_21) {
            ActionJump.actionJumpVideoPage(getContext(), this.mNewsTemplate, (ContainerNews9.VIDEOPLAYER == null || !ContainerNews9.VIDEOPLAYER.a(getTemplate().m)) ? 0 : ContainerNews9.VIDEOPLAYER.getCurrentPosition());
            com.qihoo360.newssdk.f.e.a(getContext(), this.mNewsTemplate, "click", "", "http://api.look.360.cn/srv/c", "&where=v_list");
            return;
        }
        if (view.getId() == h.newssdk_share_21 || view.getId() == h.vp_reshare) {
            String str = "?sign=" + a.b() + "&sid=" + a.I() + "&wid=" + u.a(getContext());
            com.qihoo360.newssdk.g.a aVar = new com.qihoo360.newssdk.g.a();
            aVar.j = this.mNewsTemplate.s + str;
            aVar.a = this.mNewsTemplate.u;
            aVar.k = "v_sj";
            aVar.i = com.qihoo360.newssdk.g.b.a(this.mNewsTemplate.B);
            aVar.e = aVar.j;
            aVar.g = "http://v.sj.360.cn/report/detail?url=" + this.mNewsTemplate.I + "&sign=" + a.b() + "&uid=" + u.a(getContext()) + "&device=0&net=" + m.e(getContext()) + "&version=" + a.r();
            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, true).a(aVar);
        }
    }

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

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

    @Override
    public void onDestroy() {
        if (ContainerNews9.VIDEOPLAYER != null) {
            ContainerNews9.VIDEOPLAYER.r();
        }
    }

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

    @Override
    public void onTimer() {
    }

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

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

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