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

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.comment.ICommentFavoriteService;
import java.util.LinkedHashMap;
import java.util.Map;

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

    static {
        Covode.recordClassIndex(112239);
    }

    public final void handleMsg(Message message) {
    }

    public static ICommentFavoriteService LIZ() {
        MethodCollector.i(4445);
        ICommentFavoriteService iCommentFavoriteService = (ICommentFavoriteService) Lnj.LIZ(ICommentFavoriteService.class, false);
        if (iCommentFavoriteService != null) {
            MethodCollector.o(4445);
            return iCommentFavoriteService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(ICommentFavoriteService.class, false);
        if (LIZIZ2 != null) {
            ICommentFavoriteService iCommentFavoriteService2 = (ICommentFavoriteService) LIZIZ2;
            MethodCollector.o(4445);
            return iCommentFavoriteService2;
        }
        if (Lnj.bt == null) {
            synchronized (ICommentFavoriteService.class) {
                try {
                    if (Lnj.bt == null) {
                        Lnj.bt = new CommentFavoriteServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(4445);
                    throw th;
                }
            }
        }
        CommentFavoriteServiceImpl commentFavoriteServiceImpl = (CommentFavoriteServiceImpl) Lnj.bt;
        MethodCollector.o(4445);
        return commentFavoriteServiceImpl;
    }

    public final int LIZ(String str) {
        boolean z;
        Integer num;
        MethodCollector.i(4358);
        M12.LIZ(str);
        if (str.length() == 0) {
            z = true;
        } else {
            z = false;
        }
        int i = -1;
        if (z) {
            MethodCollector.o(4358);
            return -1;
        }
        synchronized (this.LIZIZ) {
            try {
                if (this.LIZIZ.containsKey(str) && (num = this.LIZIZ.get(str)) != null) {
                    i = num.intValue();
                }
            } finally {
                MethodCollector.o(4358);
            }
        }
        return i;
    }

    public final void LIZ(String str, int i) {
        MethodCollector.i(4352);
        M12.LIZ(str);
        if (str.length() == 0) {
            MethodCollector.o(4352);
            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(4352);
            }
        }
    }
}
