update Kotlin to 1.7.10 and fix some (new?) warnings (#2647)
* update Kotlin to 1.7.10 and fix some (new?) warnings * remove unused import
This commit is contained in:
parent
12e42e9b2b
commit
4f0f9a7a12
11 changed files with 17 additions and 65 deletions
|
|
@ -48,7 +48,7 @@ class ListStatusAccessibilityDelegate(
|
|||
val pos = recyclerView.getChildAdapterPosition(host)
|
||||
val status = statusProvider.getStatus(pos) ?: return
|
||||
if (status is StatusViewData.Concrete) {
|
||||
if (!status.spoilerText.isNullOrEmpty()) {
|
||||
if (status.spoilerText.isNotEmpty()) {
|
||||
info.addAction(if (status.isExpanded) collapseCwAction else expandCwAction)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,3 @@ inline fun <T> List<T>.replacedFirstWhich(replacement: T, predicate: (T) -> Bool
|
|||
}
|
||||
return newList
|
||||
}
|
||||
|
||||
inline fun <reified R> Iterable<*>.firstIsInstanceOrNull(): R? {
|
||||
return firstOrNull { it is R }?.let { it as R }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import android.graphics.Matrix
|
|||
import android.net.Uri
|
||||
import android.provider.OpenableColumns
|
||||
import android.util.Log
|
||||
import androidx.annotation.Px
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
|
|
@ -68,43 +67,6 @@ fun getMediaSize(contentResolver: ContentResolver, uri: Uri?): Long {
|
|||
return mediaSize
|
||||
}
|
||||
|
||||
fun getSampledBitmap(contentResolver: ContentResolver, uri: Uri, @Px reqWidth: Int, @Px reqHeight: Int): Bitmap? {
|
||||
// First decode with inJustDecodeBounds=true to check dimensions
|
||||
val options = BitmapFactory.Options()
|
||||
options.inJustDecodeBounds = true
|
||||
var stream: InputStream?
|
||||
try {
|
||||
stream = contentResolver.openInputStream(uri)
|
||||
} catch (e: FileNotFoundException) {
|
||||
Log.w(TAG, e)
|
||||
return null
|
||||
}
|
||||
|
||||
BitmapFactory.decodeStream(stream, null, options)
|
||||
|
||||
IOUtils.closeQuietly(stream)
|
||||
|
||||
// Calculate inSampleSize
|
||||
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight)
|
||||
|
||||
// Decode bitmap with inSampleSize set
|
||||
options.inJustDecodeBounds = false
|
||||
return try {
|
||||
stream = contentResolver.openInputStream(uri)
|
||||
val bitmap = BitmapFactory.decodeStream(stream, null, options)
|
||||
val orientation = getImageOrientation(uri, contentResolver)
|
||||
reorientBitmap(bitmap, orientation)
|
||||
} catch (e: FileNotFoundException) {
|
||||
Log.w(TAG, e)
|
||||
null
|
||||
} catch (e: OutOfMemoryError) {
|
||||
Log.e(TAG, "OutOfMemoryError while trying to get sampled Bitmap", e)
|
||||
null
|
||||
} finally {
|
||||
IOUtils.closeQuietly(stream)
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(FileNotFoundException::class)
|
||||
fun getImageSquarePixels(contentResolver: ContentResolver, uri: Uri): Long {
|
||||
val input = contentResolver.openInputStream(uri)
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ class StatusViewHelper(private val itemView: View) {
|
|||
mediaPreviews[3].layoutParams.height = mediaPreviewHeight
|
||||
}
|
||||
}
|
||||
if (attachments.isNullOrEmpty()) {
|
||||
if (attachments.isEmpty()) {
|
||||
sensitiveMediaWarning.visibility = View.GONE
|
||||
sensitiveMediaShow.visibility = View.GONE
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,17 +32,16 @@ class FragmentViewBindingDelegate<T : ViewBinding>(
|
|||
object : DefaultLifecycleObserver {
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
fragment.viewLifecycleOwnerLiveData.observe(
|
||||
fragment,
|
||||
{ t ->
|
||||
t?.lifecycle?.addObserver(
|
||||
object : DefaultLifecycleObserver {
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
binding = null
|
||||
}
|
||||
fragment
|
||||
) { t ->
|
||||
t?.lifecycle?.addObserver(
|
||||
object : DefaultLifecycleObserver {
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
binding = null
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue