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

@ -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<List<Issues>> call = apiClosed.getClosedIssues(token, repoOwner, repoName, 1, issueState);
Call<List<Issues>> call = apiClosed.getClosedIssues(token, repoOwner, repoName, 1, issueState, resultLimit);
call.enqueue(new Callback<List<Issues>>() {
@ -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<List<Issues>> call = apiClosed.getClosedIssues(token, repoOwner, repoName, page, issueState);
Call<List<Issues>> call = apiClosed.getClosedIssues(token, repoOwner, repoName, page, issueState, resultLimit);
call.enqueue(new Callback<List<Issues>>() {

View File

@ -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<List<Issues>> call = api.getIssues(token, repoOwner, repoName, 1);
Call<List<Issues>> call = api.getIssues(token, repoOwner, repoName, 1, resultLimit);
call.enqueue(new Callback<List<Issues>>() {
@ -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<List<Issues>> call = api.getIssues(token, repoOwner, repoName, page);
Call<List<Issues>> call = api.getIssues(token, repoOwner, repoName, page, resultLimit);
call.enqueue(new Callback<List<Issues>>() {

View File

@ -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<List<UserRepositories>>() {
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
@Override
public void onChanged(@Nullable List<UserRepositories> myReposListMain) {
adapter = new MyReposListAdapter(getContext(), myReposListMain);

View File

@ -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<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState);
Call<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState, resultLimit);
call.enqueue(new Callback<List<PullRequests>>() {
@ -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<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState);
Call<List<PullRequests>> call = apiPR.getPullRequests(token, repoOwner, repoName, page, prState, resultLimit);
call.enqueue(new Callback<List<PullRequests>>() {

View File

@ -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<List<UserRepositories>>() {
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
@Override
public void onChanged(@Nullable List<UserRepositories> orgReposListMain) {
adapter = new RepositoriesByOrgAdapter(getContext(), orgReposListMain);

View File

@ -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<List<UserRepositories>>() {
repoModel.getUserRepositories(instanceUrl, instanceToken, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
@Override
public void onChanged(@Nullable List<UserRepositories> reposListMain) {
adapter = new ReposListAdapter(getContext(), reposListMain);

View File

@ -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<List<UserRepositories>>() {
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken, getContext(), pageSize, resultLimit).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
@Override
public void onChanged(@Nullable List<UserRepositories> starredReposListMain) {
adapter = new StarredReposListAdapter(getContext(), starredReposListMain);

View File

@ -81,7 +81,7 @@ public interface ApiInterface {
Call<List<OrgOwner>> getOrgOwners(@Header("Authorization") String token);
@GET("user/repos") // get user repositories
Call<List<UserRepositories>> getUserRepositories(@Header("Authorization") String token);
Call<List<UserRepositories>> getUserRepositories(@Header("Authorization") String token, @Query("page") int page, @Query("limit") int limit);
@POST("user/repos") // create new repository
Call<OrganizationRepository> createNewUserRepository(@Header("Authorization") String token, @Body OrganizationRepository jsonStr);
@ -90,10 +90,10 @@ public interface ApiInterface {
Call<UserRepositories> getUserRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
@GET("repos/{owner}/{repo}/issues") // get issues by repo
Call<List<Issues>> getIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page);
Call<List<Issues>> 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<List<Issues>> getClosedIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String issueState);
Call<List<Issues>> 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<Issues> 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<List<Labels>> getlabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
@GET("users/{username}/repos") // get current logged in user repositories
Call<List<UserRepositories>> getCurrentUserRepositories(@Header("Authorization") String token, @Path("username") String username);
Call<List<UserRepositories>> 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> createLabel(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body CreateLabel jsonStr);
@ -138,10 +138,10 @@ public interface ApiInterface {
Call<CreateLabel> 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<List<UserRepositories>> getUserStarredRepos(@Header("Authorization") String token);
Call<List<UserRepositories>> getUserStarredRepos(@Header("Authorization") String token, @Query("page") int page, @Query("limit") int limit);
@GET("orgs/{orgName}/repos") // get repositories by org
Call<List<UserRepositories>> getReposByOrg(@Header("Authorization") String token, @Path("orgName") String orgName);
Call<List<UserRepositories>> 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<List<Teams>> getTeamsByOrg(@Header("Authorization") String token, @Path("orgName") String orgName);
@ -252,7 +252,7 @@ public interface ApiInterface {
Call<JsonElement> unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
@GET("repos/{owner}/{repo}/pulls") // get repository pull requests
Call<List<PullRequests>> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state);
Call<List<PullRequests>> 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<ResponseBody> getFileDiffContents(@Path("owner") String owner, @Path("repo") String repo, @Path("filename") String fileName);

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>>() {