Skip to content

Commit

Permalink
Merge branch 'release/v0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 11, 2016
2 parents 8c8b823 + fe0e106 commit 05baac9
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 101 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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.6.0@aar') {
compile('com.mikepenz:fastadapter:0.7.0@aar') {
transitive = true
}
```
Expand Down
10 changes: 7 additions & 3 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 60
versionName '0.6.0'
versionCode 70
versionName '0.7.0'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down Expand Up @@ -52,7 +52,7 @@ dependencies {

//used to generate the drawer on the left
//https://github.com/mikepenz/MaterialDrawer
compile('com.mikepenz:materialdrawer:4.6.3@aar') {
compile('com.mikepenz:materialdrawer:5.0.0.fastAdapter.b6-SNAPSHOT@aar') {
transitive = true
exclude module: "fastadapter"
}
Expand All @@ -77,6 +77,10 @@ dependencies {
//customized version to allow minimal header animation
compile 'com.mikepenz.thirdparty:stickyheadersrecyclerview:0.4.4-SNAPSHOT@aar'

//Used to provide the FastScrollBar
//https://github.com/krimin-killr21/MaterialScrollBar
compile 'com.turingtechnologies.materialscrollbar:lib:6.1.0'

//https://github.com/JakeWharton/butterknife
compile 'com.jakewharton:butterknife:7.0.1'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,12 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {

//create our FastAdapter which will manage everything
fastAdapter = new FastAdapter<>();
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener() {
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<SampleItem>() {
@Override
public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
if (item instanceof SampleItem) {
if (((SampleItem) item).getSubItems() != null) {
fastAdapter.toggleExpandable(position);
return true;
}
public boolean onClick(View v, IAdapter<SampleItem> adapter, SampleItem item, int position) {
if (item.getSubItems() != null) {
fastAdapter.toggleExpandable(position);
return true;
}
return false;
}
Expand All @@ -118,6 +116,7 @@ public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
//get our recyclerView and do basic setup
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

//init our gridLayoutManager and configure RV
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
Expand Down Expand Up @@ -147,7 +146,6 @@ public int compare(final ITypeface object1, final ITypeface object2) {

//add all icons of all registered Fonts to the list
ArrayList<SampleItem> items = new ArrayList<>(Iconics.getRegisteredFonts(this).size());
int count = 0;
for (ITypeface font : mFonts) {
SampleItem sampleItem = new SampleItem().withName(font.getFontName());

Expand All @@ -158,12 +156,14 @@ public int compare(final ITypeface object1, final ITypeface object2) {
sampleItem.withSubItems(icons);

items.add(sampleItem);
count++;
}

//fill with some sample data
itemAdapter.add(items);

//expand one item to make sample look a bit more interesting
fastAdapter.expand(2);

//restore selections (this has to be done after the items were added
fastAdapter.withSavedInstanceState(savedInstanceState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@

import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.fastadapter.app.dummy.ImageDummyData;
import com.mikepenz.fastadapter.app.items.ImageItem;
import com.mikepenz.fastadapter.app.items.SampleItem;
import com.mikepenz.materialize.MaterializeBuilder;

public class ImageListActivity extends AppCompatActivity {
Expand All @@ -44,10 +42,10 @@ protected void onCreate(Bundle savedInstanceState) {
final ItemAdapter<ImageItem> itemAdapter = new ItemAdapter<>();

//configure our fastAdapter
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener() {
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<ImageItem>() {
@Override
public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
Toast.makeText(v.getContext(), ((SampleItem) item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
public boolean onClick(View v, IAdapter<ImageItem> adapter, ImageItem item, int position) {
Toast.makeText(v.getContext(), item.mName, Toast.LENGTH_LONG).show();
return false;
}
});
Expand Down
31 changes: 23 additions & 8 deletions app/src/main/java/com/mikepenz/fastadapter/app/SimpleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
Expand All @@ -16,14 +17,20 @@
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.fastadapter.app.adapter.FastScrollIndicatorAdapter;
import com.mikepenz.fastadapter.app.items.SampleItem;
import com.mikepenz.fastadapter.helpers.UndoHelper;
import com.mikepenz.materialize.MaterializeBuilder;
import com.turingtechnologies.materialscrollbar.AlphabetIndicator;
import com.turingtechnologies.materialscrollbar.MaterialScrollBar;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class SimpleActivity extends AppCompatActivity {
private static final String[] ALPHABET = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

//save our FastAdapter
private FastAdapter<SampleItem> fastAdapter;

Expand All @@ -47,6 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {

//create our ItemAdapter which will host our items
final ItemAdapter<SampleItem> itemAdapter = new ItemAdapter<>();
final FastScrollIndicatorAdapter<SampleItem> fastScrollIndicatorAdapter = new FastScrollIndicatorAdapter<>();

//
undoHelper = new UndoHelper(itemAdapter, new UndoHelper.UndoListener() {
Expand All @@ -60,16 +68,16 @@ public void commitRemove(int position, ArrayList<? extends IItem> removed) {
//configure our fastAdapter
//as we provide id's for the items we want the hasStableIds enabled to speed up things
fastAdapter.setHasStableIds(true);
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener() {
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<SampleItem>() {
@Override
public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
Toast.makeText(v.getContext(), ((SampleItem) item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
public boolean onClick(View v, IAdapter<SampleItem> adapter, SampleItem item, int position) {
Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
return false;
}
});
fastAdapter.withOnLongClickListener(new FastAdapter.OnLongClickListener() {
fastAdapter.withOnLongClickListener(new FastAdapter.OnLongClickListener<SampleItem>() {
@Override
public boolean onLongClick(View v, IAdapter adapter, IItem item, int position) {
public boolean onLongClick(View v, IAdapter<SampleItem> adapter, SampleItem item, int position) {
undoHelper.remove(SimpleActivity.this.findViewById(android.R.id.content), "Item removed", "Undo", Snackbar.LENGTH_LONG, position, 1);
return true;
}
Expand All @@ -79,12 +87,19 @@ public boolean onLongClick(View v, IAdapter adapter, IItem item, int position) {
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
rv.setLayoutManager(new LinearLayoutManager(this));
rv.setItemAnimator(new DefaultItemAnimator());
rv.setAdapter(itemAdapter.wrap(fastAdapter));
rv.setAdapter(fastScrollIndicatorAdapter.wrap(itemAdapter.wrap(fastAdapter)));

//add a FastScrollBar (Showcase compatiblity)
MaterialScrollBar materialScrollBar = new MaterialScrollBar(this, rv, true);
materialScrollBar.setHandleColour(ContextCompat.getColor(this, R.color.accent)).setAutoHide(false);
materialScrollBar.addIndicator(new AlphabetIndicator(this), true);

//fill with some sample data
List<SampleItem> items = new ArrayList<>();
for (int i = 1; i <= 100; i++) {
items.add(new SampleItem().withName("Test " + i).withIdentifier(100 + i));
for (String s : ALPHABET) {
for (int i = 1; i <= new Random().nextInt(100); i++) {
items.add(new SampleItem().withName(s + " Test " + i).withIdentifier(100 + i));
}
}
itemAdapter.add(items);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.mikepenz.fastadapter.app.adapter;

import com.mikepenz.fastadapter.AbstractAdapter;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.app.items.SampleItem;
import com.turingtechnologies.materialscrollbar.INameableAdapter;

import java.util.List;

/**
* Created by mikepenz on 30.12.15.
* This is a FastAdapter adapter implementation for the awesome Sticky-Headers lib by timehop
* https://github.com/timehop/sticky-headers-recyclerview
*/
public class FastScrollIndicatorAdapter<Item extends IItem> extends AbstractAdapter<Item> implements INameableAdapter {
@Override
public Character getCharacterForElement(int position) {
IItem item = getItem(position);
if (item instanceof SampleItem && ((SampleItem) item).name != null) {
//based on the position we set the headers text
return ((SampleItem) item).name.getText().charAt(0);
}
return ' ';
}

/**
* REQUIRED FOR THE FastAdapter. Set order to < 0 to tell the FastAdapter he can ignore this one.
**/

/**
* @return
*/
@Override
public int getOrder() {
return -100;
}

@Override
public int getAdapterItemCount() {
return 0;
}

@Override
public List<Item> getAdapterItems() {
return null;
}

@Override
public Item getAdapterItem(int position) {
return null;
}

@Override
public int getAdapterPosition(IItem item) {
return -1;
}

@Override
public int getGlobalPosition(int position) {
return -1;
}

}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<FrameLayout
<RelativeLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -23,5 +23,5 @@
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
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.6.0
VERSION_CODE=60
VERSION_NAME=0.7.0
VERSION_CODE=70
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 60
versionName '0.6.0'
versionCode 70
versionName '0.7.0'
}
buildTypes {
release {
Expand Down
Loading

0 comments on commit 05baac9

Please sign in to comment.