Skip to content

Commit

Permalink
Merge branch 'release/v4.1.0-b02'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Sep 1, 2019
2 parents 2c16de8 + b782d1f commit 6f3f534
Show file tree
Hide file tree
Showing 84 changed files with 641 additions and 937 deletions.
2 changes: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
v4 is a huge release changing most of the codebase to Kotlin. This comes with many refactors, and as a result of that with many breaking API changes.
We put a lot of focus on type safety with this release, as such this release is a lot more strict and tries to prevent as many potential bad type mixups as possible.

* As a result of the Kotlin migration the static methods can now be accessed via `FastAdapter.Companion`. E.g.: `FastAdapter.Companion.with(...)`
* For compatibility, most existing static fields and functions remain static in Java. For newer functions, accessing from Java may require using the `Companion` class. For instance, `FastAdapter.example()` becomes `FastAdapter.Companion.example()`
* The `IItem` interface now requires a type specification. E.g. `IItem<RecyclerView.ViewHolder>`
* The `SelectExtension` is no longer default enabled and wrapped in the `FastAdapter` use its API standalone. E.g.: `selectExtension.setSelectable(true)`, ...
* Extensions can be retrieved via `getOrCreateExtension`. `SelectExtension<?> selectExtension = (SelectExtension<?>) mFastAdapter.getOrCreateExtension(SelectExtension.class)`
Expand Down
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ Beside being blazing fast, minimizing the code you need to write, it is also rea
## A quick overview:
- Core module 100% in Kotlin
- 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), [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))
- Selection / Multi-Selection ([MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.kt), [CheckBoxSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/CheckBoxSampleActivity.kt), [RadioButtonSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/RadioButtonSampleActivity.kt))
- Expandable items ([ExpandableSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ExpandableSampleActivity.kt), [IconGridSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/IconGridActivity.kt) ,[AdvancedSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.kt))
- Write less code, get better results
- 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))
- Simple Drag & Drop ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt))
- Headers ([StickyHeaderSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.kt), [AdvancedSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.kt))
- Footers
- Filter ([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.kt))
- 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 ([ModelItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ModelItemActivity.java), [MultiTypeModelItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiTypeModelItemActivity.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))
- Endless Scroll ([EndlessScrollSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/EndlessScrollListActivity.kt))
- "Leave-Behind"-Pattern ([SwipeListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SwipeListActivity.kt))
- Split item view and model ([ModelItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/ModelItemActivity.kt), [MultiTypeModelItem](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiTypeModelItemActivity.kt))
- Chain other Adapters ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt), [StickyHeaderSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/StickyHeaderSampleActivity.kt))
- 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.kt))
- UndoHelper ([MultiselectSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/MultiselectSampleActivity.kt))
- More to come...
- FastScroller (external lib) ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.java))
- FastScroller (external lib) ([SimpleItemListSample](https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SimpleItemListActivity.kt))

# Preview
## Demo
Expand All @@ -40,39 +40,39 @@ You can try it out here [Google Play](https://play.google.com/store/apps/details
# Include in your project
## Latest releases

- Kotlin | [v4.0.0](https://github.com/mikepenz/FastAdapter/tree/v4.0.0)
- Kotlin | [v4.1.0-b02](https://github.com/mikepenz/FastAdapter/tree/v4.1.0-b02)
- Java && AndroidX | [v3.3.1](https://github.com/mikepenz/FastAdapter/tree/v3.3.1)
- Java && AppCompat | [v3.2.9](https://github.com/mikepenz/FastAdapter/tree/v3.2.9)

## Using Maven

The library is split up into core, commons, and extensions. The core functions are included in the following dependency.
```gradle
implementation 'com.mikepenz:fastadapter:${latestFastAdapterRelease}'
implementation "com.mikepenz:fastadapter:${latestFastAdapterRelease}"
implementation "androidx.appcompat:appcompat:${androidX}"
implementation "androidx.recyclerview:recyclerview:${androidX}"
```

Expandable support is included and can be added via this
```gradle
implementation 'com.mikepenz:fastadapter-extensions-expandable:${latestFastAdapterRelease}'
implementation "com.mikepenz:fastadapter-extensions-expandable:${latestFastAdapterRelease}"
//The tiny Materialize library used for its useful helper classes
implementation 'com.mikepenz:materialize:${latestVersion}' // at least 1.2.0
implementation "com.mikepenz:materialize:${latestVersion}" // at least 1.2.0
```

Many helper classes are included in the following dependency.
```gradle
implementation 'com.mikepenz:fastadapter-extensions-diff:${latestFastAdapterRelease}' // diff util helpers
implementation 'com.mikepenz:fastadapter-extensions-drag:${latestFastAdapterRelease}' // drag support
implementation 'com.mikepenz:fastadapter-extensions-scroll${latestFastAdapterRelease}' // scroll helpers
implementation 'com.mikepenz:fastadapter-extensions-swipe:${latestFastAdapterRelease}' // swipe support
implementation 'com.mikepenz:fastadapter-extensions-ui:${latestFastAdapterRelease}' // pre-defined ui components
implementation 'com.mikepenz:fastadapter-extensions-utils:${latestFastAdapterRelease}' // needs the `expandable`, `drag` and `scroll` extension.
implementation "com.mikepenz:fastadapter-extensions-diff:${latestFastAdapterRelease}" // diff util helpers
implementation "com.mikepenz:fastadapter-extensions-drag:${latestFastAdapterRelease}" // drag support
implementation "com.mikepenz:fastadapter-extensions-scroll${latestFastAdapterRelease}" // scroll helpers
implementation "com.mikepenz:fastadapter-extensions-swipe:${latestFastAdapterRelease}" // swipe support
implementation "com.mikepenz:fastadapter-extensions-ui:${latestFastAdapterRelease}" // pre-defined ui components
implementation "com.mikepenz:fastadapter-extensions-utils:${latestFastAdapterRelease}" // needs the `expandable`, `drag` and `scroll` extension.
// required for the ui components and the utils
implementation "com.google.android.material:material:${androidX}"
//The tiny Materialize library used for its useful helper classes
implementation 'com.mikepenz:materialize:${latestVersion}' // at least 1.2.0
implementation "com.mikepenz:materialize:${latestVersion}" // at least 1.2.0
```

## v4.x.y
Expand Down Expand Up @@ -287,7 +287,7 @@ open class SimpleSubExpandableItem : AbstractExpandableItem<SimpleSubExpandableI
*/
}
```
// See the `SimpleSubExpandableItem.java` of the sample application for more details.
// See the `SimpleSubExpandableItem.kt` of the sample application for more details.


## Articles
Expand Down Expand Up @@ -324,8 +324,9 @@ This free, open source software was also made possible by a group of volunteers

## Special mentions

I want to give say thanks to some special contributors who provided some huge PRs and many changes to improve this great library.
A special thanks to the very active contributors who added many improvements to this library.

* **[Allan Wang](https://github.com/AllanWang)**
* **[MFlisar](https://github.com/MFlisar)**

# License
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/mikepenz/fastadapter/app/AdvancedSampleActivity.kt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AdvancedSampleActivity : AppCompatActivity() {
private lateinit var mHeaderAdapter: ItemAdapter<SimpleItem>
private lateinit var mItemAdapter: GenericItemAdapter

private var mActionModeHelper: ActionModeHelper<IItem<out RecyclerView.ViewHolder>>? = null
private var mActionModeHelper: ActionModeHelper<GenericItem>? = null

override fun onCreate(savedInstanceState: Bundle?) {
findViewById<View>(android.R.id.content).systemUiVisibility = findViewById<View>(android.R.id.content).systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
Expand All @@ -60,12 +60,12 @@ class AdvancedSampleActivity : AppCompatActivity() {
//create our adapters
mHeaderAdapter = items()
mItemAdapter = items()
val stickyHeaderAdapter = StickyHeaderAdapter<IItem<out RecyclerView.ViewHolder>>()
val stickyHeaderAdapter = StickyHeaderAdapter<GenericItem>()

//we also want the expandable feature

//create our FastAdapter
val adapters: Collection<ItemAdapter<out IItem<out RecyclerView.ViewHolder>>> = Arrays.asList(mHeaderAdapter, mItemAdapter)
val adapters: Collection<ItemAdapter<out GenericItem>> = Arrays.asList(mHeaderAdapter, mItemAdapter)
mFastAdapter = FastAdapter.with(adapters)

mFastAdapter.getExpandableExtension()
Expand All @@ -77,13 +77,13 @@ class AdvancedSampleActivity : AppCompatActivity() {
selectExtension.multiSelect = true
selectExtension.selectOnLongClick = true

mFastAdapter.onPreClickListener = { _: View?, _: GenericAdapter, item: IItem<out RecyclerView.ViewHolder>, _: Int ->
mFastAdapter.onPreClickListener = { _: View?, _: GenericAdapter, item: GenericItem, _: Int ->
//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
val res = mActionModeHelper?.onClick(item)
res ?: false
}

mFastAdapter.onPreLongClickListener = { _: View, _: GenericAdapter, item: IItem<out RecyclerView.ViewHolder>, position: Int ->
mFastAdapter.onPreLongClickListener = { _: View, _: GenericAdapter, item: GenericItem, position: Int ->
//we do not want expandable items to be selected
if (item is IExpandable<*> && item.subItems != null) {
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import androidx.appcompat.widget.SearchView
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.GenericItem
import com.mikepenz.fastadapter.adapters.FastItemAdapter
import com.mikepenz.fastadapter.adapters.GenericFastItemAdapter
import com.mikepenz.fastadapter.adapters.GenericItemAdapter
Expand All @@ -34,7 +33,7 @@ import com.mikepenz.materialize.MaterializeBuilder
import kotlinx.android.synthetic.main.activity_sample.*
import java.util.*

class EndlessScrollListActivity : AppCompatActivity(), ItemTouchCallback, ItemFilterListener<IItem<out RecyclerView.ViewHolder>> {
class EndlessScrollListActivity : AppCompatActivity(), ItemTouchCallback, ItemFilterListener<GenericItem> {

//save our FastAdapter
private lateinit var fastItemAdapter: GenericFastItemAdapter
Expand Down Expand Up @@ -76,7 +75,7 @@ class EndlessScrollListActivity : AppCompatActivity(), ItemTouchCallback, ItemFi
}

//configure the itemAdapter
fastItemAdapter.itemFilter.filterPredicate = { item: IItem<out RecyclerView.ViewHolder>, constraint: CharSequence? ->
fastItemAdapter.itemFilter.filterPredicate = { item: GenericItem, constraint: CharSequence? ->
if (item is SimpleItem) {
//return true if we should filter it out
item.name?.text.toString().toLowerCase().contains(constraint.toString().toLowerCase())
Expand Down Expand Up @@ -186,7 +185,7 @@ class EndlessScrollListActivity : AppCompatActivity(), ItemTouchCallback, ItemFi
// save the new item order, i.e. in your database
}

override fun itemsFiltered(constraint: CharSequence?, results: List<IItem<out RecyclerView.ViewHolder>>?) {
override fun itemsFiltered(constraint: CharSequence?, results: List<GenericItem>?) {
endlessRecyclerOnScrollListener.disable()
Toast.makeText(this@EndlessScrollListActivity, "filtered items count: " + fastItemAdapter.itemCount, Toast.LENGTH_SHORT).show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.view.LayoutInflaterCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.michaelflisar.dragselectrecyclerview.DragSelectTouchListener
import com.mikepenz.fastadapter.IAdapter
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.ISelectionListener
import com.mikepenz.fastadapter.ISubItem
import com.mikepenz.fastadapter.*
import com.mikepenz.fastadapter.adapters.FastItemAdapter
import com.mikepenz.fastadapter.adapters.GenericFastItemAdapter
import com.mikepenz.fastadapter.app.items.HeaderSelectionItem
Expand All @@ -40,7 +36,7 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
private lateinit var mSelectExtension: SelectExtension<IItem<*>>
private lateinit var mRangeSelectorHelper: RangeSelectorHelper<*>
private lateinit var mDragSelectTouchListener: DragSelectTouchListener
private var mActionModeHelper: ActionModeHelper<IItem<out RecyclerView.ViewHolder>>? = null
private var mActionModeHelper: ActionModeHelper<GenericItem>? = null

override fun onCreate(savedInstanceState: Bundle?) {
findViewById<View>(android.R.id.content).systemUiVisibility = findViewById<View>(android.R.id.content).systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
Expand All @@ -64,7 +60,7 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
mSelectExtension.multiSelect = true
mSelectExtension.selectOnLongClick = true

fastItemAdapter.onPreClickListener = { _: View?, _: IAdapter<IItem<out RecyclerView.ViewHolder>>, item: IItem<out RecyclerView.ViewHolder>, _: Int ->
fastItemAdapter.onPreClickListener = { _: View?, _: IAdapter<GenericItem>, item: GenericItem, _: Int ->
//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
val res = mActionModeHelper?.onClick(this@ExpandableMultiselectDeleteSampleActivity, item)
// in this example, we want to consume a click, if the ActionModeHelper will remove the ActionMode
Expand All @@ -73,7 +69,7 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
}


fastItemAdapter.onClickListener = { _: View?, _: IAdapter<IItem<out RecyclerView.ViewHolder>>, item: IItem<out RecyclerView.ViewHolder>, _: Int ->
fastItemAdapter.onClickListener = { _: View?, _: IAdapter<GenericItem>, item: GenericItem, _: Int ->
// check if the actionMode consumes the click. This returns true, if it does, false if not
if (mActionModeHelper?.isActive == false) {
Toast.makeText(this@ExpandableMultiselectDeleteSampleActivity, (item as SimpleSubItem).name.toString() + " clicked!", Toast.LENGTH_SHORT).show()
Expand All @@ -82,7 +78,7 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
false
}

fastItemAdapter.onPreLongClickListener = { _: View, _: IAdapter<IItem<out RecyclerView.ViewHolder>>, _: IItem<out RecyclerView.ViewHolder>, position: Int ->
fastItemAdapter.onPreLongClickListener = { _: View, _: IAdapter<GenericItem>, _: GenericItem, position: Int ->
val actionModeWasActive = mActionModeHelper?.isActive ?: false
val actionMode = mActionModeHelper?.onLongClick(this@ExpandableMultiselectDeleteSampleActivity, position)
mRangeSelectorHelper.onLongClick(position)
Expand Down Expand Up @@ -126,7 +122,7 @@ class ExpandableMultiselectDeleteSampleActivity : AppCompatActivity() {
rv.adapter = fastItemAdapter

//fill with some sample data
val items = ArrayList<IItem<out RecyclerView.ViewHolder>>()
val items = ArrayList<GenericItem>()
for (i in 0..19) {
if (i % 2 == 0) {
val expandableItem = HeaderSelectionItem()
Expand Down
Loading

0 comments on commit 6f3f534

Please sign in to comment.