mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Fixed crash related to ShapeLayout for BigButton.
This commit is contained in:
+1
-1
@@ -554,7 +554,7 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
_buttonMore = buttonMore;
|
_buttonMore = buttonMore;
|
||||||
updateMoreButtons();
|
updateMoreButtons();
|
||||||
|
|
||||||
val handleLoaderGameVisibilityChanged = { b: Boolean ->
|
val handleLoaderGameVisibilityChanged: (Boolean) -> Unit = { b: Boolean ->
|
||||||
_loaderGameVisible = b
|
_loaderGameVisible = b
|
||||||
fragment.lifecycleScope.launch(Dispatchers.Main) {
|
fragment.lifecycleScope.launch(Dispatchers.Main) {
|
||||||
onShouldEnterPictureInPictureChanged.emit()
|
onShouldEnterPictureInPictureChanged.emit()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.futo.platformplayer.views.buttons
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.os.Looper
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -98,46 +99,58 @@ open class BigButton : LinearLayout {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun withIcon(resourceId: Int, rounded: Boolean = false): BigButton {
|
private fun applyIcon(resourceId: Int, rounded: Boolean) {
|
||||||
if (resourceId != -1) {
|
if (resourceId != -1) {
|
||||||
_icon.visibility = View.VISIBLE;
|
_icon.visibility = View.VISIBLE
|
||||||
_icon.setImageResource(resourceId);
|
_icon.setImageResource(resourceId)
|
||||||
} else
|
|
||||||
_icon.visibility = View.GONE;
|
|
||||||
|
|
||||||
if (rounded) {
|
|
||||||
val shapeAppearanceModel = ShapeAppearanceModel().toBuilder()
|
|
||||||
.setAllCornerSizes(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16.0f, context.resources.displayMetrics))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
_icon.scaleType = ImageView.ScaleType.FIT_CENTER;
|
|
||||||
_icon.shapeAppearanceModel = shapeAppearanceModel;
|
|
||||||
} else {
|
} else {
|
||||||
_icon.scaleType = ImageView.ScaleType.CENTER_CROP;
|
_icon.visibility = View.GONE
|
||||||
_icon.shapeAppearanceModel = ShapeAppearanceModel();
|
|
||||||
}
|
}
|
||||||
|
applyRounded(rounded)
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun withIcon(resourceId: Int, rounded: Boolean = false): BigButton {
|
||||||
|
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
|
applyIcon(resourceId, rounded)
|
||||||
|
} else {
|
||||||
|
post { applyIcon(resourceId, rounded) }
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
fun withIcon(bitmap: Bitmap, rounded: Boolean = false): BigButton {
|
fun withIcon(bitmap: Bitmap, rounded: Boolean = false): BigButton {
|
||||||
_icon.visibility = View.VISIBLE;
|
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
_icon.setImageBitmap(bitmap);
|
applyIcon(bitmap, rounded)
|
||||||
|
|
||||||
if (rounded) {
|
|
||||||
val shapeAppearanceModel = ShapeAppearanceModel().toBuilder()
|
|
||||||
.setAllCornerSizes(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16.0f, context.resources.displayMetrics))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
_icon.scaleType = ImageView.ScaleType.FIT_CENTER;
|
|
||||||
_icon.shapeAppearanceModel = shapeAppearanceModel;
|
|
||||||
} else {
|
} else {
|
||||||
_icon.scaleType = ImageView.ScaleType.CENTER_CROP;
|
post { applyIcon(bitmap, rounded) }
|
||||||
_icon.shapeAppearanceModel = ShapeAppearanceModel();
|
|
||||||
}
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
private fun applyRounded(rounded: Boolean) {
|
||||||
|
if (rounded) {
|
||||||
|
val radiusPx = TypedValue.applyDimension(
|
||||||
|
TypedValue.COMPLEX_UNIT_DIP,
|
||||||
|
16.0f,
|
||||||
|
context.resources.displayMetrics
|
||||||
|
)
|
||||||
|
val shapeAppearanceModel = ShapeAppearanceModel()
|
||||||
|
.toBuilder()
|
||||||
|
.setAllCornerSizes(radiusPx)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
_icon.scaleType = ImageView.ScaleType.FIT_CENTER
|
||||||
|
_icon.shapeAppearanceModel = shapeAppearanceModel
|
||||||
|
} else {
|
||||||
|
_icon.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||||
|
_icon.shapeAppearanceModel = ShapeAppearanceModel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun applyIcon(bitmap: Bitmap, rounded: Boolean) {
|
||||||
|
_icon.visibility = View.VISIBLE
|
||||||
|
_icon.setImageBitmap(bitmap)
|
||||||
|
applyRounded(rounded)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun withBackground(resourceId: Int): BigButton {
|
fun withBackground(resourceId: Int): BigButton {
|
||||||
|
|||||||
Reference in New Issue
Block a user