Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SimpleListActivity : AppCompatActivity() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- ListViewDelegate(layoutInflater,
- { inflater, container -> MyListItem(R.layout.list_item_layout, inflater, container) })
- .apply { setContentView(view) }
- .also { ListPresenter<String, ViewEvent>(MyRepository()).attach(it) }
- }
- class MyRepository : BaseRepository<List<String>> {
- override fun getData() = Observable.range(0, 100).map { i -> "Word number $i" }.toList()
- }
- class MyListItem(@LayoutRes layoutResId: Int, inflater: LayoutInflater, parent: ViewGroup)
- : BaseRecyclerViewItem<String, ViewEvent>(layoutResId, inflater, parent) {
- private val textView: TextView = view.findViewById(R.id.text_view)
- override fun bind(data: String) {
- textView.text = data
- }
- }
- }
Add Comment
Please, Sign In to add comment