Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class WPMainNavigationView @JvmOverloads constructor(
get() = getPageForItemId(navigationBarView.selectedItemId)
set(pageType) = updateCurrentPosition(pages().indexOf(pageType))

private var gravatarLoaded = false

interface OnPageListener {
fun onPageChanged(position: Int)
fun onNewPostButtonClicked(promptId: Int, origin: EntryPoint)
Expand Down Expand Up @@ -145,7 +147,7 @@ class WPMainNavigationView @JvmOverloads constructor(
}
}

if(getMainPageIndex() != getPosition(ME)) {
if (getMainPageIndex() != getPosition(ME)) {
setImageViewSelected(getPosition(ME), false)
}

Expand All @@ -168,6 +170,7 @@ class WPMainNavigationView @JvmOverloads constructor(
ImageType.USER,
object : ImageManager.RequestListener<android.graphics.drawable.Drawable> {
override fun onLoadFailed(e: Exception?, model: Any?) {
gravatarLoaded = false
val appLogMessage = "onLoadFailed while loading Gravatar image!"
if (e == null) {
AppLog.e(
Expand All @@ -184,6 +187,7 @@ class WPMainNavigationView @JvmOverloads constructor(
}

override fun onResourceReady(resource: android.graphics.drawable.Drawable, model: Any?) {
gravatarLoaded = true
ImageViewCompat.setImageTintList(imgIcon, null)
if (resource is BitmapDrawable) {
var bitmap = resource.bitmap
Expand Down Expand Up @@ -304,16 +308,18 @@ class WPMainNavigationView @JvmOverloads constructor(

private fun setImageViewSelected(position: Int, isSelected: Boolean) {
getImageViewForPosition(position)?.let {
if(position == getPosition(ME)) {
if(!isSelected){
// Only change the saturation if we have loaded a Gravatar image

Copilot AI Jun 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding inline documentation or clarifying the logic behind applying color filters only when gravatarLoaded is true to improve code maintainability.

Suggested change
// Only change the saturation if we have loaded a Gravatar image
// Only change the saturation if we have loaded a Gravatar image
// Apply color filters only for the "ME" position and only if the Gravatar image has been loaded.
// This ensures that the color filters are applied to the user's profile image (Gravatar) and not to other icons.

Copilot uses AI. Check for mistakes.
if (position == getPosition(ME) && gravatarLoaded) {
if (!isSelected) {
it.colorFilter = disabledColorFilter
} else
} else {
it.colorFilter = enabledColorFilter
}
}

it.isSelected = isSelected
it.alpha = if (isSelected) 1f else unselectedButtonAlpha
if(it.isSelected) {
if (it.isSelected) {
val pop = AnimationUtils.loadAnimation(it.context, R.anim.bottom_nav_icon_pop)
it.startAnimation(pop)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,18 @@ class ImageManager @Inject constructor(
* Loads the Bitmap into the ImageView.
*/
@JvmOverloads
fun load(imageView: ImageView, bitmap: Bitmap, scaleType: ScaleType = CENTER) {
fun load(
imageView: ImageView,
bitmap: Bitmap,
scaleType: ScaleType = CENTER,
requestListener: RequestListener<Drawable>? = null
) {
val context = imageView.context
if (!context.isAvailable()) return
Glide.with(context)
.load(bitmap)
.applyScaleType(scaleType)
.attachRequestListener(requestListener)
.into(imageView)
.clearOnDetach()
}
Expand Down