Skip to content

Commit

Permalink
Change method to property
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang committed Jan 6, 2020
1 parent dedd998 commit 49a29eb
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 87 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
//apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
*/
override fun remove(position: Int) {
val removeCount = removeAt(position)
notifyItemRangeRemoved(position + getHeaderLayoutCount(), removeCount)
notifyItemRangeRemoved(position + headerLayoutCount, removeCount)
compatibilityDataSizeChanged(0)
}

Expand All @@ -130,10 +130,10 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
this.data.addAll(index, newFlatData)

if (removeCount == newFlatData.size) {
notifyItemRangeChanged(index + getHeaderLayoutCount(), removeCount)
notifyItemRangeChanged(index + headerLayoutCount, removeCount)
} else {
notifyItemRangeRemoved(index + getHeaderLayoutCount(), removeCount)
notifyItemRangeInserted(index + getHeaderLayoutCount(), newFlatData.size)
notifyItemRangeRemoved(index + headerLayoutCount, removeCount)
notifyItemRangeInserted(index + headerLayoutCount, newFlatData.size)

// notifyItemRangeChanged(index + getHeaderLayoutCount(), max(removeCount, newFlatData.size)
}
Expand Down Expand Up @@ -381,7 +381,7 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
val newFlatData = flatData(newData)
this.data.addAll(parentIndex + 1, newFlatData)

val positionStart = parentIndex + 1 + getHeaderLayoutCount()
val positionStart = parentIndex + 1 + headerLayoutCount
if (removeCount == newFlatData.size) {
notifyItemRangeChanged(positionStart, removeCount)
} else {
Expand Down Expand Up @@ -453,7 +453,7 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
val node = this.data[position]

if (node is BaseExpandNode && node.isExpanded) {
val adapterPosition = position + getHeaderLayoutCount()
val adapterPosition = position + headerLayoutCount

node.isExpanded = false
if (node.childNode.isNullOrEmpty()) {
Expand Down Expand Up @@ -493,7 +493,7 @@ abstract class BaseNodeAdapter(nodeList: MutableList<BaseNode>? = null)
val node = this.data[position]

if (node is BaseExpandNode && !node.isExpanded) {
val adapterPosition = position + getHeaderLayoutCount()
val adapterPosition = position + headerLayoutCount

node.isExpanded = true
if (node.childNode.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ abstract class BaseProviderMultiAdapter<T>(data: MutableList<T>? = null) :
if (position == RecyclerView.NO_POSITION) {
return@setOnClickListener
}
position -= getHeaderLayoutCount()
position -= headerLayoutCount

val itemViewType = viewHolder.itemViewType
val provider = mItemProviders.get(itemViewType)
Expand All @@ -92,7 +92,7 @@ abstract class BaseProviderMultiAdapter<T>(data: MutableList<T>? = null) :
if (position == RecyclerView.NO_POSITION) {
return@setOnLongClickListener false
}
position -= getHeaderLayoutCount()
position -= headerLayoutCount

val itemViewType = viewHolder.itemViewType
val provider = mItemProviders.get(itemViewType)
Expand All @@ -115,7 +115,7 @@ abstract class BaseProviderMultiAdapter<T>(data: MutableList<T>? = null) :
if (position == RecyclerView.NO_POSITION) {
return@setOnClickListener
}
position -= getHeaderLayoutCount()
position -= headerLayoutCount
provider.onChildClick(viewHolder, v, data[position], position)
}
}
Expand All @@ -134,7 +134,7 @@ abstract class BaseProviderMultiAdapter<T>(data: MutableList<T>? = null) :
if (position == RecyclerView.NO_POSITION) {
return@setOnLongClickListener false
}
position -= getHeaderLayoutCount()
position -= headerLayoutCount
provider.onChildLongClick(viewHolder, v, data[position], position)
}
}
Expand Down
Loading

0 comments on commit 49a29eb

Please sign in to comment.