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
| class LiveStreamActivity : AppCompatActivity(R.layout.activity_main) { | |
| private val adapter = MessagesListAdapter() | |
| private val messageListSmoothScroller by lazy { | |
| object : LinearSmoothScroller(this) { | |
| val MILLISECONDS_PER_INCH = 400f | |
| override fun calculateSpeedPerPixel(displayMetrics: DisplayMetrics?): Float { | |
| return MILLISECONDS_PER_INCH / displayMetrics!!.densityDpi | |
| } |
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
| private fun updateMessagesList(messages: List<Message>) { | |
| adapter.submitList(messages) | |
| adapter.notifyDataSetChanged() | |
| val scrollTarget = adapter.itemCount | |
| messageListSmoothScroller.targetPosition = scrollTarget | |
| messagesList.layoutManager?.startSmoothScroll(messageListSmoothScroller) | |
| } |
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
| class ChannelFragment : Fragment() { | |
| //... | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| binding.messageListView.setMessageViewHolderFactory(MyCustomMessageViewHolderFactory()) | |
| } | |
| } |
OlderNewer