From 3c14ec81952c188d0084d2df5c8896702fc34457 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Tue, 9 May 2023 20:50:26 -0300 Subject: [PATCH] feat: hacking together a prototype for the api abstraction layer So far it works for the home timelines, next I gotta figure out how to see what type of server a logged in account is from --- .../java/org/joinmastodon/android/api/CacheController.java | 4 +++- .../org/joinmastodon/android/api/adapter/ApiAdapter.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/CacheController.java b/mastodon/src/main/java/org/joinmastodon/android/api/CacheController.java index a7a0ed78b2..71e1491d0b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/CacheController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/CacheController.java @@ -11,6 +11,7 @@ import org.joinmastodon.android.BuildConfig; import org.joinmastodon.android.MastodonApp; +import org.joinmastodon.android.api.adapter.ApiAdapter; import org.joinmastodon.android.api.requests.notifications.GetNotifications; import org.joinmastodon.android.api.requests.timelines.GetHomeTimeline; import org.joinmastodon.android.api.session.AccountSession; @@ -88,7 +89,8 @@ public void getHomeTimeline(String maxID, int count, boolean forceReload, Callba Log.w(TAG, "getHomeTimeline: corrupted status object in database", x); } } - new GetHomeTimeline(maxID, null, count, null) + ApiAdapter apiAdapter = new ApiAdapter(ApiAdapter.ServerType.MASTODON); + apiAdapter.getHomeTimeline(maxID, null, count, null) .setCallback(new Callback<>(){ @Override public void onSuccess(List result){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/adapter/ApiAdapter.java b/mastodon/src/main/java/org/joinmastodon/android/api/adapter/ApiAdapter.java index d54b88e605..6cca670a00 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/adapter/ApiAdapter.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/adapter/ApiAdapter.java @@ -5,6 +5,8 @@ import org.joinmastodon.android.api.requests.timelines.GetHomeTimeline; import org.joinmastodon.android.model.Status; +import java.util.List; + public class ApiAdapter { public final ServerType serverType; @@ -12,7 +14,7 @@ public ApiAdapter(ServerType serverType){ this.serverType = serverType; } - public MastodonAPIRequest getPostById(String id){ + public MastodonAPIRequest getPostById(String id){ switch (serverType){ case MASTODON -> { return new GetStatusByID(id); @@ -24,7 +26,7 @@ public MastodonAPIRequest getPostById(String id){ return null; } - public MastodonAPIRequest getHomeTimeline(String maxID, String minID, int limit, String sinceID){ + public MastodonAPIRequest> getHomeTimeline(String maxID, String minID, int limit, String sinceID){ switch (serverType){ case MASTODON -> { return new GetHomeTimeline(maxID, minID, limit, sinceID);