From ff6eefe1c4d813253289c290e272ce76b5178192 Mon Sep 17 00:00:00 2001 From: Mohamed Ezzat Date: Thu, 28 Apr 2016 18:46:05 +0200 Subject: [PATCH] pmd:ImmutableField - Immutable Field (#282) --- .../tachiyomi/data/source/online/english/Batoto.java | 4 ++-- .../kanade/tachiyomi/ui/base/activity/BaseRxActivity.java | 2 +- .../ui/base/adapter/SmartFragmentStatePagerAdapter.java | 2 +- .../ui/base/decoration/DividerItemDecoration.java | 2 +- .../kanade/tachiyomi/ui/base/fragment/BaseRxFragment.java | 2 +- .../tachiyomi/widget/EndlessGridScrollListener.java | 8 ++++---- .../tachiyomi/widget/EndlessListScrollListener.java | 6 +++--- .../eu/kanade/tachiyomi/widget/EndlessScrollListener.java | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.java b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.java index 6fe743f5f2..66986103eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/english/Batoto.java @@ -54,8 +54,8 @@ public class Batoto extends LoginSource { public static final Pattern staffNotice = Pattern.compile("=+Batoto Staff Notice=+([^=]+)==+", Pattern.CASE_INSENSITIVE); - private Pattern datePattern; - private Map dateFields; + private final Pattern datePattern; + private final Map dateFields; public Batoto(Context context) { super(context); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java index 3592547937..910697d8d3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java @@ -22,7 +22,7 @@ public abstract class BaseRxActivity

extends BaseActivity i private static final String PRESENTER_STATE_KEY = "presenter_state"; - private PresenterLifecycleDelegate

presenterDelegate = + private final PresenterLifecycleDelegate

presenterDelegate = new PresenterLifecycleDelegate<>(ReflectionPresenterFactory.

fromViewClass(getClass())); /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java index d90cdff9ae..3756df15e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java @@ -11,7 +11,7 @@ import java.util.List; public abstract class SmartFragmentStatePagerAdapter extends FragmentStatePagerAdapter { // Sparse array to keep track of registered fragments in memory - private SparseArray registeredFragments = new SparseArray(); + private final SparseArray registeredFragments = new SparseArray(); public SmartFragmentStatePagerAdapter(FragmentManager fragmentManager) { super(fragmentManager); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/decoration/DividerItemDecoration.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/decoration/DividerItemDecoration.java index 22e3dadf86..8c7469d8ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/decoration/DividerItemDecoration.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/decoration/DividerItemDecoration.java @@ -12,7 +12,7 @@ import android.view.View; public class DividerItemDecoration extends RecyclerView.ItemDecoration { - private Drawable mDivider; + private final Drawable mDivider; public DividerItemDecoration(Context context, AttributeSet attrs) { final TypedArray a = context.obtainStyledAttributes(attrs, new int [] { android.R.attr.listDivider }); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.java index e03e6a1cae..a0cb917986 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.java @@ -20,7 +20,7 @@ import nucleus.view.ViewWithPresenter; public abstract class BaseRxFragment

extends BaseFragment implements ViewWithPresenter

{ private static final String PRESENTER_STATE_KEY = "presenter_state"; - private PresenterLifecycleDelegate

presenterDelegate = + private final PresenterLifecycleDelegate

presenterDelegate = new PresenterLifecycleDelegate<>(ReflectionPresenterFactory.

fromViewClass(getClass())); /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessGridScrollListener.java b/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessGridScrollListener.java index efad9c911d..e49430d973 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessGridScrollListener.java +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessGridScrollListener.java @@ -9,12 +9,12 @@ public class EndlessGridScrollListener extends RecyclerView.OnScrollListener { private int previousTotal = 0; // The total number of items in the dataset after the last load private boolean loading = true; // True if we are still waiting for the last set of data to load. - private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. + private static final int VISIBLE_THRESHOLD = 5; // The minimum amount of items to have below your current scroll position before loading more. private int firstVisibleItem, visibleItemCount, totalItemCount; - private GridLayoutManager layoutManager; + private final GridLayoutManager layoutManager; - private Action0 requestNext; + private final Action0 requestNext; public EndlessGridScrollListener(GridLayoutManager layoutManager, Action0 requestNext) { this.layoutManager = layoutManager; @@ -39,7 +39,7 @@ public class EndlessGridScrollListener extends RecyclerView.OnScrollListener { previousTotal = totalItemCount; } if (!loading && (totalItemCount - visibleItemCount) - <= (firstVisibleItem + visibleThreshold)) { + <= (firstVisibleItem + VISIBLE_THRESHOLD)) { // End has been reached requestNext.call(); loading = true; diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessListScrollListener.java b/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessListScrollListener.java index 1667d15c83..768f6bd28a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessListScrollListener.java +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessListScrollListener.java @@ -9,12 +9,12 @@ public class EndlessListScrollListener extends RecyclerView.OnScrollListener { private int previousTotal = 0; // The total number of items in the dataset after the last load private boolean loading = true; // True if we are still waiting for the last set of data to load. - private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. + private static final int VISIBLE_THRESHOLD = 5; // The minimum amount of items to have below your current scroll position before loading more. private int firstVisibleItem, visibleItemCount, totalItemCount; private LinearLayoutManager layoutManager; - private Action0 requestNext; + private final Action0 requestNext; public EndlessListScrollListener(LinearLayoutManager layoutManager, Action0 requestNext) { this.layoutManager = layoutManager; @@ -39,7 +39,7 @@ public class EndlessListScrollListener extends RecyclerView.OnScrollListener { previousTotal = totalItemCount; } if (!loading && (totalItemCount - visibleItemCount) - <= (firstVisibleItem + visibleThreshold)) { + <= (firstVisibleItem + VISIBLE_THRESHOLD)) { // End has been reached requestNext.call(); loading = true; diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessScrollListener.java b/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessScrollListener.java index eea94da122..98e20aa080 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessScrollListener.java +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EndlessScrollListener.java @@ -7,13 +7,13 @@ import rx.functions.Action0; public class EndlessScrollListener implements AbsListView.OnScrollListener { // The minimum amount of items to have below your current scroll position // before loading more. - private int visibleThreshold = 5; + private static final int VISIBLE_THRESHOLD = 5; // The total number of items in the dataset after the last load private int previousTotalItemCount = 0; // True if we are still waiting for the last set of data to load. private boolean loading = true; - private Action0 requestNext; + private final Action0 requestNext; public EndlessScrollListener(Action0 requestNext) { this.requestNext = requestNext; @@ -47,7 +47,7 @@ public class EndlessScrollListener implements AbsListView.OnScrollListener { // If it isn’t currently loading, we check to see if we have breached // the visibleThreshold and need to reload more data. // If we do need to reload some more data, we execute onLoadMore to fetch the data. - if (!loading && (totalItemCount - visibleItemCount)<=(firstVisibleItem + visibleThreshold)) { + if (!loading && (totalItemCount - visibleItemCount)<=(firstVisibleItem + VISIBLE_THRESHOLD)) { requestNext.call(); loading = true; }