/* * mygram-droid: Android TV client for Foldergram. * Copyright (C) 2026 Danilo M. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ package mygram.droid; import org.json.JSONException; import java.io.IOException; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** Liked post IDs. Feed items carry no liked flag, so this set drives every heart. */ final class Likes { private static final Set ids = ConcurrentHashMap.newKeySet(); private Likes() { } static void load() throws IOException, JSONException { Set fresh = ConcurrentHashMap.newKeySet(); for (Post p : Api.likes()) fresh.add(p.id); ids.retainAll(fresh); ids.addAll(fresh); } static boolean has(int postId) { return ids.contains(postId); } static void set(int postId, boolean liked) { if (liked) ids.add(postId); else ids.remove(postId); } }