QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

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


package com.tencent.mtt.file.page.toolc.resume;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tencent.mtt.base.wup.PreferenceData;
import com.tencent.mtt.file.page.toolc.resume.DownloadUtil;
import com.tencent.mtt.file.page.toolc.resume.model.Template;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.view.toast.MttToaster;
import java.io.File;
import java.util.List;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.TypeCastException;
import kotlin.Unit;
import kotlin.io.FilesKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;

public final class TemplateManager {

    public static final TemplateManager f62920a = new TemplateManager();

    private static String f62921b = "template_11_5_v5.json";

    private static String f62922c = "https://static.res.qq.com/nav/file/" + f62921b;

    private static final List<Template> f62923d;
    private static Template e;

    static {
        List<Template> list = Template.DATA;
        Intrinsics.checkExpressionValueIsNotNull(list, "Template.DATA");
        f62923d = list;
        e = f62923d.get(0);
    }

    private TemplateManager() {
    }

    public final void a(String str) {
        Object m637constructorimpl;
        try {
            Result.Companion companion = Result.Companion;
            TemplateManager templateManager = this;
            List list = (List) new Gson().fromJson(str, new TypeToken<List<? extends Template>>() {
            }.getType());
            f62923d.clear();
            List<Template> list2 = f62923d;
            Intrinsics.checkExpressionValueIsNotNull(list, "list");
            list2.addAll(list);
            e = f62923d.get(0);
            m637constructorimpl = Result.m637constructorimpl(Unit.INSTANCE);
        } catch (Throwable th) {
            Result.Companion companion2 = Result.Companion;
            m637constructorimpl = Result.m637constructorimpl(ResultKt.createFailure(th));
        }
        if (Result.m640exceptionOrNullimpl(m637constructorimpl) != null) {
            Logs.e("TemplateManager", "parse template config file failed, delete it.");
            new File(DocumentPathManager.f62871a, f62921b).delete();
            MttToaster.show("加载模版数据失败,请稍后重试", 1);
        }
    }

    private final void d() {
        String a2 = PreferenceData.a("RESUME_HELPER_TEMPLATE_URL");
        String str = a2;
        if (str == null || str.length() == 0) {
            return;
        }
        f62922c = a2;
        int lastIndexOf$default = StringsKt.lastIndexOf$default((CharSequence) str, '/', 0, false, 6, (Object) null) + 1;
        if (a2 == null) {
            throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
        }
        String substring = a2.substring(lastIndexOf$default);
        Intrinsics.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
        f62921b = substring;
    }

    private final void e() {
        DownloadUtil downloadUtil = new DownloadUtil(new DownloadUtil.Callback() {
            @Override
            public void a(String str) {
                if (str != null) {
                    TemplateManager.f62920a.a(FilesKt.readText$default(new File(str), null, 1, null));
                }
            }
        });
        String str = f62922c;
        String str2 = DocumentPathManager.f62871a;
        Intrinsics.checkExpressionValueIsNotNull(str2, "DocumentPathManager.DOCUMENT_DIR_PATH");
        downloadUtil.a(str, str2, f62921b);
    }

    public final List<Template> a() {
        return f62923d;
    }

    public final void a(Template template) {
        Intrinsics.checkParameterIsNotNull(template, "template");
        e = template;
    }

    public final void b() {
        d();
        File file = new File(DocumentPathManager.f62871a, f62921b);
        if (file.exists()) {
            a(FilesKt.readText$default(file, null, 1, null));
        } else {
            e();
        }
    }

    public final Template c() {
        return e;
    }
}