From c222cb8e784d65f17ac29433fe51cd4c56e1b261 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 22 Oct 2026 11:11:41 +0200 Subject: Add Foldergram API client, likes set and playlist hand-off Co-Authored-By: Claude Opus 5.5 --- app/src/main/java/mygram/droid/Likes.java | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 app/src/main/java/mygram/droid/Likes.java (limited to 'app/src/main/java/mygram/droid/Likes.java') diff --git a/app/src/main/java/mygram/droid/Likes.java b/app/src/main/java/mygram/droid/Likes.java new file mode 100644 index 0000000..bbe2d51 --- /dev/null +++ b/app/src/main/java/mygram/droid/Likes.java @@ -0,0 +1,48 @@ +/* + * 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); + } +} -- cgit v1.2.3