Skip to content

Commit

Permalink
Merge branch 'release/v0.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 19, 2016
2 parents a98210e + 1775da5 commit 56eed90
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 44 deletions.
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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.9.0@aar') {
compile('com.mikepenz:fastadapter:0.9.1@aar') {
transitive = true
}
```
Expand All @@ -55,14 +55,11 @@ public class SampleItem extends AbstractItem<SampleItem, SampleItem.ViewHolder>

//The logic to bind your data to the view
@Override
public void bindView(RecyclerView.ViewHolder holder) {
Context ctx = holder.itemView.getContext();
//get our viewHolder
ViewHolder viewHolder = (ViewHolder) holder;

//set the item selected if it is
viewHolder.itemView.setSelected(isSelected());

public void bindView(ViewHolder viewHolder) {
//call super so the selection is already handled for you
super.bindView(viewHolder);

//bind our data
//set the text for the name
viewHolder.name.setText(name);
//set the text for the description or hide
Expand All @@ -71,13 +68,11 @@ public class SampleItem extends AbstractItem<SampleItem, SampleItem.ViewHolder>

//The viewHolder used for this item. This viewHolder is always reused by the RecyclerView so scrolling is blazing fast
protected static class ViewHolder extends RecyclerView.ViewHolder {
protected View view;
protected TextView name;
protected TextView description;

public ViewHolder(View view) {
super(view);
this.view = view;
this.name = (TextView) view.findViewById(com.mikepenz.materialdrawer.R.id.material_drawer_name);
this.description = (TextView) view.findViewById(com.mikepenz.materialdrawer.R.id.material_drawer_description);
}
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 90
versionName '0.9.0'
versionCode 91
versionName '0.9.1'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
android:name=".AdvancedSampleActivity"
android:label="@string/sample_advanced" />
<activity
android:name=".TypedItemActivity"
android:label="@string/sample_typed_item" />
android:name=".GenericItemActivity"
android:label="@string/sample_generic_item" />
<activity
android:name=".IconGridActivity"
android:label="@string/sample_icon_grid" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import android.view.View;

import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.adapters.TypedItemAdapter;
import com.mikepenz.fastadapter.app.typed.IconModel;
import com.mikepenz.fastadapter.app.typed.TypedIconItem;
import com.mikepenz.fastadapter.adapters.GenericItemAdapter;
import com.mikepenz.fastadapter.app.generic.IconModel;
import com.mikepenz.fastadapter.app.generic.GenericIconItem;
import com.mikepenz.iconics.Iconics;
import com.mikepenz.iconics.typeface.ITypeface;
import com.mikepenz.itemanimators.SlideDownAlphaAnimator;
Expand All @@ -22,7 +22,7 @@
import java.util.Comparator;
import java.util.List;

public class TypedItemActivity extends AppCompatActivity {
public class GenericItemActivity extends AppCompatActivity {
//save our FastAdapter
private FastAdapter fastAdapter;

Expand All @@ -37,7 +37,7 @@ protected void onCreate(Bundle savedInstanceState) {
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.sample_typed_item);
getSupportActionBar().setTitle(R.string.sample_generic_item);

//style our ui
new MaterializeBuilder().withActivity(this).build();
Expand All @@ -52,7 +52,7 @@ protected void onCreate(Bundle savedInstanceState) {
//init our gridLayoutManager and configure RV
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);

TypedItemAdapter<IconModel, TypedIconItem> itemAdapter = new TypedItemAdapter<>(TypedIconItem.class, IconModel.class);
GenericItemAdapter<IconModel, GenericIconItem> itemAdapter = new GenericItemAdapter<>(GenericIconItem.class, IconModel.class);

rv.setLayoutManager(gridLayoutManager);
rv.setItemAnimator(new SlideDownAlphaAnimator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {
new PrimaryDrawerItem().withName(R.string.sample_collapsible).withDescription(R.string.sample_collapsible_descr).withSelectable(false).withIdentifier(2).withIcon(MaterialDesignIconic.Icon.gmi_check_all),
new PrimaryDrawerItem().withName(R.string.sample_sticky_header).withDescription(R.string.sample_sticky_header_descr).withSelectable(false).withIdentifier(3).withIcon(MaterialDesignIconic.Icon.gmi_format_align_left),
new PrimaryDrawerItem().withName(R.string.sample_advanced).withDescription(R.string.sample_advanced_descr).withSelectable(false).withIdentifier(4).withIcon(MaterialDesignIconic.Icon.gmi_coffee),
new PrimaryDrawerItem().withName(R.string.sample_typed_item).withDescription(R.string.sample_typed_item_descr).withSelectable(false).withIdentifier(7).withIcon(MaterialDesignIconic.Icon.gmi_font),
new PrimaryDrawerItem().withName(R.string.sample_generic_item).withDescription(R.string.sample_generic_item_descr).withSelectable(false).withIdentifier(7).withIcon(MaterialDesignIconic.Icon.gmi_font),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName(R.string.open_source).withSelectable(false).withIdentifier(100).withIcon(MaterialDesignIconic.Icon.gmi_github)
)
Expand All @@ -93,7 +93,7 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
} else if (drawerItem.getIdentifier() == 6) {
intent = new Intent(SampleActivity.this, SimpleItemListActivity.class);
} else if (drawerItem.getIdentifier() == 7) {
intent = new Intent(SampleActivity.this, TypedItemActivity.class);
intent = new Intent(SampleActivity.this, GenericItemActivity.class);
} else if (drawerItem.getIdentifier() == 8) {
intent = new Intent(SampleActivity.this, IconGridActivity.class);
} else if (drawerItem.getIdentifier() == 100) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.mikepenz.fastadapter.app.typed;
package com.mikepenz.fastadapter.app.generic;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.mikepenz.fastadapter.app.R;
import com.mikepenz.fastadapter.items.TypedAbstractItem;
import com.mikepenz.fastadapter.items.GenericAbstractItem;
import com.mikepenz.fastadapter.utils.ViewHolderFactory;
import com.mikepenz.iconics.view.IconicsImageView;

Expand All @@ -15,9 +15,9 @@
/**
* Created by mikepenz on 28.12.15.
*/
public class TypedIconItem extends TypedAbstractItem<IconModel, TypedIconItem, TypedIconItem.ViewHolder> {
public class GenericIconItem extends GenericAbstractItem<IconModel, GenericIconItem, GenericIconItem.ViewHolder> {

public TypedIconItem(IconModel icon) {
public GenericIconItem(IconModel icon) {
super(icon);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mikepenz.fastadapter.app.typed;
package com.mikepenz.fastadapter.app.generic;

import com.mikepenz.iconics.typeface.IIcon;

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<string name="sample_sticky_header_descr">StickyHeader, Select</string>
<string name="sample_advanced">Advanced Sample</string>
<string name="sample_advanced_descr">Header, StickyHeader, Expandable, CAB, MultiSelect</string>
<string name="sample_typed_item">TypedItem Sample</string>
<string name="sample_typed_item_descr">Split up Item and Model</string>
<string name="sample_generic_item">GenericItem Sample</string>
<string name="sample_generic_item_descr">Split up Item and Model</string>
<string name="open_source">Open Source</string>
<string name="search_title">Suche</string>
</resources>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maven stuff
VERSION_NAME=0.9.0
VERSION_CODE=90
VERSION_NAME=0.9.1
VERSION_CODE=91
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 90
versionName '0.9.0'
versionCode 91
versionName '0.9.1'
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mikepenz.fastadapter.adapters;

import com.mikepenz.fastadapter.items.TypedAbstractItem;
import com.mikepenz.fastadapter.items.GenericAbstractItem;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
Expand All @@ -13,62 +13,119 @@
* A general ItemAdapter implementation based on the AbstractAdapter to speed up development for general items
* This adapter has the order of 500 which is the centered order
*/
public class TypedItemAdapter<Model, Item extends TypedAbstractItem> extends ItemAdapter<Item> {
List<Model> mItems = new ArrayList<>();
public class GenericItemAdapter<Model, Item extends GenericAbstractItem> extends ItemAdapter<Item> {
private List<Model> mItems = new ArrayList<>();
private Class<Model> modelClass;
private Class<Item> itemClass;

Class<Model> modelClass;
Class<Item> itemClass;

public TypedItemAdapter(Class<Item> itemClass, Class<Model> modelClass) {
/**
* @param itemClass the class of your item (Item extends GenericAbstractItem)
* @param modelClass the class which is your model class
*/
public GenericItemAdapter(Class<Item> itemClass, Class<Model> modelClass) {
this.itemClass = itemClass;
this.modelClass = modelClass;
}


/**
* set a new list of models for this adapter
*
* @param models
*/
public void setModel(List<Model> models) {
super.set(toItems(models));
mItems = models;
}

/**
* add an array of models
*
* @param models
*/
public void addModel(Model... models) {
super.add(toItems(models));
Collections.addAll(mItems, models);
}

/**
* add a list of models
*
* @param models
*/
public void addModel(List<Model> models) {
super.add(toItems(models));
mItems.addAll(models);
}

/**
* add an array of models at a given (global) position
*
* @param position
* @param models
*/
public void addModel(int position, Model... models) {
super.add(position, toItems(models));
mItems.addAll(position - getFastAdapter().getItemCount(getOrder()), Arrays.asList(models));
}

/**
* add a list of models at a given (global) position
*
* @param position
* @param models
*/
public void addModel(int position, List<Model> models) {
super.add(position, toItems(models));
mItems.addAll(position - getFastAdapter().getItemCount(getOrder()), models);
}

/**
* set a model at a given position
*
* @param position
* @param model
*/
public void setModel(int position, Model model) {
super.set(position, getAbstractItem(model));
mItems.set(position - getFastAdapter().getItemCount(getOrder()), model);
}

/**
* add a model at the end of the list
*
* @param model
*/
public void addModel(Model model) {
super.add(getAbstractItem(model));
mItems.add(model);
}

/**
* add a model at the given (global) position
*
* @param position
* @param model
*/
public void addModel(int position, Model model) {
super.add(position, getAbstractItem(model));
mItems.add(position - getFastAdapter().getItemCount(getOrder()), model);
}

/**
* clear all models
*/
public void clearModel() {
super.clear();
mItems.clear();
}

/**
* remove a range oof model items starting with the (global) position and the size
*
* @param position
* @param itemCount
*/
public void removeModelRange(int position, int itemCount) {
super.removeRange(position, itemCount);

Expand All @@ -82,6 +139,11 @@ public void removeModelRange(int position, int itemCount) {
}
}

/**
* remove a model at the given (global) position
*
* @param position
*/
public void removeModel(int position) {
super.remove(position);
mItems.remove(position - getFastAdapter().getItemCount(getOrder()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Created by mikepenz on 14.07.15.
* Implements the general methods of the IItem interface to speed up development.
*/
public abstract class TypedAbstractItem<Model, Item extends IItem, VH extends RecyclerView.ViewHolder> extends AbstractItem<Item, VH> {
public abstract class GenericAbstractItem<Model, Item extends IItem, VH extends RecyclerView.ViewHolder> extends AbstractItem<Item, VH> {
private Model mModel;

public TypedAbstractItem(Model model) {
public GenericAbstractItem(Model model) {
this.mModel = model;
}

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">0.9.0</string>
<string name="library_fastadapter_libraryVersion">0.9.1</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 56eed90

Please sign in to comment.