QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 DocRenderController.java 源代码,内容仅作参考
package com.tencent.mtt.file.page.toolc.doctool;
import android.os.AsyncTask;
import android.os.Bundle;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.browser.file.open.FileOpenManager;
import com.tencent.mtt.external.reader.ReaderConstantsDefine;
import com.tencent.mtt.file.page.toolc.resume.DocumentPathManager;
import com.tencent.mtt.file.page.toolc.resume.DownloadUtil;
import com.tencent.mtt.file.page.toolc.resume.TemplateDocument;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.nxeasy.sdcard.FileUtilsCompat;
import com.tencent.mtt.view.dialog.alert.MttLoadingDialog;
import java.io.File;
import java.io.FileInputStream;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.jvm.internal.Intrinsics;
import org.w3c.dom.Document;
public final class DocRenderController extends AsyncTask<Unit, Unit, Boolean> implements DownloadUtil.Callback {
public Callback f62700a;
private final String f62701b;
private final String f62702c;
private final String f62703d;
private MttLoadingDialog e;
private TemplateDocument f;
private Document g;
private final AtomicBoolean h;
private final String i;
private final String j;
public interface Callback {
void a(boolean z);
}
public DocRenderController(String title, String content) {
Intrinsics.checkParameterIsNotNull(title, "title");
Intrinsics.checkParameterIsNotNull(content, "content");
this.i = title;
this.j = content;
this.f62701b = "DocRenderController";
this.f62702c = "74c5e8987137a1653fddc6eba74babac";
this.f62703d = "https://static.res.qq.com/nav/file/74c5e8987137a1653fddc6eba74babac";
this.f = DocumentPathManager.e(this.f62702c);
this.h = new AtomicBoolean(false);
}
private final void c() {
ActivityHandler b2 = ActivityHandler.b();
Intrinsics.checkExpressionValueIsNotNull(b2, "ActivityHandler.getInstance()");
ActivityHandler.ActivityInfo m = b2.m();
if (m == null || m.b() == null) {
return;
}
this.e = new MttLoadingDialog(m.b());
MttLoadingDialog mttLoadingDialog = this.e;
if (mttLoadingDialog != null) {
mttLoadingDialog.a("加载中...");
}
MttLoadingDialog mttLoadingDialog2 = this.e;
if (mttLoadingDialog2 != null) {
mttLoadingDialog2.show();
}
}
private final void d() {
Transformer newTransformer = TransformerFactory.newInstance().newTransformer();
File file = new File(DocumentPathManager.d(this.f62702c));
if (file.exists()) {
file.delete();
}
File parentFile = file.getParentFile();
if (parentFile == null || !parentFile.exists()) {
FileUtilsCompat.a(parentFile);
}
StreamResult streamResult = new StreamResult(file);
Document document = this.g;
if (document == null) {
Intrinsics.throwUninitializedPropertyAccessException("document");
}
newTransformer.transform(new DOMSource(document), streamResult);
}
@Override
public Boolean doInBackground(Unit... params) {
Intrinsics.checkParameterIsNotNull(params, "params");
try {
Result.Companion companion = Result.Companion;
DocRenderController docRenderController = this;
docRenderController.f.a();
TemplateDocument templateDocument = docRenderController.f;
Intrinsics.checkExpressionValueIsNotNull(templateDocument, "templateDocument");
String b2 = templateDocument.b();
Intrinsics.checkExpressionValueIsNotNull(b2, "templateDocument.documentXmlPath");
docRenderController.f.a(b2, DocumentPathManager.d(docRenderController.f62702c));
Document parse = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new FileInputStream(b2));
Intrinsics.checkExpressionValueIsNotNull(parse, "builder.parse(FileInputStream(srcPath))");
docRenderController.g = parse;
Document document = docRenderController.g;
if (document == null) {
Intrinsics.throwUninitializedPropertyAccessException("document");
}
new DocumentRender(document).a(docRenderController.j);
docRenderController.d();
docRenderController.f.b(DocumentPathManager.f62872b, docRenderController.i + ".docx");
return true;
} catch (Throwable th) {
Result.Companion companion2 = Result.Companion;
Throwable m640exceptionOrNullimpl = Result.m640exceptionOrNullimpl(Result.m637constructorimpl(ResultKt.createFailure(th)));
if (m640exceptionOrNullimpl != null) {
Logs.a(this.f62701b, m640exceptionOrNullimpl);
}
return false;
}
}
public final AtomicBoolean a() {
return this.h;
}
public final void a(Callback callback) {
Intrinsics.checkParameterIsNotNull(callback, "<set-?>");
this.f62700a = callback;
}
@Override
public void a(String str) {
MttLoadingDialog mttLoadingDialog = this.e;
if (mttLoadingDialog != null) {
mttLoadingDialog.dismiss();
}
this.h.set(false);
if (str != null) {
execute(new Unit[0]);
return;
}
Callback callback = this.f62700a;
if (callback == null) {
Intrinsics.throwUninitializedPropertyAccessException("callback");
}
callback.a(false);
}
protected void a(boolean z) {
super.onPostExecute(Boolean.valueOf(z));
if (z) {
Bundle bundle = new Bundle();
bundle.putInt(ReaderConstantsDefine.DIRECT_MENU_FUNCTION_KEY, ReaderConstantsDefine.READER_REQ_FEATURE_DOCX_EDIT);
bundle.putInt(ReaderConstantsDefine.KEY_READER_SAVE_WHEN_ENTER_EDIT, 1);
FileOpenManager.a().openFile(DocumentPathManager.f62872b, this.i + ".docx", null, 30, null, bundle);
MttLoadingDialog mttLoadingDialog = this.e;
if (mttLoadingDialog != null) {
mttLoadingDialog.dismiss();
}
this.h.set(false);
}
Callback callback = this.f62700a;
if (callback == null) {
Intrinsics.throwUninitializedPropertyAccessException("callback");
}
callback.a(z);
}
public final void b() {
if (!this.h.compareAndSet(false, true)) {
Logs.c(this.f62701b, "task already running...");
return;
}
c();
File file = new File(DocumentPathManager.a(this.f62702c));
if (file.exists()) {
execute(new Unit[0]);
return;
}
DownloadUtil downloadUtil = new DownloadUtil(this);
String str = this.f62703d;
String str2 = DocumentPathManager.f62871a;
Intrinsics.checkExpressionValueIsNotNull(str2, "DocumentPathManager.DOCUMENT_DIR_PATH");
String name = file.getName();
Intrinsics.checkExpressionValueIsNotNull(name, "file.name");
downloadUtil.a(str, str2, name);
}
@Override
public void onPostExecute(Boolean bool) {
a(bool.booleanValue());
}
}