Skip to content

Commit

Permalink
feat: hacking together a prototype for the api abstraction layer
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LucasGGamerM committed May 14, 2023
1 parent eb78823 commit 3c14ec8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Status> result){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
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;

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);
Expand All @@ -24,7 +26,7 @@ public MastodonAPIRequest getPostById(String id){
return null;
}

public MastodonAPIRequest getHomeTimeline(String maxID, String minID, int limit, String sinceID){
public MastodonAPIRequest<List<Status>> getHomeTimeline(String maxID, String minID, int limit, String sinceID){
switch (serverType){
case MASTODON -> {
return new GetHomeTimeline(maxID, minID, limit, sinceID);
Expand Down

0 comments on commit 3c14ec8

Please sign in to comment.