-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
27 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
example/src/main/java/com/example/dumchev/delegateadapters/base/MockDataFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
.../main/java/com/livermor/dumchev/delegateadapters/base/adapter/CompositeDelegateAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
package com.example.dumchev.delegateadapters.base.adapter | ||
package com.livermor.dumchev.delegateadapters.base.adapter | ||
|
||
import android.view.View | ||
import com.example.delegateadapter.delegate.KDelegateAdapter | ||
import com.example.dumchev.delegateadapters.R | ||
import com.example.dumchev.delegateadapters.base.model.CompositeModel | ||
import com.livermor.delegateadapter.delegate.KDelegateAdapter | ||
import com.livermor.dumchev.delegateadapters.R | ||
import com.livermor.dumchev.delegateadapters.base.model.CompositeModel | ||
|
||
/** | ||
* @author dumchev on 11/12/2018. | ||
*/ | ||
class CompositeDelegateAdapter(clicks: View.OnClickListener) : KDelegateAdapter<CompositeModel>() { | ||
|
||
val textDelegateAdapter by lazy { TxtDelegateAdapter() } | ||
val imageDelegateAdapter by lazy { ImageDelegateAdapter(clicks) } | ||
private val textDelegateAdapter by lazy { TxtDelegateAdapter() } | ||
private val imageDelegateAdapter by lazy { ImageDelegateAdapter(clicks) } | ||
|
||
override fun onBind(item: CompositeModel, viewHolder: KViewHolder) { | ||
textDelegateAdapter.onBind(item.textViewModel, viewHolder) | ||
imageDelegateAdapter.onBind(item.imageViewModel, viewHolder) | ||
override fun KViewHolder.onBind(item: CompositeModel) { | ||
with(textDelegateAdapter) { onBind(item.textViewModel) } | ||
with(imageDelegateAdapter) { onBind(item.imageViewModel) } | ||
} | ||
|
||
override fun getLayoutId(): Int = R.layout.composite_item | ||
|
||
override fun isForViewType(items: MutableList<*>, position: Int): Boolean { | ||
return items[position] is CompositeModel | ||
} | ||
override fun isForViewType(item: Any): Boolean = item is CompositeModel | ||
} |
12 changes: 6 additions & 6 deletions
12
example/src/main/java/com/livermor/dumchev/delegateadapters/base/model/CompositeModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
package com.example.dumchev.delegateadapters.base.model | ||
package com.livermor.dumchev.delegateadapters.base.model | ||
|
||
import com.example.delegateadapter.delegate.diff.IComparableItem | ||
import com.livermor.delegateadapter.delegate.diff.KDiffUtilItem | ||
|
||
/** | ||
* @author dumchev on 11/12/2018. | ||
*/ | ||
data class CompositeModel( | ||
val imageViewModel: ImageViewModel, | ||
val textViewModel: TextViewModel | ||
) : IComparableItem { | ||
val imageViewModel: ImageItem, | ||
val textViewModel: TextItem | ||
) : KDiffUtilItem { | ||
|
||
override fun id(): Any = "" + imageViewModel.id() + textViewModel.id() | ||
override val id: Any = "" + imageViewModel.id() + textViewModel.id() | ||
override fun content(): Any = this | ||
} |