From d44183395239d3bf58ff7462067297c17f9d5e41 Mon Sep 17 00:00:00 2001 From: M M Arif Date: Thu, 12 Mar 2020 19:56:56 +0500 Subject: [PATCH] Add page and limit params to required API calls --- .../gitnex/fragments/ClosedIssuesFragment.java | 17 +++++++++-------- .../mian/gitnex/fragments/IssuesFragment.java | 17 +++++++++-------- .../fragments/MyRepositoriesFragment.java | 13 ++++++++----- .../gitnex/fragments/PullRequestsFragment.java | 17 +++++++++-------- .../fragments/RepositoriesByOrgFragment.java | 12 +++++++----- .../gitnex/fragments/RepositoriesFragment.java | 12 +++++++----- .../fragments/StarredRepositoriesFragment.java | 12 +++++++----- .../mian/gitnex/interfaces/ApiInterface.java | 14 +++++++------- .../viewmodels/MyRepositoriesViewModel.java | 8 ++++---- .../viewmodels/RepositoriesByOrgViewModel.java | 8 ++++---- .../viewmodels/RepositoriesListViewModel.java | 8 ++++---- .../StarredRepositoriesViewModel.java | 8 ++++---- 12 files changed, 79 insertions(+), 67 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java index 895c8940..04406339 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java @@ -51,6 +51,7 @@ public class ClosedIssuesFragment extends Fragment { private int pageSize = 1; private TextView noDataIssuesClosed; private String issueState = "closed"; + private int resultLimit = 50; @Nullable @Override @@ -86,7 +87,7 @@ public class ClosedIssuesFragment extends Fragment { public void run() { swipeRefresh.setRefreshing(false); - loadInitial(instanceToken, repoOwner, repoName, issueState); + loadInitial(instanceToken, repoOwner, repoName, issueState, resultLimit); adapterClosed.notifyDataChanged(); } @@ -105,7 +106,7 @@ public class ClosedIssuesFragment extends Fragment { if(issuesListClosed.size() == 10 || pageSize == 10) { int page = (issuesListClosed.size() + 10) / 10; - loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, issueState); + loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, issueState, resultLimit); } /*else { @@ -124,7 +125,7 @@ public class ClosedIssuesFragment extends Fragment { recyclerViewClosed.setAdapter(adapterClosed); apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl, getContext()); - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState, resultLimit); return v; @@ -144,16 +145,16 @@ public class ClosedIssuesFragment extends Fragment { if(tinyDb.getBoolean("resumeClosedIssues")) { - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState, resultLimit); tinyDb.putBoolean("resumeClosedIssues", false); } } - private void loadInitial(String token, String repoOwner, String repoName, String issueState) { + private void loadInitial(String token, String repoOwner, String repoName, String issueState, int resultLimit) { - Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, 1, issueState); + Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, 1, issueState, resultLimit); call.enqueue(new Callback>() { @@ -193,13 +194,13 @@ public class ClosedIssuesFragment extends Fragment { } - private void loadMore(String token, String repoOwner, String repoName, int page, String issueState){ + private void loadMore(String token, String repoOwner, String repoName, int page, String issueState, int resultLimit){ //add loading progress view issuesListClosed.add(new Issues("load")); adapterClosed.notifyItemInserted((issuesListClosed.size() - 1)); - Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, page, issueState); + Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, page, issueState, resultLimit); call.enqueue(new Callback>() { diff --git a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java index 60230f18..18a06030 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java @@ -50,6 +50,7 @@ public class IssuesFragment extends Fragment { private Context context; private int pageSize = 1; private TextView noDataIssues; + private int resultLimit = 50; @Nullable @Override @@ -85,7 +86,7 @@ public class IssuesFragment extends Fragment { public void run() { swipeRefresh.setRefreshing(false); - loadInitial(instanceToken, repoOwner, repoName); + loadInitial(instanceToken, repoOwner, repoName, resultLimit); adapter.notifyDataChanged(); } @@ -104,7 +105,7 @@ public class IssuesFragment extends Fragment { if(issuesList.size() == 10 || pageSize == 10) { int page = (issuesList.size() + 10) / 10; - loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page); + loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, resultLimit); } /*else { @@ -123,7 +124,7 @@ public class IssuesFragment extends Fragment { recyclerView.setAdapter(adapter); api = IssuesService.createService(ApiInterface.class, instanceUrl, getContext()); - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit); return v; @@ -143,16 +144,16 @@ public class IssuesFragment extends Fragment { if(tinyDb.getBoolean("resumeIssues")) { - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit); tinyDb.putBoolean("resumeIssues", false); } } - private void loadInitial(String token, String repoOwner, String repoName) { + private void loadInitial(String token, String repoOwner, String repoName, int resultLimit) { - Call> call = api.getIssues(token, repoOwner, repoName, 1); + Call> call = api.getIssues(token, repoOwner, repoName, 1, resultLimit); call.enqueue(new Callback>() { @@ -192,13 +193,13 @@ public class IssuesFragment extends Fragment { } - private void loadMore(String token, String repoOwner, String repoName, int page){ + private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit){ //add loading progress view issuesList.add(new Issues("load")); adapter.notifyItemInserted((issuesList.size() - 1)); - Call> call = api.getIssues(token, repoOwner, repoName, page); + Call> call = api.getIssues(token, repoOwner, repoName, page, resultLimit); call.enqueue(new Callback>() { diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java index b23e666a..b5f0f7da 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java @@ -48,6 +48,9 @@ public class MyRepositoriesFragment extends Fragment { private ImageView createNewRepo; private TextView noDataMyRepo; + private int pageSize = 1; + private int resultLimit = 50; + private String mParam1; private String mParam2; @@ -137,13 +140,13 @@ public class MyRepositoriesFragment extends Fragment { @Override public void run() { swipeRefresh.setRefreshing(false); - MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext()); + MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit); } }, 50); } }); - fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin); + fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, pageSize, resultLimit); return v; @@ -158,15 +161,15 @@ public class MyRepositoriesFragment extends Fragment { final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); final String userLogin = tinyDb.getString("userLogin"); - MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext()); + MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext(), pageSize, resultLimit); } - private void fetchDataAsync(String instanceUrl, String instanceToken, String userLogin) { + private void fetchDataAsync(String instanceUrl, String instanceToken, String userLogin, int pageSize, int resultLimit) { MyRepositoriesViewModel myRepoModel = new ViewModelProvider(this).get(MyRepositoriesViewModel.class); - myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext()).observe(getViewLifecycleOwner(), new Observer>() { + myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List myReposListMain) { adapter = new MyReposListAdapter(getContext(), myReposListMain); diff --git a/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java index a7f868d8..dda17a1d 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java @@ -52,6 +52,7 @@ public class PullRequestsFragment extends Fragment { private int pageSize = 1; private TextView noData; private String prState = "open"; + private int resultLimit = 50; @Nullable @Override @@ -87,7 +88,7 @@ public class PullRequestsFragment extends Fragment { public void run() { swipeRefresh.setRefreshing(false); - loadInitial(instanceToken, repoOwner, repoName, pageSize, prState); + loadInitial(instanceToken, repoOwner, repoName, pageSize, prState, resultLimit); adapter.notifyDataChanged(); } @@ -106,7 +107,7 @@ public class PullRequestsFragment extends Fragment { if(prList.size() == 10 || pageSize == 10) { int page = (prList.size() + 10) / 10; - loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, prState); + loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, prState, resultLimit); } /*else { @@ -128,7 +129,7 @@ public class PullRequestsFragment extends Fragment { recyclerView.setAdapter(adapter); apiPR = PullRequestsService.createService(ApiInterface.class, instanceUrl, getContext()); - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, pageSize, prState); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, pageSize, prState, resultLimit); return v; @@ -148,16 +149,16 @@ public class PullRequestsFragment extends Fragment { if(tinyDb.getBoolean("resumePullRequests")) { - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, pageSize, prState); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, pageSize, prState, resultLimit); tinyDb.putBoolean("resumePullRequests", false); } } - private void loadInitial(String token, String repoOwner, String repoName, int page, String prState) { + private void loadInitial(String token, String repoOwner, String repoName, int page, String prState, int resultLimit) { - Call> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState); + Call> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState, resultLimit); call.enqueue(new Callback>() { @@ -199,13 +200,13 @@ public class PullRequestsFragment extends Fragment { } - private void loadMore(String token, String repoOwner, String repoName, int page, String prState){ + private void loadMore(String token, String repoOwner, String repoName, int page, String prState, int resultLimit){ //add loading progress view prList.add(new PullRequests("load")); adapter.notifyItemInserted((prList.size() - 1)); - Call> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState); + Call> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState, resultLimit); call.enqueue(new Callback>() { diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java index cb065d06..d20bd67d 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java @@ -45,6 +45,8 @@ public class RepositoriesByOrgFragment extends Fragment { private TextView noData; private static String orgNameF = "param2"; private String orgName; + private int pageSize = 1; + private int resultLimit = 50; public RepositoriesByOrgFragment() { } @@ -97,13 +99,13 @@ public class RepositoriesByOrgFragment extends Fragment { @Override public void run() { swipeRefresh.setRefreshing(false); - RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext()); + RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext(), pageSize, resultLimit); } }, 200); } }); - fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName); + fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, pageSize, resultLimit); return v; } @@ -117,15 +119,15 @@ public class RepositoriesByOrgFragment extends Fragment { final String loginUid = tinyDb.getString("loginUid"); final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); - RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext()); + RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext(), pageSize, resultLimit); } - private void fetchDataAsync(String instanceUrl, String instanceToken, String owner) { + private void fetchDataAsync(String instanceUrl, String instanceToken, String owner, int pageSize, int resultLimit) { RepositoriesByOrgViewModel orgRepoModel = new ViewModelProvider(this).get(RepositoriesByOrgViewModel.class); - orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer>() { + orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List orgReposListMain) { adapter = new RepositoriesByOrgAdapter(getContext(), orgReposListMain); diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java index f6926fc6..c76844f2 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java @@ -44,6 +44,8 @@ public class RepositoriesFragment extends Fragment { private ReposListAdapter adapter; private ImageView createNewRepo; private TextView noDataRepo; + private int pageSize = 1; + private int resultLimit = 50; @Nullable @Override @@ -107,13 +109,13 @@ public class RepositoriesFragment extends Fragment { @Override public void run() { swipeRefresh.setRefreshing(false); - RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext()); + RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit); } }, 50); } }); - fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken)); + fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit); return v; @@ -128,16 +130,16 @@ public class RepositoriesFragment extends Fragment { final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); if(tinyDb.getBoolean("repoCreated")) { - RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext()); + RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit); tinyDb.putBoolean("repoCreated", false); } } - private void fetchDataAsync(String instanceUrl, String instanceToken) { + private void fetchDataAsync(String instanceUrl, String instanceToken, int pageSize, int resultLimit) { RepositoriesListViewModel repoModel = new ViewModelProvider(this).get(RepositoriesListViewModel.class); - repoModel.getUserRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer>() { + repoModel.getUserRepositories(instanceUrl, instanceToken, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List reposListMain) { adapter = new ReposListAdapter(getContext(), reposListMain); diff --git a/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java index 20c793f5..dfeb53c0 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java @@ -47,6 +47,8 @@ public class StarredRepositoriesFragment extends Fragment { private StarredReposListAdapter adapter; private ImageView createNewRepo; private TextView noData; + private int pageSize = 1; + private int resultLimit = 50; private OnFragmentInteractionListener mListener; @@ -132,13 +134,13 @@ public class StarredRepositoriesFragment extends Fragment { @Override public void run() { swipeRefresh.setRefreshing(false); - StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext()); + StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit); } }, 50); } }); - fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken)); + fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit); return v; } @@ -151,15 +153,15 @@ public class StarredRepositoriesFragment extends Fragment { final String loginUid = tinyDb.getString("loginUid"); final String instanceToken = "token " + tinyDb.getString(loginUid + "-token"); - StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext()); + StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit); } - private void fetchDataAsync(String instanceUrl, String instanceToken) { + private void fetchDataAsync(String instanceUrl, String instanceToken, int pageSize, int resultLimit) { StarredRepositoriesViewModel starredRepoModel = new ViewModelProvider(this).get(StarredRepositoriesViewModel.class); - starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer>() { + starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer>() { @Override public void onChanged(@Nullable List starredReposListMain) { adapter = new StarredReposListAdapter(getContext(), starredReposListMain); diff --git a/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java b/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java index 54f0bd9d..8fdb2fec 100644 --- a/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java +++ b/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java @@ -81,7 +81,7 @@ public interface ApiInterface { Call> getOrgOwners(@Header("Authorization") String token); @GET("user/repos") // get user repositories - Call> getUserRepositories(@Header("Authorization") String token); + Call> getUserRepositories(@Header("Authorization") String token, @Query("page") int page, @Query("limit") int limit); @POST("user/repos") // create new repository Call createNewUserRepository(@Header("Authorization") String token, @Body OrganizationRepository jsonStr); @@ -90,10 +90,10 @@ public interface ApiInterface { Call getUserRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/issues") // get issues by repo - Call> getIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page); + Call> getIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("limit") int limit); @GET("repos/{owner}/{repo}/issues") // get closed issues by repo - Call> getClosedIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String issueState); + Call> getClosedIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String issueState, @Query("limit") int limit); @GET("repos/{owner}/{repo}/issues/{index}") // get issue by id Call getIssueByIndex(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex); @@ -126,7 +126,7 @@ public interface ApiInterface { Call> getlabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("users/{username}/repos") // get current logged in user repositories - Call> getCurrentUserRepositories(@Header("Authorization") String token, @Path("username") String username); + Call> getCurrentUserRepositories(@Header("Authorization") String token, @Path("username") String username, @Query("page") int page, @Query("limit") int limit); @POST("repos/{owner}/{repo}/labels") // create label Call createLabel(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body CreateLabel jsonStr); @@ -138,10 +138,10 @@ public interface ApiInterface { Call patchLabel(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int labelIndex, @Body CreateLabel jsonStr); @GET("user/starred") // get user starred repositories - Call> getUserStarredRepos(@Header("Authorization") String token); + Call> getUserStarredRepos(@Header("Authorization") String token, @Query("page") int page, @Query("limit") int limit); @GET("orgs/{orgName}/repos") // get repositories by org - Call> getReposByOrg(@Header("Authorization") String token, @Path("orgName") String orgName); + Call> getReposByOrg(@Header("Authorization") String token, @Path("orgName") String orgName, @Query("page") int page, @Query("limit") int limit); @GET("orgs/{orgName}/teams") // get teams by org Call> getTeamsByOrg(@Header("Authorization") String token, @Path("orgName") String orgName); @@ -252,7 +252,7 @@ public interface ApiInterface { Call unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/pulls") // get repository pull requests - Call> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state); + Call> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state, @Query("limit") int limit); @GET("{owner}/{repo}/pulls/{filename}") // get pull diff file contents Call getFileDiffContents(@Path("owner") String owner, @Path("repo") String repo, @Path("filename") String fileName); diff --git a/app/src/main/java/org/mian/gitnex/viewmodels/MyRepositoriesViewModel.java b/app/src/main/java/org/mian/gitnex/viewmodels/MyRepositoriesViewModel.java index 2ed21acf..3e36b521 100644 --- a/app/src/main/java/org/mian/gitnex/viewmodels/MyRepositoriesViewModel.java +++ b/app/src/main/java/org/mian/gitnex/viewmodels/MyRepositoriesViewModel.java @@ -21,22 +21,22 @@ public class MyRepositoriesViewModel extends ViewModel { private static MutableLiveData> myReposList; - public LiveData> getCurrentUserRepositories(String instanceUrl, String token, String username, Context ctx) { + public LiveData> 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> call = RetrofitClient .getInstance(instanceUrl, ctx) .getApiInterface() - .getCurrentUserRepositories(token, username); + .getCurrentUserRepositories(token, username, page, limit); call.enqueue(new Callback>() { diff --git a/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesByOrgViewModel.java b/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesByOrgViewModel.java index 868b1453..913e35f5 100644 --- a/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesByOrgViewModel.java +++ b/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesByOrgViewModel.java @@ -21,20 +21,20 @@ public class RepositoriesByOrgViewModel extends ViewModel { private static MutableLiveData> orgReposList; - public LiveData> getRepositoriesByOrg(String instanceUrl, String token, String orgName, Context ctx) { + public LiveData> 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> call = RetrofitClient .getInstance(instanceUrl, ctx) .getApiInterface() - .getReposByOrg(token, orgName); + .getReposByOrg(token, orgName, page, limit); call.enqueue(new Callback>() { diff --git a/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesListViewModel.java b/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesListViewModel.java index ec43ade6..ebdd93ff 100644 --- a/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesListViewModel.java +++ b/app/src/main/java/org/mian/gitnex/viewmodels/RepositoriesListViewModel.java @@ -21,22 +21,22 @@ public class RepositoriesListViewModel extends ViewModel { private static MutableLiveData> reposList; - public LiveData> getUserRepositories(String instanceUrl, String token, Context ctx) { + public LiveData> 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> call = RetrofitClient .getInstance(instanceUrl, ctx) .getApiInterface() - .getUserRepositories(token); + .getUserRepositories(token, page, limit); call.enqueue(new Callback>() { diff --git a/app/src/main/java/org/mian/gitnex/viewmodels/StarredRepositoriesViewModel.java b/app/src/main/java/org/mian/gitnex/viewmodels/StarredRepositoriesViewModel.java index 2b9ac281..f1826030 100644 --- a/app/src/main/java/org/mian/gitnex/viewmodels/StarredRepositoriesViewModel.java +++ b/app/src/main/java/org/mian/gitnex/viewmodels/StarredRepositoriesViewModel.java @@ -21,20 +21,20 @@ public class StarredRepositoriesViewModel extends ViewModel { private static MutableLiveData> reposList; - public LiveData> getUserStarredRepositories(String instanceUrl, String token, Context ctx) { + public LiveData> 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> call = RetrofitClient .getInstance(instanceUrl, ctx) .getApiInterface() - .getUserStarredRepos(token); + .getUserStarredRepos(token, page, limit); call.enqueue(new Callback>() {