Skip to content

Commit 46b9243

Browse files
committed
Remove unneeded empty state changes in ChannelFragment
1 parent ad72b2c commit 46b9243

3 files changed

Lines changed: 11 additions & 29 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import androidx.annotation.NonNull;
2121
import androidx.annotation.Nullable;
22-
import androidx.compose.runtime.MutableState;
2322
import androidx.core.content.ContextCompat;
2423
import androidx.core.graphics.ColorUtils;
2524
import androidx.core.view.MenuProvider;
@@ -46,7 +45,6 @@
4645
import org.schabi.newpipe.local.feed.notifications.NotificationHelper;
4746
import org.schabi.newpipe.local.subscription.SubscriptionManager;
4847
import org.schabi.newpipe.ui.emptystate.EmptyStateSpec;
49-
import org.schabi.newpipe.ui.emptystate.EmptyStateSpecBuilder;
5048
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
5149
import org.schabi.newpipe.util.ChannelTabHelper;
5250
import org.schabi.newpipe.util.Constants;
@@ -105,8 +103,6 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
105103
private SubscriptionEntity channelSubscription;
106104
private MenuProvider menuProvider;
107105

108-
private MutableState<EmptyStateSpec> emptyStateSpec;
109-
110106
public static ChannelFragment getInstance(final int serviceId, final String url,
111107
final String name) {
112108
final ChannelFragment instance = new ChannelFragment();
@@ -204,9 +200,10 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
204200
protected void initViews(final View rootView, final Bundle savedInstanceState) {
205201
super.initViews(rootView, savedInstanceState);
206202

207-
emptyStateSpec = EmptyStateUtil.mutableStateOf(
208-
EmptyStateSpec.Companion.getContentNotSupported());
209-
EmptyStateUtil.setEmptyStateComposable(binding.emptyStateView, emptyStateSpec);
203+
EmptyStateUtil.setEmptyStateComposable(
204+
binding.emptyStateView,
205+
EmptyStateSpec.Companion.getContentNotSupported()
206+
);
210207

211208
tabAdapter = new TabAdapter(getChildFragmentManager());
212209
binding.viewPager.setAdapter(tabAdapter);
@@ -654,10 +651,6 @@ private void showContentNotSupportedIfNeeded() {
654651
return;
655652
}
656653

657-
emptyStateSpec.setValue(
658-
new EmptyStateSpecBuilder(emptyStateSpec.getValue())
659-
.descriptionVisibility(true)
660-
.build()
661-
);
654+
binding.emptyStateView.setVisibility(View.VISIBLE);
662655
}
663656
}

app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateComposable.kt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ fun EmptyStateComposable(
3737
descriptionModifier = spec.descriptionModifier(),
3838
descriptionText = spec.descriptionText(),
3939
descriptionTextStyle = spec.descriptionTextStyle(),
40-
descriptionTextVisibility = spec.descriptionVisibility(),
4140
)
4241

4342
@Composable
@@ -49,7 +48,6 @@ private fun EmptyStateComposable(
4948
descriptionModifier: Modifier,
5049
descriptionText: String,
5150
descriptionTextStyle: TextStyle,
52-
descriptionTextVisibility: Boolean,
5351
) {
5452
CompositionLocalProvider(
5553
LocalContentColor provides MaterialTheme.colorScheme.errorHint
@@ -65,13 +63,11 @@ private fun EmptyStateComposable(
6563
style = emojiTextStyle,
6664
)
6765

68-
if (descriptionTextVisibility) {
69-
Text(
70-
modifier = descriptionModifier,
71-
text = descriptionText,
72-
style = descriptionTextStyle,
73-
)
74-
}
66+
Text(
67+
modifier = descriptionModifier,
68+
text = descriptionText,
69+
style = descriptionTextStyle,
70+
)
7571
}
7672
}
7773
}
@@ -100,9 +96,7 @@ data class EmptyStateSpec(
10096
val descriptionText: @Composable () -> String,
10197
val descriptionModifier: () -> Modifier,
10298
val descriptionTextStyle: @Composable () -> TextStyle,
103-
val descriptionVisibility: () -> Boolean = { true },
10499
) {
105-
106100
companion object {
107101

108102
val GenericError =
@@ -162,7 +156,6 @@ data class EmptyStateSpec(
162156
descriptionModifier = { Modifier.padding(top = 20.dp) },
163157
descriptionText = { stringResource(id = R.string.content_not_supported) },
164158
descriptionTextStyle = { LocalTextStyle.current.merge(fontSize = 15.sp) },
165-
descriptionVisibility = { false },
166159
)
167160
}
168161
}

app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,13 @@ fun <T> mutableStateOf(param: T): MutableState<T> {
7171
* Used in Java land to modify [EmptyStateSpec] properties.
7272
* TODO: remove after Kotlin migration
7373
*/
74-
class EmptyStateSpecBuilder(var spec: EmptyStateSpec) {
74+
class EmptyStateSpecBuilder(private var spec: EmptyStateSpec) {
7575

7676
fun descriptionText(@StringRes stringRes: Int) = apply {
7777
spec = spec.copy(
7878
descriptionText = { stringResource(id = stringRes) }
7979
)
8080
}
8181

82-
fun descriptionVisibility(descriptionTextVisibility: Boolean) = apply {
83-
spec = spec.copy(descriptionVisibility = { descriptionTextVisibility })
84-
}
85-
8682
fun build() = spec
8783
}

0 commit comments

Comments
 (0)