导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - ActivityPolicyContent.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 ActivityPolicyContent.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.newheyd.JZKFcanjiren.Activity;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.bumptech.glide.load.Key;
import com.google.gson.Gson;
import com.newheyd.JZKFcanjiren.BaseActivity;
import com.newheyd.JZKFcanjiren.Bean.PolicyInfoBean;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.DataBaseUtils.DictionaryDatabaseManager;
import com.newheyd.JZKFcanjiren.Utils.DataUtil;
import com.newheyd.JZKFcanjiren.Utils.NewUtil;
import com.newheyd.JZKFcanjiren.Utils.StastisticUtil;
import com.newheyd.JZKFcanjiren.Utils.locationUtil.LocationAddrUtil;
import com.newheyd.JZKFcanjiren.View.TitleView;
import com.newheyd.JZKFcanjiren.model.BaseResult;
import com.newheyd.JZKFcanjiren.net.NewHYTask;
import com.tencent.connect.common.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONException;
import org.json.JSONObject;

public class ActivityPolicyContent extends BaseActivity {
    private PolicyInfoBean bean;
    private DictionaryDatabaseManager dictionaryDatabaseManager;
    private String keytype;
    private WebView mContentTv;
    private TextView mDateTv;
    private TextView mFileTv;
    private TextView mFromTv;
    private TextView mKeywordsTv;
    private TextView mLevelTv;
    private LinearLayout mO15;
    private LinearLayout mO151;
    private LinearLayout mO152;
    private LinearLayout mO153;
    private LinearLayout mO154;
    private LinearLayout mO155;
    private LinearLayout mO156;
    private LinearLayout mReferenceLy;
    private TextView mReferenceTv;
    private LinearLayout mRemarkLl;
    private TextView mRemarkTv;
    private TextView mSubTitleTv;
    private TextView mTitleTv;
    private TextView mTypeTv;
    private TitleView titleview;
    private ArrayList<LinearLayout> linearLayouts = null;
    private LinearLayout contentLy = null;
    private ProgressBar mBar = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_policy_content);
        super.onCreate(savedInstanceState);
        this.dictionaryDatabaseManager = new DictionaryDatabaseManager(this.mContext);
        freshData();
        goStatistics();
    }

    public void goStatistics() {
        HashMap<String, String> map = LocationAddrUtil.getInstance().getLocationParam(this.mContext);
        map.put("hotTitle", this.bean == null ? "" : this.bean.getTitle());
        StastisticUtil.getInstance().onEvent(this.mContext, "ActivityPolicyContent", map);
    }

    public void freshData() {
        if (this.bean != null) {
            this.mTitleTv.setText(this.bean.getTitle());
            this.mSubTitleTv.setText(this.bean.getSubtitle());
            this.mKeywordsTv.setText(this.bean.getKeyWord());
            if (isNull(this.bean.getReference())) {
                this.mReferenceLy.setVisibility(8);
            } else {
                this.mReferenceTv.setVisibility(0);
                this.mReferenceTv.setText(this.bean.getReference());
            }
            this.mFromTv.setText(this.bean.getIssueNumber());
            this.mDateTv.setText(DataUtil.formatDateOther(this.bean.getPublishDate()));
            this.mTypeTv.setText(this.dictionaryDatabaseManager.keyTOvalue("issuetype_" + this.bean.getIssuetype(), "issuetype"));
            String policyKind = this.dictionaryDatabaseManager.keyTOvalue("policyKind_" + this.bean.getPolicyKind(), "policyKind");
            TextView textView = this.mFileTv;
            if (isNull(policyKind)) {
                policyKind = "无";
            }
            textView.setText(policyKind);
            this.mLevelTv.setText(this.dictionaryDatabaseManager.keyTOvalue("projectLevel_" + this.bean.getPolicyLevel(), "projectLevel"));
            JSONObject jsonObject = null;
            try {
                JSONObject jsonObject2 = new JSONObject(new Gson().toJson(this.bean));
                jsonObject = jsonObject2;
            } catch (JSONException e) {
                e.printStackTrace();
            }
            String idtKind = this.bean.getIdtKind();
            String[] strArr = new String[6];
            HashMap<String, String[]> map = new HashMap<>();
            if (!isNull(idtKind)) {
                if (idtKind.endsWith(",")) {
                    idtKind = idtKind.substring(0, idtKind.length() - 1);
                }
                String[] idsKindArr = idtKind.split(",");
                for (String str : idsKindArr) {
                    String num = str.split("_")[1];
                    String key = "idtLevel" + num;
                    String secondKey = jsonObject.optString(key);
                    if (!isNull(secondKey)) {
                        if (secondKey.endsWith(",")) {
                            secondKey = secondKey.substring(0, secondKey.length() - 1);
                        }
                        String[] secondidsKindArr = secondKey.split(",");
                        String[] arr = new String[secondidsKindArr.length];
                        for (int j = 0; j < secondidsKindArr.length; j++) {
                            String secondNum = secondidsKindArr[j].split("_")[1];
                            arr[j] = secondNum;
                        }
                        map.put(num, secondidsKindArr);
                    } else {
                        map.put(num, null);
                    }
                }
                for (Map.Entry<String, String[]> entry : map.entrySet()) {
                    String key2 = entry.getKey();
                    int k = Integer.parseInt(key2);
                    String[] vals = entry.getValue();
                    LinearLayout outLayout = this.linearLayouts.get(k - 1);
                    if (k - 1 != 6) {
                        LinearLayout innerLayout = (LinearLayout) outLayout.getChildAt(0);
                        CheckBox b = (CheckBox) innerLayout.getChildAt(0);
                        b.setChecked(true);
                    }
                    if (vals != null && vals.length > 0) {
                        for (String str2 : vals) {
                            int index = Integer.parseInt(str2.split("_")[1]);
                            if (k - 1 == 6) {
                                index--;
                            }
                            LinearLayout ly = (LinearLayout) outLayout.getChildAt(index);
                            CheckBox b2 = (CheckBox) ly.getChildAt(0);
                            b2.setChecked(true);
                        }
                    }
                }
            }
            String cssLayout = "<html><head><meta http-equiv='content-type' content='text/html; charset=UTF-8'/><meta name='viewport' id='viewport' content='width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes'></head><style>*{padding: 0;margin: 0}#webview_content_wrapper{margin: 10px 15px 0 15px;} p{color: #191919;line-height: 2em;font-size:16px;opacity: 1;}</style>";
            String content = this.bean.getPolicyContent();
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(content);
            String content2 = m.replaceAll("");
            String htmlcontent = cssLayout + "<body><div id='webview_content_wrapper'>" + content2.replaceAll("\\?", "") + "</div></body><html>";
            this.mContentTv.loadDataWithBaseURL(null, htmlcontent, "text/html", Key.STRING_CHARSET_NAME, null);
            if (!isNull(this.bean.getRemarks())) {
                this.mRemarkLl.setVisibility(0);
                this.mRemarkTv.setText(this.bean.getRemarks());
            } else {
                this.mRemarkLl.setVisibility(8);
                LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) this.contentLy.getLayoutParams();
                params.bottomMargin = NewUtil.dip2px(this.mContext, getResources().getDimension(R.dimen.dimen_20));
                this.contentLy.setLayoutParams(params);
            }
        }
    }

    @Override
    public void onResponseBefore(NewHYTask task) {
    }

    @Override
    public void onResponseAfter(NewHYTask task) {
    }

    @Override
    public void onResponseSuccessful(NewHYTask task, BaseResult object) {
    }

    @Override
    public void onResponseError(NewHYTask task, BaseResult object) {
    }

    @Override
    public void onServerError(NewHYTask task, int failedType) {
    }

    @Override
    public void initViews() {
        this.titleview = (TitleView) findViewById(R.id.titleview);
        this.mTitleTv = (TextView) findViewById(R.id.title_tv);
        this.mSubTitleTv = (TextView) findViewById(R.id.sub_title_tv);
        this.mKeywordsTv = (TextView) findViewById(R.id.keywords_tv);
        this.mReferenceTv = (TextView) findViewById(R.id.reference_tv);
        this.mFromTv = (TextView) findViewById(R.id.from_tv);
        this.mDateTv = (TextView) findViewById(R.id.date_tv);
        this.mTypeTv = (TextView) findViewById(R.id.type_tv);
        this.mFileTv = (TextView) findViewById(R.id.file_tv);
        this.mLevelTv = (TextView) findViewById(R.id.level_tv);
        this.mO151 = (LinearLayout) findViewById(R.id.O15_1);
        this.mO152 = (LinearLayout) findViewById(R.id.O15_2);
        this.mO153 = (LinearLayout) findViewById(R.id.O15_3);
        this.mO154 = (LinearLayout) findViewById(R.id.O15_4);
        this.mO155 = (LinearLayout) findViewById(R.id.O15_5);
        this.mO156 = (LinearLayout) findViewById(R.id.O15_6);
        this.mO15 = (LinearLayout) findViewById(R.id.O15);
        this.linearLayouts = new ArrayList<>();
        this.linearLayouts.add(0, this.mO151);
        this.linearLayouts.add(1, this.mO152);
        this.linearLayouts.add(2, this.mO153);
        this.linearLayouts.add(3, this.mO154);
        this.linearLayouts.add(4, this.mO155);
        this.linearLayouts.add(5, this.mO156);
        this.linearLayouts.add(6, this.mO15);
        this.contentLy = (LinearLayout) findViewById(R.id.content_ly);
        this.mContentTv = (WebView) findViewById(R.id.content_tv);
        this.mBar = (ProgressBar) findViewById(R.id.myProgressBar);
        this.mRemarkTv = (TextView) findViewById(R.id.remark_tv);
        this.mRemarkLl = (LinearLayout) findViewById(R.id.remark_ll);
        this.mReferenceLy = (LinearLayout) findViewById(R.id.reference_ly);
        WebSettings webSettings = this.mContentTv.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webSettings.setDisplayZoomControls(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAllowFileAccess(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setSupportZoom(true);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setDomStorageEnabled(true);
        this.mContentTv.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                if (newProgress == 100) {
                    ActivityPolicyContent.this.mBar.setVisibility(8);
                } else {
                    ActivityPolicyContent.this.mBar.setVisibility(0);
                    ActivityPolicyContent.this.mBar.setProgress(newProgress);
                }
                super.onProgressChanged(view, newProgress);
            }
        });
        this.mContentTv.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return true;
            }
        });
    }

    @Override
    public void getExtraParam() {
        this.bean = (PolicyInfoBean) getIntent().getSerializableExtra("bean");
        this.keytype = getIntent().getStringExtra(Constants.PARAM_KEY_TYPE);
        if ("1".equals(this.keytype)) {
            this.titleview.setTextName("政策法规详情");
        } else if ("2".equals(this.keytype)) {
            this.titleview.setTextName("适配政策详情");
        }
    }

    @Override
    public void setListener() {
        this.titleview.setOnTitleClik(new TitleView.BackListenner() {
            @Override
            public void BackSet() {
                ActivityPolicyContent.this.finish();
            }
        }, null);
    }
}