Fix updating of current user photo on first start
This commit is contained in:
parent
46382bf3de
commit
f314d480ba
2 changed files with 23 additions and 10 deletions
|
@ -496,7 +496,13 @@ class TelegramHelper private constructor() {
|
|||
listener?.onTelegramError(error.code, error.message)
|
||||
}
|
||||
}
|
||||
TdApi.User.CONSTRUCTOR -> currentUser = obj as TdApi.User
|
||||
TdApi.User.CONSTRUCTOR -> {
|
||||
val currUser = obj as TdApi.User
|
||||
currentUser = currUser
|
||||
if (!hasLocalUserPhoto(currUser) && hasRemoteUserPhoto(currUser)) {
|
||||
requestUserPhoto(currUser)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1219,7 +1225,6 @@ class TelegramHelper private constructor() {
|
|||
chat.photo?.small = updateFile.file
|
||||
}
|
||||
listener?.onTelegramChatChanged(chat)
|
||||
return
|
||||
}
|
||||
val user = downloadUserFilesMap.remove(remoteId)
|
||||
if (user != null) {
|
||||
|
@ -1227,7 +1232,6 @@ class TelegramHelper private constructor() {
|
|||
user.profilePhoto?.small = updateFile.file
|
||||
}
|
||||
listener?.onTelegramUserChanged(user)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
|
||||
private lateinit var appBarLayout: AppBarLayout
|
||||
private lateinit var imageContainer: FrameLayout
|
||||
private lateinit var currentUserIcon: ImageView
|
||||
private lateinit var textContainer: LinearLayout
|
||||
private lateinit var titleContainer: LinearLayout
|
||||
private lateinit var optionsBtn: ImageView
|
||||
|
@ -119,13 +120,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
})
|
||||
}
|
||||
|
||||
TelegramUiHelper.setupPhoto(
|
||||
app,
|
||||
mainView.findViewById(R.id.user_icon),
|
||||
telegramHelper.getUserPhotoPath(telegramHelper.getCurrentUser()),
|
||||
R.drawable.img_user_placeholder,
|
||||
false
|
||||
)
|
||||
currentUserIcon = mainView.findViewById(R.id.user_icon)
|
||||
|
||||
optionsBtn = mainView.findViewById<ImageView>(R.id.options)
|
||||
with(activity as MainActivity) {
|
||||
|
@ -203,6 +198,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateCurrentUserPhoto()
|
||||
telegramHelper.getActiveLiveLocationMessages(null)
|
||||
updateContent()
|
||||
updateEnable = true
|
||||
|
@ -265,6 +261,9 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
}
|
||||
|
||||
override fun onTelegramUserChanged(user: TdApi.User) {
|
||||
if (user.id == telegramHelper.getCurrentUser()?.id) {
|
||||
updateCurrentUserPhoto()
|
||||
}
|
||||
updateContent()
|
||||
}
|
||||
|
||||
|
@ -289,6 +288,16 @@ class MyLocationTabFragment : Fragment(), TelegramListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateCurrentUserPhoto() {
|
||||
TelegramUiHelper.setupPhoto(
|
||||
app,
|
||||
currentUserIcon,
|
||||
telegramHelper.getUserPhotoPath(telegramHelper.getCurrentUser()),
|
||||
R.drawable.img_user_placeholder,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
private fun startHandler() {
|
||||
val updateAdapter = Handler()
|
||||
updateAdapter.postDelayed({
|
||||
|
|
Loading…
Reference in a new issue