Skip to content

Instantly share code, notes, and snippets.

View naphatamity's full-sized avatar

Naphat Far naphatamity

View GitHub Profile
@naphatamity
naphatamity / ChatAdapter.kt
Created April 15, 2021 13:11
ChatAdapter.kt
class ChatAdapter(
private val listener: ListListener
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<EkoMessage>() {
override fun areItemsTheSame(oldItem: EkoMessage, newItem: EkoMessage): Boolean {
return oldItem.getMessageId() == newItem.getMessageId()
}
@naphatamity
naphatamity / video_player.xml
Created April 15, 2021 13:15
video_player.xml
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/matchPlayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:controller_layout_id="@layout/exoplay_custom_ui"
app:layout_constraintTop_toTopOf="parent">
@naphatamity
naphatamity / VideoFragment.kt
Created April 15, 2021 13:20
VideoFragment.kt
class HomeVideoFragment() : Fragment(R.layout.video_player) {
var fullScreen = 0
var name = ""
var url = ""
var count = 0
var videoThumbnail = ""
var currentPosition: Long = 0
var playWhenReady = true
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@naphatamity
naphatamity / video_comment.xml
Last active April 27, 2021 04:56
video_comment
<include
android:id="@+id/chat_reply"
layout="@layout/chat_reply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/chat_text_input_player"
android:layout_marginEnd="0dp"
android:layout_marginBottom="0dp"
android:visibility="gone" />
@naphatamity
naphatamity / MainActivity.kt
Last active April 26, 2021 18:37
MainActivity
private fun initEkoClient() {
EkoClient.setup(apikey)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()
EkoClient.registerDevice(userID)
.displayName(userName)
.build()
class App : Application(){
override fun onCreate() {
super.onCreate()
EkoClient.setup(API_KEY)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()
EkoClient.registerDevice("Mobile_USER")
@naphatamity
naphatamity / ListListener.kt
Created April 15, 2021 13:35
ListListener
interface ListListener {
fun onItemClick(chatItem: EkoMessage, position: Int, holder: View)
fun onItemLongClick(chatItem: EkoMessage, position: Int, holder: View)
}
@naphatamity
naphatamity / item_chat_list.xml
Last active April 27, 2021 06:18
item_chat_list
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true">
@naphatamity
naphatamity / item_chat_reply.xml
Last active April 15, 2021 13:44
item_chat_reply
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:padding="10dp">
@naphatamity
naphatamity / chat_list.xml
Last active April 27, 2021 06:15
chat_list
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/content_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="false"