diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 394d97f12..2d5873e3f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -19,7 +19,6 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.compose.runtime.MutableState; import androidx.core.content.ContextCompat; import androidx.core.graphics.ColorUtils; import androidx.core.view.MenuProvider; @@ -46,7 +45,6 @@ import org.schabi.newpipe.ktx.AnimationType; import org.schabi.newpipe.local.feed.notifications.NotificationHelper; import org.schabi.newpipe.local.subscription.SubscriptionManager; import org.schabi.newpipe.ui.emptystate.EmptyStateSpec; -import org.schabi.newpipe.ui.emptystate.EmptyStateSpecBuilder; import org.schabi.newpipe.ui.emptystate.EmptyStateUtil; import org.schabi.newpipe.util.ChannelTabHelper; import org.schabi.newpipe.util.Constants; @@ -105,8 +103,6 @@ public class ChannelFragment extends BaseStateFragment private SubscriptionEntity channelSubscription; private MenuProvider menuProvider; - private MutableState emptyStateSpec; - public static ChannelFragment getInstance(final int serviceId, final String url, final String name) { final ChannelFragment instance = new ChannelFragment(); @@ -204,9 +200,10 @@ public class ChannelFragment extends BaseStateFragment protected void initViews(final View rootView, final Bundle savedInstanceState) { super.initViews(rootView, savedInstanceState); - emptyStateSpec = EmptyStateUtil.mutableStateOf( - EmptyStateSpec.Companion.getContentNotSupported()); - EmptyStateUtil.setEmptyStateComposable(binding.emptyStateView, emptyStateSpec); + EmptyStateUtil.setEmptyStateComposable( + binding.emptyStateView, + EmptyStateSpec.Companion.getContentNotSupported() + ); tabAdapter = new TabAdapter(getChildFragmentManager()); binding.viewPager.setAdapter(tabAdapter); @@ -654,10 +651,6 @@ public class ChannelFragment extends BaseStateFragment return; } - emptyStateSpec.setValue( - new EmptyStateSpecBuilder(emptyStateSpec.getValue()) - .descriptionVisibility(true) - .build() - ); + binding.emptyStateView.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt index 3af217a9c..d67aed898 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt @@ -37,7 +37,6 @@ fun EmptyStateComposable( descriptionModifier = spec.descriptionModifier(), descriptionText = spec.descriptionText(), descriptionTextStyle = spec.descriptionTextStyle(), - descriptionTextVisibility = spec.descriptionVisibility(), ) @Composable @@ -49,7 +48,6 @@ private fun EmptyStateComposable( descriptionModifier: Modifier, descriptionText: String, descriptionTextStyle: TextStyle, - descriptionTextVisibility: Boolean, ) { CompositionLocalProvider( LocalContentColor provides MaterialTheme.colorScheme.errorHint @@ -65,13 +63,11 @@ private fun EmptyStateComposable( style = emojiTextStyle, ) - if (descriptionTextVisibility) { - Text( - modifier = descriptionModifier, - text = descriptionText, - style = descriptionTextStyle, - ) - } + Text( + modifier = descriptionModifier, + text = descriptionText, + style = descriptionTextStyle, + ) } } } @@ -100,9 +96,7 @@ data class EmptyStateSpec( val descriptionText: @Composable () -> String, val descriptionModifier: () -> Modifier, val descriptionTextStyle: @Composable () -> TextStyle, - val descriptionVisibility: () -> Boolean = { true }, ) { - companion object { val GenericError = @@ -162,7 +156,6 @@ data class EmptyStateSpec( descriptionModifier = { Modifier.padding(top = 20.dp) }, descriptionText = { stringResource(id = R.string.content_not_supported) }, descriptionTextStyle = { LocalTextStyle.current.merge(fontSize = 15.sp) }, - descriptionVisibility = { false }, ) } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt index b025bdc5b..526a33850 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt @@ -71,7 +71,7 @@ fun mutableStateOf(param: T): MutableState { * Used in Java land to modify [EmptyStateSpec] properties. * TODO: remove after Kotlin migration */ -class EmptyStateSpecBuilder(var spec: EmptyStateSpec) { +class EmptyStateSpecBuilder(private var spec: EmptyStateSpec) { fun descriptionText(@StringRes stringRes: Int) = apply { spec = spec.copy( @@ -79,9 +79,5 @@ class EmptyStateSpecBuilder(var spec: EmptyStateSpec) { ) } - fun descriptionVisibility(descriptionTextVisibility: Boolean) = apply { - spec = spec.copy(descriptionVisibility = { descriptionTextVisibility }) - } - fun build() = spec }