Created
May 16, 2018 02:24
-
-
Save adrianhall/6f0a47fa50dd621bb231febeba7cf852 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
val adapter = NotesPagedListAdapter { | |
launchNoteDetailActivity(this@NoteListActivity, it.noteId) | |
} | |
viewModel.notes.observe(this, Observer { | |
it?.let { adapter.submitList(it) } | |
}) | |
note_list_recyclerview.layoutManager = LinearLayoutManager(this).apply { | |
orientation = LinearLayoutManager.VERTICAL | |
} | |
note_list_recyclerview.adapter = adapter | |
val itemTouchHelper = ItemTouchHelper(SwipeToDeleteHandler(this) { | |
it.note?.let { viewModel.deleteNote(it) } | |
adapter.notifyItemRemoved(it.adapterPosition) | |
}) | |
itemTouchHelper.attachToRecyclerView(note_list_recyclerview) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment