深瞳优学 v2.3.8版本的 MD5 值为:b789cae3101125f00094fd8828daf997

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


package cn.com.a1school.evaluation.activity.teacher;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.ViewGroup;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import cn.com.a1school.evaluation.R;
import cn.com.a1school.evaluation.activity.teacher.base.BaseTeacherActivity;
import cn.com.a1school.evaluation.base.BaseActivity;
import cn.com.a1school.evaluation.util.LogSwitchUtils;
import com.just.agentweb.AgentWeb;
import com.just.agentweb.AgentWebView;
import com.just.agentweb.WebChromeClient;
import com.just.agentweb.WebViewClient;
import com.tencent.smtt.sdk.TbsReaderView;
import com.tencent.tbs.reader.ITbsReaderCallback;
import com.tencent.tbs.reader.TbsFileInterfaceImpl;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ShowReportFormActivity extends BaseTeacherActivity implements ITbsReaderCallback {
    public static String fileCache = Environment.getExternalStorageDirectory() + "/1school/reportForm/";
    String fileExt;
    String fileName;
    String fileUrl;
    TbsReaderView tbsReaderView;

    @BindView(R.id.title)
    TextView title;

    @Override
    protected int initRootLayout() {
        return R.layout.show_report_form_activity;
    }

    @Override
    protected void initView() {
    }

    @Override
    public void onCallBackAction(Integer num, Object obj, Object obj2) {
    }

    public static void startActivity(BaseActivity baseActivity, String str) {
        Intent intent = new Intent(baseActivity, (Class<?>) ShowReportFormActivity.class);
        intent.putExtra("fileName", str);
        Matcher matcher = Pattern.compile("\\.(doc|docx|rtf|ppt|pptx|xls|xlsx|xlsm|csv|pdf|txt|epub|dwg|chm)$").matcher(str);
        if (matcher.find()) {
            intent.putExtra("fileExt", matcher.group().replace(".", ""));
            baseActivity.startActivity(intent);
        }
    }

    public static void startActivity(BaseActivity baseActivity, String str, String str2) {
        Intent intent = new Intent(baseActivity, (Class<?>) ShowReportFormActivity.class);
        intent.putExtra("fileUrl", str2);
        intent.putExtra("fileName", str);
        Matcher matcher = Pattern.compile("\\.(doc|docx|rtf|ppt|pptx|xls|xlsx|xlsm|csv|pdf|txt|epub|dwg|chm)$").matcher(str);
        if (matcher.find()) {
            intent.putExtra("fileExt", matcher.group().replace(".", ""));
            baseActivity.startActivity(intent);
        }
    }

    @Override
    protected void initData() {
        this.fileUrl = getIntent().getStringExtra("fileUrl");
        this.fileName = getIntent().getStringExtra("fileName");
        this.fileExt = getIntent().getStringExtra("fileExt");
        File file = new File(fileCache + this.fileName);
        String substring = file.getName().substring(0, file.getName().lastIndexOf("."));
        this.title.setText(substring);
        displayFile(file, this.fileExt, substring, this.fileUrl);
    }

    @OnClick({R.id.back})
    public void back() {
        finish();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    public void displayFile(File file, String str, String str2, String str3) {
        if (file == null || TextUtils.isEmpty(file.toString()) || !file.exists()) {
            return;
        }
        File file2 = new File("/storage/emulated/0/TbsReaderTemp");
        if (!file2.exists() && !file2.mkdir()) {
            LogSwitchUtils.tLoge("displayFile", "创建失败");
        }
        Bundle bundle = new Bundle();
        bundle.putString("filePath", file.toString());
        bundle.putString("fileExt", str);
        bundle.putString("tempPath", Environment.getExternalStorageDirectory() + "/TbsReaderTemp");
        bundle.putBoolean("file_reader_enable_long_press_menu", true);
        bundle.putBoolean("file_reader_is_ppt_page_mode_default", true);
        String encodeToString = Base64.encodeToString((str3 + "&fullfilename=" + str2 + "." + str).getBytes(), 0);
        StringBuilder sb = new StringBuilder();
        sb.append("https://api.yxuer.com:8443/officeView/onlinePreview?url=");
        sb.append(encodeToString);
        String sb2 = sb.toString();
        showLoadingView();
        agentWebOpenFile(sb2);
    }

    private void agentWebOpenFile(String str) {
        AgentWeb.with(this).setAgentWebParent((ViewGroup) findViewById(R.id.agentWeb), new LinearLayout.LayoutParams(-1, -1)).useDefaultIndicator().setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
                return super.shouldOverrideUrlLoading(webView, webResourceRequest);
            }

            @Override
            public void onPageStarted(WebView webView, String str2, Bitmap bitmap) {
                super.onPageStarted(webView, str2, bitmap);
            }

            @Override
            public void onPageFinished(WebView webView, String str2) {
                super.onPageFinished(webView, str2);
                ShowReportFormActivity.this.hideLoadingView();
            }

            @Override
            public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
                super.onReceivedError(webView, webResourceRequest, webResourceError);
                ShowReportFormActivity.this.hideLoadingView();
            }
        }).setWebChromeClient(new WebChromeClient()).setWebLayout(null).setWebView(new AgentWebView(this)).setSecurityType(AgentWeb.SecurityType.STRICT_CHECK).createAgentWeb().ready().go(str).getWebCreator().getWebView().getSettings().setJavaScriptEnabled(true);
    }

    private ITbsReaderCallback tbsCallBack() {
        return new ITbsReaderCallback() {
            @Override
            public void onCallBackAction(Integer num, Object obj, Object obj2) {
                Log.i(ShowReportFormActivity.this.TAG, "actionType=" + num + ",args=" + obj + ",result=" + obj2);
                if (7000 == num.intValue() && (obj instanceof Bundle) && 1 == ((Bundle) obj).getInt("typeId")) {
                    ShowReportFormActivity.super.finish();
                    TbsFileInterfaceImpl.getInstance().closeFileReader();
                }
            }
        };
    }

    private String getFileType(String str) {
        int lastIndexOf;
        return (!TextUtils.isEmpty(str) && (lastIndexOf = str.lastIndexOf(46)) > -1) ? str.substring(lastIndexOf + 1) : "";
    }
}