diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java index eacaff13..6ed7a40e 100644 --- a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java @@ -27,10 +27,10 @@ import org.mian.gitnex.R; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.fragments.BottomSheetRepoFragment; import org.mian.gitnex.fragments.BranchesFragment; -import org.mian.gitnex.fragments.ClosedIssuesFragment; +import org.mian.gitnex.fragments.IssuesClosedFragment; import org.mian.gitnex.fragments.CollaboratorsFragment; import org.mian.gitnex.fragments.FilesFragment; -import org.mian.gitnex.fragments.IssuesFragment; +import org.mian.gitnex.fragments.IssuesOpenFragment; import org.mian.gitnex.fragments.LabelsFragment; import org.mian.gitnex.fragments.MilestonesFragment; import org.mian.gitnex.fragments.PullRequestsFragment; @@ -262,10 +262,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF case 1: // files return FilesFragment.newInstance(repoOwner, repoName); case 2: // issues - fragment = new IssuesFragment(); + fragment = new IssuesOpenFragment(); break; case 3: // closed issues - fragment = new ClosedIssuesFragment(); + fragment = new IssuesClosedFragment(); break; case 4: // pull requests fragment = new PullRequestsFragment(); diff --git a/app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/IssuesClosedFragment.java similarity index 94% rename from app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java rename to app/src/main/java/org/mian/gitnex/fragments/IssuesClosedFragment.java index 04406339..968f2e9a 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ClosedIssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/IssuesClosedFragment.java @@ -39,7 +39,7 @@ import retrofit2.Response; * Author M M Arif */ -public class ClosedIssuesFragment extends Fragment { +public class IssuesClosedFragment extends Fragment { private ProgressBar mProgressBarClosed; private RecyclerView recyclerViewClosed; @@ -52,6 +52,7 @@ public class ClosedIssuesFragment extends Fragment { private TextView noDataIssuesClosed; private String issueState = "closed"; private int resultLimit = 50; + private String requestType = "issues" ; @Nullable @Override @@ -87,7 +88,7 @@ public class ClosedIssuesFragment extends Fragment { public void run() { swipeRefresh.setRefreshing(false); - loadInitial(instanceToken, repoOwner, repoName, issueState, resultLimit); + loadInitial(instanceToken, repoOwner, repoName, issueState, resultLimit, requestType); adapterClosed.notifyDataChanged(); } @@ -106,7 +107,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, resultLimit); + loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, issueState, resultLimit, requestType); } /*else { @@ -125,7 +126,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, resultLimit); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState, resultLimit, requestType); return v; @@ -145,16 +146,16 @@ public class ClosedIssuesFragment extends Fragment { if(tinyDb.getBoolean("resumeClosedIssues")) { - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState, resultLimit); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState, resultLimit, requestType); tinyDb.putBoolean("resumeClosedIssues", false); } } - private void loadInitial(String token, String repoOwner, String repoName, String issueState, int resultLimit) { + private void loadInitial(String token, String repoOwner, String repoName, String issueState, int resultLimit, String requestType) { - Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, 1, issueState, resultLimit); + Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, 1, issueState, resultLimit, requestType); call.enqueue(new Callback>() { @@ -194,13 +195,13 @@ public class ClosedIssuesFragment extends Fragment { } - private void loadMore(String token, String repoOwner, String repoName, int page, String issueState, int resultLimit){ + private void loadMore(String token, String repoOwner, String repoName, int page, String issueState, int resultLimit, String requestType){ //add loading progress view issuesListClosed.add(new Issues("load")); adapterClosed.notifyItemInserted((issuesListClosed.size() - 1)); - Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, page, issueState, resultLimit); + Call> call = apiClosed.getClosedIssues(token, repoOwner, repoName, page, issueState, resultLimit, requestType); 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/IssuesOpenFragment.java similarity index 95% rename from app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java rename to app/src/main/java/org/mian/gitnex/fragments/IssuesOpenFragment.java index 18a06030..cf5100b2 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/IssuesOpenFragment.java @@ -39,7 +39,7 @@ import java.util.Objects; * Author M M Arif */ -public class IssuesFragment extends Fragment { +public class IssuesOpenFragment extends Fragment { private ProgressBar mProgressBar; private RecyclerView recyclerView; @@ -51,6 +51,7 @@ public class IssuesFragment extends Fragment { private int pageSize = 1; private TextView noDataIssues; private int resultLimit = 50; + private String requestType = "issues" ; @Nullable @Override @@ -86,7 +87,7 @@ public class IssuesFragment extends Fragment { public void run() { swipeRefresh.setRefreshing(false); - loadInitial(instanceToken, repoOwner, repoName, resultLimit); + loadInitial(instanceToken, repoOwner, repoName, resultLimit, requestType); adapter.notifyDataChanged(); } @@ -105,7 +106,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, resultLimit); + loadMore(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, page, resultLimit, requestType); } /*else { @@ -124,7 +125,7 @@ public class IssuesFragment extends Fragment { recyclerView.setAdapter(adapter); api = IssuesService.createService(ApiInterface.class, instanceUrl, getContext()); - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, requestType); return v; @@ -144,16 +145,16 @@ public class IssuesFragment extends Fragment { if(tinyDb.getBoolean("resumeIssues")) { - loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit); + loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, resultLimit, requestType); tinyDb.putBoolean("resumeIssues", false); } } - private void loadInitial(String token, String repoOwner, String repoName, int resultLimit) { + private void loadInitial(String token, String repoOwner, String repoName, int resultLimit, String requestType) { - Call> call = api.getIssues(token, repoOwner, repoName, 1, resultLimit); + Call> call = api.getIssues(token, repoOwner, repoName, 1, resultLimit, requestType); call.enqueue(new Callback>() { @@ -193,13 +194,13 @@ public class IssuesFragment extends Fragment { } - private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit){ + private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit, String requestType){ //add loading progress view issuesList.add(new Issues("load")); adapter.notifyItemInserted((issuesList.size() - 1)); - Call> call = api.getIssues(token, repoOwner, repoName, page, resultLimit); + Call> call = api.getIssues(token, repoOwner, repoName, page, resultLimit, requestType); call.enqueue(new Callback>() { 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 8fdb2fec..e00149c3 100644 --- a/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java +++ b/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java @@ -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, @Query("limit") int limit); + Call> getIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("limit") int limit, @Query("type") String requestType); @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, @Query("limit") int limit); + 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, @Query("type") String requestType); @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);