Skip to content

Commit 722994e

Browse files
author
hb
committed
Bug fixed.
1 parent 0a3d4bb commit 722994e

5 files changed

Lines changed: 40 additions & 19 deletions

File tree

0 Bytes
Binary file not shown.

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Grab via Maven:
1616
<dependency>
1717
<groupId>com.dc.easyadapter</groupId>
1818
<artifactId>easyadapter</artifactId>
19-
<version>1.2</version>
19+
<version>1.2.1</version>
2020
<type>pom</type>
2121
</dependency>
2222
```
2323
or Gradle:
2424
```groovy
25-
implementation 'com.dc.easyadapter:easyadapter:1.2'
25+
implementation 'com.dc.easyadapter:easyadapter:1.2.1'
2626
```
2727

2828
To enable data binding
@@ -55,7 +55,6 @@ apply plugin: 'kotlin-kapt' //Top at build.gradle
5555

5656
``` kotlin
5757
class CategoryAdapter() :EasyAdapter<Category, InflaterCategoryBinding>(R.layout.inflater_category) {
58-
5958
override fun onBind(binding: InflaterCategoryBinding, model: Category) {
6059
binding.apply {
6160
tvName.text = model.name
@@ -69,7 +68,7 @@ class CategoryAdapter() :EasyAdapter<Category, InflaterCategoryBinding>(R.layout
6968

7069
``` kotlin
7170
//Override in Adapter
72-
override fun onCreatingHolder(binding: InflaterCategoryBinding, easyHolder: BaseHolder) {
71+
override fun onCreatingHolder(binding: InflaterCategoryBinding, easyHolder: EasyHolder) {
7372
super.onCreatingHolder(binding, easyHolder)
7473
binding.root.setOnClickListener(easyHolder.clickListener)
7574
}
@@ -83,16 +82,15 @@ adapter.setRecyclerViewItemClick { itemView, model ->
8382

8483
#### 2) Filter (Search,etc..)
8584
``` kotlin
86-
adapter.performFilter(text, object :EasyAdapter.OnFilter<Category>{
87-
override fun onFilterApply(text: String, model: Category): Boolean {
88-
if (model.name?.toLowerCase()?.contains(text.toLowerCase())!!) {
89-
return true //Return True if you want to include this model in this text search
90-
}
91-
return false //It will not include model if you return false
85+
adapter.performFilter(newText, object : EasyAdapter.OnFilter<Category> {
86+
override fun onFilterApply(filter: Any, model: Category): Boolean {
87+
return model.name.toLowerCase().contains(filter.toString().toLowerCase())
9288
}
9389

94-
override fun onResult(data: ArrayList<Category>?) {
95-
//Filtered List to do any operation
90+
override fun onFilterResult(filteredList: ArrayList<Category>?) {
91+
adapter.clear(false)
92+
adapter.addAll(filteredList, false)
93+
adapter.notifyDataSetChanged()
9694
}
9795
})
9896

@@ -118,7 +116,7 @@ adapter.enableSwipeAction(binding.recyclerView)
118116
```
119117

120118
``` kotlin
121-
override fun onCreatingHolder(binding: InflaterCategoryBinding, easyHolder: BaseHolder) {
119+
override fun onCreatingHolder(binding: InflaterCategoryBinding, easyHolder: EasyHolder) {
122120
binding.llDelete.post {
123121
easyHolder.setEnableSwipeToDelete(binding.llCategory, 0, binding.llDelete.measuredWidth)
124122
}
@@ -218,6 +216,16 @@ Use tools attribute for previewing Layout, so you don't need to always run appli
218216
tools:text="@sample/filename"
219217
```
220218

219+
### Version Change from x.x to 1.2.1
220+
221+
Behaviour Changes
222+
- Changed BaseHolder to EasyHolder name
223+
- Adapter perform filter now has object type parameter for more generalize
224+
- Perform filter will not update data you need to manually update data.
225+
- clear() to clear(deepClean) to clean temporary data which is used for filter
226+
- addAll() to addAll(deepCopy) to add list as well as temporary list which is also used for filter
227+
- Minor bug fixed
228+
221229
### [Special Thanks to] <br />
222230

223231
https://github.com/alex-townsend/SwipeOpenItemTouchHelper

app/src/main/java/easyadapter/dc/com/easyadapter/MainActivity.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,15 @@ class MainActivity : AppCompatActivity() {
5151

5252
override fun onQueryTextChange(newText: String): Boolean {
5353
adapter.performFilter(newText, object : EasyAdapter.OnFilter<Category> {
54+
override fun onFilterApply(filter: Any, model: Category): Boolean {
55+
return model.name.toLowerCase().contains(filter.toString().toLowerCase())
56+
}
57+
5458
override fun onFilterResult(filteredList: ArrayList<Category>?) {
5559
adapter.clear(false)
5660
adapter.addAll(filteredList, false)
5761
adapter.notifyDataSetChanged()
5862
}
59-
60-
override fun onFilterApply(filter: Any, model: Category): Boolean {
61-
return model.name.toLowerCase().contains(filter.toString().toLowerCase())
62-
}
63-
6463
})
6564
return false
6665
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package easyadapter.dc.com.easyadapter;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
5+
/**
6+
* Created by HB on 18/5/18.
7+
*/
8+
public class Test extends AppCompatActivity {
9+
10+
11+
public void sa() {
12+
13+
}
14+
}

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
33
ext {
44
PUBLISH_GROUP_ID = 'com.dc.easyadapter'
55
PUBLISH_ARTIFACT_ID = 'easyadapter'
6-
PUBLISH_VERSION = '1.2'
6+
PUBLISH_VERSION = '1.2.1'
77
}
88

99
android {

0 commit comments

Comments
 (0)