Remove some dead code
This commit is contained in:
@@ -1,19 +1,9 @@
|
||||
package eu.kanade.tachiyomi.util.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import coil.ImageLoader
|
||||
import coil.imageLoader
|
||||
import coil.load
|
||||
import coil.request.ImageRequest
|
||||
import coil.target.ImageViewTarget
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.animatorDurationScale
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
|
||||
/**
|
||||
@@ -29,33 +19,3 @@ fun ImageView.setVectorCompat(@DrawableRes drawable: Int, @AttrRes tint: Int? =
|
||||
}
|
||||
setImageDrawable(vector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the image referenced by [data] and set it on this [ImageView],
|
||||
* and if the image is animated, this will also disable that animation
|
||||
* if [Context.animatorDurationScale] is 0
|
||||
*/
|
||||
fun ImageView.loadAutoPause(
|
||||
data: Any?,
|
||||
loader: ImageLoader = context.imageLoader,
|
||||
builder: ImageRequest.Builder.() -> Unit = {},
|
||||
) {
|
||||
load(data, loader) {
|
||||
placeholder(ColorDrawable(context.getColor(R.color.cover_placeholder)))
|
||||
error(R.drawable.cover_error)
|
||||
|
||||
// Build the original request so we can add on our success listener
|
||||
val originalListener = apply(builder).build().listener
|
||||
listener(
|
||||
onSuccess = { request, metadata ->
|
||||
(request.target as? ImageViewTarget)?.drawable.let {
|
||||
if (it is Animatable && context.animatorDurationScale == 0f) it.stop()
|
||||
}
|
||||
originalListener?.onSuccess(request, metadata)
|
||||
},
|
||||
onStart = { request -> originalListener?.onStart(request) },
|
||||
onCancel = { request -> originalListener?.onCancel(request) },
|
||||
onError = { request, throwable -> originalListener?.onError(request, throwable) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.annotation.MenuRes
|
||||
@@ -29,15 +28,11 @@ import androidx.compose.runtime.CompositionContext
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.descendants
|
||||
import androidx.core.view.forEach
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.inputMethodManager
|
||||
|
||||
inline fun ComposeView.setComposeContent(crossinline content: @Composable () -> Unit) {
|
||||
consumeWindowInsets = false
|
||||
@@ -70,24 +65,6 @@ inline fun ComponentActivity.setComposeContent(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a snackbar in this view.
|
||||
*
|
||||
* @param message the message to show.
|
||||
* @param length the duration of the snack.
|
||||
* @param f a function to execute in the snack, allowing for example to define a custom action.
|
||||
*/
|
||||
inline fun View.snack(
|
||||
message: String,
|
||||
length: Int = 10_000,
|
||||
f: Snackbar.() -> Unit = {},
|
||||
): Snackbar {
|
||||
val snack = Snackbar.make(this, message, length)
|
||||
snack.f()
|
||||
snack.show()
|
||||
return snack
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tooltip shown on long press.
|
||||
*
|
||||
@@ -173,20 +150,6 @@ inline fun View.popupMenu(
|
||||
return popup
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this ViewGroup's first child of specified class
|
||||
*/
|
||||
inline fun <reified T> ViewGroup.findChild(): T? {
|
||||
return children.find { it is T } as? T
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this ViewGroup's first descendant of specified class
|
||||
*/
|
||||
inline fun <reified T> ViewGroup.findDescendant(): T? {
|
||||
return descendants.find { it is T } as? T
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a deep copy of the provided [Drawable]
|
||||
*/
|
||||
@@ -210,7 +173,3 @@ fun View?.isVisibleOnScreen(): Boolean {
|
||||
val screen = Rect(0, 0, Resources.getSystem().displayMetrics.widthPixels, Resources.getSystem().displayMetrics.heightPixels)
|
||||
return actualPosition.intersect(screen)
|
||||
}
|
||||
|
||||
fun View.hideKeyboard() {
|
||||
context.inputMethodManager.hideSoftInputFromWindow(windowToken, 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user