Skip to content

Commit b8d34e7

Browse files
committed
Feature: added the compare replace whole list for changing the list.
1 parent 30bbe97 commit b8d34e7

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ please. There is a simple sample for this library. 😄
105105
It's very easy to import, you just put them into your gradle file.
106106

107107
```gradle
108-
compile "com.devrapid.jieyi:adaptiverecyclerview:1.0.6"
108+
compile "com.devrapid.jieyi:adaptiverecyclerview:1.0.7"
109109
```
110110

111111
## Maven

adaptiverecyclerview/src/main/java/com/devrapid/adaptiverecyclerview/AdaptiveAdapter.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ abstract class AdaptiveAdapter<VT : ViewTypeFactory, M : IVisitable<VT>, VH : Re
5757
}
5858

5959
//region Necessary override methods.
60-
override fun getItemCount(): Int = dataList.size
60+
override fun getItemCount() = dataList.size
6161

62-
override fun getItemViewType(position: Int): Int = dataList[position].type(typeFactory)
62+
override fun getItemViewType(position: Int) = dataList[position].type(typeFactory)
6363

6464
override fun onBindViewHolder(holder: VH, position: Int) =
6565
(holder as AdaptiveViewHolder<VT, M>).initView(dataList[position], position, this)
@@ -72,6 +72,8 @@ abstract class AdaptiveAdapter<VT : ViewTypeFactory, M : IVisitable<VT>, VH : Re
7272
}
7373
//endregion
7474

75+
fun listDescription() = dataList.joinToString("\n") { it.toString() }
76+
7577
// OPTIMIZE(jieyi): 2018/12/04 There's no checking bounding.
7678
open fun appendList(list: MutableList<M>) {
7779
val startIndex = dataList.size
@@ -133,6 +135,10 @@ abstract class AdaptiveAdapter<VT : ViewTypeFactory, M : IVisitable<VT>, VH : Re
133135
return true
134136
}
135137

138+
open fun replaceWholeList(newList: MutableList<M>) {
139+
updateList { newList }
140+
}
141+
136142
private fun updateList(getNewListBlock: () -> MutableList<M>) {
137143
val newList = getNewListBlock()
138144
val res = DiffUtil.calculateDiff(diffUtil.apply {

adaptiverecyclerview/src/main/java/com/devrapid/adaptiverecyclerview/AdaptiveViewHolder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
1313
abstract class AdaptiveViewHolder<in VT : ViewTypeFactory, in M : IVisitable<VT>>(
1414
view: View
1515
) : RecyclerView.ViewHolder(view) {
16-
protected val mContext: Context = view.context
16+
protected val mContext: Context = itemView.context
1717

1818
/**
1919
* Set the views' properties.
@@ -22,5 +22,5 @@ abstract class AdaptiveViewHolder<in VT : ViewTypeFactory, in M : IVisitable<VT>
2222
* @param position the index of a list.
2323
* @param adapter parent adapter.
2424
*/
25-
abstract fun initView(model: M, position: Int, adapter: Any)
25+
abstract fun initView(model: M, position: Int, adapter: AdaptiveAdapter<*, *, *>)
2626
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ buildscript {
1414

1515
// NOTE: Do not place your application dependencies here; they belong
1616
// in the individual module build.gradle files
17-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
18-
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
17+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
18+
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1919
}
2020
}
2121

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ proj_name=adaptiverecyclerview
2222
proj_libname=AdaptiveRecyclerview
2323
proj_group=com.devrapid.jieyi
2424
proj_artifactid=adaptiverecyclerview
25-
proj_version=1.0.6
25+
proj_version=1.0.7
2626
proj_description=Create an adaptive recycler view for each of type view.
2727
proj_websiteurl=https://github.com/pokk/AdaptiveRecyclerView
2828
proj_issuetrackerurl=https://github.com/pokk/AdaptiveRecyclerView/issues

0 commit comments

Comments
 (0)