Skip to content

Conversation

YeWintNaing05
Copy link

@YeWintNaing05 YeWintNaing05 commented Oct 9, 2019

### About Changes

Super Adapter with generic

  1. It take 4 para -real item view,item holder,other view,other view holder
    abstract class SuperAdapter<R, RHolder : SuperViewHolder<R>, B, BHolder : SuperViewHolder<B>> : RecyclerView.Adapter<RecyclerView.ViewHolder>()
  2. add two abstract fun for create two view holder -one is for real item view and other is for view between real items.
    abstract fun onCreateViewHolderBetweenElements(view: View): BHolder
    abstract fun onCreateRealViewHolder(view: View): RHolder
  3. add two abstract variable for two layout resource id -one is for real item view and other is for view between real items.
    @get:LayoutRes abstract val realViewItemResLayout: Int
    @get:LayoutRes abstract val itemBetweenElementsResLayout: Int
  4. add two abstract fun with two para (holder,data) for bind data with real view and other view
    abstract fun onBindOtherViewHolder(holder: BHolder, data: B)
    abstract fun onBindRealViewHolder(holder: RHolder, data: R)

Dummy object with generic

  1. create abstract class for custom data type
    abstract class DataForOther<T>{ abstract val data : T }
  2. change dummy object with generic and implements above interface
    class DummyObject<T>(val position:Int, val data: T) : Comparable<DummyObject<T>>, { override fun compareTo(other: DummyObject<T>): Int { //let's sort the object based on position in ascending order //returns a negative integer, zero, or a positive integer as this position //is less than, equal to, or greater than the specified object. return this.position - other.position } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant