From 91d4b0c9adfa696c7f34880670d4e424973f6548 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 11 Nov 2018 14:53:32 +0100 Subject: [PATCH] - Server selection stubs --- app/src/main/AndroidManifest.xml | 23 ++-- .../activity/SelectServerActivity.java | 43 ++++++ .../net/schueller/peertube/model/Server.java | 122 ++++++++++++++++++ .../schueller/peertube/model/ServerList.java | 16 +++ .../network/GetServerListDataService.java | 16 +++ .../res/layout/activity_select_server.xml | 9 ++ 6 files changed, 216 insertions(+), 13 deletions(-) create mode 100644 app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java create mode 100644 app/src/main/java/net/schueller/peertube/model/Server.java create mode 100644 app/src/main/java/net/schueller/peertube/model/ServerList.java create mode 100644 app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java create mode 100644 app/src/main/res/layout/activity_select_server.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aac212d..a4be24e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,28 +10,23 @@ - - + - + - - - - @@ -59,10 +53,13 @@ android:label="@string/title_activity_settings" /> - + + \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java new file mode 100644 index 0000000..9c06c8d --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java @@ -0,0 +1,43 @@ +package net.schueller.peertube.activity; + +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +import net.schueller.peertube.R; +import net.schueller.peertube.model.ServerList; +import net.schueller.peertube.network.GetServerListDataService; +import net.schueller.peertube.network.RetrofitInstance; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class SelectServerActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_select_server); + + // get list of peertube servers + + // TODO: Get here via settings, get data from API, add to adapter and show in recycle view, upon selection fill settings field + + GetServerListDataService service = RetrofitInstance.getRetrofitInstance("https://instances.joinpeertube.org/api/v1/").create(GetServerListDataService.class); + Call call = service.getInstancesData(0, 500); + call.enqueue(new Callback() { + @Override + public void onResponse(@NonNull Call call, @NonNull Response response) { + // response.body().getVideoArrayList(); + } + + @Override + public void onFailure(@NonNull Call call, @NonNull Throwable t) { + + } + }); + + + } +} diff --git a/app/src/main/java/net/schueller/peertube/model/Server.java b/app/src/main/java/net/schueller/peertube/model/Server.java new file mode 100644 index 0000000..f8b1d21 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/model/Server.java @@ -0,0 +1,122 @@ +package net.schueller.peertube.model; + +public class Server { + + private Integer id; + private String host; + private String name; + private String shortDescription; + private String version; + private Boolean signupAllowed; + private Integer userVideoQuota; + private Integer totalUsers; + private Integer totalVideos; + private Integer totalLocalVideos; + private Integer totalInstanceFollowers; + private Integer totalInstanceFollowing; + private Integer health; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getShortDescription() { + return shortDescription; + } + + public void setShortDescription(String shortDescription) { + this.shortDescription = shortDescription; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public Boolean getSignupAllowed() { + return signupAllowed; + } + + public void setSignupAllowed(Boolean signupAllowed) { + this.signupAllowed = signupAllowed; + } + + public Integer getUserVideoQuota() { + return userVideoQuota; + } + + public void setUserVideoQuota(Integer userVideoQuota) { + this.userVideoQuota = userVideoQuota; + } + + public Integer getTotalUsers() { + return totalUsers; + } + + public void setTotalUsers(Integer totalUsers) { + this.totalUsers = totalUsers; + } + + public Integer getTotalVideos() { + return totalVideos; + } + + public void setTotalVideos(Integer totalVideos) { + this.totalVideos = totalVideos; + } + + public Integer getTotalLocalVideos() { + return totalLocalVideos; + } + + public void setTotalLocalVideos(Integer totalLocalVideos) { + this.totalLocalVideos = totalLocalVideos; + } + + public Integer getTotalInstanceFollowers() { + return totalInstanceFollowers; + } + + public void setTotalInstanceFollowers(Integer totalInstanceFollowers) { + this.totalInstanceFollowers = totalInstanceFollowers; + } + + public Integer getTotalInstanceFollowing() { + return totalInstanceFollowing; + } + + public void setTotalInstanceFollowing(Integer totalInstanceFollowing) { + this.totalInstanceFollowing = totalInstanceFollowing; + } + + public Integer getHealth() { + return health; + } + + public void setHealth(Integer health) { + this.health = health; + } +} \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/model/ServerList.java b/app/src/main/java/net/schueller/peertube/model/ServerList.java new file mode 100644 index 0000000..709cdc2 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/model/ServerList.java @@ -0,0 +1,16 @@ +package net.schueller.peertube.model; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + +public class ServerList { + + @SerializedName("data") + private ArrayList serverList; + + public ArrayList getServerArrayList() { + return serverList; + } + +} \ No newline at end of file diff --git a/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java b/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java new file mode 100644 index 0000000..5962353 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/network/GetServerListDataService.java @@ -0,0 +1,16 @@ +package net.schueller.peertube.network; + +import net.schueller.peertube.model.ServerList; + +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.Query; + +public interface GetServerListDataService { + @GET("instances/") + Call getInstancesData( + @Query("start") int start, + @Query("count") int count + ); + +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_select_server.xml b/app/src/main/res/layout/activity_select_server.xml new file mode 100644 index 0000000..d3f16ec --- /dev/null +++ b/app/src/main/res/layout/activity_select_server.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file