Remove unneeded empty state changes in ChannelFragment
This commit is contained in:
parent
ad72b2cb31
commit
46b9243661
|
@ -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<ChannelInfo>
|
|||
private SubscriptionEntity channelSubscription;
|
||||
private MenuProvider menuProvider;
|
||||
|
||||
private MutableState<EmptyStateSpec> 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<ChannelInfo>
|
|||
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<ChannelInfo>
|
|||
return;
|
||||
}
|
||||
|
||||
emptyStateSpec.setValue(
|
||||
new EmptyStateSpecBuilder(emptyStateSpec.getValue())
|
||||
.descriptionVisibility(true)
|
||||
.build()
|
||||
);
|
||||
binding.emptyStateView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ fun <T> mutableStateOf(param: T): MutableState<T> {
|
|||
* 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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue