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 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 {
|
private fun isChannel(chat: TdApi.Chat): Boolean {
|
||||||
return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel
|
return chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ object TelegramUiHelper {
|
||||||
app: TelegramApplication,
|
app: TelegramApplication,
|
||||||
iv: ImageView?,
|
iv: ImageView?,
|
||||||
photoPath: String?,
|
photoPath: String?,
|
||||||
placeholderId: Int = R.drawable.img_user_picture
|
placeholderId: Int = R.drawable.img_user_picture,
|
||||||
|
useThemedIcon: Boolean = true
|
||||||
) {
|
) {
|
||||||
if (iv == null) {
|
if (iv == null) {
|
||||||
return
|
return
|
||||||
|
@ -26,12 +27,11 @@ object TelegramUiHelper {
|
||||||
bitmap = app.uiUtils.getCircleBitmap(photoPath)
|
bitmap = app.uiUtils.getCircleBitmap(photoPath)
|
||||||
}
|
}
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
drawable =
|
drawable = if (useThemedIcon) {
|
||||||
if (placeholderId == R.drawable.img_user_picture || placeholderId == R.drawable.img_group_picture) {
|
app.uiUtils.getThemedIcon(placeholderId)
|
||||||
app.uiUtils.getIcon(placeholderId)
|
} else {
|
||||||
} else {
|
app.uiUtils.getIcon(placeholderId)
|
||||||
app.uiUtils.getThemedIcon(placeholderId)
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
iv.setImageBitmap(bitmap)
|
iv.setImageBitmap(bitmap)
|
||||||
|
|
|
@ -344,14 +344,9 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
||||||
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
||||||
val chat = chats[position]
|
val chat = chats[position]
|
||||||
val lastItem = position == itemCount - 1
|
val lastItem = position == itemCount - 1
|
||||||
val placeholderId: Int =
|
val placeholderId: Int = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture
|
||||||
if (chat.type is TdApi.ChatTypeBasicGroup || chat.type is TdApi.ChatTypeSupergroup) {
|
|
||||||
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.title?.text = chat.title
|
||||||
holder.description?.text = "Some description" // FIXME
|
holder.description?.text = "Some description" // FIXME
|
||||||
holder.checkBox?.apply {
|
holder.checkBox?.apply {
|
||||||
|
|
|
@ -208,14 +208,9 @@ class SetTimeDialogFragment : DialogFragment() {
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ChatViewHolder, position: Int) {
|
||||||
val chat = chats[position]
|
val chat = chats[position]
|
||||||
val placeholderId: Int =
|
val placeholderId: Int = if (telegramHelper.isGroup(chat)) R.drawable.img_group_picture else R.drawable.img_user_picture
|
||||||
if (chat.type is TdApi.ChatTypeBasicGroup || chat.type is TdApi.ChatTypeSupergroup) {
|
|
||||||
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.title?.text = chat.title
|
||||||
holder.description?.text = "Some description" // FIXME
|
holder.description?.text = "Some description" // FIXME
|
||||||
holder.textInArea?.apply {
|
holder.textInArea?.apply {
|
||||||
|
|
Loading…
Reference in a new issue