mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-28 12:57:57 +01:00
pmd:ImmutableField - Immutable Field (#282)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user