2019-06-03 23:25:05 +02:00
|
|
|
package org.mian.gitnex.actions;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2020-04-30 12:42:22 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2019-06-03 23:25:05 +02:00
|
|
|
import com.google.gson.JsonElement;
|
|
|
|
import org.mian.gitnex.R;
|
|
|
|
import org.mian.gitnex.clients.RetrofitClient;
|
2020-08-18 16:11:31 +02:00
|
|
|
import org.mian.gitnex.database.api.DraftsApi;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.helpers.AlertDialogs;
|
|
|
|
import org.mian.gitnex.helpers.Authorization;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.helpers.Toasty;
|
|
|
|
import org.mian.gitnex.models.IssueComments;
|
2020-10-12 20:11:23 +02:00
|
|
|
import org.mian.gitnex.models.Issues;
|
2020-04-30 12:42:22 +02:00
|
|
|
import org.mian.gitnex.models.UpdateIssueState;
|
2019-06-03 23:25:05 +02:00
|
|
|
import retrofit2.Call;
|
|
|
|
import retrofit2.Callback;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Author M M Arif
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class IssueActions {
|
|
|
|
|
2020-08-18 16:11:31 +02:00
|
|
|
public static void editIssueComment(final Context ctx, final int commentId, final String commentBody, long draftIdOnCreate) {
|
2020-04-30 12:42:22 +02:00
|
|
|
|
|
|
|
final TinyDB tinyDb = new TinyDB(ctx);
|
|
|
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
|
|
final String loginUid = tinyDb.getString("loginUid");
|
|
|
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
|
|
String repoFullName = tinyDb.getString("repoFullName");
|
|
|
|
String[] parts = repoFullName.split("/");
|
|
|
|
final String repoOwner = parts[0];
|
|
|
|
final String repoName = parts[1];
|
|
|
|
|
|
|
|
IssueComments commentBodyJson = new IssueComments(commentBody);
|
|
|
|
Call<IssueComments> call;
|
|
|
|
|
|
|
|
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().patchIssueComment(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
|
|
|
|
|
|
|
call.enqueue(new Callback<IssueComments>() {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onResponse(@NonNull Call<IssueComments> call, @NonNull retrofit2.Response<IssueComments> response) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(response.isSuccessful()) {
|
|
|
|
if(response.code() == 200) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
tinyDb.putBoolean("commentEdited", true);
|
2020-08-18 16:11:31 +02:00
|
|
|
Toasty.info(ctx, ctx.getString(R.string.editCommentUpdatedText));
|
|
|
|
|
|
|
|
DraftsApi draftsApi = new DraftsApi(ctx);
|
|
|
|
draftsApi.deleteSingleDraft((int) draftIdOnCreate);
|
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(response.code() == 401) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(response.code() == 403) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(response.code() == 404) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<IssueComments> call, @NonNull Throwable t) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-10-12 20:11:23 +02:00
|
|
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
});
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
public static void closeReopenIssue(final Context ctx, final int issueIndex, final String issueState) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
final TinyDB tinyDb = new TinyDB(ctx);
|
|
|
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
|
|
final String loginUid = tinyDb.getString("loginUid");
|
|
|
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
|
|
String repoFullName = tinyDb.getString("repoFullName");
|
|
|
|
String[] parts = repoFullName.split("/");
|
|
|
|
final String repoOwner = parts[0];
|
|
|
|
final String repoName = parts[1];
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
UpdateIssueState issueStatJson = new UpdateIssueState(issueState);
|
|
|
|
Call<JsonElement> call;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().closeReopenIssue(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
call.enqueue(new Callback<JsonElement>() {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onResponse(@NonNull Call<JsonElement> call, @NonNull retrofit2.Response<JsonElement> response) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(response.isSuccessful()) {
|
|
|
|
if(response.code() == 201) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
tinyDb.putBoolean("resumeIssues", true);
|
|
|
|
tinyDb.putBoolean("resumeClosedIssues", true);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(issueState.equals("closed")) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
|
2020-04-30 12:42:22 +02:00
|
|
|
tinyDb.putString("issueState", "closed");
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(issueState.equals("open")) {
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.issueStateReopened));
|
2020-04-30 12:42:22 +02:00
|
|
|
tinyDb.putString("issueState", "open");
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(response.code() == 401) {
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(response.code() == 403) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.authorizeError));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(response.code() == 404) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.warning(ctx, ctx.getString(R.string.apiNotFound));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<JsonElement> call, @NonNull Throwable t) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-10-12 20:11:23 +02:00
|
|
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
});
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
public static void subscribe(final Context ctx) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
final TinyDB tinyDB = new TinyDB(ctx);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
final String instanceUrl = tinyDB.getString("instanceUrl");
|
2020-05-21 20:58:00 +02:00
|
|
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
|
|
|
if(repoFullName.length != 2) {
|
|
|
|
return;
|
|
|
|
}
|
2020-04-30 12:42:22 +02:00
|
|
|
final String userLogin = tinyDB.getString("userLogin");
|
2020-05-21 20:58:00 +02:00
|
|
|
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
2020-04-30 12:42:22 +02:00
|
|
|
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
Call<Void> call;
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().addIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
call.enqueue(new Callback<Void>() {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(response.isSuccessful()) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(response.code() == 201) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
2020-05-21 20:58:00 +02:00
|
|
|
tinyDB.putBoolean("issueSubscribed", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(response.code() == 200) {
|
|
|
|
|
|
|
|
tinyDB.putBoolean("issueSubscribed", true);
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(response.code() == 401) {
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-10-12 20:11:23 +02:00
|
|
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
});
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
public static void unsubscribe(final Context ctx) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
final TinyDB tinyDB = new TinyDB(ctx);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
final String instanceUrl = tinyDB.getString("instanceUrl");
|
2020-05-21 20:58:00 +02:00
|
|
|
String[] repoFullName = tinyDB.getString("repoFullName").split("/");
|
|
|
|
if(repoFullName.length != 2) {
|
|
|
|
return;
|
|
|
|
}
|
2020-04-30 12:42:22 +02:00
|
|
|
final String userLogin = tinyDB.getString("userLogin");
|
2020-05-21 20:58:00 +02:00
|
|
|
final String token = "token " + tinyDB.getString(tinyDB.getString("loginUid") + "-token");
|
2020-04-30 12:42:22 +02:00
|
|
|
final int issueNr = Integer.parseInt(tinyDB.getString("issueNumber"));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
Call<Void> call;
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().delIssueSubscriber(token, repoFullName[0], repoFullName[1], issueNr, userLogin);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
call.enqueue(new Callback<Void>() {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(response.isSuccessful()) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
if(response.code() == 201) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
2020-05-21 20:58:00 +02:00
|
|
|
tinyDB.putBoolean("issueSubscribed", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(response.code() == 200) {
|
|
|
|
|
|
|
|
tinyDB.putBoolean("issueSubscribed", false);
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-18 16:29:42 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else if(response.code() == 401) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(ctx, ctx.getResources().getString(R.string.alertDialogTokenRevokedTitle), ctx.getResources().getString(R.string.alertDialogTokenRevokedMessage), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyNegativeButton), ctx.getResources().getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(ctx, ctx.getString(R.string.unsubscriptionError));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-30 12:42:22 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-10-12 20:11:23 +02:00
|
|
|
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
2020-04-30 12:42:22 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-10-12 20:11:23 +02:00
|
|
|
public static ActionResult<ActionResult.None> reply(Context context, String comment, int issueIndex) {
|
|
|
|
|
|
|
|
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
|
|
|
TinyDB tinyDb = new TinyDB(context);
|
|
|
|
|
|
|
|
String instanceUrl = tinyDb.getString("instanceUrl");
|
|
|
|
String loginUid = tinyDb.getString("loginUid");
|
|
|
|
String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
|
|
|
|
|
|
|
String repoFullName = tinyDb.getString("repoFullName");
|
|
|
|
String[] parts = repoFullName.split("/");
|
|
|
|
String repoOwner = parts[0];
|
|
|
|
String repoName = parts[1];
|
|
|
|
|
|
|
|
Issues issueComment = new Issues(comment);
|
|
|
|
|
|
|
|
Call<Issues> call = RetrofitClient
|
|
|
|
.getInstance(instanceUrl, context)
|
|
|
|
.getApiInterface()
|
|
|
|
.replyCommentToIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
|
|
|
|
|
|
|
call.enqueue(new Callback<Issues>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResponse(@NonNull Call<Issues> call, @NonNull retrofit2.Response<Issues> response) {
|
|
|
|
|
|
|
|
if(response.code() == 201) {
|
|
|
|
|
|
|
|
actionResult.finish(ActionResult.Status.SUCCESS);
|
|
|
|
|
|
|
|
tinyDb.putBoolean("commentPosted", true);
|
|
|
|
tinyDb.putBoolean("resumeIssues", true);
|
|
|
|
tinyDb.putBoolean("resumePullRequests", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(response.code() == 401) {
|
|
|
|
|
|
|
|
AlertDialogs.authorizationTokenRevokedDialog(context, context.getString(R.string.alertDialogTokenRevokedTitle),
|
|
|
|
context.getString(R.string.alertDialogTokenRevokedMessage),
|
|
|
|
context.getString(R.string.alertDialogTokenRevokedCopyNegativeButton),
|
|
|
|
context.getString(R.string.alertDialogTokenRevokedCopyPositiveButton));
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
actionResult.finish(ActionResult.Status.FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(@NonNull Call<Issues> call, @NonNull Throwable t) {
|
|
|
|
|
|
|
|
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return actionResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-03 23:25:05 +02:00
|
|
|
}
|