Skip to content

Commit

Permalink
Merge branch 'release/v0.5.0-SNAPSHOT'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 8, 2016
2 parents 975d508 + 0ce200a commit 0d92f30
Show file tree
Hide file tree
Showing 24 changed files with 564 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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.4.2-SNAPSHOT@aar') {
compile('com.mikepenz:fastadapter:0.5.0-SNAPSHOT@aar') {
transitive = true
}

Expand Down
12 changes: 8 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "com.mikepenz.crossfader.app"
minSdkVersion 11
targetSdkVersion 23
versionCode 42
versionName '0.4.2-SNAPSHOT'
versionCode 50
versionName '0.5.0-SNAPSHOT'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down Expand Up @@ -53,8 +52,9 @@ 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.b4-SNAPSHOT@aar') {
transitive = true
exclude module: "fastadapter"
}
//used to generate the Open Source section
//https://github.com/mikepenz/AboutLibraries
Expand All @@ -73,4 +73,8 @@ dependencies {

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

//used to load the images in the ImageListSample
//https://github.com/bumptech/glide
compile 'com.github.bumptech.glide:glide:3.6.1'
}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ImageListActivity"
android:label="@string/sample_image_list" />
<activity
android:name=".MultiselectSampleActivity"
android:label="@string/sample_multi_select" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean onClick(View v, IAdapter adapter, IItem item, int position) {
//fill with some sample data
List<SampleItem> items = new ArrayList<>();
for (int i = 1; i <= 100; i++) {
SampleItem sampleItem = new SampleItem().withName("Test " + i + (i % 10 == 0 ? "(Collapsible)" : "")).withIdentifier(100 + i);
SampleItem sampleItem = new SampleItem().withName("Test " + i + (i % 10 == 0 ? " (Collapsible)" : "")).withIdentifier(100 + i);

//add subitems so we can showcase the collapsible functionality
if (i % 10 == 0) {
Expand Down
106 changes: 106 additions & 0 deletions app/src/main/java/com/mikepenz/fastadapter/app/ImageListActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.mikepenz.fastadapter.app;

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

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 {
//save our FastAdapter
private FastAdapter<ImageItem> fastAdapter;

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

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

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

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

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

//configure our fastAdapter
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener() {
@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();
return false;
}
});

//get our recyclerView and do basic setup
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
//find out how many columns we display
int columns = getResources().getInteger(R.integer.wall_splash_columns);
if (columns == 1) {
//linearLayoutManager for one column
rv.setLayoutManager(new LinearLayoutManager(this));
} else {
//gridLayoutManager for more than one column ;)
rv.setLayoutManager(new GridLayoutManager(this, columns));
}
rv.setItemAnimator(new DefaultItemAnimator());
rv.setAdapter(itemAdapter.wrap(fastAdapter));

//fill with some sample data
itemAdapter.add(ImageDummyData.getImages(mOnLovedClickListener));

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

private ImageItem.OnItemClickListener mOnLovedClickListener = new ImageItem.OnItemClickListener() {
@Override
public void onLovedClick(String image, boolean starred) {
Toast.makeText(ImageListActivity.this, image + " - " + starred, Toast.LENGTH_SHORT).show();
}
};

@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 @@ -55,6 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
.withSavedInstance(savedInstanceState)
.withShowDrawerOnFirstLaunch(true)
.addDrawerItems(
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),
Expand All @@ -75,6 +76,8 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
intent = new Intent(SampleActivity.this, StickyHeaderSampleActivity.class);
} else if (drawerItem.getIdentifier() == 4) {
intent = new Intent(SampleActivity.this, AdvancedSampleActivity.class);
} else if (drawerItem.getIdentifier() == 5) {
intent = new Intent(SampleActivity.this, ImageListActivity.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
@@ -0,0 +1,53 @@
package com.mikepenz.fastadapter.app.dummy;

import com.mikepenz.fastadapter.app.items.ImageItem;

import java.util.Arrays;
import java.util.List;

/**
* Created by mikepenz on 08.01.16.
*/
public class ImageDummyData {

public static List<ImageItem> getImages(ImageItem.OnItemClickListener onItemClickListener) {
return toList(
new ImageItem().withName("Yang Zhuo Yong Cuo, Tibet China").withDescription("#100063").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/yang_zhuo_yong_cuo,_tibet-china-63.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Yellowstone United States").withDescription("#100017").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/yellowstone-united_states-17.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Victoria Australia").withDescription("#100031").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/victoria-australia-31.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Valencia Spain").withDescription("#100082").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/valencia-spain-82.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Xigaze, Tibet China").withDescription("#100030").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/xigaze,_tibet-china-30.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Utah United States").withDescription("#100096").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/utah-united_states-96.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Utah United States").withDescription("#100015").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/utah-united_states-15.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Utah United States").withDescription("#100088").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/utah-united_states-88.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Umm Al Quwain United Arab Emirates").withDescription("#100013").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/umm_al_quwain-united_arab_emirates-13.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Texas United States").withDescription("#100026").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/texas-united_states-26.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Siuslaw National Forest United States").withDescription("#100092").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/siuslaw_national_forest-united_states-92.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("The Minquiers Channel Islands").withDescription("#100069").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/the_minquiers-channel_islands-69.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Texas United States").withDescription("#100084").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/texas-united_states-84.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Tabuaeran Kiribati").withDescription("#100050").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/tabuaeran-kiribati-50.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Stanislaus River United States").withDescription("#100061").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/stanislaus_river-united_states-61.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("S?ehitkamil Turkey").withDescription("#100072").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/s?ehitkamil-turkey-72.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Salinas Grandes Argentina").withDescription("#100025").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/salinas_grandes-argentina-25.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Shadegan Refuge Iran").withDescription("#100012").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/shadegan_refuge-iran-12.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("San Pedro De Atacama Chile").withDescription("#100043").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/san_pedro_de_atacama-chile-43.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Ragged Island The Bahamas").withDescription("#100064").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/ragged_island-the_bahamas-64.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Qinghai Lake China").withDescription("#100080").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/qinghai_lake-china-80.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Qesm Al Wahat Ad Dakhlah Egypt").withDescription("#100056").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/qesm_al_wahat_ad_dakhlah-egypt-56.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Riedstadt Germany").withDescription("#100042").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/riedstadt-germany-42.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Redwood City United States").withDescription("#100048").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/redwood_city-united_states-48.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Nyingchi, Tibet China").withDescription("#100098").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/nyingchi,_tibet-china-98.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Ngari, Tibet China").withDescription("#100057").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/ngari,_tibet-china-57.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Pozoantiguo Spain").withDescription("#100099").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/pozoantiguo-spain-99.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Ningaloo Australia").withDescription("#100073").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/ningaloo-australia-73.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Niederzier Germany").withDescription("#100079").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/niederzier-germany-79.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Olympic Dam Australia").withDescription("#100065").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/olympic_dam-australia-65.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Peedamulla Australia").withDescription("#100040").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/peedamulla-australia-40.jpg").withOnItemClickListener(onItemClickListener),
new ImageItem().withName("Nevado Tres Cruces Park Chile").withDescription("#100089").withImage("https://raw.githubusercontent.com/mikepenz/earthview-wallpapers/develop/thumb/nevado_tres_cruces_park-chile-89.jpg").withOnItemClickListener(onItemClickListener)
);
}

private static List<ImageItem> toList(ImageItem... imageItems) {
return Arrays.asList(imageItems);
}
}
Loading

0 comments on commit 0d92f30

Please sign in to comment.