fixed gif upload
This commit is contained in:
parent
d1212e8893
commit
482c99cb4f
|
@ -35,8 +35,8 @@ android {
|
|||
applicationId "org.mariotaku.twidere"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 24
|
||||
versionCode 206
|
||||
versionName '3.2.2'
|
||||
versionCode 207
|
||||
versionName '3.2.3'
|
||||
multiDexEnabled true
|
||||
|
||||
buildConfigField 'boolean', 'LEAK_CANARY_ENABLED', 'Boolean.parseBoolean("false")'
|
||||
|
|
|
@ -671,23 +671,29 @@ class UpdateStatusTask(
|
|||
o.inSampleSize = Utils.calculateInSampleSize(o.outWidth, o.outHeight,
|
||||
sizeLimit.x, sizeLimit.y)
|
||||
o.inJustDecodeBounds = false
|
||||
val bitmap = BitmapFactoryUtils.decodeUri(resolver, mediaUri, null, o)
|
||||
if (bitmap != null && mediaType != "image/gif") {
|
||||
val os = DirectByteArrayOutputStream()
|
||||
when (mediaType) {
|
||||
"image/png", "image/x-png", "image/webp", "image-x-webp" -> {
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 0, os)
|
||||
}
|
||||
else -> {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 85, os)
|
||||
}
|
||||
}
|
||||
length = os.size().toLong()
|
||||
cis = ContentLengthInputStream(os.inputStream(true), length)
|
||||
} else {
|
||||
if (mediaType == "image/gif") {
|
||||
val st = resolver.openInputStream(mediaUri) ?: throw FileNotFoundException(mediaUri.toString())
|
||||
length = st.available().toLong()
|
||||
cis = ContentLengthInputStream(st, length)
|
||||
} else {
|
||||
val bitmap = BitmapFactoryUtils.decodeUri(resolver, mediaUri, null, o)
|
||||
if (bitmap != null) {
|
||||
val os = DirectByteArrayOutputStream()
|
||||
when (mediaType) {
|
||||
"image/png", "image/x-png", "image/webp", "image-x-webp" -> {
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 0, os)
|
||||
}
|
||||
else -> {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 85, os)
|
||||
}
|
||||
}
|
||||
length = os.size().toLong()
|
||||
cis = ContentLengthInputStream(os.inputStream(true), length)
|
||||
} else {
|
||||
val st = resolver.openInputStream(mediaUri) ?: throw FileNotFoundException(mediaUri.toString())
|
||||
length = st.available().toLong()
|
||||
cis = ContentLengthInputStream(st, length)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val st = resolver.openInputStream(mediaUri) ?: throw FileNotFoundException(mediaUri.toString())
|
||||
|
|
Loading…
Reference in New Issue