导航菜单

页面标题

页面副标题

MedEd v5.3.6 - ArticleDetailActivity.java 源代码

正在查看: MedEd v5.3.6 应用的 ArticleDetailActivity.java JAVA 源代码文件

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


package com.freshchat.consumer.sdk.activity;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.constraintlayout.widget.WO.IDVO;
import com.freshchat.consumer.sdk.FaqOptions;
import com.freshchat.consumer.sdk.Freshchat;
import com.freshchat.consumer.sdk.FreshchatWebViewListener;
import com.freshchat.consumer.sdk.R;
import com.freshchat.consumer.sdk.activity.ds;
import com.freshchat.consumer.sdk.beans.Article;
import com.freshchat.consumer.sdk.beans.Category;
import com.freshchat.consumer.sdk.service.d.e;
import com.freshchat.consumer.sdk.service.e.o$a;
import com.freshchat.consumer.sdk.service.e.y$a;
import defpackage.Jl1;
import defpackage.Ml1$a;
import java.lang.ref.WeakReference;
import java.util.Locale;
import java.util.regex.Pattern;

public class ArticleDetailActivity extends cr implements Ml1$a<Article>, ds.b {
    private static String l = "isArticleVoted";
    private static String s = "HL_ARTICLE_TITLE";
    private static final String t;
    private static final String u;
    private static String z;
    private String[] B;
    private String a;
    private String b;
    private String c;
    private View i;
    private View j;
    private ds k;
    private RelativeLayout m;
    private View n;
    private View o;
    private View p;
    private View q;
    private com.freshchat.consumer.sdk.b.t r;
    private String v;
    private boolean w;
    private boolean y;
    FaqOptions g = new FaqOptions();
    private Bundle h = null;
    private boolean x = false;
    private String d = IDVO.ciJNYE;
    private boolean A = false;
    WebViewClient C = new a(this);
    View.OnClickListener D = new c(this);
    View.OnClickListener E = new f(this);

    static {
        String a = qe.a(new StringBuilder("<head><link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_res/raw/normalize.css\"/><script src='file:///freshchat_assets/freshchat_hacks.js'></script><title>"), s, "</title></head>");
        t = a;
        u = CS.a("<!DOCTYPE html>\t<html>", a, "<body onload='correctIframe()'> <bdi>");
    }

    public void i() {
        new com.freshchat.consumer.sdk.service.d.e(getApplicationContext(), e.a.channels_launch).r("source", "article_not_helpful").r("article_id", this.v).r("category_id", this.b).hV();
    }

    private void n() {
        if (this.w) {
            return;
        }
        String str = z;
        if (str == null || !str.equals(this.v)) {
            Animation loadAnimation = AnimationUtils.loadAnimation(this, R.anim.freshchat_slide_up);
            this.n.bringToFront();
            this.n.startAnimation(loadAnimation);
            this.n.setVisibility(0);
        }
    }

    public void o() {
        if (this.w) {
            return;
        }
        this.n.startAnimation(AnimationUtils.loadAnimation(this, R.anim.freshchat_slide_down));
        this.n.setVisibility(8);
    }

    private void p() {
        if (getSupportActionBar() != null) {
            getSupportActionBar().f();
        }
    }

    private void q() {
        if (getSupportActionBar() != null) {
            getSupportActionBar().s();
        }
    }

    private void r() {
        this.k.postDelayed(new g(this), 500L);
    }

    public com.freshchat.consumer.sdk.util.ao s() {
        return com.freshchat.consumer.sdk.util.cc.a(a(), this.g);
    }

    public com.freshchat.consumer.sdk.b.t h() {
        if (this.r == null) {
            this.r = new com.freshchat.consumer.sdk.b.t(this);
        }
        return this.r;
    }

    @Override
    public void k() {
        o();
    }

    @Override
    public void l() {
        p();
        this.x = true;
        this.n.setVisibility(8);
    }

    @Override
    public void m() {
        q();
        r();
        this.x = false;
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.x) {
            return;
        }
        r();
    }

    @Override
    public void onCreate(Bundle bundle) {
        FreshchatWebViewListener webviewListener;
        super.onCreate(bundle);
        Locale cd = com.freshchat.consumer.sdk.util.cn.cd(this);
        a(bundle);
        Intent intent = getIntent();
        a(intent);
        Bundle extras = intent.getExtras();
        this.h = extras;
        this.g = com.freshchat.consumer.sdk.util.an.e(extras);
        e();
        setContentView(R.layout.freshchat_activity_article_detail);
        E();
        c(!com.freshchat.consumer.sdk.util.ds.c(this.g.getFilteredViewTitle()) ? this.g.getFilteredViewTitle() : com.freshchat.consumer.sdk.util.ds.c(this.c) ? getString(R.string.freshchat_activity_title_article_detail) : this.c);
        d();
        com.freshchat.consumer.sdk.util.b.a(getApplicationContext(), o$a.NORMAL);
        f();
        this.w = h().Z(this.v);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
        layoutParams.addRule(13, -1);
        RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -1);
        layoutParams2.addRule(10, -1);
        this.j = LayoutInflater.from(this).inflate(R.layout.freshchat_partial_article_progress, (ViewGroup) null);
        ds dsVar = new ds(this);
        this.k = dsVar;
        dsVar.setWebViewClient(this.C);
        this.k.a(this, 85);
        this.m.addView(this.k.getLayout(), layoutParams2);
        this.m.addView(this.j, layoutParams);
        if (bundle != null) {
            this.k.restoreState(bundle);
        }
        this.i = this.k;
        Locale cd2 = com.freshchat.consumer.sdk.util.cn.cd(this);
        if (cd == null || cd2 == null || !com.freshchat.consumer.sdk.util.ds.B(cd.getLanguage(), cd2.getLanguage()) || (webviewListener = Freshchat.getInstance(this).getWebviewListener()) == null) {
            return;
        }
        webviewListener.onLocaleChangedByWebView(new WeakReference<>(this));
    }

    @Override
    public Jl1<Article> onCreateLoader(int i, Bundle bundle) {
        return new com.freshchat.consumer.sdk.h.m(getApplicationContext(), bundle.getString("article_id"), bundle.containsKey("EXTRA_FETCH_CATEGORY_INFO"));
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.freshchat_article_detail_list, menu);
        return true;
    }

    public void onDestroy() {
        super.onDestroy();
        ds dsVar = this.k;
        if (dsVar != null) {
            dsVar.destroy();
        }
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4 || !this.k.cz()) {
            return super.onKeyDown(i, keyEvent);
        }
        this.k.cA();
        return true;
    }

    @Override
    public void onLoaderReset(Jl1<Article> jl1) {
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        return super.onOptionsItemSelected(menuItem);
    }

    @Override
    public void onPause() {
        super.onPause();
        if (com.freshchat.consumer.sdk.util.dz.kw() && com.freshchat.consumer.sdk.util.dz.kj()) {
            this.k.onPause();
        } else if (com.freshchat.consumer.sdk.util.dz.kh()) {
            this.k.cB();
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        this.w = h().Z(this.v);
        g();
        if (com.freshchat.consumer.sdk.util.dz.kw() && com.freshchat.consumer.sdk.util.dz.kj()) {
            this.k.onResume();
        }
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        bundle.putBoolean(l, this.w);
        super.onSaveInstanceState(bundle);
    }

    public void onStart() {
        super.onStart();
        if (com.freshchat.consumer.sdk.util.dz.kr()) {
            this.k.onResume();
        }
    }

    public void onStop() {
        super.onStop();
        if (com.freshchat.consumer.sdk.util.dz.kr()) {
            this.k.onPause();
        }
        this.k.stopLoading();
    }

    private String a(Article article) {
        String str;
        if (article == null) {
            return null;
        }
        this.b = article.getCategoryId();
        StringBuilder sb = new StringBuilder();
        String replaceAll = article.getDescription().replaceAll("src=\"//", "src=\"http://").replaceAll("value=\"//", "value=\"http://");
        Pattern compile = Pattern.compile("<\\s*(img|iframe).*?src\\s*=[ '\"]+http[s]?:\\/\\/.*?>");
        if (com.freshchat.consumer.sdk.util.db.cm(this) || !compile.matcher(replaceAll).find()) {
            str = "";
        } else {
            str = "<div class='offline-article-message'>" + getString(R.string.freshchat_faq_rich_media_content_cannot_be_displayed) + "</div>";
        }
        this.a = article.getTitle();
        sb.append(u);
        sb.append("<div class=\"article-title\";><h3 >");
        fj.b(sb, this.a, "</h3></div>", str, "<div class=\"article-body\">");
        String a = qe.a(sb, replaceAll, "</div></bdi></body></html>");
        return !com.freshchat.consumer.sdk.util.ds.c(this.c) ? a.replace(s, this.c) : a;
    }

    private void c() {
        com.freshchat.consumer.sdk.util.ba.a(a(), this.b, this.c, this.v, this.a, this.B);
        if (this.A) {
            return;
        }
        new com.freshchat.consumer.sdk.service.d.e(getApplicationContext(), e.a.faq_open_article).r("category_id", this.b).r("category_name", this.c).r("article_id", this.v).r("article_name", this.a).r("source", this.d).hV();
        this.A = true;
    }

    private void d() {
        this.p = findViewById(R.id.freshchat_upvote);
        this.q = findViewById(R.id.freshchat_downvote);
        this.n = findViewById(R.id.freshchat_voting_view);
        this.o = findViewById(R.id.freshchat_contact_us_group);
        this.m = (RelativeLayout) findViewById(R.id.freshchat_solution_article_root_layout);
        ((TextView) findViewById(R.id.freshchat_contact_us_btn)).setText(R.string.freshchat_faq_not_helpful_contact_us);
    }

    private void e() {
        Bundle bundle = new Bundle();
        bundle.putString("article_id", this.v);
        if (com.freshchat.consumer.sdk.util.ds.c(this.c)) {
            bundle.putBoolean("EXTRA_FETCH_CATEGORY_INFO", true);
        }
        getSupportLoaderManager().b(bundle, this);
    }

    private void f() {
        this.p.setOnClickListener(this.D);
        this.q.setOnClickListener(this.D);
        this.o.setOnClickListener(this.E);
    }

    private void g() {
        View view;
        int i;
        if (this.g.shouldShowContactUsOnFaqNotHelpful() && this.w && h().Y(this.v)) {
            this.o.bringToFront();
            view = this.o;
            i = 0;
        } else {
            view = this.o;
            i = 8;
        }
        view.setVisibility(i);
    }

    @Override
    public String[] b() {
        return new String[]{"com.freshchat.consumer.sdk.actions.TokenWaitTimeout", "com.freshchat.consumer.sdk.actions.FAQApiVersionChanged"};
    }

    @Override
    public void j() {
        n();
    }

    @Override
    public void onLoadFinished(Jl1<Article> jl1, Article article) {
        Category hw;
        String a = a(article);
        if (com.freshchat.consumer.sdk.util.ds.a(a)) {
            if ((jl1 instanceof com.freshchat.consumer.sdk.h.m) && (hw = ((com.freshchat.consumer.sdk.h.m) jl1).hw()) != null) {
                String title = hw.getTitle();
                this.c = title;
                a = a.replace(s, title);
            }
            this.k.loadDataWithBaseURL(null, a, "text/html", "utf-8", null);
        }
        c();
    }

    @Override
    public void a(Context context, Intent intent) {
    }

    private void a(Intent intent) {
        if (!intent.hasExtra("article_id")) {
            Toast.makeText((Context) this, R.string.freshchat_faq_failed_to_load, 0).show();
            finish();
        }
        long longExtra = intent.getLongExtra("article_id", -1L);
        if (longExtra > 0) {
            this.v = Long.toString(longExtra);
        } else {
            Toast.makeText((Context) this, R.string.freshchat_faq_failed_to_load, 0).show();
            finish();
        }
        if (intent.hasExtra("category_id")) {
            this.b = intent.getStringExtra("category_id");
        }
        if (intent.hasExtra("category_name")) {
            this.c = intent.getStringExtra("category_name");
        }
        if (intent.hasExtra("EVENT_LAUNCH_SOURCE")) {
            this.d = intent.getStringExtra("EVENT_LAUNCH_SOURCE");
        }
        if (intent.hasExtra("LAUNCHED_FROM_CONVERSATION")) {
            this.y = intent.getBooleanExtra("LAUNCHED_FROM_CONVERSATION", false);
        }
        this.B = intent.getStringArrayExtra("INPUT_TAGS");
    }

    private void a(Bundle bundle) {
        this.w = bundle != null ? bundle.getBoolean(l) : false;
    }

    public void a(y$a y_a) {
        y$a y_a2 = y$a.Upvote;
        com.freshchat.consumer.sdk.util.ba.a(a(), this.b, this.c, this.v, this.a, y_a == y_a2);
        new com.freshchat.consumer.sdk.service.d.e(getApplicationContext(), y_a == y_a2 ? e.a.faq_upvote_article : e.a.faq_downvote_article).r("article_id", this.v).r("category_id", this.b).r("article_name", this.a).hV();
    }
}