-
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v0.5.0-SNAPSHOT'
- Loading branch information
Showing
24 changed files
with
564 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
app/src/main/java/com/mikepenz/fastadapter/app/ImageListActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/mikepenz/fastadapter/app/dummy/ImageDummyData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.