Skip to content

Commit

Permalink
Merge branch 'release/v1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 30, 2016
2 parents dfc72cb + 9f70887 commit bb30c6b
Show file tree
Hide file tree
Showing 22 changed files with 257 additions and 27 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ Beside being blazing fast, minimizing the code you need to write, it is also rea
- Simple Drag & Drop
- Headers
- Footers
- FastScroller (external lib)
- Highly optimized code
- Includes suggestions from the Android Team
- Easily extensible
- Chain other Adapters
- Comes with useful Helpers
- ActionModeHelper
- UndoHelper
- More to come...

#Preview
Expand All @@ -32,7 +34,7 @@ You can try it out here [Google Play](https://play.google.com/store/apps/details
#Include in your project
##Using Maven
```javascript
compile('com.mikepenz:fastadapter:1.0.0@aar') {
compile('com.mikepenz:fastadapter:1.0.1@aar') {
transitive = true
}
```
Expand Down
8 changes: 4 additions & 4 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 100
versionName '1.0.0'
versionCode 101
versionName '1.0.1'

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

//used to generate the drawer on the left
//https://github.com/mikepenz/MaterialDrawer
compile('com.mikepenz:materialdrawer:5.0.0.fastAdapter.b15-SNAPSHOT@aar') {
compile('com.mikepenz:materialdrawer:5.0.0.b22-SNAPSHOT@aar') {
transitive = true
exclude module: "fastadapter"
}
Expand All @@ -78,7 +78,7 @@ dependencies {

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

//https://github.com/JakeWharton/butterknife
compile 'com.jakewharton:butterknife:7.0.1'
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@
<activity
android:name=".AdvancedSampleActivity"
android:label="@string/sample_advanced" />
<activity
android:name=".IconGridActivity"
android:label="@string/sample_icon_grid" />
<activity
android:name=".GenericItemActivity"
android:label="@string/sample_generic_item" />
<activity
android:name=".IconGridActivity"
android:label="@string/sample_icon_grid" />
android:name=".MultiTypeGenericItemActivity"
android:label="@string/sample_multi_generic_item" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean onClick(View v, IAdapter<ImageItem> adapter, ImageItem item, int
mFastItemAdapter.withOnCreateViewHolderListener(new FastAdapter.OnCreateViewHolderListener() {
@Override
public RecyclerView.ViewHolder onPreCreateViewHolder(ViewGroup parent, int viewType) {
return mFastItemAdapter.getTypeInstances().get(viewType).getViewHolder(parent);
return mFastItemAdapter.getTypeInstance(viewType).getViewHolder(parent);
}

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

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.adapters.GenericItemAdapter;
import com.mikepenz.fastadapter.app.generic.GenericIconItem;
import com.mikepenz.fastadapter.app.generic.IconModel;
import com.mikepenz.fastadapter.app.generic.RightGenericIconItem;
import com.mikepenz.fastadapter.utils.Function;
import com.mikepenz.iconics.Iconics;
import com.mikepenz.iconics.typeface.ITypeface;
import com.mikepenz.itemanimators.SlideDownAlphaAnimator;
import com.mikepenz.materialize.MaterializeBuilder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

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

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);

//improve ui
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.sample_multi_generic_item);

//style our ui
new MaterializeBuilder().withActivity(this).build();


//create our FastAdapter which will manage everything
fastAdapter = new FastAdapter();

//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);

//if you need multiple items for different models you can also do this be defining a Function which get's the model object and returns the item (extends IItem)
GenericItemAdapter itemAdapter = new GenericItemAdapter(new Function() {
@Override
public Object apply(Object o) {
//depending on your logic you can now decide which model maps to which item.
if (o instanceof IconModel) {
if (((IconModel) o).normal) {
return new GenericIconItem((IconModel) o);
} else {
return new RightGenericIconItem((IconModel) o);
}
} else {
throw new IllegalArgumentException("The passed model can't be created within this Factory");
}
}
});

rv.setLayoutManager(gridLayoutManager);
rv.setItemAnimator(new SlideDownAlphaAnimator());
rv.setAdapter(itemAdapter.wrap(fastAdapter));

//order fonts by their name
List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
Collections.sort(mFonts, new Comparator<ITypeface>() {
@Override
public int compare(final ITypeface object1, final ITypeface object2) {
return object1.getFontName().compareTo(object2.getFontName());
}
});

//add all icons of all registered Fonts to the list
ArrayList<IconModel> models = new ArrayList<>();
int i = 0;
for (ITypeface font : mFonts) {
for (String icon : font.getIcons()) {
if (i % 3 == 0) {
models.add(new IconModel(font.getIcon(icon)));
} else {
models.add(new IconModel(font.getIcon(icon), false));
}
i++;
}
}

//fill with some sample data
itemAdapter.addModel(models);

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

//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
//add the values which need to be saved from the adapter to the bundel
outState = fastAdapter.saveInstanceState(outState);
super.onSaveInstanceState(outState);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
//handle the click on the back arrow click
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;

default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public boolean onLongClick(View v, IAdapter<SampleItem> adapter, SampleItem item
rv.setAdapter(itemAdapter.wrap(headerAdapter.wrap(mFastAdapter)));

//fill with some sample data
headerAdapter.add(new SampleItem().withName("Header").withIdentifier(1));
headerAdapter.add(new SampleItem().withName("Header").withIdentifier(1).withSelectable(false));
List<SampleItem> items = new ArrayList<>();
for (int i = 1; i <= 100; i++) {
items.add(new SampleItem().withName("Test " + i).withIdentifier(100 + i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected void onCreate(Bundle savedInstanceState) {
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_generic_item).withDescription(R.string.sample_generic_item_descr).withSelectable(false).withIdentifier(7).withIcon(MaterialDesignIconic.Icon.gmi_font),
new PrimaryDrawerItem().withName(R.string.sample_multi_generic_item).withDescription(R.string.sample_multi_generic_item_descr).withSelectable(false).withIdentifier(9).withIcon(MaterialDesignIconic.Icon.gmi_format_list_numbered),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName(R.string.open_source).withSelectable(false).withIdentifier(100).withIcon(MaterialDesignIconic.Icon.gmi_github)
)
Expand All @@ -96,6 +97,8 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
intent = new Intent(SampleActivity.this, GenericItemActivity.class);
} else if (drawerItem.getIdentifier() == 8) {
intent = new Intent(SampleActivity.this, IconGridActivity.class);
} else if (drawerItem.getIdentifier() == 9) {
intent = new Intent(SampleActivity.this, MultiTypeGenericItemActivity.class);
} else if (drawerItem.getIdentifier() == 100) {
intent = new LibsBuilder()
.withFields(R.string.class.getFields())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.mikepenz.fastadapter.drag.SimpleDragCallback;
import com.mikepenz.materialize.MaterializeBuilder;
import com.turingtechnologies.materialscrollbar.AlphabetIndicator;
import com.turingtechnologies.materialscrollbar.MaterialScrollBar;
import com.turingtechnologies.materialscrollbar.DragScrollBar;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -94,8 +94,8 @@ public boolean filter(SampleItem item, CharSequence constraint) {
recyclerView.setAdapter(fastScrollIndicatorAdapter.wrap(fastItemAdapter));

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

//fill with some sample data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public GenericIconItem(IconModel icon) {
*/
@Override
public int getType() {
return R.id.fastadapter_icon_item_id;
return R.id.fastadapter_generic_icon_item_id;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ public IconModel(IIcon icon) {
this.icon = icon;
}

public IconModel(IIcon icon, boolean normal) {
this.icon = icon;
this.normal = normal;
}

public IIcon icon;

public boolean normal = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mikepenz.fastadapter.app.generic;

import com.mikepenz.fastadapter.app.R;

/**
* Created by mikepenz on 28.12.15.
*/
public class RightGenericIconItem extends GenericIconItem {
public RightGenericIconItem(IconModel icon) {
super(icon);
}

/**
* defines the type defining this item. must be unique. preferably an id
*
* @return the type
*/
@Override
public int getType() {
return R.id.fastadapter_right_generic_icon_item_id;
}

/**
* defines the layout which will be used for this item in the list
*
* @return the layout for this item
*/
@Override
public int getLayoutRes() {
return R.layout.right_icon_item;
}
}
45 changes: 45 additions & 0 deletions app/src/main/res/layout/right_icon_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2014 Mike Penz
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clickable="true"
android:orientation="horizontal">

<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/button_rect_list_normal"
android:clickable="false"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="56dp"
android:paddingStart="8dp"
android:textColor="@color/md_light_primary_text"
android:textSize="14sp" />

<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="right"
android:clickable="false"
android:padding="8dp"
android:scaleType="fitXY" />
</android.support.v7.widget.CardView>
2 changes: 2 additions & 0 deletions app/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
<item name="fastadapter_image_item_id" type="id" />
<item name="fastadapter_simple_image_item_id" type="id" />
<item name="fastadapter_icon_item_id" type="id" />
<item name="fastadapter_generic_icon_item_id" type="id" />
<item name="fastadapter_right_generic_icon_item_id" type="id" />
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<string name="sample_advanced_descr">Header, StickyHeader, Expandable, CAB, MultiSelect</string>
<string name="sample_generic_item">GenericItem Sample</string>
<string name="sample_generic_item_descr">Split up Item and Model</string>
<string name="sample_multi_generic_item">MultiGenericItem Sample</string>
<string name="sample_multi_generic_item_descr">Split up multiple Items and Models in one GenericAdapter</string>
<string name="open_source">Open Source</string>
<string name="search_title">Suche</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha7'
classpath 'com.android.tools.build:gradle:2.0.0-alpha8'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
Expand Down
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=1.0.0
VERSION_CODE=100
VERSION_NAME=1.0.1
VERSION_CODE=101
GROUP=com.mikepenz

POM_DESCRIPTION=FastAdapter Library
Expand Down
Loading

0 comments on commit bb30c6b

Please sign in to comment.