Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to always subscribe to refresh listener #1259

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,73 +26,72 @@
* A fragment that displays the Playlists belonging to a Channel
*/
public class ChannelPlaylistsFragment extends VideosGridFragment implements PlaylistClickListener, SwipeRefreshLayout.OnRefreshListener {
private PlaylistsGridAdapter playlistsGridAdapter;
private MainActivityListener mainActivityListener;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);


if (playlistsGridAdapter == null) {
playlistsGridAdapter = new PlaylistsGridAdapter(getActivity(), this);
} else {
playlistsGridAdapter.setContext(getActivity());
}

YouTubeChannel channel = (YouTubeChannel) requireArguments()
.getSerializable(ChannelBrowserFragment.CHANNEL_OBJ);
playlistsGridAdapter.setFetcher(createFetcher(channel));

gridviewBinding.swipeRefreshLayout.setOnRefreshListener(this);

gridviewBinding.gridView.setAdapter(playlistsGridAdapter);

return view;
}

private YouTubeTasks.ChannelPlaylistFetcher createFetcher(YouTubeChannel channel) {
if (SkyTubeApp.getSettings().isUseNewPipe()) {
return new GetPlaylistsForChannel(channel);
} else {
return new LegacyGetChannelPlaylists(channel);
}
}

@Override
public void onDestroy() {
playlistsGridAdapter.clearBackgroundTasks();
super.onDestroy();
}

@Override
public String getFragmentName() {
return SkyTubeApp.getStr(R.string.playlists);
}

@Override
public void onClickPlaylist(YouTubePlaylist playlist) {
if(mainActivityListener != null)
mainActivityListener.onPlaylistClick(playlist);
}

public void setMainActivityListener(MainActivityListener mainActivityListener) {
this.mainActivityListener = mainActivityListener;
}

@Override
public void onRefresh() {
playlistsGridAdapter.refresh(youTubePlaylists -> gridviewBinding.swipeRefreshLayout.setRefreshing(false));
}

@Override
protected VideoCategory getVideoCategory() {
return null;
}

@Override
public int getPriority() {
return 6;
}
private PlaylistsGridAdapter playlistsGridAdapter;
private MainActivityListener mainActivityListener;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);


if (playlistsGridAdapter == null) {
playlistsGridAdapter = new PlaylistsGridAdapter(getActivity(), this);
} else {
playlistsGridAdapter.setContext(getActivity());
}

YouTubeChannel channel = (YouTubeChannel) requireArguments()
.getSerializable(ChannelBrowserFragment.CHANNEL_OBJ);
playlistsGridAdapter.setFetcher(createFetcher(channel));

gridviewBinding.gridView.setAdapter(playlistsGridAdapter);

return view;
}

private YouTubeTasks.ChannelPlaylistFetcher createFetcher(YouTubeChannel channel) {
if (SkyTubeApp.getSettings().isUseNewPipe()) {
return new GetPlaylistsForChannel(channel);
} else {
return new LegacyGetChannelPlaylists(channel);
}
}

@Override
public void onDestroy() {
playlistsGridAdapter.clearBackgroundTasks();
super.onDestroy();
}

@Override
public String getFragmentName() {
return SkyTubeApp.getStr(R.string.playlists);
}

@Override
public void onClickPlaylist(YouTubePlaylist playlist) {
if(mainActivityListener != null) {
mainActivityListener.onPlaylistClick(playlist);
}
}

public void setMainActivityListener(MainActivityListener mainActivityListener) {
this.mainActivityListener = mainActivityListener;
}

@Override
public void onRefresh() {
playlistsGridAdapter.refresh(youTubePlaylists -> gridviewBinding.swipeRefreshLayout.setRefreshing(false));
}

@Override
protected VideoCategory getVideoCategory() {
return null;
}

@Override
public int getPriority() {
return 6;
}
}
Loading
Loading