Skip to content

Commit 55e4014

Browse files
committed
Use custom EmptyStateSpec for bookmark fragment
1 parent 1cd5563 commit 55e4014

4 files changed

Lines changed: 15 additions & 18 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/bookmark/BookmarkFragment.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.schabi.newpipe.local.holder.RemoteBookmarkPlaylistItemHolder;
3939
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
4040
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
41+
import org.schabi.newpipe.ui.emptystate.EmptyStateSpec;
4142
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
4243
import org.schabi.newpipe.util.NavigationHelper;
4344
import org.schabi.newpipe.util.OnClickGesture;
@@ -124,7 +125,10 @@ protected void initViews(final View rootView, final Bundle savedInstanceState) {
124125
super.initViews(rootView, savedInstanceState);
125126

126127
itemListAdapter.setUseItemHandle(true);
127-
EmptyStateUtil.setEmptyStateComposable(rootView.findViewById(R.id.empty_state_view));
128+
EmptyStateUtil.setEmptyStateComposable(
129+
rootView.findViewById(R.id.empty_state_view),
130+
EmptyStateSpec.Companion.getNoBookmarkedPlaylist()
131+
);
128132
}
129133

130134
@Override

app/src/main/java/org/schabi/newpipe/settings/SelectPlaylistFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.schabi.newpipe.error.UserAction;
2929
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
3030
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
31+
import org.schabi.newpipe.ui.emptystate.EmptyStateSpec;
3132
import org.schabi.newpipe.ui.emptystate.EmptyStateUtil;
3233
import org.schabi.newpipe.util.image.CoilHelper;
3334

@@ -64,7 +65,8 @@ public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup
6465
recyclerView = v.findViewById(R.id.items_list);
6566
emptyView = v.findViewById(R.id.empty_state_view);
6667

67-
EmptyStateUtil.setEmptyStateText(emptyView, R.string.no_playlist_bookmarked_yet);
68+
EmptyStateUtil.setEmptyStateComposable(emptyView,
69+
EmptyStateSpec.Companion.getNoBookmarkedPlaylist());
6870
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
6971
final SelectPlaylistAdapter playlistAdapter = new SelectPlaylistAdapter();
7072
recyclerView.setAdapter(playlistAdapter);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,12 @@ data class EmptyStateSpec(
113113
emojiText = { "(︶︹︺)" },
114114
descriptionText = { stringResource(id = R.string.content_not_supported) },
115115
)
116+
117+
val NoBookmarkedPlaylist =
118+
EmptyStateSpec(
119+
modifier = { it },
120+
emojiText = { "(╥﹏╥)" },
121+
descriptionText = { stringResource(id = R.string.no_playlist_bookmarked_yet) },
122+
)
116123
}
117124
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package org.schabi.newpipe.ui.emptystate
44

55
import androidx.annotation.StringRes
6-
import androidx.compose.material3.Text
76
import androidx.compose.runtime.MutableState
87
import androidx.compose.runtime.State
98
import androidx.compose.ui.platform.ComposeView
@@ -12,21 +11,6 @@ import androidx.compose.ui.res.stringResource
1211
import org.schabi.newpipe.ui.theme.AppTheme
1312
import androidx.compose.runtime.mutableStateOf as composeRuntimeMutableStateOf
1413

15-
@JvmOverloads
16-
fun ComposeView.setEmptyStateText(
17-
@StringRes stringRes: Int,
18-
strategy: ViewCompositionStrategy = ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed,
19-
) = apply {
20-
setViewCompositionStrategy(strategy)
21-
setContent {
22-
AppTheme {
23-
Text(
24-
text = stringResource(id = stringRes),
25-
)
26-
}
27-
}
28-
}
29-
3014
@JvmOverloads
3115
fun ComposeView.setEmptyStateComposable(
3216
spec: EmptyStateSpec = EmptyStateSpec.GenericError,

0 commit comments

Comments
 (0)