Skip to content

Commit

Permalink
Merge branch 'release/v0.4.2-SNAPSHOT'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 6, 2016
2 parents 135846b + 60e2559 commit 975d508
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Beside being blazing fast, minimizing the code you need to write, it is also rea
#Include in your project
##Using Maven
```javascript
compile('com.mikepenz:fastadapter:0.4.1-SNAPSHOT@aar') {
compile('com.mikepenz:fastadapter:0.4.2-SNAPSHOT@aar') {
transitive = true
}

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.mikepenz.crossfader.app"
minSdkVersion 11
targetSdkVersion 23
versionCode 41
versionName '0.4.1-SNAPSHOT'
versionCode 42
versionName '0.4.2-SNAPSHOT'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ org.gradle.daemon=true
org.gradle.parallel=true

# Maven stuff
VERSION_NAME=0.4.1-SNAPSHOT
VERSION_CODE=41
VERSION_NAME=0.4.2-SNAPSHOT
VERSION_CODE=42
GROUP=com.mikepenz

POM_DESCRIPTION=FastAdapter Library
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 41
versionName '0.4.1-SNAPSHOT'
versionCode 42
versionName '0.4.2-SNAPSHOT'
}
buildTypes {
release {
Expand Down
42 changes: 22 additions & 20 deletions library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ public void onClick(View v) {
int pos = holder.getAdapterPosition();
if (pos != RecyclerView.NO_POSITION) {
boolean consumed = false;
if (mOnClickListener != null) {
RelativeInfo relativeInfo = getRelativeInfo(pos);
consumed = mOnClickListener.onClick(v, relativeInfo.adapter, (IItem) relativeInfo.item, pos);
}

if (!consumed && (!(mMultiSelect && mMultiSelectOnLongClick) || !mMultiSelect)) {
handleSelection(pos);
RelativeInfo<Item> relativeInfo = getRelativeInfo(pos);
if (relativeInfo.item != null && relativeInfo.item.isEnabled()) {
if (mOnClickListener != null) {
consumed = mOnClickListener.onClick(v, relativeInfo.adapter, relativeInfo.item, pos);
}

if (!consumed && (!(mMultiSelect && mMultiSelectOnLongClick) || !mMultiSelect)) {
handleSelection(relativeInfo.item, pos);
}
}
}
}
Expand All @@ -213,13 +215,15 @@ public boolean onLongClick(View v) {
int pos = holder.getAdapterPosition();
if (pos != RecyclerView.NO_POSITION) {
boolean consumed = false;
if (mOnLongClickListener != null) {
RelativeInfo relativeInfo = getRelativeInfo(pos);
consumed = mOnLongClickListener.onLongClick(v, relativeInfo.adapter, (IItem) relativeInfo.item, pos);
}

if (!consumed && (mMultiSelect && mMultiSelectOnLongClick)) {
handleSelection(pos);
RelativeInfo<Item> relativeInfo = getRelativeInfo(pos);
if (relativeInfo.item != null && relativeInfo.item.isEnabled()) {
if (mOnLongClickListener != null) {
consumed = mOnLongClickListener.onLongClick(v, relativeInfo.adapter, relativeInfo.item, pos);
}

if (!consumed && (mMultiSelect && mMultiSelectOnLongClick)) {
handleSelection(relativeInfo.item, pos);
}
}
return consumed;
}
Expand All @@ -233,8 +237,8 @@ public boolean onTouch(View v, MotionEvent event) {
if (mOnTouchListener != null) {
int pos = holder.getAdapterPosition();
if (pos != RecyclerView.NO_POSITION) {
RelativeInfo relativeInfo = getRelativeInfo(pos);
return mOnTouchListener.onTouch(v, event, relativeInfo.adapter, (IItem) relativeInfo.item, pos);
RelativeInfo<Item> relativeInfo = getRelativeInfo(pos);
return mOnTouchListener.onTouch(v, event, relativeInfo.adapter, relativeInfo.item, pos);
}
}
return false;
Expand Down Expand Up @@ -310,8 +314,7 @@ public RelativeInfo<Item> getRelativeInfo(int position) {
RelativeInfo<Item> relativeInfo = new RelativeInfo<>();
IAdapter adapter = getAdapter(position);
if (adapter != null) {
Item item = (Item) adapter.getAdapterItem(position - getItemCount(adapter.getOrder()));
relativeInfo.item = item;
relativeInfo.item = (Item) adapter.getAdapterItem(position - getItemCount(adapter.getOrder()));
relativeInfo.adapter = adapter;
}
return relativeInfo;
Expand Down Expand Up @@ -474,8 +477,7 @@ public void toggleSelection(int position) {
*
* @param position the global position
*/
private void handleSelection(int position) {
Item item = getItem(position);
private void handleSelection(Item item, int position) {
if (!item.isSelectable()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,34 @@ public void onClick(View v) {
}

private void notifyCommit() {
if (mHistory.action == ACTION_REMOVE) {
mUndoListener.commitRemove(mHistory.position, mHistory.items);
mHistory = null;
if (mHistory != null) {
if (mHistory.action == ACTION_REMOVE) {
mUndoListener.commitRemove(mHistory.position, mHistory.items);
mHistory = null;
}
}
}

private void doChange() {
if (mHistory.action == ACTION_REMOVE) {
if (mHistory.items.size() == 1) {
mItemAdapter.remove(mHistory.position);
} else {
mItemAdapter.removeItemRange(mHistory.position, mHistory.items.size());
if (mHistory != null) {
if (mHistory.action == ACTION_REMOVE) {
if (mHistory.items.size() == 1) {
mItemAdapter.remove(mHistory.position);
} else {
mItemAdapter.removeItemRange(mHistory.position, mHistory.items.size());
}
}
}
}

private void undoChange() {
if (mHistory.action == ACTION_REMOVE) {
if (mHistory.items.size() == 1) {
mItemAdapter.add(mHistory.position, mHistory.items.get(0));
} else {
mItemAdapter.add(mHistory.position, mHistory.items);
if (mHistory != null) {
if (mHistory.action == ACTION_REMOVE) {
if (mHistory.items.size() == 1) {
mItemAdapter.add(mHistory.position, mHistory.items.get(0));
} else {
mItemAdapter.add(mHistory.position, mHistory.items);
}
}
}
mHistory = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
The <b>FastAdapter</b> is here to simplify this process. You do not have to worry about the adapter anymore. Just write the logic for how your view should look like, and you are done. This library has a fast and highly optimized core which provides core functionality, most apps require. It also prevents common mistakes by taking away those steps from the devs. Beside being blazing fast, minimizing the code you need to write, it is also really easy to extend. Just provide another Adapter implementation, hook into the adapter chain, custom select / deselection behaviors. Everything is possible.
]]>
</string>
<string name="library_fastadapter_libraryVersion">0.4.1-SNAPSHOT</string>
<string name="library_fastadapter_libraryVersion">0.4.2-SNAPSHOT</string>
<string name="library_fastadapter_libraryWebsite">https://github.com/mikepenz/FastAdapter</string>
<string name="library_fastadapter_licenseId">apache_2_0</string>
<string name="library_fastadapter_isOpenSource">true</string>
Expand Down

0 comments on commit 975d508

Please sign in to comment.