Skip to content

Commit

Permalink
fix #3046
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang committed Feb 25, 2020
1 parent addcd3d commit ba4984c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

viewBinding {
enabled = true
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ import com.chad.baserecyclerviewadapterhelper.R
import com.chad.baserecyclerviewadapterhelper.activity.multi.ChooseMultipleItemUseTypeActivity
import com.chad.baserecyclerviewadapterhelper.activity.node.ChooseNodeUseTypeActivity
import com.chad.baserecyclerviewadapterhelper.adapter.HomeAdapter
import com.chad.baserecyclerviewadapterhelper.databinding.ActivityHomeBinding
import com.chad.baserecyclerviewadapterhelper.entity.HomeEntity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemClickListener
import kotlinx.android.synthetic.main.activity_home.*

class HomeActivity : AppCompatActivity(), OnItemClickListener {

private lateinit var binding: ActivityHomeBinding

/**
* RV适配器
*/
private val homeAdapter by lazy {
HomeAdapter(homeItemData).apply {
animationEnable = true

val top = layoutInflater.inflate(R.layout.top_view, recyclerView, false)
val top = layoutInflater.inflate(R.layout.top_view, binding.recyclerView, false)
addHeaderView(top)
setOnItemClickListener(this@HomeActivity)
// setOnItemClickListener { adapter, _, position ->
Expand All @@ -43,9 +45,10 @@ class HomeActivity : AppCompatActivity(), OnItemClickListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
binding = ActivityHomeBinding.inflate(layoutInflater)
setContentView(binding.root)

recyclerView.adapter = homeAdapter
binding.recyclerView.adapter = homeAdapter
}

private val homeItemData: ArrayList<HomeEntity>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:orientation="vertical">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Mar 29 22:14:15 CST 2018
#Tue Feb 25 13:08:15 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ abstract class BaseQuickAdapter<T, VH : BaseViewHolder>
* @param item T?
* @return Int
*/
fun getItemPosition(item: T?): Int {
open fun getItemPosition(item: T?): Int {
return if (item != null && data.isNotEmpty()) data.indexOf(item) else -1
}

Expand Down Expand Up @@ -942,7 +942,15 @@ abstract class BaseQuickAdapter<T, VH : BaseViewHolder>
} ?: ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

insert = true
} else {
emptyView.layoutParams?.let {
val lp = mEmptyLayout.layoutParams
lp.width = it.width
lp.height = it.height
mEmptyLayout.layoutParams = lp
}
}

mEmptyLayout.removeAllViews()
mEmptyLayout.addView(emptyView)
isUseEmpty = true
Expand Down

0 comments on commit ba4984c

Please sign in to comment.