Skip to content

Commit

Permalink
Merge branch 'release/v0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 18, 2016
2 parents f3378aa + fb6533f commit a98210e
Show file tree
Hide file tree
Showing 39 changed files with 1,356 additions and 237 deletions.
2 changes: 1 addition & 1 deletion 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.8.1@aar') {
compile('com.mikepenz:fastadapter:0.9.0@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 81
versionName '0.8.1'
versionCode 90
versionName '0.9.0'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:label="@string/app_name"
android:theme="@style/CustomTheme">
<!-- android:supportsRtl="true" -->
<activity android:name=".IconGridActivity">
<activity android:name=".SampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -33,5 +33,11 @@
<activity
android:name=".AdvancedSampleActivity"
android:label="@string/sample_advanced" />
<activity
android:name=".TypedItemActivity"
android:label="@string/sample_typed_item" />
<activity
android:name=".IconGridActivity"
android:label="@string/sample_icon_grid" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ 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);
Expand All @@ -70,7 +73,7 @@ protected void onCreate(Bundle savedInstanceState) {
mFastAdapter.setHasStableIds(true);
mFastAdapter.withMultiSelect(true);
mFastAdapter.withMultiSelectOnLongClick(true);
mFastAdapter.withOnClickListener(new FastAdapter.OnClickListener() {
mFastAdapter.withOnPreClickListener(new FastAdapter.OnClickListener() {
@Override
public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
//we handle the default onClick behavior for the actionMode. This will return null if it didn't do anything and you can handle a normal onClick
Expand All @@ -79,7 +82,7 @@ public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
}
});

mFastAdapter.withOnLongClickListener(new FastAdapter.OnLongClickListener() {
mFastAdapter.withOnPreLongClickListener(new FastAdapter.OnLongClickListener() {
@Override
public boolean onLongClick(View v, IAdapter adapter, IItem item, int position) {
ActionMode actionMode = mActionModeHelper.onLongClick(AdvancedSampleActivity.this, position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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.adapters.FastItemAdapter;
import com.mikepenz.fastadapter.app.items.SampleItem;
import com.mikepenz.itemanimators.SlideDownAlphaAnimator;
import com.mikepenz.materialize.MaterializeBuilder;
Expand All @@ -22,13 +22,16 @@

public class CollapsibleSampleActivity extends AppCompatActivity {
//save our FastAdapter
private FastAdapter fastAdapter;
private FastItemAdapter fastItemAdapter;

@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);
Expand All @@ -38,20 +41,15 @@ protected void onCreate(Bundle savedInstanceState) {
new MaterializeBuilder().withActivity(this).build();

//create our FastAdapter
fastAdapter = new FastAdapter();

//create our adapters
final ItemAdapter<SampleItem> itemAdapter = new ItemAdapter<>();
fastItemAdapter = new FastItemAdapter();

//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() {
fastItemAdapter.withOnPreClickListener(new FastAdapter.OnClickListener() {
@Override
public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
if (item instanceof SampleItem) {
if (((SampleItem) item).getSubItems() != null) {
fastAdapter.toggleExpandable(position);
fastItemAdapter.toggleExpandable(position);
return true;
}
}
Expand All @@ -63,7 +61,7 @@ public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
rv.setLayoutManager(new LinearLayoutManager(this));
rv.setItemAnimator(new SlideDownAlphaAnimator());
rv.setAdapter(itemAdapter.wrap(fastAdapter));
rv.setAdapter(fastItemAdapter);

//fill with some sample data
List<SampleItem> items = new ArrayList<>();
Expand All @@ -80,10 +78,10 @@ public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
}
items.add(sampleItem);
}
itemAdapter.add(items);
fastItemAdapter.add(items);

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

//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Expand All @@ -93,7 +91,7 @@ public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
@Override
protected void onSaveInstanceState(Bundle outState) {
//add the values which need to be saved from the adapter to the bundel
outState = fastAdapter.saveInstanceState(outState);
outState = fastItemAdapter.saveInstanceState(outState);
super.onSaveInstanceState(outState);
}

Expand Down
113 changes: 34 additions & 79 deletions app/src/main/java/com/mikepenz/fastadapter/app/IconGridActivity.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
package com.mikepenz.fastadapter.app;

import android.content.Intent;
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.aboutlibraries.Libs;
import com.mikepenz.aboutlibraries.LibsBuilder;
import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.IExpandable;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.fastadapter.adapters.FastItemAdapter;
import com.mikepenz.fastadapter.app.items.IconItem;
import com.mikepenz.fastadapter.app.items.SampleItem;
import com.mikepenz.iconics.Iconics;
import com.mikepenz.iconics.typeface.ITypeface;
import com.mikepenz.itemanimators.SlideDownAlphaAnimator;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import com.mikepenz.materialize.MaterializeBuilder;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -36,84 +30,37 @@ public class IconGridActivity extends AppCompatActivity {
//save our header or result
private Drawer result = null;
//save our FastAdapter
private FastAdapter<IItem> fastAdapter;
private FastItemAdapter fastItemAdapter;

@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_icon_grid);

//Create the drawer
result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withHasStableIds(true)
.withSavedInstance(savedInstanceState)
.withShowDrawerOnFirstLaunch(true)
.addDrawerItems(
new PrimaryDrawerItem().withName(R.string.sample_simple_item_list).withSelectable(false).withIdentifier(6).withIcon(MaterialDesignIconic.Icon.gmi_format_align_justify),
new PrimaryDrawerItem().withName(R.string.sample_image_list).withSelectable(false).withIdentifier(5).withIcon(MaterialDesignIconic.Icon.gmi_wallpaper),
new PrimaryDrawerItem().withName(R.string.sample_multi_select).withSelectable(false).withIdentifier(1).withIcon(MaterialDesignIconic.Icon.gmi_select_all),
new PrimaryDrawerItem().withName(R.string.sample_collapsible).withSelectable(false).withIdentifier(2).withIcon(MaterialDesignIconic.Icon.gmi_check_all),
new PrimaryDrawerItem().withName(R.string.sample_sticky_header).withSelectable(false).withIdentifier(3).withIcon(MaterialDesignIconic.Icon.gmi_format_align_left),
new PrimaryDrawerItem().withName(R.string.sample_advanced).withSelectable(false).withDescription(R.string.sample_advanced_descr).withIdentifier(4).withIcon(MaterialDesignIconic.Icon.gmi_coffee),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName(R.string.open_source).withSelectable(false).withIdentifier(100).withIcon(MaterialDesignIconic.Icon.gmi_github)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem != null) {
Intent intent = null;
if (drawerItem.getIdentifier() == 1) {
intent = new Intent(IconGridActivity.this, MultiselectSampleActivity.class);
} else if (drawerItem.getIdentifier() == 2) {
intent = new Intent(IconGridActivity.this, CollapsibleSampleActivity.class);
} else if (drawerItem.getIdentifier() == 3) {
intent = new Intent(IconGridActivity.this, StickyHeaderSampleActivity.class);
} else if (drawerItem.getIdentifier() == 4) {
intent = new Intent(IconGridActivity.this, AdvancedSampleActivity.class);
} else if (drawerItem.getIdentifier() == 5) {
intent = new Intent(IconGridActivity.this, ImageListActivity.class);
} else if (drawerItem.getIdentifier() == 6) {
intent = new Intent(IconGridActivity.this, SimpleItemListActivity.class);
} else if (drawerItem.getIdentifier() == 100) {
intent = new LibsBuilder()
.withFields(R.string.class.getFields())
.withActivityTitle(getString(R.string.open_source))
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
.intent(IconGridActivity.this);
}
if (intent != null) {
IconGridActivity.this.startActivity(intent);
}
}
return false;
}
})
.withSelectedItemByPosition(-1)
.build();
//style our ui
new MaterializeBuilder().withActivity(this).build();

//create our FastAdapter which will manage everything
fastAdapter = new FastAdapter<IItem>();
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<IItem>() {
fastItemAdapter = new FastItemAdapter();
fastItemAdapter.withOnPreClickListener(new FastAdapter.OnClickListener<IItem>() {
@Override
public boolean onClick(View v, IAdapter<IItem> adapter, IItem item, int position) {
if (item instanceof IExpandable && ((IExpandable) item).getSubItems() != null) {
fastAdapter.toggleExpandable(position);
fastItemAdapter.toggleExpandable(position);
return true;
}
return false;
}
});

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

//get our recyclerView and do basic setup
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

Expand All @@ -122,19 +69,20 @@ public boolean onClick(View v, IAdapter<IItem> adapter, IItem item, int position
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
switch (fastAdapter.getItemViewType(position)) {
switch (fastItemAdapter.getItemViewType(position)) {
case R.id.fastadapter_sample_item_id:
return 3;
case R.id.fastadapter_icon_item_id:
return 1;
default:
return 1;
return -1;
}
}
});

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

//order fonts by their name
List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
Expand All @@ -160,31 +108,38 @@ public int compare(final ITypeface object1, final ITypeface object2) {
}

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

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

//restore selections (this has to be done after the items were added
fastAdapter.withSavedInstanceState(savedInstanceState);
fastItemAdapter.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 drawer to the bundle
outState = result.saveInstanceState(outState);
//add the values which need to be saved from the adapter to the bundel
outState = fastAdapter.saveInstanceState(outState);
outState = fastItemAdapter.saveInstanceState(outState);
super.onSaveInstanceState(outState);
}

@Override
public void onBackPressed() {
//handle the back press :D close the drawer first and if the drawer is closed close the activity
if (result != null && result.isDrawerOpen()) {
result.closeDrawer();
} else {
super.onBackPressed();
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);
}
}
}
Loading

0 comments on commit a98210e

Please sign in to comment.