Skip to content

Commit

Permalink
perf: 整理 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
limuyang2 committed Aug 7, 2023
1 parent dd42634 commit 07647f9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class DiffDragAndSwipeAdapter :
override fun onBindViewHolder(
holder: QuickViewHolder, position: Int, item: DiffEntity?
) {
holder.setText(R.id.tweetName, item!!.title)
if (item == null) return

holder.setText(R.id.tweetName, item.title)
.setText(R.id.tweetText, item.content)
.setText(R.id.tweetDate, item.date)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.chad.library.adapter.base.BaseMultiItemAdapter
/**
* https://github.com/CymChad/BaseRecyclerViewAdapterHelper
*/
class HomeAdapter(data: MutableList<HomeEntity>) : BaseMultiItemAdapter<HomeEntity>(data) {
class HomeAdapter(data: List<HomeEntity>) : BaseMultiItemAdapter<HomeEntity>(data) {

class ItemVH(val viewBinding: HomeItemViewBinding) : RecyclerView.ViewHolder(viewBinding.root)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HomeTopHeaderAdapter : BaseSingleItemAdapter<Any, HomeTopHeaderAdapter.VH>
override fun onBindViewHolder(holder: VH, item: Any?) {
}

override fun getItemViewType(position: Int, list: List<Any>): Int {
override fun getItemViewType(position: Int, list: List<Any?>): Int {
return HEAD_VIEWTYPE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class AutoLoadMoreRefreshUseActivity : BaseViewBindingActivity<ActivityLoadMoreB
private fun request() {

Request(pageInfo.page, object : RequestCallBack {
override fun success(data: List<Status?>) {
override fun success(data: List<Status>) {
viewBinding.refreshLayout.isRefreshing = false
if (pageInfo.isFirstPage) {
// 如果是加载的第一页数据,用 submitList()
Expand Down Expand Up @@ -201,7 +201,7 @@ class AutoLoadMoreRefreshUseActivity : BaseViewBindingActivity<ActivityLoadMoreB
*
* @param data 数据
*/
fun success(data: List<Status?>)
fun success(data: List<Status>)

/**
* 模拟加载失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class NoAutoAutoLoadMoreRefreshUseActivity : BaseViewBindingActivity<ActivityLoa
private fun request() {

Request(pageInfo.page, object : RequestCallBack {
override fun success(data: List<Status?>) {
override fun success(data: List<Status>) {
viewBinding.refreshLayout.isRefreshing = false
if (pageInfo.isFirstPage) {
// 如果是加载的第一页数据,用 submitList()
Expand Down Expand Up @@ -211,7 +211,7 @@ class NoAutoAutoLoadMoreRefreshUseActivity : BaseViewBindingActivity<ActivityLoa
*
* @param data 数据
*/
fun success(data: List<Status?>)
fun success(data: List<Status>)

/**
* 模拟加载失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.text.style.ClickableSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.text.buildSpannedString
import androidx.core.text.inSpans
import androidx.recyclerview.widget.RecyclerView
Expand All @@ -21,7 +22,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter
* @date: 2019-12-04
* @Description:
*/
class RecyclerViewAdapter : BaseQuickAdapter<Status?, RecyclerViewAdapter.VH>() {
class RecyclerViewAdapter : BaseQuickAdapter<Status, RecyclerViewAdapter.VH>() {
class VH(
parent: ViewGroup,
val viewBinding: LayoutAnimationBinding = LayoutAnimationBinding.inflate(
Expand Down Expand Up @@ -59,8 +60,7 @@ class RecyclerViewAdapter : BaseQuickAdapter<Status?, RecyclerViewAdapter.VH>()
}

override fun updateDrawState(ds: TextPaint) {
ds.color =
context.resources.getColor(R.color.clickspan_color)
ds.color = ContextCompat.getColor(context, R.color.clickspan_color)
ds.isUnderlineText = true
}
}
Expand Down

0 comments on commit 07647f9

Please sign in to comment.