From b31a36d880c4e7bddbaa1c535bf16d54bce70f9e Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Sun, 19 Dec 2021 13:39:08 +0100 Subject: [PATCH] Move more interfaces to `structs` (#1022) Moves the `FragmentRefreshListener` and the `Protocol` interface/enum to the `structs` package. Co-authored-by: qwerty287 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1022 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 Co-committed-by: qwerty287 --- .../activities/AddNewAccountActivity.java | 2 +- .../mian/gitnex/activities/LoginActivity.java | 3 +- .../gitnex/activities/RepoDetailActivity.java | 36 +++++++------------ .../structs/FragmentRefreshListener.java | 7 ++++ .../org/mian/gitnex/structs/Protocol.java | 3 ++ 5 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 app/src/main/java/org/mian/gitnex/structs/FragmentRefreshListener.java create mode 100644 app/src/main/java/org/mian/gitnex/structs/Protocol.java diff --git a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java index e78fb260..40e233de 100644 --- a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java @@ -20,6 +20,7 @@ import org.mian.gitnex.helpers.PathsHelper; import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.UrlHelper; import org.mian.gitnex.helpers.Version; +import org.mian.gitnex.structs.Protocol; import java.net.URI; import io.mikael.urlbuilder.UrlBuilder; import retrofit2.Call; @@ -34,7 +35,6 @@ public class AddNewAccountActivity extends BaseActivity { private View.OnClickListener onClickListener; private ActivityAddNewAccountBinding viewBinding; - private enum Protocol {HTTPS, HTTP} private String spinnerSelectedValue; @Override diff --git a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java index b4a08d08..f47d7445 100644 --- a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java @@ -28,6 +28,7 @@ import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.UrlHelper; import org.mian.gitnex.helpers.Version; +import org.mian.gitnex.structs.Protocol; import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.List; @@ -43,8 +44,6 @@ import retrofit2.Callback; public class LoginActivity extends BaseActivity { - private enum Protocol {HTTPS, HTTP} - private enum LoginType {BASIC, TOKEN} private Button loginButton; diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java index f1518f19..b5e20c91 100644 --- a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Typeface; -import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -51,6 +50,7 @@ import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Version; import org.mian.gitnex.structs.BottomSheetListener; +import org.mian.gitnex.structs.FragmentRefreshListener; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -69,10 +69,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe private TextView textViewBadgeRelease; private FragmentRefreshListener fragmentRefreshListener; - private FragmentRefreshListenerPr fragmentRefreshListenerPr; - private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone; - private FragmentRefreshListenerFiles fragmentRefreshListenerFiles; - private FragmentRefreshListenerFilterIssuesByMilestone fragmentRefreshListenerFilterIssuesByMilestone; + private FragmentRefreshListener fragmentRefreshListenerPr; + private FragmentRefreshListener fragmentRefreshListenerMilestone; + private FragmentRefreshListener fragmentRefreshListenerFiles; + private FragmentRefreshListener fragmentRefreshListenerFilterIssuesByMilestone; private String repositoryOwner; private String repositoryName; @@ -779,38 +779,28 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe } // Issues milestone filter interface - public FragmentRefreshListenerFilterIssuesByMilestone getFragmentRefreshListenerFilterIssuesByMilestone() { return fragmentRefreshListenerFilterIssuesByMilestone; } + public FragmentRefreshListener getFragmentRefreshListenerFilterIssuesByMilestone() { return fragmentRefreshListenerFilterIssuesByMilestone; } - public void setFragmentRefreshListenerFilterIssuesByMilestone(FragmentRefreshListenerFilterIssuesByMilestone fragmentRefreshListener) { this.fragmentRefreshListenerFilterIssuesByMilestone = fragmentRefreshListener; } - - public interface FragmentRefreshListenerFilterIssuesByMilestone { void onRefresh(String text); } + public void setFragmentRefreshListenerFilterIssuesByMilestone(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListenerFilterIssuesByMilestone = fragmentRefreshListener; } // Issues interface public FragmentRefreshListener getFragmentRefreshListener() { return fragmentRefreshListener; } public void setFragmentRefreshListener(FragmentRefreshListener fragmentRefreshListener) { this.fragmentRefreshListener = fragmentRefreshListener; } - public interface FragmentRefreshListener { void onRefresh(String text); } - // Pull request interface - public FragmentRefreshListenerPr getFragmentRefreshListenerPr() { return fragmentRefreshListenerPr; } + public FragmentRefreshListener getFragmentRefreshListenerPr() { return fragmentRefreshListenerPr; } - public void setFragmentRefreshListenerPr(FragmentRefreshListenerPr fragmentRefreshListenerPr) { this.fragmentRefreshListenerPr = fragmentRefreshListenerPr; } - - public interface FragmentRefreshListenerPr { void onRefresh(String text); } + public void setFragmentRefreshListenerPr(FragmentRefreshListener fragmentRefreshListenerPr) { this.fragmentRefreshListenerPr = fragmentRefreshListenerPr; } // Milestones interface - public FragmentRefreshListenerMilestone getFragmentRefreshListenerMilestone() { return fragmentRefreshListenerMilestone; } + public FragmentRefreshListener getFragmentRefreshListenerMilestone() { return fragmentRefreshListenerMilestone; } - public void setFragmentRefreshListenerMilestone(FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone) { this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone; } - - public interface FragmentRefreshListenerMilestone { void onRefresh(String text); } + public void setFragmentRefreshListenerMilestone(FragmentRefreshListener fragmentRefreshListenerMilestone) { this.fragmentRefreshListenerMilestone = fragmentRefreshListenerMilestone; } // Files interface - public FragmentRefreshListenerFiles getFragmentRefreshListenerFiles() { return fragmentRefreshListenerFiles; } + public FragmentRefreshListener getFragmentRefreshListenerFiles() { return fragmentRefreshListenerFiles; } - public void setFragmentRefreshListenerFiles(FragmentRefreshListenerFiles fragmentRefreshListenerFiles) { this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles; } - - public interface FragmentRefreshListenerFiles { void onRefresh(String text); } + public void setFragmentRefreshListenerFiles(FragmentRefreshListener fragmentRefreshListenerFiles) { this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles; } } diff --git a/app/src/main/java/org/mian/gitnex/structs/FragmentRefreshListener.java b/app/src/main/java/org/mian/gitnex/structs/FragmentRefreshListener.java new file mode 100644 index 00000000..725365ce --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/structs/FragmentRefreshListener.java @@ -0,0 +1,7 @@ +package org.mian.gitnex.structs; + +public interface FragmentRefreshListener { + + void onRefresh(String text); + +} diff --git a/app/src/main/java/org/mian/gitnex/structs/Protocol.java b/app/src/main/java/org/mian/gitnex/structs/Protocol.java new file mode 100644 index 00000000..ab860b74 --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/structs/Protocol.java @@ -0,0 +1,3 @@ +package org.mian.gitnex.structs; + +public enum Protocol {HTTPS, HTTP}