Skip to content

Commit

Permalink
Merge branch 'release/v1.2.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Mar 21, 2016
2 parents 173b6f4 + c1e33c5 commit 12dd9bb
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can try it out here [Google Play](https://play.google.com/store/apps/details

The library is split up into core, and extensions. The core functions are included in the following dependency.
```gradle
compile('com.mikepenz:fastadapter:1.2.6@aar') {
compile('com.mikepenz:fastadapter:1.2.7@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 @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 126
versionName '1.2.6'
versionCode 127
versionName '1.2.7'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
19 changes: 17 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 126
versionName '1.2.6'
versionCode 127
versionName '1.2.7'
}
buildTypes {
release {
Expand All @@ -33,4 +33,19 @@ dependencies {
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.robolectric:robolectric-utils:3.0'
testCompile 'org.robolectric:shadows-core:3.0'
testCompile 'org.robolectric:shadows-support-v4:3.0'
testCompile 'org.robolectric:shadows-multidex:3.0'
testCompile 'com.squareup.assertj:assertj-android:1.1.1'
testCompile 'com.squareup.assertj:assertj-android-design:1.1.1@aar'
testCompile 'com.squareup.assertj:assertj-android-appcompat-v7:1.1.1@aar'
testCompile("com.squareup.assertj:assertj-android-support-v4:1.1.1@aar") {
exclude group: "com.android.support", module: "support-annotations"
exclude group: "com.android.support", module: "support-v4"
}
}
4 changes: 2 additions & 2 deletions library/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ POM_NAME=FastAdapter Library
POM_ARTIFACT_ID=fastadapter
POM_PACKAGING=aar

VERSION_NAME=1.2.6
VERSION_CODE=126
VERSION_NAME=1.2.7
VERSION_CODE=127
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ public FastItemAdapter<Item> add(int position, Item item) {
return this;
}

/**
* moves an item within the list from a position to a position
*
* @param fromPosition the position global from which we want to move
* @param toPosition the global position to which to move
* @return this
*/
public FastItemAdapter<Item> move(int fromPosition, int toPosition) {
mItemAdapter.move(fromPosition, toPosition);
return this;
}

/**
* removes an item at the given position within the existing icons
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public List<Item> getAdapterItems() {
*/
@Override
public int getAdapterPosition(Item item) {
for (int i = 0; i < mItems.size(); i++) {
int length = mItems.size();
for (int i = 0; i < length; i++) {
if (mItems.get(i).getIdentifier() == item.getIdentifier()) {
return i;
}
Expand Down Expand Up @@ -363,6 +364,22 @@ public ItemAdapter<Item> set(int position, Item item) {
return this;
}

/**
* moves an item within the list from a position to a position
*
* @param fromPosition the position global from which we want to move
* @param toPosition the global position to which to move
* @return this
*/
public ItemAdapter<Item> move(int fromPosition, int toPosition) {
int preItemCount = getFastAdapter().getPreItemCount(fromPosition);
Item item = mItems.get(fromPosition - preItemCount);
mItems.remove(fromPosition - preItemCount);
mItems.set(toPosition - preItemCount, item);
getFastAdapter().notifyAdapterItemMoved(fromPosition, toPosition);
return this;
}

/**
* removes an item at the given position within the existing icons
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public static SortedSet<Integer> adjustPosition(Set<Integer> positions, int star
public static SparseIntArray adjustPosition(SparseIntArray positions, int startPosition, int endPosition, int adjustBy) {
SparseIntArray newPositions = new SparseIntArray();

for (int i = 0; i < positions.size(); i++) {
int length = positions.size();
for (int i = 0; i < length; i++) {
int position = positions.keyAt(i);

//if our current position is not within the bounds to check for we can add it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<b>FastAdapter</b>, the bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
]]>
</string>
<string name="library_fastadapter_libraryVersion">1.2.6</string>
<string name="library_fastadapter_libraryVersion">1.2.7</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
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.mikepenz.fastadapter;

import android.support.v7.widget.RecyclerView;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;


/**
* @author Shubham Chaudhary on 17/03/16
*/
@RunWith(RobolectricGradleTestRunner.class)
public class FastAdapterTest {
private FastAdapter<IItem> adapter;

@Before public void setUp() throws Exception {
adapter = new FastAdapter<>();
}

@Test public void constructor_HasStableId() throws Exception {
assertThat(adapter.hasStableIds()).isTrue();
}

@Test public void constructor_Default_IsSelectable() throws Exception {
assertThat(adapter.isSelectable()).isTrue(); //default
}

@Test public void withSelectable() throws Exception {
assertThat(adapter.withSelectable(true).isSelectable()).isTrue();
assertThat(adapter.withSelectable(false).isSelectable()).isFalse();
}

@Test public void withBindViewHolderListener_OnBindViewHolder_Callback() throws Exception {
FastAdapter.OnBindViewHolderListener listener = mock(FastAdapter.OnBindViewHolderListener.class);
RecyclerView.ViewHolder holder = mock(RecyclerView.ViewHolder.class);
adapter.withOnBindViewHolderListener(listener);

adapter.onBindViewHolder(holder, 10);

verify(listener, only()).onBindViewHolder(holder, 10);
}
}
3 changes: 3 additions & 0 deletions library/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
constants=com.mikepenz.fastadapter.BuildConfig
packageName=com.mikepenz.fastadapter
sdk=21

0 comments on commit 12dd9bb

Please sign in to comment.