-
Notifications
You must be signed in to change notification settings - Fork 694
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
1 parent
8ca8994
commit df577da
Showing
26 changed files
with
816 additions
and
239 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
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
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
74 changes: 74 additions & 0 deletions
74
...tlin/app/src/main/java/com/quickblox/sample/videochat/kotlin/adapters/AudioCallAdapter.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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.quickblox.sample.videochat.kotlin.adapters | ||
|
||
import android.content.Context | ||
import android.text.TextUtils | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.quickblox.sample.videochat.kotlin.R | ||
|
||
class AudioCallAdapter(context: Context?, private var usersList: List<ReconnectingUserModel>) : | ||
RecyclerView.Adapter<AudioCallAdapter.ViewHolder>() { | ||
private val inflater: LayoutInflater | ||
|
||
init { | ||
inflater = LayoutInflater.from(context) | ||
} | ||
|
||
fun updateList(usersList: List<ReconnectingUserModel>) { | ||
this.usersList = usersList | ||
notifyDataSetChanged() | ||
} | ||
|
||
fun getItemByUserId(userId: Int): ReconnectingUserModel? { | ||
for (item in usersList) { | ||
if (item.getUser().id == userId) { | ||
return item | ||
} | ||
} | ||
return null | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val view: View = inflater.inflate(R.layout.audio_call_item, parent, false) | ||
return ViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
val user = usersList[position].getUser() | ||
val name: String | ||
name = if (TextUtils.isEmpty(user.fullName)) { | ||
user.login | ||
} else { | ||
user.fullName | ||
} | ||
holder.setName(name) | ||
if (!TextUtils.isEmpty(usersList[position].getReconnectingState())) { | ||
holder.setStatus(usersList[position].getReconnectingState()) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return usersList.size | ||
} | ||
|
||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
private val nameView: TextView | ||
private val statusView: TextView | ||
|
||
init { | ||
nameView = itemView.findViewById<View>(R.id.name) as TextView | ||
statusView = itemView.findViewById<View>(R.id.status) as TextView | ||
} | ||
|
||
fun setStatus(status: String?) { | ||
statusView.text = status | ||
} | ||
|
||
fun setName(name: String?) { | ||
nameView.text = name | ||
} | ||
} | ||
} |
Oops, something went wrong.