Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
beiger committed Dec 16, 2018
1 parent b2d4529 commit ee773d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.recyclerview.widget.RecyclerView
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

abstract class BaseRecycleViewActivity<DB : ViewDataBinding, VM : BaseViewModel, AD : BaseRecycleViewAdapter<T>, T : IsSame> : AppCompatActivity(), View.OnClickListener {
abstract class BaseRecycleViewActivity<DB : ViewDataBinding, VM : BaseViewModel, AD : BaseRecycleViewAdapter<T, *>, T : IsSame> : AppCompatActivity(), View.OnClickListener {
lateinit var mBinding: DB
lateinit var mViewModel: VM
protected var mCompositeDisposable = CompositeDisposable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView

abstract class BaseRecycleViewAdapter<T : IsSame> : RecyclerView.Adapter<BaseViewHolder<*>>() {
abstract class BaseRecycleViewAdapter<T : IsSame, VH: BaseViewHolder<*>> : RecyclerView.Adapter<VH>() {
protected var mData: List<T>? = ArrayList()
protected var mListener: OnClickListener? = null

Expand Down Expand Up @@ -47,7 +47,7 @@ abstract class BaseRecycleViewAdapter<T : IsSame> : RecyclerView.Adapter<BaseVie
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<*> {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
return createHolder(parent, viewType)
}

Expand All @@ -56,12 +56,12 @@ abstract class BaseRecycleViewAdapter<T : IsSame> : RecyclerView.Adapter<BaseVie
return DataBindingUtil.inflate(LayoutInflater.from(parent.context), layoutId, parent, false)
}

protected abstract fun createHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<*>
protected abstract fun createHolder(parent: ViewGroup, viewType: Int): VH

/**
* 子类不用继承
*/
override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) {
override fun onBindViewHolder(holder: VH, position: Int) {
holder.binding.root.setOnClickListener {
if (mListener != null) {
mListener!!.onClick(position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import androidx.recyclerview.widget.RecyclerView
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

abstract class BaseRecycleViewFragment<DB : ViewDataBinding, VM : BaseViewModel, AVM : BaseViewModel, AD : BaseRecycleViewAdapter<T>, T : IsSame> : Fragment(), View.OnClickListener {
abstract class BaseRecycleViewFragment<DB : ViewDataBinding, VM : BaseViewModel, AVM : BaseViewModel, AD : BaseRecycleViewAdapter<T, *>, T : IsSame> : Fragment(), View.OnClickListener {
lateinit var mBinding: DB
lateinit var mViewModel: VM
lateinit var mActivityViewModel: AVM
Expand Down

0 comments on commit ee773d2

Please sign in to comment.