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

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


package com.qihoo360.newssdk.page;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.qihoo360.newssdk.comment.InfoPageCommentBar;
import com.qihoo360.newssdk.ui.common.AvatarIconView;
import com.qihoo360.newssdk.ui.common.NetErrorView;
import com.qihoo360.newssdk.ui.common.RefreshListView;
import com.qihoo360.newssdk.video.net.CommentsHelper;
import com.qihoo360.newssdk.video.widget.ScreenVideoPlayer;
import com.qihoo360.newssdk.view.action.ActionJump;
import com.qihoo360.newssdk.view.action.StartActivityUtil;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class NewsVideoPage extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener, com.qihoo360.newssdk.comment.h, com.qihoo360.newssdk.ui.common.w {
    private View A;
    private TextView B;
    private TextView C;
    private View D;
    private View E;
    private AvatarIconView F;
    private TextView G;
    private View H;
    private TextView I;
    private View J;
    private boolean K;
    private List L;
    private boolean M;
    private AsyncTask N;
    private AsyncTask O;
    private AsyncTask P;
    private AsyncTask Q;
    private AsyncTask R;
    private com.qihoo360.newssdk.f.a.a.e b;
    private int c;
    private com.qihoo360.newssdk.video.b.a d;
    private ScreenVideoPlayer e;
    private RefreshListView f;
    private com.qihoo360.newssdk.video.a.a g;
    private InfoPageCommentBar h;
    private List i;
    private ViewGroup k;
    private int l;
    private int m;
    private int n;
    private int o;
    private String p;
    private NetErrorView q;
    private String s;
    private TextView t;
    private ImageView u;
    private TextView v;
    private TextView w;
    private View x;
    private TextView y;
    private View z;
    private boolean a = true;
    private boolean j = true;
    private String r = "暂无评论";
    private boolean S = true;
    private int T = 1;
    private final int U = 5;
    private final int V = 4;
    private final int W = 8;

    public static int o(NewsVideoPage newsVideoPage) {
        int i = newsVideoPage.T;
        newsVideoPage.T = i + 1;
        return i;
    }

    public static void a(Context context, String str) {
        Bundle bundle = new Bundle();
        bundle.putString("extra_key_initial_template", str);
        ActionJump.startActivityByParams(context, NewsVideoPage.class.getName(), bundle);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        setContentView(com.qihoo360.newssdk.i.newssdk_activity_videoinfo);
        try {
            getWindow().setFormat(-2);
            getWindow().setSoftInputMode(18);
            setRequestedOrientation(10);
        } catch (Exception e) {
        }
        super.onCreate(bundle);
        b();
    }

    @Override
    protected void onResume() {
        super.onResume();
        try {
            if (this.e != null && (this.e.c() || this.e.e())) {
                this.e.f();
            }
            if (this.h != null) {
                this.h.a();
            }
            if (this.g != null) {
                this.g.notifyDataSetChanged();
            }
            if (this.d != null && this.d.t != null && !TextUtils.isEmpty(this.d.t.a)) {
                b(CommentsHelper.c(this.d.t.a));
            }
        } catch (Exception e) {
        }
    }

    @Override
    protected void onPause() {
        try {
            if (this.e != null) {
                this.e.b();
            }
        } catch (Exception e) {
        }
        super.onPause();
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (configuration != null) {
            try {
                if (configuration.orientation == 1) {
                    if (com.qihoo360.newssdk.a.g()) {
                        this.h.setVisibility(0);
                    }
                } else {
                    this.h.setVisibility(8);
                }
            } catch (Exception e) {
            }
        }
    }

    @Override
    protected void onDestroy() {
        try {
            if (this.e != null) {
                this.e.r();
            }
            if (this.M && this.d != null) {
                com.qihoo360.newssdk.comment.b.a(this, this.d.i, this.L);
            }
            com.qihoo360.newssdk.video.net.c.a(true, this.N, this.O, this.P, this.Q, this.R);
        } catch (Exception e) {
        }
        super.onDestroy();
    }

    private void b() {
        Bundle extras;
        this.k = (ViewGroup) findViewById(com.qihoo360.newssdk.h.vinfo_videocontainer);
        this.f = (RefreshListView) findViewById(com.qihoo360.newssdk.h.vinfo_listview);
        d();
        findViewById(com.qihoo360.newssdk.h.vinfo_closebtn).setOnClickListener(this);
        findViewById(com.qihoo360.newssdk.h.vinfo_playbtn).setOnClickListener(this);
        findViewById(com.qihoo360.newssdk.h.vinfo_thumbcontainer).setOnClickListener(this);
        e();
        this.f.setPullRefreshEnable(false);
        this.f.setOnItemClickListener(this);
        this.f.setOnItemLongClickListener(this);
        this.f.setOnLoadNextPageListener(this);
        this.b = StartActivityUtil.getTemplateWithIntent(getIntent());
        if (this.b != null) {
            this.l = this.b.e;
            this.m = this.b.f;
            this.n = this.b.i;
            this.o = this.b.j;
            this.p = this.b.k;
            if (getIntent() != null && (extras = getIntent().getExtras()) != null) {
                this.c = extras.getInt("key_start_position", 0);
            }
            this.g = new com.qihoo360.newssdk.video.a.a(this, null, this.b);
            this.f.setAdapter((ListAdapter) this.g);
            c();
            this.t.setText(this.b.u);
            if (!com.qihoo360.newssdk.i.m.b(this)) {
                this.t.postDelayed(new am(this), 500L);
            } else {
                f();
            }
            this.J = findViewById(com.qihoo360.newssdk.h.newsvideopage_mask);
        }
    }

    @Override
    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        if (i == 4 && this.e != null && this.e.u()) {
            return true;
        }
        return super.onKeyUp(i, keyEvent);
    }

    @Override
    public void onClick(View view) {
        String str;
        try {
            if (view.getId() == com.qihoo360.newssdk.h.vinfo_closebtn) {
                if (this.e.s()) {
                    this.e.t();
                    return;
                } else {
                    finish();
                    return;
                }
            }
            if (view.getId() == com.qihoo360.newssdk.h.vinfo_playbtn || view.getId() == com.qihoo360.newssdk.h.vinfo_thumbcontainer) {
                c();
                this.e.o();
                return;
            }
            if (view.getId() == com.qihoo360.newssdk.h.cbar_commenticon) {
                int firstVisiblePosition = this.f.getFirstVisiblePosition();
                int a = this.g.a();
                if (firstVisiblePosition < a) {
                    this.f.setSelection(Math.min(Math.max(0, this.f.getHeaderViewsCount() + a), this.g.getCount() - 1));
                    if (a >= this.g.getCount() - 1) {
                        this.f.postDelayed(new an(this), 200L);
                        return;
                    }
                    return;
                }
                this.f.setSelection(0);
                return;
            }
            if (view.getId() == com.qihoo360.newssdk.h.vinfo_zan) {
                if (this.d != null && this.d.s != null) {
                    a(this.d.s.b, 1);
                    return;
                }
                return;
            }
            if (view.getId() == com.qihoo360.newssdk.h.vinfo_cai) {
                if (this.d != null && this.d.s != null) {
                    a(this.d.s.b, 2);
                    return;
                }
                return;
            }
            if (view.getId() == com.qihoo360.newssdk.h.cbar_sharebtn || view.getId() == com.qihoo360.newssdk.h.vp_reshare) {
                if (this.d != null) {
                    com.qihoo360.newssdk.g.a aVar = new com.qihoo360.newssdk.g.a();
                    aVar.a = this.d.f;
                    aVar.j = this.d.s.c + "?sign=" + com.qihoo360.newssdk.a.b() + "&sid=" + com.qihoo360.newssdk.a.I() + "&wid=" + com.qihoo360.newssdk.i.u.a(this);
                    aVar.e = aVar.j;
                    aVar.b = this.d.g;
                    aVar.k = "v_sj";
                    aVar.g = "http://v.sj.360.cn/report/detail?url=" + this.d.i + "&sign=" + com.qihoo360.newssdk.a.b() + "&uid=" + com.qihoo360.newssdk.i.u.a(this) + "&device=0";
                    try {
                        aVar.i = this.d.p;
                    } catch (Throwable th) {
                    }
                    aVar.l = new com.qihoo360.newssdk.f.c.b.b();
                    aVar.l.a = this.l;
                    aVar.l.b = this.m;
                    aVar.l.c = this.n;
                    aVar.l.d = this.o;
                    aVar.l.e = this.p;
                    aVar.m = "detail_bottom";
                    com.qihoo360.newssdk.g.h.a(this, this.f, null, this.J, true).a(aVar);
                    return;
                }
                return;
            }
            if (view.getId() == com.qihoo360.newssdk.h.vinfo_titlecontainer) {
                if (this.A.getVisibility() == 0) {
                    this.A.setVisibility(8);
                    this.u.setSelected(false);
                    return;
                } else {
                    if (this.d.r != null || this.d.e > 0) {
                        this.A.setVisibility(0);
                        this.u.setSelected(true);
                        return;
                    }
                    return;
                }
            }
            if (view.getId() == com.qihoo360.newssdk.h.vinfo_zmtattention) {
                a(this.I.isSelected() ? false : true);
                return;
            }
            if ((view.getId() == com.qihoo360.newssdk.h.vinfo_zmtAvatar || view.getId() == com.qihoo360.newssdk.h.vinfo_zmtname) && !TextUtils.isEmpty(this.d.t.g)) {
                if (CommentsHelper.a((Context) this, false)) {
                    str = this.d.t.g + "&cookie=" + CommentsHelper.a(this);
                } else {
                    str = this.d.t.g + "&token=" + URLEncoder.encode(com.qihoo360.newssdk.i.s.a(this), "UTF-8");
                }
                ActionJump.actionJumpUrl(this, str + "#video");
            }
        } catch (Exception e) {
        }
    }

    private void c() {
        if (this.e == null) {
            Rect rect = new Rect();
            int dimension = (int) getResources().getDimension(com.qihoo360.newssdk.f.videoinfo_videoheight);
            rect.top = 0;
            rect.bottom = dimension;
            this.e = ScreenVideoPlayer.a(this, rect, null, null);
            this.e.setSupportChangeFeture(true);
            this.e.setPlayerPlace("v_detail");
            this.e.setOnShareClick(this);
            this.k.addView(this.e);
        }
    }

    private void d() {
        this.h = (InfoPageCommentBar) findViewById(com.qihoo360.newssdk.h.vinfo_commentbar);
        this.h.setCommentDoneListener(this);
        this.h.setCommentBtnClickL(this);
        this.h.setOnShareClick(this);
        if (!com.qihoo360.newssdk.a.g()) {
            this.h.setVisibility(8);
            findViewById(com.qihoo360.newssdk.h.vinfo_maincontainer).setPadding(0, 0, 0, 0);
        }
    }

    private void e() {
        View inflate = View.inflate(this, com.qihoo360.newssdk.i.newssdk_view_videoinfo_header, null);
        this.t = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_titlev);
        this.u = (ImageView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_titlearraw);
        this.v = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_playcount);
        this.w = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zan);
        this.y = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_cai);
        this.x = inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zananiview);
        this.z = inflate.findViewById(com.qihoo360.newssdk.h.vinfo_caianiview);
        this.A = inflate.findViewById(com.qihoo360.newssdk.h.vinfo_ptimecontainer);
        this.B = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_ptime);
        this.C = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_tagv);
        this.w.setOnClickListener(this);
        this.y.setOnClickListener(this);
        inflate.findViewById(com.qihoo360.newssdk.h.vinfo_titlecontainer).setOnClickListener(this);
        Drawable drawable = getResources().getDrawable(com.qihoo360.newssdk.g.newssdk_ic_cai_selector);
        drawable.setBounds(0, 0, (drawable.getIntrinsicWidth() * 2) / 3, (drawable.getIntrinsicHeight() * 2) / 3);
        this.y.setCompoundDrawables(drawable, null, null, null);
        Drawable drawable2 = getResources().getDrawable(com.qihoo360.newssdk.g.newssdk_ic_zan_selector);
        drawable2.setBounds(0, 0, (drawable2.getIntrinsicWidth() * 2) / 3, (drawable2.getIntrinsicHeight() * 2) / 3);
        this.w.setCompoundDrawables(drawable2, null, null, null);
        this.f.addHeaderView(inflate);
        this.q = (NetErrorView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_neterror);
        this.q.a(new ao(this));
        this.D = inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zmtcontainer);
        this.E = inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zmtdivider);
        this.F = (AvatarIconView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zmtAvatar);
        this.H = inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zmtloading);
        this.G = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zmtname);
        this.I = (TextView) inflate.findViewById(com.qihoo360.newssdk.h.vinfo_zmtattention);
        this.I.setOnClickListener(this);
        this.F.setOnClickListener(this);
        this.G.setOnClickListener(this);
    }

    public void a(com.qihoo360.newssdk.video.b.a aVar) {
        if (aVar != null) {
            this.t.setText(aVar.f);
            this.v.setText(aVar.h + "次播放");
            this.A.setVisibility(8);
            this.u.setSelected(false);
            if (aVar.e > 0) {
                this.B.setVisibility(0);
                this.B.setText(new SimpleDateFormat("yyyy年MM月dd日").format(Long.valueOf(aVar.e)) + "发布");
            } else {
                this.B.setVisibility(8);
            }
            if (aVar.r != null && aVar.r.size() > 0) {
                StringBuilder sb = new StringBuilder("标签:");
                Iterator it = aVar.r.iterator();
                while (it.hasNext()) {
                    sb.append((String) it.next()).append(" ");
                }
                SpannableString spannableString = new SpannableString(sb);
                spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#406599")), 3, sb.length(), 33);
                this.C.setVisibility(0);
                this.C.setText(spannableString);
            } else {
                this.C.setVisibility(8);
            }
            if (aVar.t != null) {
                this.D.setVisibility(0);
                this.E.setVisibility(0);
                this.F.a();
                this.F.setDefaultMeasurement(com.qihoo360.newssdk.i.e.a(this, 36.0f));
                com.nostra13.universalimageloader.core.g.a().a(aVar.t.b, this.F);
                this.G.setText(aVar.t.c);
                return;
            }
            this.D.setVisibility(8);
            this.E.setVisibility(8);
        }
    }

    @Override
    public void onItemClick(AdapterView adapterView, View view, int i, long j) {
        try {
            int headerViewsCount = i - this.f.getHeaderViewsCount();
            switch (this.g.getItemViewType(headerViewsCount)) {
                case 1:
                    com.qihoo360.newssdk.comment.a.c cVar = (com.qihoo360.newssdk.comment.a.c) this.g.getItem(headerViewsCount);
                    CommentInfoPage.a(this, 0, cVar, this.d.i, this.d.q, cVar.n == 0);
                    return;
                case 2:
                    com.qihoo360.newssdk.video.b.d dVar = (com.qihoo360.newssdk.video.b.d) this.g.getItem(headerViewsCount);
                    if (this.M && this.d != null) {
                        com.qihoo360.newssdk.comment.b.a(this, this.d.i, this.L);
                        this.M = false;
                        this.K = false;
                    }
                    a(dVar.c);
                    com.qihoo360.newssdk.f.e.a(this, this.l, this.m, this.n, this.o, this.p, "click", "relate", "v_detail", "http://api.look.360.cn/srv/c", dVar.a, "");
                    return;
                case 3:
                    this.g.b(headerViewsCount);
                    if (this.i.size() > 8) {
                        this.g.a((Collection) this.i.subList(4, 8), headerViewsCount);
                        this.g.a(8);
                    } else if (this.i.size() > 4) {
                        this.g.a((Collection) this.i.subList(4, this.i.size()), headerViewsCount);
                        this.g.a(this.i.size());
                    }
                    this.j = false;
                    this.g.notifyDataSetChanged();
                    return;
                case 4:
                    EditText editText = this.h.getEditText();
                    editText.requestFocus();
                    com.qihoo360.newssdk.video.net.c.a(this, editText);
                    return;
                default:
                    return;
            }
        } catch (Exception e) {
            if (this.a) {
                e.printStackTrace();
            }
        }
    }

    public void a(String str) {
        com.qihoo360.newssdk.video.net.c.a(true, this.P);
        this.P = new ap(this, str);
        this.P.execute("");
    }

    public void a(int i) {
        if (i == 0) {
            this.q.setVisibility(8);
            this.g.b(this.r);
            this.g.notifyDataSetChanged();
            return;
        }
        if (i == 1) {
            this.q.setVisibility(0);
            if (this.g != null) {
                this.g.b();
                this.g.notifyDataSetChanged();
            }
            if (this.e != null) {
                this.e.n();
                return;
            }
            return;
        }
        if (i == 2 && this.q.getVisibility() != 0 && this.g != null) {
            this.g.b(this.r);
            this.g.a(this.r);
            this.g.notifyDataSetChanged();
        }
    }

    public void f() {
        if (!com.qihoo360.newssdk.i.m.a(this)) {
            Toast.makeText(this, getResources().getString(com.qihoo360.newssdk.j.video_error_net), 0).show();
            this.s = this.b.I;
            a(1);
            return;
        }
        a(this.b.I);
    }

    public void g() {
        if (this.N == null || this.N.getStatus() == AsyncTask.Status.FINISHED) {
            this.N = new aq(this);
            this.N.execute("");
        }
    }

    public void b(com.qihoo360.newssdk.video.b.a aVar) {
        com.qihoo360.newssdk.video.net.c.a(true, this.O);
        this.O = new ar(this, aVar);
        this.O.execute("");
    }

    private void a(String str, int i) {
        if (this.y.isSelected()) {
            Toast.makeText(this, "已踩过", 0).show();
            return;
        }
        if (this.w.isSelected()) {
            Toast.makeText(this, "已赞过", 0).show();
            return;
        }
        try {
            com.qihoo360.newssdk.h.a.a.a(this.d.i, i);
            if (i == 1) {
                this.w.setSelected(true);
                this.w.setText((Integer.valueOf(this.w.getText().toString()).intValue() + 1) + "");
            } else {
                this.y.setSelected(true);
                this.y.setText((Integer.valueOf(this.y.getText().toString()).intValue() + 1) + "");
            }
            b(i);
        } catch (Exception e) {
        }
        if (this.Q == null || this.Q.getStatus() == AsyncTask.Status.FINISHED) {
            this.Q = new as(this, str, i);
            this.Q.execute("");
        }
    }

    private void b(int i) {
        if (i == 1) {
            this.x.setVisibility(0);
            AnimationSet animationSet = (AnimationSet) AnimationUtils.loadAnimation(this, com.qihoo360.newssdk.c.newssdk_add_score_anim);
            animationSet.setFillAfter(true);
            animationSet.setFillBefore(true);
            this.x.startAnimation(animationSet);
            return;
        }
        if (i == 2) {
            this.z.setVisibility(0);
            AnimationSet animationSet2 = (AnimationSet) AnimationUtils.loadAnimation(this, com.qihoo360.newssdk.c.newssdk_add_score_anim);
            animationSet2.setFillAfter(true);
            animationSet2.setFillBefore(true);
            this.z.startAnimation(animationSet2);
        }
    }

    private void a(boolean z) {
        if ((this.R == null || this.R.getStatus() == AsyncTask.Status.FINISHED) && this.d != null && this.d.t != null) {
            this.R = new at(this, z);
            this.R.execute("");
        }
    }

    public void b(boolean z) {
        if (z) {
            this.I.setText("已关注");
            this.I.setSelected(true);
            Drawable drawable = getResources().getDrawable(com.qihoo360.newssdk.g.newssdk_ic_attentioned);
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
            this.I.setCompoundDrawables(drawable, null, null, null);
        } else {
            this.I.setText("+ 关注");
            this.I.setCompoundDrawables(null, null, null, null);
            this.I.setSelected(false);
        }
        this.I.setVisibility(0);
    }

    @Override
    public void a() {
        if (this.S) {
            g();
        } else {
            this.f.a(2);
        }
    }

    @Override
    public void a(com.qihoo360.newssdk.comment.a.b bVar) {
        if (bVar != null && bVar.a == 0) {
            this.g.a(bVar.c, this.g.a());
            this.g.notifyDataSetChanged();
            a(bVar.c);
            if (this.h != null) {
                this.h.setCommentNum(this.h.getCommentNum() + 1);
            }
            a(0);
        }
    }

    private void a(com.qihoo360.newssdk.comment.a.c cVar) {
        if (cVar != null) {
            if (this.L == null) {
                this.L = new ArrayList();
            }
            this.L.add(0, cVar);
            this.M = true;
        }
    }

    @Override
    public boolean onItemLongClick(AdapterView adapterView, View view, int i, long j) {
        try {
            int headerViewsCount = i - this.f.getHeaderViewsCount();
            if (this.g.getItemViewType(headerViewsCount) == 1) {
                com.qihoo360.newssdk.comment.a.c cVar = (com.qihoo360.newssdk.comment.a.c) this.g.getItem(headerViewsCount);
                com.qihoo360.newssdk.comment.a aVar = new com.qihoo360.newssdk.comment.a(this);
                aVar.a(cVar);
                aVar.show();
            }
        } catch (Exception e) {
        }
        return true;
    }
}