Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
davideas committed Feb 13, 2017
2 parents f1aff7f + 12d5e2d commit f156c4c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ private void initializeRecyclerView(Bundle savedInstanceState) {
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);

// EndlessScrollListener - OnLoadMore (v5.0.0)
mAdapter.setEndlessScrollListener(this, mProgressItem)
mAdapter//.setLoadingMoreAtStartUp(true) //To call only if the list is empty
//.setEndlessPageSize(3) //Endless is automatically disabled if newItems < 3
.setEndlessTargetCount(15); //Endless is automatically disabled if totalItems >= 15
.setEndlessTargetCount(15) //Endless is automatically disabled if totalItems >= 15
//.setEndlessScrollThreshold(1); //Default=1
.setEndlessScrollListener(this, mProgressItem);

// Add 1 Scrollable Header and 1 Footer items
mAdapter.showLayoutInfo(savedInstanceState == null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public FlexibleAdapter(@Nullable List<T> items, @Nullable Object listeners, bool
* @deprecated Use {@link #addListener(Object)}
*/
@Deprecated
public FlexibleAdapter initializeListeners(@Nullable Object listener) {
public FlexibleAdapter<T> initializeListeners(@Nullable Object listener) {
return addListener(listener);
}

Expand All @@ -270,7 +270,7 @@ public FlexibleAdapter initializeListeners(@Nullable Object listener) {
* @since 5.0.0-b6
*/
@CallSuper
public FlexibleAdapter addListener(@Nullable Object listener) {
public FlexibleAdapter<T> addListener(@Nullable Object listener) {
if (DEBUG && listener != null) {
Log.i(TAG, "Adding listener class " + getClassName(listener) + " as:");
}
Expand Down Expand Up @@ -340,7 +340,7 @@ public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b6
*/
public FlexibleAdapter expandItemsAtStartUp() {
public FlexibleAdapter<T> expandItemsAtStartUp() {
int position = 0;
setScrollAnimate(true);
multiRange = true;
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public boolean isRemoveOrphanHeaders() {
* references, most of the time, user has the control on the items to remove, headers as well.
*/
@Deprecated
public FlexibleAdapter setRemoveOrphanHeaders(boolean removeOrphanHeaders) {
public FlexibleAdapter<T> setRemoveOrphanHeaders(boolean removeOrphanHeaders) {
if (DEBUG) Log.i(TAG, "Set removeOrphanHeaders=" + removeOrphanHeaders);
this.removeOrphanHeaders = removeOrphanHeaders;
return this;
Expand All @@ -1052,7 +1052,7 @@ public FlexibleAdapter setRemoveOrphanHeaders(boolean removeOrphanHeaders) {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b6
*/
public FlexibleAdapter setUnlinkAllItemsOnRemoveHeaders(boolean unlinkOnRemoveHeader) {
public FlexibleAdapter<T> setUnlinkAllItemsOnRemoveHeaders(boolean unlinkOnRemoveHeader) {
if (DEBUG) Log.i(TAG, "Set unlinkOnRemoveHeader=" + unlinkOnRemoveHeader);
this.unlinkOnRemoveHeader = unlinkOnRemoveHeader;
return this;
Expand Down Expand Up @@ -1087,7 +1087,7 @@ public List<IHeader> getOrphanHeaders() {
* this method also show header, for that we should use add item or section.
*/
@Deprecated
public FlexibleAdapter linkHeaderTo(@NonNull T item, @NonNull IHeader header) {
public FlexibleAdapter<T> linkHeaderTo(@NonNull T item, @NonNull IHeader header) {
linkHeaderTo(item, header, Payload.LINK);
if (header.isHidden() && headersShown) {
showHeaderOf(getGlobalPositionOf(item), item, false);
Expand Down Expand Up @@ -1299,7 +1299,7 @@ public boolean areHeadersSticky() {
* @deprecated Use {@link #setStickyHeaders(boolean)} with {@code true} as parameter.
*/
@Deprecated
public FlexibleAdapter enableStickyHeader() {
public FlexibleAdapter<T> enableStickyHeader() {
return setStickyHeaders(true);
}

Expand Down Expand Up @@ -1358,7 +1358,7 @@ public void disableStickyHeaders() {
* @see #setStickyHeaderElevation(float)
* @since 5.0.0-rc1
*/
public FlexibleAdapter setStickyHeaders(boolean sticky) {
public FlexibleAdapter<T> setStickyHeaders(boolean sticky) {
return setStickyHeaders(sticky, mStickyContainer);
}

Expand All @@ -1376,7 +1376,7 @@ public FlexibleAdapter setStickyHeaders(boolean sticky) {
* @see #setStickyHeaderElevation(float)
* @since 5.0.0-rc1
*/
public FlexibleAdapter setStickyHeaders(final boolean sticky, @NonNull ViewGroup stickyContainer) {
public FlexibleAdapter<T> setStickyHeaders(final boolean sticky, @NonNull ViewGroup stickyContainer) {
if (DEBUG) Log.i(TAG, "Set stickyHeaders=" + sticky + " (in Post!)" +
(stickyContainer != null ? " with user defined Sticky Container" : ""));

Expand Down Expand Up @@ -1429,7 +1429,7 @@ public float getStickyHeaderElevation() {
* @see #getStickyHeaderElevation()
* @since 5.0.0-rc1
*/
public FlexibleAdapter setStickyHeaderElevation(@FloatRange(from = 0) float stickyElevation) {
public FlexibleAdapter<T> setStickyHeaderElevation(@FloatRange(from = 0) float stickyElevation) {
mStickyElevation = stickyElevation;
return this;
}
Expand Down Expand Up @@ -1482,7 +1482,7 @@ public ViewGroup getStickyHeaderContainer() {
* @deprecated Use {@link #setStickyHeaders(boolean, ViewGroup)}.
*/
@Deprecated
public FlexibleAdapter setStickyHeaderContainer(@NonNull ViewGroup stickyContainer) {
public FlexibleAdapter<T> setStickyHeaderContainer(@NonNull ViewGroup stickyContainer) {
if (mStickyHeaderHelper != null) {
Log.w(TAG, "StickyHeader has been already initialized! Call this method before enabling StickyHeaders");
}
Expand All @@ -1506,7 +1506,7 @@ public FlexibleAdapter setStickyHeaderContainer(@NonNull ViewGroup stickyContain
* @see #setAnimationOnScrolling(boolean)
* @since 5.0.0-b6
*/
public FlexibleAdapter setDisplayHeadersAtStartUp(boolean displayHeaders) {
public FlexibleAdapter<T> setDisplayHeadersAtStartUp(boolean displayHeaders) {
if (!headersShown && displayHeaders) {
showAllHeaders(true);
}
Expand All @@ -1524,7 +1524,7 @@ public FlexibleAdapter setDisplayHeadersAtStartUp(boolean displayHeaders) {
* @see #setDisplayHeadersAtStartUp(boolean)
* @since 5.0.0-b1
*/
public FlexibleAdapter showAllHeaders() {
public FlexibleAdapter<T> showAllHeaders() {
showAllHeaders(false);
return this;
}
Expand Down Expand Up @@ -1933,7 +1933,8 @@ public int getEndlessPageSize() {
* @return this Adapter, so the call can be chained
* @since 5.0.0-rc1
*/
public FlexibleAdapter setEndlessPageSize(@IntRange(from = 0) int endlessPageSize) {
public FlexibleAdapter<T> setEndlessPageSize(@IntRange(from = 0) int endlessPageSize) {
if (DEBUG) Log.i(TAG, "Set endlessPageSize=" + endlessPageSize);
mEndlessPageSize = endlessPageSize;
return this;
}
Expand Down Expand Up @@ -1963,11 +1964,33 @@ public int getEndlessTargetCount() {
* @see #getEndlessTargetCount()
* @since 5.0.0-rc1
*/
public FlexibleAdapter setEndlessTargetCount(@IntRange(from = 0) int endlessTargetCount) {
public FlexibleAdapter<T> setEndlessTargetCount(@IntRange(from = 0) int endlessTargetCount) {
if (DEBUG) Log.i(TAG, "Set endlessTargetCount=" + endlessTargetCount);
mEndlessTargetCount = endlessTargetCount;
return this;
}

/**
* Sets if Endless / Loading More should be triggered at start-up, especially when the
* list is empty.
* <p>Default value is {@code false}.</p>
*
* @param enable true to trigger a loading at start up, false to trigger loading with binding
* @return this Adapter, so the call can be chained
*/
public FlexibleAdapter<T> setLoadingMoreAtStartUp(boolean enable) {
if (DEBUG) Log.i(TAG, "Set loadingAtStartup=" + enable);
if (enable) {
mHandler.post(new Runnable() {
@Override
public void run() {
onLoadMore(0);
}
});
}
return this;
}

/**
* Sets the progressItem to be displayed at the end of the list and activate the Loading More
* feature.
Expand All @@ -1981,7 +2004,7 @@ public FlexibleAdapter setEndlessTargetCount(@IntRange(from = 0) int endlessTarg
* @see #setEndlessScrollListener(EndlessScrollListener, IFlexible)
* @since 5.0.0-b8
*/
public FlexibleAdapter setEndlessProgressItem(@Nullable T progressItem) {
public FlexibleAdapter<T> setEndlessProgressItem(@Nullable T progressItem) {
endlessScrollEnabled = progressItem != null;
if (progressItem != null) {
setEndlessScrollThreshold(mEndlessScrollThreshold);
Expand All @@ -2008,7 +2031,7 @@ public FlexibleAdapter setEndlessProgressItem(@Nullable T progressItem) {
* @see #setEndlessProgressItem(IFlexible)
* @since 5.0.0-b6
*/
public FlexibleAdapter setEndlessScrollListener(@Nullable EndlessScrollListener endlessScrollListener,
public FlexibleAdapter<T> setEndlessScrollListener(@Nullable EndlessScrollListener endlessScrollListener,
@NonNull T progressItem) {
if (DEBUG) Log.i(TAG, "Set endlessScrollListener=" + getClassName(endlessScrollListener));
mEndlessScrollListener = endlessScrollListener;
Expand All @@ -2023,7 +2046,7 @@ public FlexibleAdapter setEndlessScrollListener(@Nullable EndlessScrollListener
* @return this Adapter, so the call can be chained
* @since 5.0.0-b6
*/
public FlexibleAdapter setEndlessScrollThreshold(@IntRange(from = 1) int thresholdItems) {
public FlexibleAdapter<T> setEndlessScrollThreshold(@IntRange(from = 1) int thresholdItems) {
// Increase visible threshold based on number of columns
if (mRecyclerView != null) {
int spanCount = Utils.getSpanCount(mRecyclerView.getLayoutManager());
Expand Down Expand Up @@ -2185,7 +2208,7 @@ public boolean isAutoCollapseOnExpand() {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b1
*/
public FlexibleAdapter setAutoCollapseOnExpand(boolean collapseOnExpand) {
public FlexibleAdapter<T> setAutoCollapseOnExpand(boolean collapseOnExpand) {
if (DEBUG) Log.i(TAG, "Set autoCollapseOnExpand=" + collapseOnExpand);
this.collapseOnExpand = collapseOnExpand;
return this;
Expand All @@ -2209,7 +2232,7 @@ public boolean isAutoScrollOnExpand() {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b1
*/
public FlexibleAdapter setAutoScrollOnExpand(boolean scrollOnExpand) {
public FlexibleAdapter<T> setAutoScrollOnExpand(boolean scrollOnExpand) {
if (DEBUG) Log.i(TAG, "Set setAutoScrollOnExpand=" + scrollOnExpand);
this.scrollOnExpand = scrollOnExpand;
return this;
Expand Down Expand Up @@ -2264,7 +2287,7 @@ public int getMinCollapsibleLevel() {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b6
*/
public FlexibleAdapter setMinCollapsibleLevel(int minCollapsibleLevel) {
public FlexibleAdapter<T> setMinCollapsibleLevel(int minCollapsibleLevel) {
if (DEBUG) Log.i(TAG, "Set minCollapsibleLevel=" + minCollapsibleLevel);
this.mMinCollapsibleLevel = minCollapsibleLevel;
return this;
Expand Down Expand Up @@ -3525,7 +3548,7 @@ public boolean isPermanentDelete() {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b6
*/
public FlexibleAdapter setPermanentDelete(boolean permanentDelete) {
public FlexibleAdapter<T> setPermanentDelete(boolean permanentDelete) {
if (DEBUG) Log.i(TAG, "Set permanentDelete=" + permanentDelete);
this.permanentDelete = permanentDelete;
return this;
Expand Down Expand Up @@ -3553,7 +3576,7 @@ public boolean isRestoreWithSelection() {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b1
*/
public FlexibleAdapter setRestoreSelectionOnUndo(boolean restoreSelection) {
public FlexibleAdapter<T> setRestoreSelectionOnUndo(boolean restoreSelection) {
if (DEBUG) Log.i(TAG, "Set restoreSelectionOnUndo=" + restoreSelection);
this.restoreSelection = restoreSelection;
return this;
Expand Down Expand Up @@ -4097,7 +4120,7 @@ private void resetFilterFlags(List<T> items) {
* @return this Adapter, so the call can be chained
* @since 5.0.0-b8
*/
public FlexibleAdapter setAnimateToLimit(int limit) {
public FlexibleAdapter<T> setAnimateToLimit(int limit) {
if (DEBUG) Log.i(TAG, "Set animateToLimit=" + limit);
mAnimateToLimit = limit;
return this;
Expand Down Expand Up @@ -4133,7 +4156,7 @@ public boolean isAnimateChangesWithDiffUtil() {
* final release.
*/
@Deprecated
public FlexibleAdapter setAnimateChangesWithDiffUtil(boolean useDiffUtil) {
public FlexibleAdapter<T> setAnimateChangesWithDiffUtil(boolean useDiffUtil) {
this.useDiffUtil = useDiffUtil;
return this;
}
Expand All @@ -4149,7 +4172,7 @@ public FlexibleAdapter setAnimateChangesWithDiffUtil(boolean useDiffUtil) {
* final release.
*/
@Deprecated
public FlexibleAdapter setDiffUtilCallback(DiffUtilCallback diffUtilCallback) {
public FlexibleAdapter<T> setDiffUtilCallback(DiffUtilCallback diffUtilCallback) {
this.diffUtilCallback = diffUtilCallback;
return this;
}
Expand Down

0 comments on commit f156c4c

Please # to comment.