mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
Use Gradle-native formatter (#1208)
Run `gradle :app:spotlessApply` to apply formatting. # Changes from current code format This does not match with the old intellij based code format because I can't apply some rules there. - newlines after `else`, `catch` etc. (means there are `} else {` statements) - no spaces around `if` braces (there are statements like `if (true) {` instead of `if(true) {` Closes https://codeberg.org/gitnex/GitNex/issues/1187 Closes https://codeberg.org/gitnex/GitNex/issues/1202 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1208 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
3c65e95db3
commit
325560c08d
254 changed files with 20604 additions and 14474 deletions
|
@ -31,17 +31,17 @@
|
|||
<option name="BLANK_LINES_AROUND_FIELD_IN_INTERFACE" value="1"/>
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1"/>
|
||||
<option name="BLANK_LINES_BEFORE_CLASS_END" value="1"/>
|
||||
<option name="ELSE_ON_NEW_LINE" value="true"/>
|
||||
<option name="CATCH_ON_NEW_LINE" value="true"/>
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true"/>
|
||||
<option name="ELSE_ON_NEW_LINE" value="false"/>
|
||||
<option name="CATCH_ON_NEW_LINE" value="false"/>
|
||||
<option name="FINALLY_ON_NEW_LINE" value="false"/>
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false"/>
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_TRY_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="true"/>
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="true"/>
|
||||
<option name="CALL_PARAMETERS_WRAP" value="1"/>
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="1"/>
|
||||
<option name="THROWS_LIST_WRAP" value="1"/>
|
||||
|
|
|
@ -7,12 +7,11 @@ pipeline:
|
|||
regex: " \\\\* \\\\@author [\\\\S\\\\s]+"
|
||||
must_contain: true
|
||||
|
||||
#style:
|
||||
#image: qwerty287/woodpecker-intellij-formatter
|
||||
#group: check
|
||||
# settings:
|
||||
#file_pattern: "*.java"
|
||||
#path: "app/"
|
||||
style:
|
||||
image: alvrme/alpine-android:android-31-jdk11
|
||||
group: check
|
||||
commands:
|
||||
- ./gradlew :app:spotlessCheck
|
||||
|
||||
test:
|
||||
image: alvrme/alpine-android:android-31-jdk11
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
plugins {
|
||||
id "com.diffplug.spotless" version "6.11.0"
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
|
@ -118,3 +121,18 @@ dependencies {
|
|||
}
|
||||
implementation 'io.github.amrdeveloper:codeview:1.3.5'
|
||||
}
|
||||
|
||||
spotless {
|
||||
java {
|
||||
target 'src/**/*.java'
|
||||
|
||||
importOrder('android', 'androidx', 'com', 'junit', 'net', 'org', 'java', 'javax', '', '\\#')
|
||||
removeUnusedImports()
|
||||
|
||||
googleJavaFormat().aosp()
|
||||
|
||||
indentWithTabs()
|
||||
|
||||
formatAnnotations()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,4 @@ public class MainActivityTest {
|
|||
ActivityScenario<MainActivity> a = ActivityScenario.launch(MainActivity.class);
|
||||
a.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.main.gitnex.helpers;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.view.View;
|
||||
|
@ -8,7 +10,6 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mian.gitnex.helpers.AppUtil;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author qwerty287
|
||||
|
@ -91,22 +92,43 @@ public class AppUtilTest {
|
|||
|
||||
@Test
|
||||
public void getUriFromGitUrlTest() {
|
||||
assertEquals("https://git@codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals("ssh://git@codeberg.org/gitnex/GitNex", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org/gitnex/GitNex").toString());
|
||||
assertEquals("https://git@codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex.git", AppUtil.getUriFromGitUrl("https://codeberg.org/gitnex/GitNex.git").toString());
|
||||
assertEquals("https://gitnex.com", AppUtil.getUriFromGitUrl("https://gitnex.com").toString());
|
||||
assertEquals("https://gitnex.com:3000", AppUtil.getUriFromGitUrl("https://gitnex.com:3000").toString());
|
||||
assertEquals(
|
||||
"https://git@codeberg.org/gitnex/GitNex",
|
||||
AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex",
|
||||
AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex").toString());
|
||||
assertEquals(
|
||||
"ssh://git@codeberg.org/gitnex/GitNex",
|
||||
AppUtil.getUriFromGitUrl("ssh://git@codeberg.org/gitnex/GitNex").toString());
|
||||
assertEquals(
|
||||
"https://git@codeberg.org/gitnex/GitNex.git",
|
||||
AppUtil.getUriFromGitUrl("ssh://git@codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex.git",
|
||||
AppUtil.getUriFromGitUrl("codeberg.org:gitnex/GitNex.git").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex.git",
|
||||
AppUtil.getUriFromGitUrl("https://codeberg.org/gitnex/GitNex.git").toString());
|
||||
assertEquals(
|
||||
"https://gitnex.com", AppUtil.getUriFromGitUrl("https://gitnex.com").toString());
|
||||
assertEquals(
|
||||
"https://gitnex.com:3000",
|
||||
AppUtil.getUriFromGitUrl("https://gitnex.com:3000").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeSchemeTest() {
|
||||
assertEquals("https://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("ssh://codeberg.org/gitnex/GitNex"), "https").toString());
|
||||
assertEquals("https://gitnex.com", AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
|
||||
assertEquals("ssh://codeberg.org/gitnex/GitNex", AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh").toString());
|
||||
assertEquals(
|
||||
"https://codeberg.org/gitnex/GitNex",
|
||||
AppUtil.changeScheme(Uri.parse("ssh://codeberg.org/gitnex/GitNex"), "https")
|
||||
.toString());
|
||||
assertEquals(
|
||||
"https://gitnex.com",
|
||||
AppUtil.changeScheme(Uri.parse("http://gitnex.com"), "https").toString());
|
||||
assertEquals(
|
||||
"ssh://codeberg.org/gitnex/GitNex",
|
||||
AppUtil.changeScheme(Uri.parse("http://codeberg.org/gitnex/GitNex"), "ssh")
|
||||
.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -45,5 +45,4 @@ public class ToastyTest {
|
|||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Toasty.success(context, "GitNex success test");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.concurrent.TimeUnit;
|
|||
/**
|
||||
* @author opyale
|
||||
*/
|
||||
|
||||
public class ActionResult<R> {
|
||||
|
||||
private final BlockingQueue<Boolean> blockingQueue;
|
||||
|
@ -22,7 +21,6 @@ public class ActionResult<R> {
|
|||
|
||||
blockingQueue = new ArrayBlockingQueue<>(1);
|
||||
onFinishedListeners = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public void finish(@NonNull Status status) {
|
||||
|
@ -33,54 +31,48 @@ public class ActionResult<R> {
|
|||
public void finish(@NonNull Status status, R result) {
|
||||
|
||||
try {
|
||||
if(blockingQueue.poll(5, TimeUnit.SECONDS)) {
|
||||
if (blockingQueue.poll(5, TimeUnit.SECONDS)) {
|
||||
|
||||
for(OnFinishedListener<R> onFinishedListener : onFinishedListeners)
|
||||
for (OnFinishedListener<R> onFinishedListener : onFinishedListeners)
|
||||
onFinishedListener.onFinished(status, result);
|
||||
}
|
||||
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
catch(InterruptedException ignored) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
|
||||
if(invalidated) {
|
||||
if (invalidated) {
|
||||
throw new IllegalStateException("Already invalidated");
|
||||
}
|
||||
this.invalidated = true;
|
||||
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public synchronized final void accept(@NonNull OnFinishedListener<R>... onFinishedListeners) {
|
||||
public final synchronized void accept(@NonNull OnFinishedListener<R>... onFinishedListeners) {
|
||||
|
||||
invalidate();
|
||||
|
||||
this.blockingQueue.add(true);
|
||||
this.onFinishedListeners.addAll(Arrays.asList(onFinishedListeners));
|
||||
|
||||
}
|
||||
|
||||
public synchronized final void discard() {
|
||||
public final synchronized void discard() {
|
||||
|
||||
invalidate();
|
||||
this.blockingQueue.add(false);
|
||||
|
||||
}
|
||||
|
||||
public enum Status {SUCCESS, FAILED}
|
||||
public enum Status {
|
||||
SUCCESS,
|
||||
FAILED
|
||||
}
|
||||
|
||||
public interface OnFinishedListener<R> {
|
||||
|
||||
void onFinished(Status status, R result);
|
||||
|
||||
}
|
||||
|
||||
public static class None {
|
||||
|
||||
}
|
||||
|
||||
public static class None {}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View;
|
|||
import android.widget.ProgressBar;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Issue;
|
||||
import org.gitnex.tea4j.v2.models.User;
|
||||
import org.mian.gitnex.R;
|
||||
|
@ -12,103 +13,130 @@ import org.mian.gitnex.adapters.AssigneesListAdapter;
|
|||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class AssigneesActions {
|
||||
|
||||
public static void getCurrentIssueAssignees(Context ctx, String repoOwner, String repoName, int issueIndex, List<String> currentAssignees) {
|
||||
public static void getCurrentIssueAssignees(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
int issueIndex,
|
||||
List<String> currentAssignees) {
|
||||
|
||||
Call<Issue> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
Call<Issue> callSingleIssueLabels =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetIssue(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
callSingleIssueLabels.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Issue> call,
|
||||
@NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
Issue issueAssigneesList = response.body();
|
||||
assert issueAssigneesList != null;
|
||||
Issue issueAssigneesList = response.body();
|
||||
assert issueAssigneesList != null;
|
||||
|
||||
if(issueAssigneesList.getAssignees() != null) {
|
||||
if (issueAssigneesList.getAssignees() != null) {
|
||||
|
||||
if(issueAssigneesList.getAssignees().size() > 0) {
|
||||
if (issueAssigneesList.getAssignees().size() > 0) {
|
||||
|
||||
for(int i = 0; i < issueAssigneesList.getAssignees().size(); i++) {
|
||||
for (int i = 0;
|
||||
i < issueAssigneesList.getAssignees().size();
|
||||
i++) {
|
||||
|
||||
currentAssignees.add(issueAssigneesList.getAssignees().get(i).getLogin());
|
||||
currentAssignees.add(
|
||||
issueAssigneesList
|
||||
.getAssignees()
|
||||
.get(i)
|
||||
.getLogin());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryAssignees(Context ctx, String repoOwner, String repoName, List<User> assigneesList, MaterialAlertDialogBuilder materialAlertDialogBuilder, AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryAssignees(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
List<User> assigneesList,
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder,
|
||||
AssigneesListAdapter assigneesAdapter,
|
||||
CustomAssigneesSelectionDialogBinding assigneesBinding,
|
||||
ProgressBar progressBar) {
|
||||
|
||||
Call<List<User>> call = RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
Call<List<User>> call =
|
||||
RetrofitClient.getApiInterface(ctx).repoGetAssignees(repoOwner, repoName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<User>> call, @NonNull retrofit2.Response<List<User>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<User>> call,
|
||||
@NonNull retrofit2.Response<List<User>> response) {
|
||||
|
||||
assigneesList.clear();
|
||||
List<User> assigneesList_ = response.body();
|
||||
assigneesList.clear();
|
||||
List<User> assigneesList_ = response.body();
|
||||
|
||||
if(response.code() == 200) {
|
||||
if (response.code() == 200) {
|
||||
|
||||
assert assigneesList_ != null;
|
||||
assert assigneesList_ != null;
|
||||
|
||||
if(assigneesList_.size() > 0) {
|
||||
if (assigneesList_.size() > 0) {
|
||||
|
||||
assigneesList.addAll(assigneesList_);
|
||||
materialAlertDialogBuilder.show();
|
||||
}
|
||||
else {
|
||||
assigneesList.addAll(assigneesList_);
|
||||
materialAlertDialogBuilder.show();
|
||||
} else {
|
||||
|
||||
Toasty.warning(ctx, ctx.getResources().getString(R.string.noAssigneesFound));
|
||||
Toasty.warning(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.noAssigneesFound));
|
||||
}
|
||||
|
||||
assigneesBinding.assigneesRecyclerView.setAdapter(assigneesAdapter);
|
||||
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
assigneesBinding.assigneesRecyclerView.setAdapter(assigneesAdapter);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if(progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<User>> call, @NonNull Throwable t) {
|
||||
|
||||
if(progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,97 +16,114 @@ import retrofit2.Callback;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class CollaboratorActions {
|
||||
|
||||
public static void deleteCollaborator(final Context context, String userName, RepositoryContext repository) {
|
||||
public static void deleteCollaborator(
|
||||
final Context context, String userName, RepositoryContext repository) {
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoDeleteCollaborator(repository.getOwner(), repository.getName(), userName);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.repoDeleteCollaborator(
|
||||
repository.getOwner(), repository.getName(), userName);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> 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();
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(
|
||||
context,
|
||||
context.getString(R.string.removeCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
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<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void addCollaborator(final Context context, String permission, String userName, RepositoryContext repository) {
|
||||
public static void addCollaborator(
|
||||
final Context context,
|
||||
String permission,
|
||||
String userName,
|
||||
RepositoryContext repository) {
|
||||
|
||||
AddCollaboratorOption permissionString = new AddCollaboratorOption();
|
||||
permissionString.setPermission(permission);
|
||||
|
||||
Call<Void> call = RetrofitClient.getApiInterface(context).repoAddCollaborator(repository.getOwner(), repository.getName(), userName, permissionString);
|
||||
Call<Void> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.repoAddCollaborator(
|
||||
repository.getOwner(),
|
||||
repository.getName(),
|
||||
userName,
|
||||
permissionString);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> 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();
|
||||
CollaboratorsFragment.refreshCollaborators = true;
|
||||
Toasty.success(
|
||||
context,
|
||||
context.getString(R.string.addCollaboratorToastText));
|
||||
((AddCollaboratorToRepositoryActivity) context).finish();
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
}
|
||||
else if(response.code() == 403) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
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<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,243 +25,288 @@ import retrofit2.Response;
|
|||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class IssueActions {
|
||||
|
||||
public static ActionResult<Response<?>> edit(Context context, String comment, int commentId, IssueContext issue) {
|
||||
public static ActionResult<Response<?>> edit(
|
||||
Context context, String comment, int commentId, IssueContext issue) {
|
||||
|
||||
ActionResult<Response<?>> actionResult = new ActionResult<>();
|
||||
|
||||
EditIssueCommentOption commentObj = new EditIssueCommentOption();
|
||||
commentObj.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueEditComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) commentId, commentObj);
|
||||
Call<Comment> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.issueEditComment(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) commentId,
|
||||
commentObj);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Comment> call, @NonNull retrofit2.Response<Comment> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Comment> call,
|
||||
@NonNull retrofit2.Response<Comment> response) {
|
||||
|
||||
switch(response.code()) {
|
||||
switch (response.code()) {
|
||||
case 200:
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
break;
|
||||
|
||||
case 200:
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
break;
|
||||
case 401:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
break;
|
||||
|
||||
case 401:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
break;
|
||||
default:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
actionResult.finish(ActionResult.Status.FAILED, response);
|
||||
break;
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
public static void closeReopenIssue(final Context ctx, final String issueState, IssueContext issue) {
|
||||
public static void closeReopenIssue(
|
||||
final Context ctx, final String issueState, IssueContext issue) {
|
||||
|
||||
EditIssueOption issueStatJson = new EditIssueOption();
|
||||
issueStatJson.setState(issueState);
|
||||
Call<Issue> call = RetrofitClient.getApiInterface(ctx).issueEditIssue(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueStatJson);
|
||||
Call<Issue> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueEditIssue(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
issueStatJson);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Issue> call, @NonNull retrofit2.Response<Issue> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Issue> call,
|
||||
@NonNull retrofit2.Response<Issue> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 201) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
if(issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
if(issueState.equals("closed")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prClosed));
|
||||
if (issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues =
|
||||
issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests =
|
||||
issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
||||
if (issueState.equals("closed")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prClosed));
|
||||
} else if (issueState.equals("open")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prReopened));
|
||||
}
|
||||
} else {
|
||||
if (issueState.equals("closed")) {
|
||||
Toasty.success(
|
||||
ctx, ctx.getString(R.string.issueStateClosed));
|
||||
} else if (issueState.equals("open")) {
|
||||
Toasty.success(
|
||||
ctx, ctx.getString(R.string.issueStateReopened));
|
||||
}
|
||||
}
|
||||
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
if (((Activity) ctx).getIntent().getStringExtra("openedFromLink")
|
||||
== null
|
||||
|| !((Activity) ctx)
|
||||
.getIntent()
|
||||
.getStringExtra("openedFromLink")
|
||||
.equals("true")) {
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
}
|
||||
}
|
||||
else if(issueState.equals("open")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.prReopened));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(issueState.equals("closed")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateClosed));
|
||||
}
|
||||
else if(issueState.equals("open")) {
|
||||
Toasty.success(ctx, ctx.getString(R.string.issueStateReopened));
|
||||
}
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
IssueDetailActivity.singleIssueUpdate = true;
|
||||
((IssueDetailActivity) ctx).onResume();
|
||||
if(((Activity) ctx).getIntent().getStringExtra("openedFromLink") == null || !((Activity) ctx).getIntent().getStringExtra("openedFromLink").equals("true")) {
|
||||
RepoDetailActivity.updateRepo = true;
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
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
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void subscribe(final Context ctx, IssueContext issue) {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueAddSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueAddSubscription(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.subscribedSuccessfully));
|
||||
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);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadySubscribed));
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.subscriptionError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void unsubscribe(final Context ctx, IssueContext issue) {
|
||||
|
||||
Call<Void> call;
|
||||
|
||||
call = RetrofitClient.getApiInterface(ctx)
|
||||
.issueDeleteSubscription(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), ((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueDeleteSubscription(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
((BaseActivity) ctx).getAccount().getAccount().getUserName());
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Void> call, @NonNull retrofit2.Response<Void> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
if (response.code() == 201) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.unsubscribedSuccessfully));
|
||||
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);
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 200) {
|
||||
|
||||
Toasty.success(ctx, ctx.getString(R.string.alreadyUnsubscribed));
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
}
|
||||
else {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.unSubscriptionError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Void> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static ActionResult<ActionResult.None> reply(Context context, String comment, IssueContext issue) {
|
||||
public static ActionResult<ActionResult.None> reply(
|
||||
Context context, String comment, IssueContext issue) {
|
||||
|
||||
ActionResult<ActionResult.None> actionResult = new ActionResult<>();
|
||||
|
||||
CreateIssueCommentOption issueComment = new CreateIssueCommentOption();
|
||||
issueComment.setBody(comment);
|
||||
|
||||
Call<Comment> call = RetrofitClient.getApiInterface(context).issueCreateComment(issue.getRepository().getOwner(), issue.getRepository().getName(), (long) issue.getIssueIndex(), issueComment);
|
||||
Call<Comment> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.issueCreateComment(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issue.getIssueIndex(),
|
||||
issueComment);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<Comment> call, @NonNull retrofit2.Response<Comment> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<Comment> call,
|
||||
@NonNull retrofit2.Response<Comment> response) {
|
||||
|
||||
if(response.code() == 201) {
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
if (response.code() == 201) {
|
||||
actionResult.finish(ActionResult.Status.SUCCESS);
|
||||
|
||||
if(issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues = issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests = issue.getIssue().getPullRequest() != null;
|
||||
if (issue.hasIssue()) {
|
||||
IssuesFragment.resumeIssues =
|
||||
issue.getIssue().getPullRequest() == null;
|
||||
PullRequestsFragment.resumePullRequests =
|
||||
issue.getIssue().getPullRequest() != null;
|
||||
}
|
||||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
|
||||
} else {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(context);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
actionResult.finish(ActionResult.Status.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Comment> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(context, context.getResources().getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(
|
||||
context,
|
||||
context.getResources()
|
||||
.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,124 +5,160 @@ import android.view.View;
|
|||
import android.widget.ProgressBar;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Label;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.adapters.LabelsListAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
||||
/**
|
||||
* @author M M Arif
|
||||
*/
|
||||
|
||||
public class LabelsActions {
|
||||
|
||||
public static void getCurrentIssueLabels(Context ctx, String repoOwner, String repoName, int issueIndex, List<Integer> currentLabelsIds) {
|
||||
public static void getCurrentIssueLabels(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
int issueIndex,
|
||||
List<Integer> currentLabelsIds) {
|
||||
|
||||
Call<List<Label>> callSingleIssueLabels = RetrofitClient.getApiInterface(ctx).issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
Call<List<Label>> callSingleIssueLabels =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueGetLabels(repoOwner, repoName, (long) issueIndex);
|
||||
|
||||
callSingleIssueLabels.enqueue(new Callback<>() {
|
||||
callSingleIssueLabels.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
List<Label> issueLabelsList = response.body();
|
||||
List<Label> issueLabelsList = response.body();
|
||||
|
||||
assert issueLabelsList != null;
|
||||
assert issueLabelsList != null;
|
||||
|
||||
if(issueLabelsList.size() > 0) {
|
||||
if (issueLabelsList.size() > 0) {
|
||||
|
||||
for(int i = 0; i < issueLabelsList.size(); i++) {
|
||||
for (int i = 0; i < issueLabelsList.size(); i++) {
|
||||
|
||||
currentLabelsIds.add(Math.toIntExact(issueLabelsList.get(i).getId()));
|
||||
currentLabelsIds.add(
|
||||
Math.toIntExact(issueLabelsList.get(i).getId()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericError));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
Toasty.error(ctx, ctx.getString(R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getRepositoryLabels(Context ctx, String repoOwner, String repoName, List<Label> labelsList, MaterialAlertDialogBuilder materialAlertDialogBuilder, LabelsListAdapter labelsAdapter,
|
||||
CustomLabelsSelectionDialogBinding labelsBinding, ProgressBar progressBar) {
|
||||
public static void getRepositoryLabels(
|
||||
Context ctx,
|
||||
String repoOwner,
|
||||
String repoName,
|
||||
List<Label> labelsList,
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder,
|
||||
LabelsListAdapter labelsAdapter,
|
||||
CustomLabelsSelectionDialogBinding labelsBinding,
|
||||
ProgressBar progressBar) {
|
||||
|
||||
Call<List<Label>> call = RetrofitClient.getApiInterface(ctx).issueListLabels(repoOwner, repoName, null, null);
|
||||
Call<List<Label>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueListLabels(repoOwner, repoName, null, null);
|
||||
|
||||
call.enqueue(new Callback<>() {
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Label>> call, @NonNull retrofit2.Response<List<Label>> response) {
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull retrofit2.Response<List<Label>> response) {
|
||||
|
||||
labelsList.clear();
|
||||
labelsList.clear();
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
if(response.body() != null) {
|
||||
if (response.body() != null) {
|
||||
|
||||
labelsList.addAll(response.body());
|
||||
labelsList.addAll(response.body());
|
||||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Label>> callOrgLabels =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.orgListLabels(repoOwner, null, null);
|
||||
|
||||
callOrgLabels.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull retrofit2.Response<List<Label>>
|
||||
responseOrg) {
|
||||
|
||||
if (responseOrg.body() != null) {
|
||||
|
||||
labelsList.addAll(responseOrg.body());
|
||||
materialAlertDialogBuilder.show();
|
||||
}
|
||||
|
||||
if (labelsList.isEmpty()) {
|
||||
|
||||
Toasty.warning(
|
||||
ctx,
|
||||
ctx.getResources()
|
||||
.getString(R.string.noDataFound));
|
||||
}
|
||||
|
||||
labelsBinding.labelsRecyclerView.setAdapter(
|
||||
labelsAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Label>> call,
|
||||
@NonNull Throwable t) {
|
||||
|
||||
Toasty.error(
|
||||
ctx,
|
||||
ctx.getString(
|
||||
R.string.genericServerResponseError));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
Toasty.error(ctx, ctx.getResources().getString(R.string.genericError));
|
||||
}
|
||||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// Load organization labels
|
||||
Call<List<Label>> callOrgLabels = RetrofitClient.getApiInterface(ctx).orgListLabels(repoOwner, null, null);
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Label>> call, @NonNull Throwable t) {
|
||||
|
||||
callOrgLabels.enqueue(new Callback<>() {
|
||||
|
||||
@Override
|
||||