feat: Integrate AvatarRepository into chat components for improved avatar handling and caching

This commit is contained in:
2026-01-28 00:28:56 +05:00
parent f92bc8b0d5
commit 8702539d09
8 changed files with 142 additions and 73 deletions

View File

@@ -230,9 +230,21 @@ object AvatarFileManager {
*/
fun base64ToBitmap(base64: String): Bitmap? {
return try {
val imageBytes = Base64.decode(base64, Base64.NO_WRAP)
BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
// Check for data URI prefix
val actualBase64 = if (base64.contains(",")) {
android.util.Log.d("AvatarFileManager", "🔍 Removing data URI prefix, orig len=${base64.length}")
base64.substringAfter(",")
} else {
base64
}
android.util.Log.d("AvatarFileManager", "🔍 Decoding base64, len=${actualBase64.length}, prefix=${actualBase64.take(50)}")
val imageBytes = Base64.decode(actualBase64, Base64.NO_WRAP)
android.util.Log.d("AvatarFileManager", "🔍 Decoded bytes=${imageBytes.size}")
val bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
android.util.Log.d("AvatarFileManager", "🔍 Bitmap result=${bitmap != null}, size=${bitmap?.width}x${bitmap?.height}")
bitmap
} catch (e: Exception) {
android.util.Log.e("AvatarFileManager", "❌ base64ToBitmap error: ${e.message}")
null
}
}