Skip to content

Commit

Permalink
Fixed #606 - Selection Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
davideas committed May 7, 2018
1 parent d9e3b6f commit b77cc53
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ protected boolean isViewCollapsibleOnClick() {
* @return always true, if not overridden
* @since 5.0.0-b1
*/
@Override
protected boolean isViewCollapsibleOnLongClick() {
return true;//default=true
}
Expand Down
4 changes: 2 additions & 2 deletions flexible-adapter-app/version.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Sun Apr 29 23:38:35 CEST 2018
#Tue May 08 00:20:53 CEST 2018
MAJOR=5
MINOR=0
PATCH=0
PRE_RELEASE=
BUILD=5541
BUILD=5571
CODE=23
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public FlexibleAdapter<T> removeListener(Object listener) {
*/
@CallSuper
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
log.v("Attached Adapter to RecyclerView");
if (headersShown && areHeadersSticky()) {
Expand All @@ -404,7 +404,7 @@ public void onAttachedToRecyclerView(RecyclerView recyclerView) {
*/
@CallSuper
@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
if (areHeadersSticky()) {
mStickyHeaderHelper.detachFromRecyclerView();
mStickyHeaderHelper = null;
Expand Down Expand Up @@ -613,8 +613,6 @@ public void updateDataSet(@Nullable List<T> items) {
public void updateDataSet(@Nullable List<T> items, boolean animate) {
mOriginalList = null; // Reset original list from filter
if (items == null) items = new ArrayList<>();
// Always clear cache of bound view holders
discardBoundViewHolders();
if (animate) {
mHandler.removeMessages(UPDATE);
mHandler.sendMessage(Message.obtain(mHandler, UPDATE, items));
Expand Down Expand Up @@ -1767,7 +1765,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
* @since 5.0.0-b1
*/
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position, List payloads) {
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
if (!autoMap) {
// If everything has been set properly, this should never happen ;-)
throw new IllegalStateException("AutoMap is not active, this method cannot be called. You should implement the AutoMap properly.");
Expand Down Expand Up @@ -1814,7 +1812,7 @@ public void onViewDetachedFromWindow(@NonNull RecyclerView.ViewHolder holder) {

@CallSuper
@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
if (areHeadersSticky()) {
// #297 - Empty (Invisible) Header Item when Using Sticky Headers
Expand Down Expand Up @@ -5488,6 +5486,10 @@ protected void onPostExecute(Void result) {
}

private void prepareItemsForUpdate(List<T> newItems) {
// Clear cache of bound view holders
if (notifyChangeOfUnfilteredItems) {
discardBoundViewHolders();
}
// Display Scrollable Headers and Footers
restoreScrollableHeadersAndFooters(newItems);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
Expand Down Expand Up @@ -156,7 +157,7 @@ public static void useTag(String tag) {
* @since 5.0.0-b6
*/
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
if (mFastScrollerDelegate != null) {
mFastScrollerDelegate.onAttachedToRecyclerView(recyclerView);
Expand All @@ -171,7 +172,7 @@ public void onAttachedToRecyclerView(RecyclerView recyclerView) {
* @since 5.0.0-b6
*/
@Override
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
super.onDetachedFromRecyclerView(recyclerView);
if (mFastScrollerDelegate != null) {
mFastScrollerDelegate.onDetachedFromRecyclerView(recyclerView);
Expand Down Expand Up @@ -473,7 +474,7 @@ private void notifySelectionChanged(int positionStart, int itemCount) {
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List payloads) {
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
// Bind the correct view elevation
if (holder instanceof FlexibleViewHolder) {
FlexibleViewHolder flexHolder = (FlexibleViewHolder) holder;
Expand All @@ -496,7 +497,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, List
}

@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof FlexibleViewHolder) {
boolean recycled = mBoundViewHolders.remove(holder);
log.v("onViewRecycled viewSize=%s %s %s recycled=%s", mBoundViewHolders.size(), getClassName(holder), holder, recycled);
Expand Down Expand Up @@ -562,7 +563,6 @@ public Set<Integer> getSelectedPositionsAsSet() {
* @since 1.0.0
*/
public void onSaveInstanceState(Bundle outState) {
discardBoundViewHolders();
outState.putIntegerArrayList(TAG, new ArrayList<>(mSelectedPositions));
if (getSelectedItemCount() > 0) log.d("Saving selection %s", mSelectedPositions);
}
Expand Down

0 comments on commit b77cc53

Please sign in to comment.