4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1

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


package com.m4399.gamecenter.plugin.main.viewholder.special;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Keep;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.widget.LinearLayout;
import com.framework.database.tables.CachesTable;
import com.framework.rxbus.RxBus;
import com.framework.rxbus.annotation.Subscribe;
import com.framework.rxbus.annotation.Tag;
import com.framework.rxbus.thread.EventThread;
import com.framework.utils.DensityUtils;
import com.igexin.push.f.p;
import com.m4399.gamecenter.plugin.main.R;
import com.m4399.gamecenter.plugin.main.controllers.web.GameCommentJsInterface;
import com.m4399.gamecenter.plugin.main.helpers.k;
import com.m4399.gamecenter.plugin.main.manager.router.GameCenterRouterManager;
import com.m4399.gamecenter.plugin.main.manager.v;
import com.m4399.gamecenter.plugin.main.models.home.CategoryAlbumListModel;
import com.m4399.gamecenter.plugin.main.widget.web.WebViewLayout;
import com.m4399.support.quick.RecyclerQuickAdapter;
import com.m4399.support.quick.RecyclerQuickViewHolder;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;

public class SpecialDetailCommentHolder extends RecyclerQuickViewHolder implements View.OnClickListener {
    private View aJr;
    private WebViewLayout aZC;
    private GameCommentJsInterface apa;
    private String bLj;
    private String dFP;
    private a erQ;
    private int erR;
    private int mCommentId;
    private RecyclerView mRecyclerView;
    private int mReplyId;
    private int specialId;

    public void setCommentId(int i) {
        this.mCommentId = i;
    }

    public void setReplyId(int i) {
        this.mReplyId = i;
    }

    public void setItemViewTopPadding(int i) {
        this.erR = i;
        WZ();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        TI();
        WebViewLayout webViewLayout = this.aZC;
        if (webViewLayout != null) {
            webViewLayout.stopLoading();
            this.aZC.loadData("<a></a>", "text/html", p.b);
            this.aZC.removeAllViews();
            this.aZC.setVisibility(8);
            this.aZC.onDestroy();
            this.aZC = null;
            GameCommentJsInterface gameCommentJsInterface = this.apa;
            if (gameCommentJsInterface != null) {
                gameCommentJsInterface.onDestroy();
                this.apa = null;
            }
        }
    }

    private void TH() {
        RxBus.register(this);
    }

    private void TI() {
        RxBus.unregister(this);
    }

    public SpecialDetailCommentHolder(Context context, View view) {
        super(context, view);
        this.dFP = "";
        this.erR = 0;
    }

    @Override
    protected void initView() {
        this.aZC = (WebViewLayout) findViewById(R.id.webView_layout);
        this.mRecyclerView = (RecyclerView) findViewById(R.id.hot_special_recycler_view);
        this.aJr = findViewById(R.id.more_special_view);
        this.aJr.setOnClickListener(this);
        this.erQ = new a(this.mRecyclerView);
        this.erQ.setOnItemClickListener(new RecyclerQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, Object obj, int i) {
                CategoryAlbumListModel categoryAlbumListModel = (CategoryAlbumListModel) obj;
                Bundle bundle = new Bundle();
                bundle.putInt("intent.extra.special.id", categoryAlbumListModel.getId());
                bundle.putString("intent.extra.special.name", categoryAlbumListModel.getTitle());
                GameCenterRouterManager.getInstance().openSpecialDetail(SpecialDetailCommentHolder.this.getContext(), bundle, new int[0]);
            }
        });
        this.mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), 1, false));
        this.mRecyclerView.setAdapter(this.erQ);
        TH();
    }

    @Keep
    @Subscribe(tags = {@Tag("tag.common.comment.reply")})
    public void onCommonCmtReplySuccess(String str) {
        E(k.JS_REPLY_COMMON_CMT_SUCCESS, str);
    }

    @Keep
    @Subscribe(tags = {@Tag("tag.common.comment.praise")}, thread = EventThread.MAIN_THREAD)
    public void praiseCommonComment(Bundle bundle) {
        String string = bundle.getString("intent.extra.from.key");
        if (TextUtils.isEmpty(string) || string.equals("special_detail")) {
            return;
        }
        int i = bundle.getInt("intent.extra.comment.id");
        k.executeJs(this.aZC, "javascript:m_common.praiseSuccess(" + i + ")");
    }

    @Keep
    @Subscribe(tags = {@Tag("tag.common.comment.del")})
    public void removeCommonComment(String str) {
        E(k.JS_DEL_COMMON_CMT, str);
    }

    private void E(String str, String str2) {
        k.executeJs(this.aZC, str + "('" + str2 + "')");
    }

    @Keep
    @Subscribe(tags = {@Tag("tag.comment.resize.height")}, thread = EventThread.MAIN_THREAD)
    public void resizeWebViewContentHeight(Integer num) {
        if (this.aZC != null && num.intValue() == 2) {
            this.aZC.loadUrl("javascript:window.resizeHeightJs.resize(document.body.getBoundingClientRect().height)");
        }
    }

    @Keep
    @Subscribe(tags = {@Tag("fragment.add.comment")})
    public void onReceiveCommentResult(Bundle bundle) {
        if (this.specialId != bundle.getInt("intent.extra.special.id")) {
            return;
        }
        int i = bundle.getInt("intent.extra.comment.action.type", 1);
        String string = bundle.getString("intent.extra.comment.server.result");
        k.executeJs(this.aZC, (i == 1 ? k.JS_COMMON_ADD_COMMENT : k.JS_COMMON_REPLY_COMMENT) + "('" + string + "')");
    }

    private void WY() {
        if (this.apa == null) {
            this.apa = new GameCommentJsInterface(this.aZC, getContext()) {
                @Keep
                @JavascriptInterface
                public String getCardColor() {
                    return SpecialDetailCommentHolder.this.dFP;
                }

                @Keep
                @JavascriptInterface
                public String getBackgroundColor() {
                    return SpecialDetailCommentHolder.this.dFP;
                }
            };
        }
        this.apa.setSpecialId(this.specialId);
        this.apa.setFrom("special_detail");
        this.apa.setSpecialName(this.bLj);
        this.apa.addWebRequestParam(CachesTable.COLUMN_KEY, Integer.valueOf(this.specialId));
        this.apa.addWebRequestParam("positionPage", 6);
        int i = this.mCommentId;
        if (i != 0) {
            this.apa.addWebRequestParam("commentId", Integer.valueOf(i));
        }
        int i2 = this.mReplyId;
        if (i2 != 0) {
            this.apa.addWebRequestParam("replyId", Integer.valueOf(i2));
        }
        this.aZC.addJavascriptInterface(this.apa, "android");
        this.aZC.addJavascriptInterface(new WebViewResizeHeightJsInterface(), "resizeHeightJs");
        v.getInstance().loadTemplate(3, this.aZC, null, new v.b((Activity) getContext(), this.aZC, 3));
    }

    public void setBackgroundColor(String str) {
        this.dFP = str;
    }

    public void setCommentData(int i, String str) {
        this.specialId = i;
        this.bLj = str;
        WZ();
        WY();
    }

    private void WZ() {
        if (this.itemView == null) {
            return;
        }
        this.itemView.setPadding(this.itemView.getPaddingLeft(), this.erR, this.itemView.getPaddingRight(), this.itemView.getPaddingBottom());
    }

    public void resolveHeight() {
        WebViewLayout webViewLayout = this.aZC;
        if (webViewLayout == null) {
            return;
        }
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) webViewLayout.getLayoutParams();
        if (layoutParams.height == -2 || layoutParams.height >= DensityUtils.dip2px(getContext(), 50.0f)) {
            return;
        }
        resizeWebViewContentHeight(2);
    }

    public void setRecommendList(List list) {
        this.erQ.replaceAll(list);
        this.aJr.setVisibility(list.isEmpty() ? 8 : 0);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.more_special_view) {
            GameCenterRouterManager.getInstance().openSpecialList(getContext(), new int[0]);
        }
    }

    public class WebViewResizeHeightJsInterface {
        int caQ;

        private WebViewResizeHeightJsInterface() {
            this.caQ = 0;
        }

        @Keep
        @JavascriptInterface
        public void resize(final float f) {
            this.caQ++;
            if (SpecialDetailCommentHolder.this.getContext() == null || SpecialDetailCommentHolder.this.aZC == null) {
                return;
            }
            if (f < 50.0f && this.caQ <= 10) {
                Observable.timer(100L, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()).subscribe(new Action1<Long>() {
                    @Override
                    public void call(Long l) {
                        SpecialDetailCommentHolder.this.resizeWebViewContentHeight(2);
                    }
                });
            } else {
                com.m4399.gamecenter.plugin.main.utils.e.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (SpecialDetailCommentHolder.this.getContext() == null || SpecialDetailCommentHolder.this.aZC == null) {
                            return;
                        }
                        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) SpecialDetailCommentHolder.this.aZC.getLayoutParams();
                        layoutParams.height = f <= 50.0f ? -2 : DensityUtils.dip2px(SpecialDetailCommentHolder.this.getContext(), f);
                        SpecialDetailCommentHolder.this.aZC.setLayoutParams(layoutParams);
                    }
                });
            }
        }
    }
}