package com.ss.android.ugc.aweme.shortvideo.sticker.question;

import X.Lea;
import X.Lnj;
import X.M12;
import android.os.Message;
import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.question.IQuestionFavoriteService;
import java.util.LinkedHashMap;
import java.util.Map;

public final class QuestionFavoriteServiceImpl implements WeakHandler.IHandler, IQuestionFavoriteService {
    public final int LIZ = 64;
    public final Map<String, Integer> LIZIZ = new LinkedHashMap();

    static {
        Covode.recordClassIndex(112501);
    }

    public final void handleMsg(Message message) {
    }

    public static IQuestionFavoriteService LIZ() {
        MethodCollector.i(1396);
        IQuestionFavoriteService iQuestionFavoriteService = (IQuestionFavoriteService) Lnj.LIZ(IQuestionFavoriteService.class, false);
        if (iQuestionFavoriteService != null) {
            MethodCollector.o(1396);
            return iQuestionFavoriteService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IQuestionFavoriteService.class, false);
        if (LIZIZ2 != null) {
            IQuestionFavoriteService iQuestionFavoriteService2 = (IQuestionFavoriteService) LIZIZ2;
            MethodCollector.o(1396);
            return iQuestionFavoriteService2;
        }
        if (Lnj.bu == null) {
            synchronized (IQuestionFavoriteService.class) {
                try {
                    if (Lnj.bu == null) {
                        Lnj.bu = new QuestionFavoriteServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(1396);
                    throw th;
                }
            }
        }
        QuestionFavoriteServiceImpl questionFavoriteServiceImpl = (QuestionFavoriteServiceImpl) Lnj.bu;
        MethodCollector.o(1396);
        return questionFavoriteServiceImpl;
    }

    public final void LIZ(String str, int i) {
        MethodCollector.i(1393);
        M12.LIZ(str);
        if (str.length() == 0) {
            MethodCollector.o(1393);
            return;
        }
        synchronized (this.LIZIZ) {
            try {
                if (this.LIZIZ.size() >= this.LIZ) {
                    this.LIZIZ.entrySet().remove((Map.Entry) Lea.LIZLLL(this.LIZIZ.entrySet()));
                }
                this.LIZIZ.put(str, Integer.valueOf(i));
            } finally {
                MethodCollector.o(1393);
            }
        }
    }
}
