mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
crash fixes
This commit is contained in:
parent
34966dfd4e
commit
ff0968f4a6
@ -39,8 +39,7 @@ class AccountPreferences(
|
||||
private val preferences: SharedPreferences,
|
||||
val accountKey: UserKey
|
||||
) {
|
||||
private val accountPreferences = context.getSharedPreferences(
|
||||
"$ACCOUNT_PREFERENCES_NAME_PREFIX$accountKey", Context.MODE_PRIVATE)
|
||||
private val accountPreferences = getSharedPreferencesForAccount(context, accountKey)
|
||||
|
||||
val defaultNotificationLightColor: Int
|
||||
get() {
|
||||
@ -154,8 +153,12 @@ class AccountPreferences(
|
||||
}
|
||||
|
||||
fun getSharedPreferencesForAccount(context: Context, accountKey: UserKey): SharedPreferences {
|
||||
return context.getSharedPreferences("$ACCOUNT_PREFERENCES_NAME_PREFIX$accountKey",
|
||||
return context.getSharedPreferences("$ACCOUNT_PREFERENCES_NAME_PREFIX${accountKey.sanitized()}",
|
||||
Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
private fun UserKey.sanitized(): String {
|
||||
return toString().replace(Regex("[^\\w\\d@-_.]"), "_")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -917,9 +917,14 @@ class UpdateStatusTask(
|
||||
o.inSampleSize = o.calculateInSampleSize(imageLimit.maxWidth, imageLimit.maxHeight)
|
||||
o.inJustDecodeBounds = false
|
||||
// Do actual image decoding
|
||||
val bitmap = context.contentResolver.openInputStream(mediaUri).use {
|
||||
BitmapFactory.decodeStream(it, null, o)
|
||||
} ?: return null
|
||||
val bitmap = try {
|
||||
context.contentResolver.openInputStream(mediaUri).use {
|
||||
BitmapFactory.decodeStream(it, null, o)
|
||||
} ?: return null
|
||||
} catch (oome: OutOfMemoryError) {
|
||||
Analyzer.logException(OutOfMemoryError("OOM Image size: $imageSize, width: ${o.outWidth}, height: ${o.outHeight}, type: ${o.outMimeType}"))
|
||||
return null
|
||||
}
|
||||
|
||||
val size = Point(bitmap.width, bitmap.height)
|
||||
val ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mediaType)
|
||||
|
Loading…
x
Reference in New Issue
Block a user