add isGroup method
This commit is contained in:
parent
5a2e858934
commit
459f1ba37f
4 changed files with 15 additions and 21 deletions
|
@ -129,6 +129,10 @@ class TelegramHelper private constructor() {
|
|||
|
||||
fun getSupergroupFullInfo(id: Int) = supergroupsFullInfo[id]
|
||||
|
||||
fun isGroup(chat: TdApi.Chat): Boolean {
|
||||
return chat.type is TdApi.ChatTypeSupergroup || chat.type is TdApi.ChatTypeBasicGroup
|
||||
}
|
||||
|
||||
private fun isChannel(chat: TdApi.Chat): Boolean {
|
||||
return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ object TelegramUiHelper {
|
|||
app: TelegramApplication,
|
||||
iv: ImageView?,
|
||||
photoPath: String?,
|
||||
placeholderId: Int = R.drawable.img_user_picture
|
||||
placeholderId: Int = R.drawable.img_user_picture,
|
||||
useThemedIcon: Boolean = true
|
||||
) {
|
||||
if (iv == null) {
|
||||
return
|
||||
|
@ -26,12 +27,11 @@ object TelegramUiHelper {
|
|||
bitmap = app.uiUtils.getCircleBitmap(photoPath)
|
||||
}
|
||||
if (bitmap == null) {
|
||||
drawable =
|
||||
if (placeholderId == R.drawable.img_user_picture || placeholderId == R.drawable.img_group_picture) {
|
||||
app.uiUtils.getIcon(placeholderId)
|
||||
} else {
|
||||
app.uiUtils.getThemedIcon(placeholderId)
|
||||
}
|
||||
drawable = if (useThemedIcon) {
|
||||
app.uiUtils.getThemedIcon(placeholderId)
|
||||
} else {
|
||||
app.uiUtils.getIcon(placeholderId)
|
||||
}
|
||||
}
|
||||
if (bitmap != null) {
|
||||
iv.setImageBitmap(bitmap)
|
||||
|
|
|
@ -344,14 +344,9 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
||||
val chat = chats[position]
|
||||
val lastItem = position == itemCount - 1
|
||||
val placeholderId: Int =
|
||||
if (chat.type is TdApi.ChatTypeBasicGroup || chat.type is TdApi.ChatTypeSupergroup) {
|
||||
R.drawable.img_group_picture
|
||||
} else {
|
||||
R.drawable.img_user_picture
|
||||
}
|
||||
val placeholderId: Int = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture
|
||||
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId)
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false)
|
||||
holder.title?.text = chat.title
|
||||
holder.description?.text = "Some description" // FIXME
|
||||
holder.checkBox?.apply {
|
||||
|
|
|
@ -208,14 +208,9 @@ class SetTimeDialogFragment : DialogFragment() {
|
|||
|
||||
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
||||
val chat = chats[position]
|
||||
val placeholderId: Int =
|
||||
if (chat.type is TdApi.ChatTypeBasicGroup || chat.type is TdApi.ChatTypeSupergroup) {
|
||||
R.drawable.img_group_picture
|
||||
} else {
|
||||
R.drawable.img_user_picture
|
||||
}
|
||||
val placeholderId: Int = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture
|
||||
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId)
|
||||
TelegramUiHelper.setupPhoto(app, holder.icon, chat.photo?.small?.local?.path, placeholderId, false)
|
||||
holder.title?.text = chat.title
|
||||
holder.description?.text = "Some description" // FIXME
|
||||
holder.textInArea?.apply {
|
||||
|
|
Loading…
Reference in a new issue