Skip to content

Commit

Permalink
Merge branch 'hotfix/1.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrer757 committed Oct 5, 2017
2 parents ed53288 + 718b0d8 commit a629961
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [1.4.1] - 2017-10-05
### Fixed
- [#5](https://github.com/Simdea/gmlrva/issues/5), Not updating view types when add, remove or update the recycler view elements.

## [1.4] - 2017-10-05
### Added
- CHANGELOG.md file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Configuration
```gradle
dependencies {
...
compile 'pt.simdea:gmlrva.lib:1.4'
compile 'pt.simdea:gmlrva.lib:1.4.1'
...
}
```
Expand Down
2 changes: 1 addition & 1 deletion gmlrva-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ project.ext {
description = 'Generic RecyclerView Adapter that supports multiple layouts.'
groupId = 'pt.simdea'
artifactId = 'gmlrva.lib'
version = "1.4"
version = "1.4.1"
website = 'https://github.com/simdea/gmlrva'
scm = 'https://github.com/simdea/gmlrva'
tags = ['android', 'recyclerview', 'adapter', 'generic', 'multiple', 'layout']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ public class GenericMultipleLayoutAdapter extends RecyclerView.Adapter<RecyclerV
private final Context mContext;
private final List<IGenericRecyclerViewLayout> mDataSet;
private final boolean mSkipQueuedUpdates;

/* View Type Auxiliary Variable */
private final SparseArray<IGenericRecyclerViewLayout> mViewTypes = new SparseArray<>();

/* UI & Worker Thread Variables */
private final ArrayDeque<List<? extends IGenericRecyclerViewLayout>> mPendingUpdates = new ArrayDeque<>();
private final Handler mHandler = new Handler();
/* View Type Auxiliary Variable */
private SparseArray<IGenericRecyclerViewLayout> mViewTypes;

/**
* Instantiates a new GenericMultipleLayoutAdapter.
Expand Down Expand Up @@ -102,6 +100,7 @@ public GenericMultipleLayoutAdapter(@NonNull final List<? extends IGenericRecycl
= new ArrayList<>(mPendingUpdates.isEmpty() ? mDataSet : mPendingUpdates.peekLast());
newList.add(item);
updateList(newList);
updateViewTypes();
}

/**
Expand All @@ -114,6 +113,7 @@ public GenericMultipleLayoutAdapter(@NonNull final List<? extends IGenericRecycl
= new ArrayList<>(mPendingUpdates.isEmpty() ? mDataSet : mPendingUpdates.peekLast());
newList.addAll(items);
updateList(newList);
updateViewTypes();
}

/**
Expand All @@ -129,6 +129,7 @@ public GenericMultipleLayoutAdapter(@NonNull final List<? extends IGenericRecycl
= new ArrayList<>(mPendingUpdates.isEmpty() ? mDataSet : mPendingUpdates.peekLast());
newList.add(position, item);
updateList(newList);
updateViewTypes();
}

/**
Expand All @@ -142,6 +143,7 @@ public GenericMultipleLayoutAdapter(@NonNull final List<? extends IGenericRecycl
if (!newList.isEmpty() && newList.contains(item)) {
newList.remove(item);
updateList(newList);
updateViewTypes();
}
}

Expand All @@ -166,6 +168,7 @@ public GenericMultipleLayoutAdapter(@NonNull final List<? extends IGenericRecycl
if (!newList.isEmpty() && !items.isEmpty()) {
newList.removeAll(items);
updateList(newList);
updateViewTypes();
}
}

Expand Down Expand Up @@ -200,6 +203,7 @@ public GenericMultipleLayoutAdapter(@NonNull final List<? extends IGenericRecycl
mPendingUpdates.add(items);
if (mPendingUpdates.size() == 1) {
innerUpdateList(items); // no pending update, so execute the update
updateViewTypes();
}
}

Expand Down Expand Up @@ -277,6 +281,7 @@ private void applyPayloadChange(final int position, @NonNull final Bundle payloa

/** Procedure meant to update this Adapter's handled View Types. */
private void updateViewTypes() {
mViewTypes = new SparseArray<>();
for (final IGenericRecyclerViewLayout item : mDataSet) {
if (mViewTypes.get(item.getViewType()) == null) {
mViewTypes.put(item.getViewType(), item);
Expand Down

0 comments on commit a629961

Please sign in to comment.