Commit 39fbcb80 authored by Yusuke Iwaki's avatar Yusuke Iwaki

fix coding styles.

parent c43c00f8
...@@ -3,20 +3,24 @@ package chat.rocket.android.helper; ...@@ -3,20 +3,24 @@ package chat.rocket.android.helper;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@SuppressWarnings("PMD.AbstractNaming")
public abstract class LoadMoreScrollListener extends RecyclerView.OnScrollListener { public abstract class LoadMoreScrollListener extends RecyclerView.OnScrollListener {
private final LinearLayoutManager layoutManager; private final LinearLayoutManager layoutManager;
private final int loadThreshold; private final int loadThreshold;
private boolean isLoading; private boolean isLoading;
/**
* constructor. loadThreshold is better to set to 0.4 * total.
*/
public LoadMoreScrollListener(LinearLayoutManager layoutManager, int loadThreshold) { public LoadMoreScrollListener(LinearLayoutManager layoutManager, int loadThreshold) {
this.layoutManager = layoutManager; this.layoutManager = layoutManager;
this.loadThreshold = loadThreshold; this.loadThreshold = loadThreshold;
setLoadingDone(); setLoadingDone();
} }
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { @Override public void onScrolled(RecyclerView recyclerView, int deltaX, int deltaY) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, deltaX, deltaY);
final int visibleItemCount = recyclerView.getChildCount(); final int visibleItemCount = recyclerView.getChildCount();
final int totalItemCount = layoutManager.getItemCount(); final int totalItemCount = layoutManager.getItemCount();
...@@ -25,7 +29,7 @@ public abstract class LoadMoreScrollListener extends RecyclerView.OnScrollListen ...@@ -25,7 +29,7 @@ public abstract class LoadMoreScrollListener extends RecyclerView.OnScrollListen
if (!isLoading if (!isLoading
&& firstVisibleItem + visibleItemCount >= totalItemCount - loadThreshold && firstVisibleItem + visibleItemCount >= totalItemCount - loadThreshold
&& visibleItemCount < totalItemCount && visibleItemCount < totalItemCount
&& dy < 0) { && deltaY < 0) {
isLoading = true; isLoading = true;
requestMoreItem(); requestMoreItem();
} }
......
...@@ -6,6 +6,7 @@ import chat.rocket.android.realm_helper.RealmModelListAdapter; ...@@ -6,6 +6,7 @@ import chat.rocket.android.realm_helper.RealmModelListAdapter;
import chat.rocket.android.realm_helper.RealmModelViewHolder; import chat.rocket.android.realm_helper.RealmModelViewHolder;
import io.realm.RealmObject; import io.realm.RealmObject;
@SuppressWarnings({"PMD.AbstractNaming", "PMD.GenericsNaming"})
/** /**
* RealmModelListAdapter with header and footer. * RealmModelListAdapter with header and footer.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment