mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-03-08 23:57:44 +01:00
UI enhancements and Refactors (#1102)
As title Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1102 Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
42f6611585
commit
885bfc5d1f
@ -2,7 +2,6 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
@ -18,7 +17,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AssigneesActions {
|
||||
@ -29,7 +28,7 @@ public class AssigneesActions {
|
||||
.getApiInterface(ctx)
|
||||
.getIssueByIndex(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<Issues>() {
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
@ -39,7 +38,7 @@ public class AssigneesActions {
|
||||
Issues issueAssigneesList = response.body();
|
||||
assert issueAssigneesList != null;
|
||||
|
||||
if (issueAssigneesList.getAssignees() != null) {
|
||||
if(issueAssigneesList.getAssignees() != null) {
|
||||
|
||||
if(issueAssigneesList.getAssignees().size() > 0) {
|
||||
|
||||
@ -50,14 +49,17 @@ public class AssigneesActions {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -67,7 +69,7 @@ public class AssigneesActions {
|
||||
.getApiInterface(ctx)
|
||||
.getAllAssignees(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull retrofit2.Response<List<Collaborators>> response) {
|
||||
@ -78,7 +80,7 @@ public class AssigneesActions {
|
||||
assigneesBinding.progressBar.setVisibility(View.GONE);
|
||||
assigneesBinding.dialogFrame.setVisibility(View.VISIBLE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
assert assigneesList_ != null;
|
||||
|
||||
@ -99,7 +101,6 @@ public class AssigneesActions {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,7 +109,5 @@ public class AssigneesActions {
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.gitnex.tea4j.models.Permission;
|
||||
@ -13,13 +12,11 @@ import org.mian.gitnex.fragments.CollaboratorsFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CollaboratorActions {
|
||||
@ -30,53 +27,44 @@ public class CollaboratorActions {
|
||||
.getApiInterface(context)
|
||||
.deleteCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), userName);
|
||||
|
||||
call.enqueue(new Callback<Collaborators>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Collaborators> call, @NonNull retrofit2.Response<Collaborators> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Collaborators> call, @NonNull retrofit2.Response<Collaborators> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//Log.i("addCollaboratorSearch", addCollaboratorSearch.getText().toString());
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -89,90 +77,44 @@ public class CollaboratorActions {
|
||||
.getApiInterface(context)
|
||||
.addCollaborator(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
|
||||
call.enqueue(new Callback<Permission>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Permission> call, @NonNull retrofit2.Response<Permission> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Permission> call, @NonNull retrofit2.Response<Permission> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity)context).finish();
|
||||
//AddCollaboratorToRepositoryActivity usersSearchData = new AddCollaboratorToRepositoryActivity();
|
||||
//usersSearchData.loadUserSearchList(instanceToken, searchKeyword, context);
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(context, context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Permission> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Permission> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static ActionResult<List<Collaborators>> getCollaborators(Context context, RepositoryContext repository) {
|
||||
|
||||
ActionResult<List<Collaborators>> actionResult = new ActionResult<>();
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getApiInterface(context)
|
||||
.getCollaborators(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
actionResult.finish(ActionResult.Status.SUCCESS, response.body());
|
||||
}
|
||||
else {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class IssueActions {
|
||||
@ -34,7 +34,7 @@ public class IssueActions {
|
||||
.patchIssueComment(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), commentId, new IssueComments(comment));
|
||||
|
||||
call.enqueue(new Callback<IssueComments>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
||||
@ -47,7 +47,8 @@ public class IssueActions {
|
||||
|
||||
case 401:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton), context.getResources().getString(R.string.navLogout));
|
||||
break;
|
||||
|
||||
@ -79,7 +80,7 @@ public class IssueActions {
|
||||
.closeReopenIssue(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@ -87,7 +88,7 @@ public class IssueActions {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 201) {
|
||||
|
||||
if (issue.hasIssue()) {
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
}
|
||||
@ -104,25 +105,22 @@ public class IssueActions {
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton), ctx.getResources().getString(R.string.navLogout));
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -143,7 +141,7 @@ public class IssueActions {
|
||||
.addIssueSubscriber(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@ -153,26 +151,20 @@ public class IssueActions {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton), ctx.getResources().getString(R.string.navLogout));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,7 +183,7 @@ public class IssueActions {
|
||||
call = RetrofitClient.getApiInterface(ctx).delIssueSubscriber(((BaseActivity) ctx).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<Void>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@ -201,26 +193,22 @@ public class IssueActions {
|
||||
if(response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton), ctx.getResources().getString(R.string.navLogout));
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -242,7 +230,7 @@ public class IssueActions {
|
||||
.replyCommentToIssue(((BaseActivity) context).getAccount().getAuthorization(), issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(), issue.getIssueIndex(), issueComment);
|
||||
|
||||
call.enqueue(new Callback<Issues>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
||||
@ -250,7 +238,7 @@ public class IssueActions {
|
||||
if(response.code() == 201) {
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
|
||||
if (issue.hasIssue()) {
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPull_request() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPull_request() != null;
|
||||
}
|
||||
@ -258,8 +246,7 @@ public class IssueActions {
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getString(R.string.cancelButton),
|
||||
context.getString(R.string.alertDialogTokenRevokedMessage), context.getString(R.string.cancelButton),
|
||||
context.getString(R.string.navLogout));
|
||||
|
||||
}
|
||||
@ -277,7 +264,5 @@ public class IssueActions {
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.actions;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
@ -17,7 +16,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class LabelsActions {
|
||||
@ -28,34 +27,34 @@ public class LabelsActions {
|
||||
.getApiInterface(ctx)
|
||||
.getIssueLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName, issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<List<Labels>>() {
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<Labels> issueLabelsList = response.body();
|
||||
|
||||
assert issueLabelsList != null;
|
||||
|
||||
if(issueLabelsList.size() > 0) {
|
||||
|
||||
for (int i = 0; i < issueLabelsList.size(); i++) {
|
||||
for(int i = 0; i < issueLabelsList.size(); i++) {
|
||||
|
||||
currentLabelsIds.add(issueLabelsList.get(i).getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -65,14 +64,14 @@ public class LabelsActions {
|
||||
.getApiInterface(ctx)
|
||||
.getLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<Labels>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
|
||||
|
||||
labelsList.clear();
|
||||
|
||||
if (response.code() == 200) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
if(response.body() != null) {
|
||||
|
||||
@ -80,11 +79,10 @@ public class LabelsActions {
|
||||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Labels>> callOrgLabels = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
Call<List<Labels>> callOrgLabels = RetrofitClient.getApiInterface(ctx)
|
||||
.getOrganizationLabels(((BaseActivity) ctx).getAccount().getAuthorization(), repoOwner);
|
||||
|
||||
callOrgLabels.enqueue(new Callback<List<Labels>>() {
|
||||
callOrgLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> responseOrg) {
|
||||
@ -107,7 +105,11 @@ public class LabelsActions {
|
||||
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
|
||||
}
|
||||
|
||||
@Override public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -116,7 +118,6 @@ public class LabelsActions {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,7 +126,5 @@ public class LabelsActions {
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
@ -15,13 +14,11 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MilestoneActions {
|
||||
|
||||
static final private String TAG = "MilestoneActions : ";
|
||||
|
||||
public static void closeMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
|
||||
Milestones milestoneStateJson = new Milestones("closed");
|
||||
@ -29,9 +26,9 @@ public class MilestoneActions {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getOwner(), milestoneId_, milestoneStateJson);
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@ -39,34 +36,25 @@ public class MilestoneActions {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void openMilestone(final Context ctx, int milestoneId_, RepositoryContext repository) {
|
||||
@ -76,9 +64,9 @@ public class MilestoneActions {
|
||||
|
||||
call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getOwner(), milestoneId_, milestoneStateJson);
|
||||
.closeReopenMilestone(((BaseActivity) ctx).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), milestoneId_, milestoneStateJson);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@ -86,33 +74,24 @@ public class MilestoneActions {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.milestoneStatusUpdate));
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,44 +23,56 @@ public class PullRequestActions {
|
||||
.getApiInterface(context)
|
||||
.deleteBranch(((BaseActivity) context).getAccount().getAuthorization(), repoOwner, repoName, headBranch);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
|
||||
if(showToasts) Toasty.success(context, context.getString(R.string.deleteBranchSuccess));
|
||||
if(showToasts) {
|
||||
Toasty.success(context, context.getString(R.string.deleteBranchSuccess));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs
|
||||
.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle), context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton), context.getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton), context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
if(showToasts) Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
if(showToasts) Toasty.warning(context, context.getString(R.string.deleteBranchErrorNotFound));
|
||||
if(showToasts) {
|
||||
Toasty.warning(context, context.getString(R.string.deleteBranchErrorNotFound));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if(showToasts) Toasty.error(context, context.getString(R.string.genericError));
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
if(showToasts) Toasty.error(context, context.getString(R.string.deleteBranchError));
|
||||
if(showToasts) {
|
||||
Toasty.error(context, context.getString(R.string.deleteBranchError));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public static void updatePr(Context context, String repoOwner, String repoName, String index, Boolean rebase) {
|
||||
|
||||
String strategy;
|
||||
if(rebase == null) {
|
||||
strategy = null;
|
||||
@ -71,11 +83,13 @@ public class PullRequestActions {
|
||||
else {
|
||||
strategy = "rebase";
|
||||
}
|
||||
|
||||
RetrofitClient.getApiInterface(context).updatePullRequest(((BaseActivity) context).getAccount().getAuthorization(), repoOwner, repoName, Integer.parseInt(index), strategy)
|
||||
.enqueue(new Callback<Void>() {
|
||||
.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
Toasty.success(context, context.getString(R.string.updatePrSuccess));
|
||||
}
|
||||
@ -94,9 +108,9 @@ public class PullRequestActions {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.gson.JsonElement;
|
||||
import org.mian.gitnex.R;
|
||||
@ -15,7 +14,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class RepositoryActions {
|
||||
@ -28,51 +27,44 @@ public class RepositoryActions {
|
||||
.getApiInterface(context)
|
||||
.starRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(context, context.getString(R.string.starRepositorySuccess));
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(context, context.getString(R.string.starRepositorySuccess));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void unStarRepository(final Context context, RepositoryContext repository) {
|
||||
@ -83,51 +75,44 @@ public class RepositoryActions {
|
||||
.getApiInterface(context)
|
||||
.unStarRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(context, context.getString(R.string.unStarRepositorySuccess));
|
||||
MainActivity.repoCreated = true;
|
||||
Toasty.success(context, context.getString(R.string.unStarRepositorySuccess));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void watchRepository(final Context context, RepositoryContext repository) {
|
||||
@ -138,50 +123,45 @@ public class RepositoryActions {
|
||||
.getApiInterface(context)
|
||||
.watchRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.watchRepositorySuccess));
|
||||
Toasty.success(context, context.getString(R.string.watchRepositorySuccess));
|
||||
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void unWatchRepository(final Context context, RepositoryContext repository) {
|
||||
@ -192,48 +172,40 @@ public class RepositoryActions {
|
||||
.getApiInterface(context)
|
||||
.unWatchRepository(((BaseActivity) context).getAccount().getAuthorization(), repository.getOwner(), repository.getName());
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
|
||||
if(response.code() == 204) {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
Toasty.success(context, context.getString(R.string.unWatchRepositorySuccess));
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
Toasty.error(context, context.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class TeamActions {
|
||||
@ -24,7 +24,7 @@ public class TeamActions {
|
||||
.getApiInterface(context)
|
||||
.removeTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@ -34,45 +34,36 @@ public class TeamActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.memberRemovedMessage));
|
||||
((AddNewTeamMemberActivity)context).finish();
|
||||
|
||||
((AddNewTeamMemberActivity) context).finish();
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void addTeamMember(final Context context, String userName, int teamId) {
|
||||
@ -81,7 +72,7 @@ public class TeamActions {
|
||||
.getApiInterface(context)
|
||||
.addTeamMember(((BaseActivity) context).getAccount().getAuthorization(), teamId, userName);
|
||||
|
||||
call.enqueue(new Callback<JsonElement>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
||||
@ -91,45 +82,34 @@ public class TeamActions {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.success(context, context.getString(R.string.memberAddedMessage));
|
||||
((AddNewTeamMemberActivity)context).finish();
|
||||
|
||||
((AddNewTeamMemberActivity) context).finish();
|
||||
}
|
||||
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context, context.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
|
||||
context.getResources().getString(R.string.alertDialogTokenRevokedMessage), context.getResources().getString(R.string.cancelButton),
|
||||
context.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.authorizeError));
|
||||
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(context, context.getString(R.string.apiNotFound));
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(context, context.getString(R.string.genericError));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -15,9 +14,11 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.gitnex.tea4j.models.UserSearch;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.CollaboratorSearchAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.ActivityAddCollaboratorToRepositoryBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -25,7 +26,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
@ -86,30 +87,29 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
.getApiInterface(ctx)
|
||||
.getUserBySearch(getAccount().getAuthorization(), searchKeyword, 10, 1);
|
||||
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
|
||||
if (response.code() == 200) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
assert response.body() != null;
|
||||
getUsersList(response.body().getData(), ctx);
|
||||
}
|
||||
else {
|
||||
assert response.body() != null;
|
||||
getUsersList(response.body().getData(), ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -147,5 +147,4 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
|
||||
super.onResume();
|
||||
repository.checkAccountSwitch(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class AddNewAccountActivity extends BaseActivity {
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commits>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
@ -200,7 +200,7 @@ public class CommitsActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Commits>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -302,8 +302,7 @@ public class LoginActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<GiteaVersion> callVersion, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure-versionCheck", t.toString());
|
||||
Toasty.error(ctx, getResources().getString(R.string.errorOnLogin));
|
||||
Toasty.error(ctx, getResources().getString(R.string.genericServerResponseError));
|
||||
enableProcessButton();
|
||||
}
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CollaboratorSearchAdapter extends RecyclerView.Adapter<CollaboratorSearchAdapter.CollaboratorSearchViewHolder> {
|
||||
@ -74,7 +74,7 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
pBuilder.setTitle(R.string.newTeamPermission);
|
||||
pBuilder.setSingleChoiceItems(permissionList, permissionSelectedChoice, null)
|
||||
.setCancelable(false)
|
||||
.setNegativeButton(R.string.cancelButton, null)
|
||||
.setNeutralButton(R.string.cancelButton, null)
|
||||
.setPositiveButton(R.string.addButton, (dialog, which) -> {
|
||||
|
||||
ListView lw = ((AlertDialog)dialog).getListView();
|
||||
@ -164,7 +164,6 @@ public class CollaboratorSearchAdapter extends RecyclerView.Adapter<Collaborator
|
||||
else {
|
||||
holder.addCollaboratorButtonRemove.setVisibility(View.GONE);
|
||||
holder.addCollaboratorButtonAdd.setVisibility(View.GONE);
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,9 +39,8 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
private final Context context;
|
||||
private List<Milestones> dataList;
|
||||
private Runnable loadMoreListener;
|
||||
private boolean isLoading = false;
|
||||
private boolean isMoreDataAvailable = true;
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||
private final RepositoryContext repository;
|
||||
|
||||
public MilestonesAdapter(Context ctx, List<Milestones> dataListMain, RepositoryContext repository) {
|
||||
@ -63,7 +62,7 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
||||
|
||||
isLoading = true;
|
||||
loadMoreListener.run();
|
||||
loadMoreListener.onLoadMore();
|
||||
}
|
||||
((MilestonesAdapter.DataHolder) holder).bindData(dataList.get(position));
|
||||
}
|
||||
@ -123,14 +122,14 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
MilestoneActions.closeMilestone(ctx, milestoneId_, repository);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
updateAdapter(getBindingAdapterPosition());
|
||||
});
|
||||
|
||||
openMilestone.setOnClickListener(v12 -> {
|
||||
|
||||
MilestoneActions.openMilestone(ctx, milestoneId_, repository);
|
||||
dialog.dismiss();
|
||||
updateAdapter(getAdapterPosition());
|
||||
updateAdapter(getBindingAdapterPosition());
|
||||
});
|
||||
|
||||
});
|
||||
@ -231,12 +230,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAdapter(int position) {
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
@ -247,18 +240,32 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
private void updateAdapter(int position) {
|
||||
dataList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, dataList.size());
|
||||
}
|
||||
|
||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||
isMoreDataAvailable = moreDataAvailable;
|
||||
if(!isMoreDataAvailable) {
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void notifyDataChanged() {
|
||||
notifyDataSetChanged();
|
||||
isLoading = false;
|
||||
loadMoreListener.onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
||||
public interface OnLoadMoreListener {
|
||||
void onLoadMore();
|
||||
void onLoadFinished();
|
||||
}
|
||||
|
||||
public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) {
|
||||
this.loadMoreListener = loadMoreListener;
|
||||
}
|
||||
|
||||
|
@ -1,28 +1,28 @@
|
||||
package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ExploreIssuesAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentSearchIssuesBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.viewmodels.IssuesViewModel;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class ExploreIssuesFragment extends Fragment {
|
||||
@ -30,37 +30,18 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
private FragmentSearchIssuesBinding viewBinding;
|
||||
private ExploreIssuesAdapter adapter;
|
||||
private int page = 1;
|
||||
private final String TAG = Constants.exploreIssues;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
viewBinding = FragmentSearchIssuesBinding.inflate(inflater, container, false);
|
||||
|
||||
viewBinding.searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString().equals("")) {
|
||||
InputMethodManager imm = (InputMethodManager) requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0);
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), String.valueOf(viewBinding.searchKeyword.getText()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
if(!Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString().equals("")) {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), String.valueOf(viewBinding.searchKeyword.getText()));
|
||||
}
|
||||
else {
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "");
|
||||
}
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "");
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
}, 50));
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(requireActivity(), DividerItemDecoration.VERTICAL);
|
||||
@ -110,4 +91,33 @@ public class ExploreIssuesFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
menu.clear();
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query);
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@ -15,7 +14,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
@ -30,17 +28,15 @@ import org.mian.gitnex.databinding.CustomExploreRepositoriesDialogBinding;
|
||||
import org.mian.gitnex.databinding.FragmentExploreRepoBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Template Author M M Arif
|
||||
* Author 6543
|
||||
* Modified M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class ExploreRepositoriesFragment extends Fragment {
|
||||
@ -52,7 +48,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private final boolean repoTypeInclude = true;
|
||||
private final String sort = "updated";
|
||||
private final String order = "desc";
|
||||
private final String TAG = Constants.exploreRepositories;
|
||||
private int resultLimit;
|
||||
private List<UserRepositories> dataList;
|
||||
private ExploreRepositoriesAdapter adapter;
|
||||
@ -77,26 +72,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(context);
|
||||
|
||||
viewBinding.searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString().equals("")) {
|
||||
InputMethodManager imm = (InputMethodManager) requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0);
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(String.valueOf(viewBinding.searchKeyword.getText()), resultLimit);
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewReposSearch.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial("", resultLimit);
|
||||
@ -106,7 +81,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewReposSearch.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
loadMore("", resultLimit, page);
|
||||
}
|
||||
}));
|
||||
|
||||
@ -125,9 +100,12 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient
|
||||
.getApiInterface(context).queryRepos(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, repoTypeInclude, sort, order, includeTopic, includeDescription, includeTemplate, onlyArchived, resultLimit, 1);
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.body() != null && response.body().getSearchedData().size() > 0) {
|
||||
dataList.clear();
|
||||
@ -147,13 +125,14 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -163,9 +142,12 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getApiInterface(context)
|
||||
.queryRepos(((BaseActivity) requireActivity()).getAccount().getAuthorization(), searchKeyword, repoTypeInclude, sort, order, includeTopic, includeDescription, includeTemplate, onlyArchived, resultLimit, page);
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
List<UserRepositories> result = response.body().getSearchedData();
|
||||
@ -181,13 +163,14 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -196,15 +179,43 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
menu.clear();
|
||||
inflater.inflate(R.menu.filter_menu, menu);
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
inflater.inflate(R.menu.filter_menu_explore, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem filter = menu.findItem(R.id.filter);
|
||||
MenuItem filter = menu.findItem(R.id.filter_explore);
|
||||
|
||||
filter.setOnMenuItemClickListener(filter_ -> {
|
||||
|
||||
showFilterOptions();
|
||||
return false;
|
||||
});
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(query, resultLimit);
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewReposSearch.post(() -> {
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(query, resultLimit, page);
|
||||
}
|
||||
}));
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showFilterOptions() {
|
||||
|
@ -4,12 +4,13 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
@ -23,15 +24,15 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentExploreUsersBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.SnackBar;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class ExploreUsersFragment extends Fragment {
|
||||
@ -42,7 +43,6 @@ public class ExploreUsersFragment extends Fragment {
|
||||
private List<UserInfo> usersList;
|
||||
private UsersAdapter adapter;
|
||||
private int pageSize;
|
||||
private final String TAG = Constants.exploreUsers;
|
||||
private int resultLimit;
|
||||
|
||||
@Override
|
||||
@ -50,32 +50,13 @@ public class ExploreUsersFragment extends Fragment {
|
||||
|
||||
viewBinding = FragmentExploreUsersBinding.inflate(inflater, container, false);
|
||||
context = getContext();
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
resultLimit = Constants.getCurrentResultLimit(context);
|
||||
|
||||
usersList = new ArrayList<>();
|
||||
adapter = new UsersAdapter(usersList, context);
|
||||
|
||||
viewBinding.searchKeyword.setOnEditorActionListener((v1, actionId, event) -> {
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString().equals("")) {
|
||||
InputMethodManager imm = (InputMethodManager) requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0);
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit);
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> {
|
||||
if(usersList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (usersList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), "", resultLimit);
|
||||
@ -104,9 +85,12 @@ public class ExploreUsersFragment extends Fragment {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
.getApiInterface(context).getUserBySearch(token, searchKeyword, resultLimit, 1);
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.body() != null && response.body().getData().size() > 0) {
|
||||
usersList.clear();
|
||||
@ -126,13 +110,14 @@ public class ExploreUsersFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -141,9 +126,12 @@ public class ExploreUsersFragment extends Fragment {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
Call<UserSearch> call = RetrofitClient.getApiInterface(context).getUserBySearch(token, searchKeyword, resultLimit, page);
|
||||
call.enqueue(new Callback<UserSearch>() {
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<UserSearch> call, @NonNull Response<UserSearch> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
List<UserInfo> result = response.body().getData();
|
||||
@ -161,13 +149,49 @@ public class ExploreUsersFragment extends Fragment {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
Toasty.error(requireActivity(), requireActivity().getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
menu.clear();
|
||||
inflater.inflate(R.menu.search_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query, resultLimit);
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> {
|
||||
if(usersList.size() == resultLimit || pageSize == resultLimit) {
|
||||
int page = (usersList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), query, resultLimit, page);
|
||||
}
|
||||
}));
|
||||
searchView.setQuery(null, false);
|
||||
searchItem.collapseActionView();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@ -15,6 +14,7 @@ import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
@ -22,34 +22,26 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.MilestonesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentMilestonesBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
||||
import org.mian.gitnex.viewmodels.MilestonesViewModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MilestonesFragment extends Fragment {
|
||||
|
||||
private FragmentMilestonesBinding viewBinding;
|
||||
|
||||
private Menu menu;
|
||||
private List<Milestones> dataList;
|
||||
private MilestonesAdapter adapter;
|
||||
private Context ctx;
|
||||
private int pageSize = Constants.milestonesPageInit;
|
||||
private final String TAG = Constants.tagMilestonesFragment;
|
||||
private int resultLimit = Constants.resultLimitOldGiteaInstances;
|
||||
|
||||
private RepositoryContext repository;
|
||||
private String milestoneId;
|
||||
private int page = 1;
|
||||
public String state = "open";
|
||||
|
||||
public static MilestonesFragment newInstance(RepositoryContext repository) {
|
||||
MilestonesFragment fragment = new MilestonesFragment();
|
||||
@ -68,7 +60,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
viewBinding = FragmentMilestonesBinding.inflate(inflater, container, false);
|
||||
setHasOptionsMenu(true);
|
||||
ctx = getContext();
|
||||
Context ctx = getContext();
|
||||
|
||||
milestoneId = requireActivity().getIntent().getStringExtra("milestoneId");
|
||||
requireActivity().getIntent().removeExtra("milestoneId");
|
||||
@ -76,135 +68,84 @@ public class MilestonesFragment extends Fragment {
|
||||
viewBinding.recyclerView.setHasFixedSize(true);
|
||||
viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
// if gitea is 1.12 or higher use the new limit
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.12.0")) {
|
||||
resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
}
|
||||
|
||||
dataList = new ArrayList<>();
|
||||
adapter = new MilestonesAdapter(ctx, dataList, repository);
|
||||
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerView.post(() -> {
|
||||
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, repository.getMilestoneState().toString());
|
||||
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(viewBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
viewBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
viewBinding.recyclerView.setHasFixedSize(true);
|
||||
viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
||||
page = 1;
|
||||
dataList.clear();
|
||||
viewBinding.pullToRefresh.setRefreshing(false);
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, repository.getMilestoneState().toString());
|
||||
adapter.updateList(dataList);
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), state);
|
||||
}, 50));
|
||||
|
||||
((RepoDetailActivity) requireActivity()).setFragmentRefreshListenerMilestone(milestoneState -> {
|
||||
|
||||
if(milestoneState.equals("closed")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
}
|
||||
else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
dataList.clear();
|
||||
|
||||
adapter = new MilestonesAdapter(ctx, dataList, repository);
|
||||
|
||||
if(((BaseActivity) requireActivity()).getAccount().requiresVersion("1.12.0")) {
|
||||
|
||||
adapter.setLoadMoreListener(() -> viewBinding.recyclerView.post(() -> {
|
||||
|
||||
if(dataList.size() == resultLimit || pageSize == resultLimit) {
|
||||
|
||||
int page = (dataList.size() + resultLimit) / resultLimit;
|
||||
loadMore(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), page, resultLimit, milestoneState);
|
||||
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
state = milestoneState;
|
||||
if(milestoneState.equals("open")) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
}
|
||||
|
||||
page = 1;
|
||||
dataList.clear();
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
viewBinding.noDataMilestone.setVisibility(View.GONE);
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, milestoneState);
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), milestoneState);
|
||||
});
|
||||
|
||||
loadInitial(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), resultLimit, repository.getMilestoneState().toString());
|
||||
fetchDataAsync(((BaseActivity) requireActivity()).getAccount().getAuthorization(), repository.getOwner(), repository.getName(), state);
|
||||
return viewBinding.getRoot();
|
||||
|
||||
}
|
||||
|
||||
private void loadInitial(String token, String repoOwner, String repoName, int resultLimit, String milestoneState) {
|
||||
private void fetchDataAsync(String instanceToken, String repoOwner, String repoName, String state) {
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient.getApiInterface(ctx).getMilestones(token, repoOwner, repoName, 1, resultLimit, milestoneState);
|
||||
MilestonesViewModel milestonesViewModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
milestonesViewModel.getMilestonesList(instanceToken, repoOwner, repoName, state, getContext()).observe(getViewLifecycleOwner(), milestonesListMain -> {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull Response<List<Milestones>> response) {
|
||||
adapter = new MilestonesAdapter(getContext(), milestonesListMain, repository);
|
||||
adapter.setLoadMoreListener(new MilestonesAdapter.OnLoadMoreListener() {
|
||||
|
||||
if(response.code() == 200) {
|
||||
@Override
|
||||
public void onLoadMore() {
|
||||
|
||||
assert response.body() != null;
|
||||
if(response.body().size() > 0) {
|
||||
page += 1;
|
||||
MilestonesViewModel.loadMoreMilestones(instanceToken, repoOwner, repoName, page, state, getContext(), adapter);
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
dataList.clear();
|
||||
dataList.addAll(response.body());
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.noDataMilestone.setVisibility(View.GONE);
|
||||
@Override
|
||||
public void onLoadFinished() {
|
||||
|
||||
if(milestoneId != null) {
|
||||
viewBinding.recyclerView.scrollToPosition(getMilestoneIndex(Integer.parseInt(milestoneId), response.body()));
|
||||
}
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
if(adapter.getItemCount() > 0) {
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
viewBinding.noDataMilestone.setVisibility(View.GONE);
|
||||
dataList.addAll(milestonesListMain);
|
||||
if(milestoneId != null) {
|
||||
viewBinding.recyclerView.scrollToPosition(getMilestoneIndex(Integer.parseInt(milestoneId), milestonesListMain));
|
||||
}
|
||||
}
|
||||
else {
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.recyclerView.setAdapter(adapter);
|
||||
viewBinding.noDataMilestone.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
dataList.clear();
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.noDataMilestone.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
private static int getMilestoneIndex(int milestoneId, List<Milestones> milestones) {
|
||||
for (Milestones milestone : milestones) {
|
||||
@ -215,59 +156,6 @@ public class MilestonesFragment extends Fragment {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit, String milestoneState) {
|
||||
|
||||
viewBinding.progressLoadMore.setVisibility(View.VISIBLE);
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient.getApiInterface(ctx).getMilestones(token, repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
|
||||
call.enqueue(new Callback<List<Milestones>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull Response<List<Milestones>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
//remove loading view
|
||||
dataList.remove(dataList.size() - 1);
|
||||
|
||||
List<Milestones> result = response.body();
|
||||
|
||||
assert result != null;
|
||||
if(result.size() > 0) {
|
||||
|
||||
pageSize = result.size();
|
||||
dataList.addAll(result);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
adapter.setMoreDataAvailable(false);
|
||||
|
||||
}
|
||||
|
||||
adapter.notifyDataChanged();
|
||||
viewBinding.progressLoadMore.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e(TAG, String.valueOf(response.code()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
|
||||
@ -276,12 +164,6 @@ public class MilestonesFragment extends Fragment {
|
||||
inflater.inflate(R.menu.filter_menu_milestone, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
if(repository.getMilestoneState() == RepositoryContext.State.CLOSED) {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter_closed);
|
||||
} else {
|
||||
menu.getItem(1).setIcon(R.drawable.ic_filter);
|
||||
}
|
||||
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
@ -299,11 +181,8 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
filter(newText);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void filter(String text) {
|
||||
@ -321,5 +200,4 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
adapter.updateList(arr);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package org.mian.gitnex.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -10,10 +9,12 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import org.gitnex.tea4j.models.Teams;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.UserGridAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationTeamInfoMembersBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
@ -68,10 +69,11 @@ public class OrganizationTeamInfoMembersFragment extends Fragment {
|
||||
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
call.enqueue(new Callback<List<UserInfo>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
|
||||
if(response.isSuccessful() && response.body() != null && response.body().size() > 0) {
|
||||
teamUserInfo.clear();
|
||||
teamUserInfo.addAll(response.body());
|
||||
@ -80,7 +82,8 @@ public class OrganizationTeamInfoMembersFragment extends Fragment {
|
||||
|
||||
binding.noDataMembers.setVisibility(View.GONE);
|
||||
binding.members.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
binding.members.setVisibility(View.GONE);
|
||||
binding.noDataMembers.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -90,10 +93,9 @@ public class OrganizationTeamInfoMembersFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.CreateOrganizationActivity;
|
||||
@ -23,6 +24,7 @@ import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.OrganizationsListAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentOrganizationsBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.DividerItemDecorator;
|
||||
import org.mian.gitnex.viewmodels.OrganizationsViewModel;
|
||||
|
||||
/**
|
||||
@ -52,8 +54,8 @@ public class OrganizationsFragment extends Fragment {
|
||||
|
||||
fragmentOrganizationsBinding.recyclerView.setHasFixedSize(true);
|
||||
fragmentOrganizationsBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(fragmentOrganizationsBinding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
|
||||
RecyclerView.ItemDecoration dividerItemDecoration = new DividerItemDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.shape_list_divider));
|
||||
fragmentOrganizationsBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
fragmentOrganizationsBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -12,10 +12,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.activities.CreateRepoActivity;
|
||||
@ -23,6 +24,7 @@ import org.mian.gitnex.activities.MainActivity;
|
||||
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentRepositoriesBinding;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.DividerItemDecorator;
|
||||
import org.mian.gitnex.viewmodels.RepositoriesViewModel;
|
||||
|
||||
/**
|
||||
@ -51,8 +53,8 @@ public class RepositoriesFragment extends Fragment {
|
||||
|
||||
fragmentRepositoriesBinding.recyclerView.setHasFixedSize(true);
|
||||
fragmentRepositoriesBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(fragmentRepositoriesBinding.recyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
|
||||
RecyclerView.ItemDecoration dividerItemDecoration = new DividerItemDecorator(ContextCompat.getDrawable(requireContext(), R.drawable.shape_list_divider));
|
||||
fragmentRepositoriesBinding.recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
fragmentRepositoriesBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
|
@ -27,7 +27,7 @@ import org.mian.gitnex.databinding.FragmentTeamsByOrgBinding;
|
||||
import org.mian.gitnex.viewmodels.TeamsByOrgViewModel;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class TeamsByOrgFragment extends Fragment {
|
||||
@ -37,7 +37,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noDataTeams;
|
||||
private static String orgNameF = "param2";
|
||||
private static final String orgNameF = "param2";
|
||||
private String orgName;
|
||||
private OrgPermissions permissions;
|
||||
private TeamsByOrgAdapter adapter;
|
||||
@ -133,11 +133,6 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||
androidx.appcompat.widget.SearchView searchView = (androidx.appcompat.widget.SearchView) searchItem.getActionView();
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -17,7 +16,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AdminCronTasksViewModel extends ViewModel {
|
||||
@ -38,42 +37,35 @@ public class AdminCronTasksViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.adminGetCronTasks(token, page, limit);
|
||||
|
||||
call.enqueue(new Callback<List<CronTasks>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<CronTasks>> call, @NonNull Response<List<CronTasks>> response) {
|
||||
|
||||
if (response.code() == 200) {
|
||||
if(response.isSuccessful()) {
|
||||
tasksList.postValue(response.body());
|
||||
}
|
||||
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage),
|
||||
ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.cancelButton),
|
||||
ctx.getResources().getString(R.string.navLogout));
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
}
|
||||
else if(response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<CronTasks>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.AdminGetUsersAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -36,20 +37,23 @@ public class AdminGetUsersViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.adminGetUsers(token, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserInfo>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
usersList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
usersList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -59,12 +63,12 @@ public class AdminGetUsersViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.adminGetUsers(token, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserInfo>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<UserInfo> list = usersList.getValue();
|
||||
assert list != null;
|
||||
@ -79,13 +83,14 @@ public class AdminGetUsersViewModel extends ViewModel {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.e("onResponse", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.Collaborators;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CollaboratorsViewModel extends ViewModel {
|
||||
@ -35,25 +36,24 @@ public class CollaboratorsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getCollaborators(token, owner, repo);
|
||||
|
||||
call.enqueue(new Callback<List<Collaborators>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Collaborators>> call, @NonNull Response<List<Collaborators>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
collaboratorsList.postValue(response.body());
|
||||
} else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
collaboratorsList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,13 +13,14 @@ import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class FilesViewModel extends ViewModel {
|
||||
@ -41,24 +42,27 @@ public class FilesViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getFiles(token, owner, repo, ref);
|
||||
|
||||
call.enqueue(new Callback<List<Files>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
if(response.isSuccessful() && response.body() != null && !response.body().isEmpty()) {
|
||||
Collections.sort(response.body(), (byType1, byType2) -> byType1.getType().compareTo(byType2.getType()));
|
||||
filesList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
noDataFiles.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.errorOnLogin));
|
||||
}
|
||||
if(response.isSuccessful() && response.body() != null && !response.body().isEmpty()) {
|
||||
Collections.sort(response.body(), Comparator.comparing(Files::getType));
|
||||
filesList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
noDataFiles.setVisibility(View.VISIBLE);
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -76,25 +80,27 @@ public class FilesViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getDirFiles(token, owner, repo, filesDir, ref);
|
||||
|
||||
call.enqueue(new Callback<List<Files>>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
if(response.isSuccessful() && response.body() != null && !response.body().isEmpty()) {
|
||||
Collections.sort(response.body(), (byType1, byType2) -> byType1.getType().compareTo(byType2.getType()));
|
||||
filesList2.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
noDataFiles.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.errorOnLogin));
|
||||
}
|
||||
if(response.isSuccessful() && response.body() != null && !response.body().isEmpty()) {
|
||||
Collections.sort(response.body(), Comparator.comparing(Files::getType));
|
||||
filesList2.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
noDataFiles.setVisibility(View.VISIBLE);
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.IssueComments;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class IssueCommentsViewModel extends ViewModel {
|
||||
@ -39,32 +40,27 @@ public class IssueCommentsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getIssueComments(token, owner, repo, index);
|
||||
|
||||
call.enqueue(new Callback<List<IssueComments>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<IssueComments>> call, @NonNull Response<List<IssueComments>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<IssueComments>> call, @NonNull Response<List<IssueComments>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
issueComments.postValue(response.body());
|
||||
if(onLoadingFinished != null) {
|
||||
onLoadingFinished.run();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
issueComments.postValue(response.body());
|
||||
if(onLoadingFinished != null) {
|
||||
onLoadingFinished.run();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<IssueComments>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<IssueComments>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -63,7 +62,7 @@ public class IssuesViewModel extends ViewModel {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -74,13 +73,13 @@ public class IssuesViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.queryIssues(token, searchKeyword, type, created, state, resultLimit, page);
|
||||
|
||||
call.enqueue(new Callback<List<Issues>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Issues>> call, @NonNull Response<List<Issues>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<Issues> list = issuesList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
@ -100,7 +99,8 @@ public class IssuesViewModel extends ViewModel {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class LabelsViewModel extends ViewModel {
|
||||
@ -35,27 +36,24 @@ public class LabelsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getLabels(token, owner, repo);
|
||||
|
||||
call.enqueue(new Callback<List<Labels>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull Response<List<Labels>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull Response<List<Labels>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
labelsList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
labelsList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MembersByOrgViewModel extends ViewModel {
|
||||
@ -35,25 +36,24 @@ public class MembersByOrgViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getMembersByOrg(token, owner);
|
||||
|
||||
call.enqueue(new Callback<List<UserInfo>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
membersList.postValue(response.body());
|
||||
} else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
membersList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.Milestones;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.MilestonesAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class MilestonesViewModel extends ViewModel {
|
||||
|
||||
private static MutableLiveData<List<Milestones>> milestonesList;
|
||||
private static final int resultLimit = Constants.resultLimitNewGiteaInstances;
|
||||
|
||||
public LiveData<List<Milestones>> getMilestonesList(String token, String repoOwner, String repoName, String milestoneState, Context ctx) {
|
||||
|
||||
milestonesList = new MutableLiveData<>();
|
||||
loadMilestonesList(token, repoOwner, repoName, milestoneState, ctx);
|
||||
|
||||
return milestonesList;
|
||||
}
|
||||
|
||||
public static void loadMilestonesList(String token, String repoOwner, String repoName, String milestoneState, Context ctx) {
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient.getApiInterface(ctx).getMilestones(token, repoOwner, repoName, 1, resultLimit, milestoneState);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull Response<List<Milestones>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
milestonesList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void loadMoreMilestones(String token, String repoOwner, String repoName, int page, String milestoneState, Context ctx, MilestonesAdapter adapter) {
|
||||
|
||||
Call<List<Milestones>> call = RetrofitClient.getApiInterface(ctx).getMilestones(token, repoOwner, repoName, page, resultLimit, milestoneState);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Milestones>> call, @NonNull Response<List<Milestones>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<Milestones> list = milestonesList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
|
||||
if(response.body().size() != 0) {
|
||||
list.addAll(response.body());
|
||||
adapter.updateList(list);
|
||||
}
|
||||
else {
|
||||
adapter.setMoreDataAvailable(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Milestones>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
@ -10,14 +9,16 @@ import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.Labels;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class OrganizationLabelsViewModel extends ViewModel {
|
||||
@ -38,7 +39,7 @@ public class OrganizationLabelsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getOrganizationLabels(token, owner);
|
||||
|
||||
call.enqueue(new Callback<List<Labels>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull Response<List<Labels>> response) {
|
||||
@ -51,16 +52,15 @@ public class OrganizationLabelsViewModel extends ViewModel {
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
noData.setVisibility(View.VISIBLE);
|
||||
Log.i("onResponse-org-labels", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.UserOrganizations;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.OrganizationsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -36,23 +37,24 @@ public class OrganizationsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getUserOrgs(token, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserOrganizations>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserOrganizations>> call, @NonNull Response<List<UserOrganizations>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserOrganizations>> call, @NonNull Response<List<UserOrganizations>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
orgList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
orgList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserOrganizations>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserOrganizations>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -62,7 +64,7 @@ public class OrganizationsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getUserOrgs(token, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<UserOrganizations>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserOrganizations>> call, @NonNull Response<List<UserOrganizations>> response) {
|
||||
@ -81,15 +83,15 @@ public class OrganizationsViewModel extends ViewModel {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.e("onResponse", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserOrganizations>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.Emails;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class ProfileEmailsViewModel extends ViewModel {
|
||||
@ -35,25 +36,24 @@ public class ProfileEmailsViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getUserEmails(token);
|
||||
|
||||
call.enqueue(new Callback<List<Emails>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Emails>> call, @NonNull Response<List<Emails>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Emails>> call, @NonNull Response<List<Emails>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
emailsList.postValue(response.body());
|
||||
} else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
emailsList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Emails>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Emails>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,26 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.GitTag;
|
||||
import org.gitnex.tea4j.models.Releases;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.BaseActivity;
|
||||
import org.mian.gitnex.adapters.ReleasesAdapter;
|
||||
import org.mian.gitnex.adapters.TagsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Constants;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class ReleasesViewModel extends ViewModel {
|
||||
@ -47,23 +48,24 @@ public class ReleasesViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getReleases(token, owner, repo, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Releases>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Releases>> call, @NonNull Response<List<Releases>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Releases>> call, @NonNull Response<List<Releases>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
releasesList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
releasesList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Releases>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Releases>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -73,12 +75,12 @@ public class ReleasesViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getReleases(token, owner, repo, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<Releases>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Releases>> call, @NonNull Response<List<Releases>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
List<Releases> list = releasesList.getValue();
|
||||
assert list != null;
|
||||
assert response.body() != null;
|
||||
@ -92,13 +94,14 @@ public class ReleasesViewModel extends ViewModel {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Releases>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -125,37 +128,39 @@ public class ReleasesViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getTags(token, owner, repo, 1, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<GitTag>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<GitTag>> call, @NonNull Response<List<GitTag>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
tagsList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<GitTag>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void loadMoreTags(String token, String owner, String repo, int page, Context ctx, TagsAdapter adapter) {
|
||||
|
||||
Call<List<GitTag>> call = RetrofitClient
|
||||
.getApiInterface(ctx)
|
||||
.getTags(token, owner, repo, page, resultLimit);
|
||||
|
||||
call.enqueue(new Callback<List<GitTag>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<GitTag>> call, @NonNull Response<List<GitTag>> response) {
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
if(response.isSuccessful()) {
|
||||
|
||||
List<GitTag> list = tagsList.getValue();
|
||||
assert list != null;
|
||||
@ -170,13 +175,14 @@ public class ReleasesViewModel extends ViewModel {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<GitTag>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class RepoStargazersViewModel extends ViewModel {
|
||||
@ -35,21 +36,24 @@ public class RepoStargazersViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getRepoStargazers(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<UserInfo>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
stargazersList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
stargazersList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.UserInfo;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class RepoWatchersViewModel extends ViewModel {
|
||||
@ -35,20 +36,24 @@ public class RepoWatchersViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getRepoWatchers(token, repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<List<UserInfo>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserInfo>> call, @NonNull Response<List<UserInfo>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
watchersList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
watchersList.postValue(response.body());
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserInfo>> call, Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import org.gitnex.tea4j.models.UserRepositories;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -49,22 +50,26 @@ public class RepositoriesViewModel extends ViewModel {
|
||||
break;
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
reposList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
reposList.postValue(response.body());
|
||||
}
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@ -88,7 +93,7 @@ public class RepositoriesViewModel extends ViewModel {
|
||||
break;
|
||||
}
|
||||
|
||||
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||
@ -107,14 +112,14 @@ public class RepositoriesViewModel extends ViewModel {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.e("onResponse", String.valueOf(response.code()));
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.mian.gitnex.viewmodels;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
@ -19,7 +18,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class TeamsByOrgViewModel extends ViewModel {
|
||||
@ -40,31 +39,33 @@ public class TeamsByOrgViewModel extends ViewModel {
|
||||
.getApiInterface(ctx)
|
||||
.getTeamsByOrg(token, orgName);
|
||||
|
||||
call.enqueue(new Callback<List<Teams>>() {
|
||||
call.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Teams>> call, @NonNull Response<List<Teams>> response) {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Teams>> call, @NonNull Response<List<Teams>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
teamsList.postValue(response.body());
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
noDataTeams.setText(R.string.authorizeError);
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
noDataTeams.setText(R.string.genericError);
|
||||
}
|
||||
}
|
||||
if(response.isSuccessful()) {
|
||||
teamsList.postValue(response.body());
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
noDataTeams.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
noDataTeams.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Teams>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.toString());
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
noDataTeams.setText(R.string.genericError);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Teams>> call, @NonNull Throwable t) {
|
||||
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
noDataTeams.setVisibility(View.GONE);
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,45 +14,6 @@
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
app:indicatorColor="?attr/progressIndicatorColor" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/searchKeywordLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:hintTextColor="?attr/hintColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:startIconDrawable="@drawable/ic_search"
|
||||
app:startIconTint="?attr/iconsColor"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
android:hint="@string/exploreTextBoxHint">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/searchKeyword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:imeOptions="actionSend"
|
||||
android:inputType="text"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noData"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -14,45 +14,6 @@
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
app:indicatorColor="?attr/progressIndicatorColor" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/searchKeywordLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:hintTextColor="?attr/hintColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:startIconDrawable="@drawable/ic_search"
|
||||
app:startIconTint="?attr/iconsColor"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
android:hint="@string/exploreUsers">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/searchKeyword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:imeOptions="actionSend"
|
||||
android:inputType="text"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noData"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -15,6 +15,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:paddingBottom="64dp"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
@ -48,7 +50,6 @@
|
||||
android:contentDescription="@string/pageTitleCreateOrganization"
|
||||
android:textColor="@color/colorWhite"
|
||||
android:backgroundTint="?attr/fabColor"
|
||||
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"
|
||||
app:iconTint="@color/colorWhite"
|
||||
app:icon="@drawable/ic_add" />
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
android:paddingBottom="64dp"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
@ -50,7 +52,6 @@
|
||||
android:contentDescription="@string/pageTitleNewRepo"
|
||||
android:textColor="@color/colorWhite"
|
||||
android:backgroundTint="?attr/fabColor"
|
||||
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"
|
||||
app:iconTint="@color/colorWhite"
|
||||
app:icon="@drawable/ic_add" />
|
||||
|
||||
|
@ -14,45 +14,6 @@
|
||||
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
|
||||
app:indicatorColor="?attr/progressIndicatorColor" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/searchKeywordLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:boxBackgroundColor="?attr/inputBackgroundColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
app:hintTextColor="?attr/hintColor"
|
||||
app:boxStrokeErrorColor="@color/darkRed"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:startIconDrawable="@drawable/ic_search"
|
||||
app:startIconTint="?attr/iconsColor"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?attr/iconsColor"
|
||||
android:hint="@string/exploreIssues">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/searchKeyword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/inputTextColor"
|
||||
android:textColorHighlight="?attr/hintColor"
|
||||
android:textColorHint="?attr/hintColor"
|
||||
android:imeOptions="actionSend"
|
||||
android:inputType="text"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noData"
|
||||
android:layout_width="match_parent"
|
||||
|
12
app/src/main/res/menu/filter_menu_explore.xml
Normal file
12
app/src/main/res/menu/filter_menu_explore.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/filter_explore"
|
||||
android:icon="@drawable/ic_filter"
|
||||
android:title="@string/strFilter"
|
||||
android:orderInCategory="0"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
@ -594,8 +594,6 @@
|
||||
<string name="openMilestone">Open Milestone</string>
|
||||
<string name="milestoneStatusUpdate">Milestone status updated successfully</string>
|
||||
|
||||
<string name="errorOnLogin">We cannot reach the server, please check your server status</string>
|
||||
|
||||
<string name="reportViewerHeader">Crash Reports</string>
|
||||
<string name="settingsEnableReportsText">Enable Crash Reports</string>
|
||||
<string name="crashTitle">GitNex has stopped :(</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user