Add page and limit params to required API calls

This commit is contained in:
M M Arif
2020-03-12 19:56:56 +05:00
parent 4ac1f4f486
commit d441833952
12 changed files with 79 additions and 67 deletions

View File

@@ -21,22 +21,22 @@ public class MyRepositoriesViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> myReposList;
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username, Context ctx) {
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username, Context ctx, int page, int limit) {
//if (myReposList == null) {
myReposList = new MutableLiveData<>();
loadMyReposList(instanceUrl, token, username, ctx);
loadMyReposList(instanceUrl, token, username, ctx, page, limit);
//}
return myReposList;
}
public static void loadMyReposList(String instanceUrl, String token, String username, Context ctx) {
public static void loadMyReposList(String instanceUrl, String token, String username, Context ctx, int page, int limit) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getCurrentUserRepositories(token, username);
.getCurrentUserRepositories(token, username, page, limit);
call.enqueue(new Callback<List<UserRepositories>>() {

View File

@@ -21,20 +21,20 @@ public class RepositoriesByOrgViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> orgReposList;
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName, Context ctx) {
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName, Context ctx, int page, int limit) {
orgReposList = new MutableLiveData<>();
loadOrgRepos(instanceUrl, token, orgName, ctx);
loadOrgRepos(instanceUrl, token, orgName, ctx, page, limit);
return orgReposList;
}
public static void loadOrgRepos(String instanceUrl, String token, String orgName, Context ctx) {
public static void loadOrgRepos(String instanceUrl, String token, String orgName, Context ctx, int page, int limit) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getReposByOrg(token, orgName);
.getReposByOrg(token, orgName, page, limit);
call.enqueue(new Callback<List<UserRepositories>>() {

View File

@@ -21,22 +21,22 @@ public class RepositoriesListViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> reposList;
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token, Context ctx) {
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token, Context ctx, int page, int limit) {
//if (reposList == null) {
reposList = new MutableLiveData<>();
loadReposList(instanceUrl, token, ctx);
loadReposList(instanceUrl, token, ctx, page, limit);
//}
return reposList;
}
public static void loadReposList(String instanceUrl, String token, Context ctx) {
public static void loadReposList(String instanceUrl, String token, Context ctx, int page, int limit) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getUserRepositories(token);
.getUserRepositories(token, page, limit);
call.enqueue(new Callback<List<UserRepositories>>() {

View File

@@ -21,20 +21,20 @@ public class StarredRepositoriesViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> reposList;
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token, Context ctx) {
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token, Context ctx, int page, int limit) {
reposList = new MutableLiveData<>();
loadStarredReposList(instanceUrl, token, ctx);
loadStarredReposList(instanceUrl, token, ctx, page, limit);
return reposList;
}
public static void loadStarredReposList(String instanceUrl, String token, Context ctx) {
public static void loadStarredReposList(String instanceUrl, String token, Context ctx, int page, int limit) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getUserStarredRepos(token);
.getUserStarredRepos(token, page, limit);
call.enqueue(new Callback<List<UserRepositories>>() {