Skip to content

Commit

Permalink
Merge branch 'release/v3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 13, 2018
2 parents b83371e + 1bf2095 commit 630a133
Show file tree
Hide file tree
Showing 26 changed files with 608 additions and 199 deletions.
42 changes: 12 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
language: android

android:
components:
# Update tools and then platform-tools explicitly so lint gets an updated database. Can be removed once 3.0 is out.
- tools
- platform-tools
- sys-img-armeabi-v7a-android-18

# The BuildTools version used by your project
- build-tools-27.0.1

# The SDK version used to compile your project
- build-tools-27.0.2
- android-27

# Additional components
- extra-google-m2repository
- extra-android-m2repository
licenses:
- '.+'

- sys-img-armeabi-v7a-android-18
before_install:
- yes | sdkmanager "platforms;android-27"
- yes | sdkmanager "build-tools;27.0.1"
- yes | sdkmanager "build-tools;27.0.2"
jdk:
- oraclejdk8

before_script:
# Install SDK license so Android Gradle plugin can install deps.
- mkdir "$ANDROID_HOME/licenses" || true
- echo "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-license"

script: ./gradlew clean test

- oraclejdk8
script:
- ./gradlew clean test
branches:
except:
- gh-pages

notifications:
email: false

sudo: false

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

cache:
directories:
- $HOME/.gradle
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ You can try it out here [Google Play](https://play.google.com/store/apps/details

The library is split up into core, commons, and extensions. The core functions are included in the following dependency.
```gradle
implementation 'com.mikepenz:fastadapter:3.0.5@aar'
implementation 'com.mikepenz:fastadapter:3.1.0@aar'
implementation 'com.android.support:appcompat-v7:${latestSupportLib}'
implementation 'com.android.support:recyclerview-v7:${latestSupportLib}'
```

The commons package comes with some useful helpers (which are not needed in all cases) This one for example includes the `FastItemAdapter`
```gradle
implementation 'com.mikepenz:fastadapter-commons:3.0.5@aar'
implementation 'com.mikepenz:fastadapter-commons:3.1.0@aar'
```

Expandable support is included and can be added via this
```gradle
implementation 'com.mikepenz:fastadapter-extensions-expandable:3.0.5@aar'
implementation 'com.mikepenz:fastadapter-extensions-expandable:3.1.0@aar'
//The tiny Materialize library used for its useful helper classes
implementation 'com.mikepenz:materialize:${latestVersion}@aar'
```

Many helper classes are included in the following dependency. (This functionality also needs the `Expandable` extension
```gradle
implementation 'com.mikepenz:fastadapter-extensions:3.0.5@aar'
implementation 'com.mikepenz:fastadapter-extensions:3.1.0@aar'
implementation 'com.android.support:design:${versions.supportLib}'
//The tiny Materialize library used for its useful helper classes
implementation 'com.mikepenz:materialize:${latestVersion}@aar'
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 {
defaultConfig {
minSdkVersion setup.minSdk
targetSdkVersion setup.targetSdk
versionCode 3050
versionName '3.0.5'
versionCode 3100
versionName '3.1.0'

setProperty("archivesBaseName", "FastAdapter-v$versionName-c$versionCode")
}
Expand Down
37 changes: 20 additions & 17 deletions app/src/main/java/com/mikepenz/fastadapter/app/SortActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import android.view.View;
import android.widget.Toast;

import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.fastadapter.app.items.SimpleItem;
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter;
import com.mikepenz.fastadapter.listeners.OnClickListener;
import com.mikepenz.fastadapter.utils.ComparableItemListImpl;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.mikepenz.materialize.MaterializeBuilder;
Expand Down Expand Up @@ -56,7 +58,9 @@ public class SortActivity extends AppCompatActivity {
RecyclerView recyclerView;

//save our FastAdapter
private FastItemAdapter<SimpleItem> fastItemAdapter;
private FastAdapter<SimpleItem> fastAdapter;
private ItemAdapter<SimpleItem> itemAdapter;
private ComparableItemListImpl<SimpleItem> itemListImpl;

@SortingStrategy
private int sortingStrategy;
Expand All @@ -77,11 +81,13 @@ protected void onCreate(Bundle savedInstanceState) {
new MaterializeBuilder().withActivity(this).build();

//create our FastAdapter which will manage everything
fastItemAdapter = new FastItemAdapter<>();
fastItemAdapter.withSelectable(true);
itemListImpl = new ComparableItemListImpl<>(getComparator());
itemAdapter = new ItemAdapter<>(itemListImpl);
fastAdapter = FastAdapter.with(itemAdapter);
fastAdapter.withSelectable(true);

//configure our fastAdapter
fastItemAdapter.withOnClickListener(new OnClickListener<SimpleItem>() {
fastAdapter.withOnClickListener(new OnClickListener<SimpleItem>() {
@Override
public boolean onClick(View v, IAdapter<SimpleItem> adapter,
SimpleItem item, int position) {
Expand All @@ -95,7 +101,7 @@ public boolean onClick(View v, IAdapter<SimpleItem> adapter,
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(fastItemAdapter);
recyclerView.setAdapter(fastAdapter);

if (savedInstanceState != null) {
//Retrieve the previous sorting strategy from the instance state
Expand All @@ -105,14 +111,11 @@ public boolean onClick(View v, IAdapter<SimpleItem> adapter,
sortingStrategy = SORT_NONE;
}

//we sort the list
fastItemAdapter.getItemAdapter().withComparator(getComparator());

//initial filling of the list
fastItemAdapter.setNewList(generateUnsortedList());
itemAdapter.setNewList(generateUnsortedList());

//restore selections (this has to be done after the items were added
fastItemAdapter.withSavedInstanceState(savedInstanceState);
fastAdapter.withSavedInstanceState(savedInstanceState);

//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Expand All @@ -127,7 +130,7 @@ int toSortingStrategy(int val) {
@Override
protected void onSaveInstanceState(Bundle outState) {
//add the values which need to be saved from the adapter to the bundle
outState = fastItemAdapter.saveInstanceState(outState);
outState = fastAdapter.saveInstanceState(outState);
//We need to persist our sorting strategy between orientation changes
outState.putInt("sorting_strategy", sortingStrategy);
super.onSaveInstanceState(outState);
Expand All @@ -153,24 +156,24 @@ public boolean onOptionsItemSelected(MenuItem item) {
//Set the new sorting strategy
sortingStrategy = SORT_NONE;
//randomize the items
Collections.shuffle(fastItemAdapter.getAdapterItems());
fastItemAdapter.notifyDataSetChanged();
Collections.shuffle(itemAdapter.getAdapterItems());
fastAdapter.notifyDataSetChanged();
return true;
case R.id.item_sort_asc:
//Set the new sorting strategy
sortingStrategy = SORT_ASCENDING;
//Set the new comparator to the list
fastItemAdapter.getItemAdapter().withComparator(getComparator());
itemListImpl.withComparator(getComparator());
return true;
case R.id.item_sort_desc:
//Set the new sorting strategy
sortingStrategy = SORT_DESCENDING;
//Set the new comparator to the list
fastItemAdapter.getItemAdapter().withComparator(getComparator());
itemListImpl.withComparator(getComparator());
return true;
case android.R.id.home:
Toast.makeText(getApplicationContext(), "selections = " +
fastItemAdapter.getSelections(), Toast.LENGTH_LONG).show();
fastAdapter.getSelections(), Toast.LENGTH_LONG).show();
onBackPressed();
return true;
default:
Expand Down
8 changes: 5 additions & 3 deletions library-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

group "com.mikepenz"
version "3.0.0"
version "3.1.0"

android {
compileSdkVersion setup.compileSdk
Expand All @@ -10,10 +10,12 @@ android {
defaultConfig {
minSdkVersion setup.minSdk
targetSdkVersion setup.targetSdk
versionCode 3050
versionName '3.0.5'
versionCode 3100
versionName '3.1.0'

consumerProguardFiles 'consumer-proguard-rules.pro'

resValue "string", "fastadapter_lib_version", "${versionName}"
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions library-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_NAME=FastAdapter Library
POM_ARTIFACT_ID=fastadapter
POM_PACKAGING=aar
VERSION_NAME=3.0.5
VERSION_CODE=3050
VERSION_NAME=3.1.0
VERSION_CODE=3100
36 changes: 36 additions & 0 deletions library-core/src/main/java/com/mikepenz/fastadapter/IItemList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.mikepenz.fastadapter;

import java.util.List;

/**
* The Item list interface
*/

public interface IItemList<Item> {

int getAdapterPosition(long identifier);

void remove(int position, int preItemCount);

void removeRange(int position, int itemCount, int preItemCount);

void move(int fromPosition, int toPosition, int preItemCount);

int size();

void clear(int preItemCount);

boolean isEmpty();

void addAll(List<Item> items, int preItemCount);

void set(int position, Item item);

void setNewList(List<Item> items);

void addAll(int position, List<Item> items, int preItemCount);

List<Item> getItems();

Item get(int position);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mikepenz.fastadapter.IInterceptor;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.IItemList;

/**
* Created by mikepenz on 27.12.15.
Expand All @@ -13,6 +14,10 @@ public ItemAdapter() {
super((IInterceptor<Item, Item>) IInterceptor.DEFAULT);
}

public ItemAdapter(IItemList<Item> itemList) {
super(itemList, (IInterceptor<Item, Item>) IInterceptor.DEFAULT);
}

/**
* static method to retrieve a new `ItemAdapter`
*
Expand Down
Loading

0 comments on commit 630a133

Please sign in to comment.