-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
559 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FastAdapter contributors (sorted alphabeticaly) | ||
============================================ | ||
|
||
* **[Fabian Terhorst](https://github.com/FabianTerhorst)** | ||
|
||
* EndlessScroll-Listener (EndlessScroll Sample) | ||
|
||
* **[Mattias Isegran Bergander](https://github.com/mattiasbe)** | ||
|
||
* "Leave-Behind"-Pattern (SwipeList Sample) | ||
|
||
* **[Rainer Lang](https://github.com/Rainer-Lang)** | ||
|
||
* |
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 |
---|---|---|
|
@@ -8,37 +8,37 @@ Beside being blazing fast, minimizing the code you need to write, it is also rea | |
|
||
##A quick overview: | ||
- Click / Long-Click listeners | ||
- Selection / Multi-Selection [MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.java) | ||
- Selection / Multi-Selection [ | ||
- [MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.java) | ||
- [CheckBoxSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/CheckBoxSampleActivity.java) | ||
- [RadioButtonSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/RadioButtonSampleActivity.java) | ||
- Expandable items | ||
- [ExpandableSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ExpandableSampleActivity.java) | ||
- [IconGridSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/IconGridActivity.java) | ||
- [AdvancedSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.java) | ||
- Write less code, get better results | ||
- Simple Drag & Drop | ||
- [SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
- Highly optimized code | ||
- Simple Drag & Drop [(SimpleItemListSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
- Headers | ||
- [StickyHeaderSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.java) | ||
- [AdvancedSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.java) | ||
- Footers | ||
- FastScroller (external lib) | ||
- [SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
- Filter | ||
- [SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
- Highly optimized code | ||
- Filter [(SimpleItemListSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
- Includes suggestions from the Android Team | ||
- Easily extensible | ||
- Endless Scroll [(EndlessScrollSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/EndlessScrollListActivity.java) | ||
- "Leave-Behind"-Pattern [(SwipeListSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SwipeListActivity.java) | ||
- Split item view and model | ||
- [GenericItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/GenericItemActivity.java) | ||
- [MultiTypeGenericItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiTypeGenericItemActivity.java) | ||
- Chain other Adapters | ||
- [SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
- [StickyHeaderSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.java) | ||
- Comes with useful Helpers | ||
- ActionModeHelper [MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.java) | ||
- UndoHelper [MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.java) | ||
- ActionModeHelper [(MultiselectSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.java) | ||
- UndoHelper [(MultiselectSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.java) | ||
- More to come... | ||
- FastScroller (external lib) [(SimpleItemListSample)](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java) | ||
|
||
#Preview | ||
##Demo | ||
|
@@ -52,14 +52,14 @@ You can try it out here [Google Play](https://play.google.com/store/apps/details | |
|
||
The library is split up into core, and extensions. The core functions are included in the following dependency. | ||
```gradle | ||
compile('com.mikepenz:fastadapter:1.1.2@aar') { | ||
compile('com.mikepenz:fastadapter:1.2.0@aar') { | ||
transitive = true | ||
} | ||
``` | ||
|
||
All additions are included in the following dependency. | ||
```gradle | ||
compile 'com.mikepenz:fastadapter-extensions:1.1.2@aar' | ||
compile 'com.mikepenz:fastadapter-extensions:1.2.0@aar' | ||
``` | ||
|
||
|
||
|
@@ -142,6 +142,10 @@ Other Libs: | |
* Mike Penz | ||
* [mikepenz.com](http://mikepenz.com) - <[email protected]> | ||
* [paypal.me/mikepenz](http://paypal.me/mikepenz) | ||
|
||
#Contributors | ||
|
||
This free, open source software was also made possible by a group of volunteers that put many hours of hard work into it. See the [CONTRIBUTORS.md](CONTRIBUTORS.md) file for details. | ||
|
||
#License | ||
|
||
|
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
201 changes: 201 additions & 0 deletions
201
app/src/main/java/com/mikepenz/fastadapter/app/EndlessScrollListActivity.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,201 @@ | ||
package com.mikepenz.fastadapter.app; | ||
|
||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.DefaultItemAnimator; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.SearchView; | ||
import android.support.v7.widget.Toolbar; | ||
import android.support.v7.widget.helper.ItemTouchHelper; | ||
import android.text.TextUtils; | ||
import android.view.Menu; | ||
import android.view.MenuInflater; | ||
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.IItemAdapter; | ||
import com.mikepenz.fastadapter.adapters.FastItemAdapter; | ||
import com.mikepenz.fastadapter.adapters.FooterAdapter; | ||
import com.mikepenz.fastadapter.adapters.ItemAdapter.ItemFilterListener; | ||
import com.mikepenz.fastadapter.app.items.SampleItem; | ||
import com.mikepenz.fastadapter_extensions.drag.ItemTouchCallback; | ||
import com.mikepenz.fastadapter_extensions.drag.SimpleDragCallback; | ||
import com.mikepenz.fastadapter_extensions.items.ProgressItem; | ||
import com.mikepenz.fastadapter_extensions.scroll.EndlessRecyclerOnScrollListener; | ||
import com.mikepenz.materialize.MaterializeBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class EndlessScrollListActivity extends AppCompatActivity implements ItemTouchCallback, ItemFilterListener { | ||
|
||
//save our FastAdapter | ||
private FastItemAdapter<SampleItem> fastItemAdapter; | ||
private FooterAdapter<ProgressItem> footerAdapter; | ||
|
||
//drag & drop | ||
private SimpleDragCallback touchCallback; | ||
private ItemTouchHelper touchHelper; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_sample); | ||
|
||
// Handle Toolbar | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
|
||
//style our ui | ||
new MaterializeBuilder().withActivity(this).build(); | ||
|
||
//create our FastAdapter which will manage everything | ||
fastItemAdapter = new FastItemAdapter<>(); | ||
|
||
//create our FooterAdapter which will manage the progress items | ||
footerAdapter = new FooterAdapter<>(); | ||
|
||
//configure our fastAdapter | ||
fastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<SampleItem>() { | ||
@Override | ||
public boolean onClick(View v, IAdapter<SampleItem> adapter, SampleItem item, int position) { | ||
Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show(); | ||
return false; | ||
} | ||
}); | ||
|
||
//configure the itemAdapter | ||
fastItemAdapter.withFilterPredicate(new IItemAdapter.Predicate<SampleItem>() { | ||
@Override | ||
public boolean filter(SampleItem item, CharSequence constraint) { | ||
//return true if we should filter it out | ||
//return false to keep it | ||
return !item.name.getText().toLowerCase().contains(constraint.toString().toLowerCase()); | ||
} | ||
}); | ||
|
||
fastItemAdapter.getItemAdapter().withItemFilterListener(this); | ||
|
||
//get our recyclerView and do basic setup | ||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv); | ||
LinearLayoutManager manager = new LinearLayoutManager(this); | ||
recyclerView.setLayoutManager(manager); | ||
recyclerView.setItemAnimator(new DefaultItemAnimator()); | ||
recyclerView.setAdapter(footerAdapter.wrap(fastItemAdapter)); | ||
recyclerView.addOnScrollListener(new EndlessRecyclerOnScrollListener(manager, 15) { | ||
@Override | ||
public void onLoadMore(final int currentPage) { | ||
new Handler().postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
footerAdapter.clear(); | ||
footerAdapter.add(new ProgressItem()); | ||
//simulate networking (2 seconds) | ||
Handler handler = new Handler(); | ||
handler.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
footerAdapter.clear(); | ||
for (int i = 1; i < 16; i++) { | ||
fastItemAdapter.add(fastItemAdapter.getAdapterItemCount(), new SampleItem().withName("Item " + i + " Page " + currentPage)); | ||
} | ||
} | ||
}, 2000); | ||
} | ||
}, 10); | ||
|
||
} | ||
}); | ||
|
||
//fill with some sample data (load the first page here) | ||
List<SampleItem> items = new ArrayList<>(); | ||
for (int i = 1; i < 16; i++) { | ||
items.add(new SampleItem().withName("Item " + i + " Page " + 1)); | ||
} | ||
fastItemAdapter.add(items); | ||
|
||
//add drag and drop for item | ||
touchCallback = new SimpleDragCallback(this); | ||
touchHelper = new ItemTouchHelper(touchCallback); // Create ItemTouchHelper and pass with parameter the SimpleDragCallback | ||
touchHelper.attachToRecyclerView(recyclerView); // Attach ItemTouchHelper to RecyclerView | ||
|
||
//restore selections (this has to be done after the items were added | ||
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 adapter to the bundel | ||
outState = fastItemAdapter.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); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu items for use in the action bar | ||
MenuInflater inflater = getMenuInflater(); | ||
inflater.inflate(R.menu.search, menu); | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | ||
final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); | ||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { | ||
@Override | ||
public boolean onQueryTextSubmit(String s) { | ||
touchCallback.setIsDragEnabled(false); | ||
fastItemAdapter.filter(s); | ||
return true; | ||
} | ||
|
||
|
||
@Override | ||
public boolean onQueryTextChange(String s) { | ||
fastItemAdapter.filter(s); | ||
touchCallback.setIsDragEnabled(TextUtils.isEmpty(s)); | ||
return true; | ||
} | ||
}); | ||
} else { | ||
menu.findItem(R.id.search).setVisible(false); | ||
} | ||
|
||
return super.onCreateOptionsMenu(menu); | ||
} | ||
|
||
@Override | ||
public boolean itemTouchOnMove(int oldPosition, int newPosition) { | ||
Collections.swap(fastItemAdapter.getAdapterItems(), oldPosition, newPosition); // change position | ||
fastItemAdapter.notifyAdapterItemMoved(oldPosition, newPosition); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void itemsFiltered() { | ||
Toast.makeText(EndlessScrollListActivity.this, "filtered items count: " + fastItemAdapter.getItemCount(), Toast.LENGTH_SHORT).show(); | ||
} | ||
} |
Oops, something went wrong.