2022-10-23 10:27:35 +02:00
|
|
|
package org.schabi.newpipe.fragments.list.channel;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.R;
|
|
|
|
import org.schabi.newpipe.error.UserAction;
|
|
|
|
import org.schabi.newpipe.extractor.InfoItem;
|
|
|
|
import org.schabi.newpipe.extractor.ListExtractor;
|
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelTabInfo;
|
2022-11-05 00:23:03 +01:00
|
|
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
2022-10-23 10:27:35 +02:00
|
|
|
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
|
|
|
import org.schabi.newpipe.util.ExtractorHelper;
|
|
|
|
|
|
|
|
import icepick.State;
|
|
|
|
import io.reactivex.rxjava3.core.Single;
|
|
|
|
|
|
|
|
public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTabInfo> {
|
|
|
|
|
|
|
|
@State
|
2022-11-05 00:23:03 +01:00
|
|
|
protected ListLinkHandler tabHandler;
|
2022-11-29 19:25:35 +01:00
|
|
|
@State
|
|
|
|
protected String channelName;
|
|
|
|
|
2022-10-23 10:27:35 +02:00
|
|
|
public static ChannelTabFragment getInstance(final int serviceId,
|
2022-11-29 19:25:35 +01:00
|
|
|
final ListLinkHandler tabHandler,
|
|
|
|
final String channelName) {
|
2022-10-23 10:27:35 +02:00
|
|
|
final ChannelTabFragment instance = new ChannelTabFragment();
|
|
|
|
instance.serviceId = serviceId;
|
|
|
|
instance.tabHandler = tabHandler;
|
2022-11-29 19:25:35 +01:00
|
|
|
instance.channelName = channelName;
|
2022-10-23 10:27:35 +02:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ChannelTabFragment() {
|
|
|
|
super(UserAction.REQUESTED_CHANNEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*//////////////////////////////////////////////////////////////////////////
|
|
|
|
// LifeCycle
|
|
|
|
//////////////////////////////////////////////////////////////////////////*/
|
|
|
|
|
2022-10-23 11:28:34 +02:00
|
|
|
@Override
|
2022-10-23 21:28:54 +02:00
|
|
|
public void onCreate(final Bundle savedInstanceState) {
|
2022-10-23 11:28:34 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setHasOptionsMenu(false);
|
|
|
|
}
|
|
|
|
|
2022-10-23 10:27:35 +02:00
|
|
|
@Override
|
|
|
|
public View onCreateView(@NonNull final LayoutInflater inflater,
|
|
|
|
@Nullable final ViewGroup container,
|
|
|
|
@Nullable final Bundle savedInstanceState) {
|
|
|
|
return inflater.inflate(R.layout.fragment_channel_tab, container, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Single<ChannelTabInfo> loadResult(final boolean forceLoad) {
|
|
|
|
return ExtractorHelper.getChannelTab(serviceId, tabHandler, forceLoad);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Single<ListExtractor.InfoItemsPage<InfoItem>> loadMoreItemsLogic() {
|
|
|
|
return ExtractorHelper.getMoreChannelTabItems(serviceId, tabHandler, currentNextPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setTitle(final String title) {
|
2022-11-29 19:25:35 +01:00
|
|
|
super.setTitle(channelName);
|
2022-10-23 10:27:35 +02:00
|
|
|
}
|
|
|
|
}
|