2022-10-23 10:27:35 +02:00
|
|
|
package org.schabi.newpipe.fragments.list.channel;
|
|
|
|
|
2022-10-23 17:01:39 +02:00
|
|
|
import static org.schabi.newpipe.extractor.stream.StreamExtractor.UNKNOWN_SUBSCRIBER_COUNT;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2022-10-23 10:27:35 +02:00
|
|
|
import android.view.LayoutInflater;
|
2022-10-23 17:01:39 +02:00
|
|
|
import android.widget.LinearLayout;
|
2022-10-23 10:27:35 +02:00
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
2022-10-23 17:01:39 +02:00
|
|
|
|
|
|
|
import org.schabi.newpipe.R;
|
2023-04-05 16:17:31 +02:00
|
|
|
import org.schabi.newpipe.extractor.StreamingService;
|
2022-10-23 17:01:39 +02:00
|
|
|
import org.schabi.newpipe.extractor.channel.ChannelInfo;
|
2023-04-05 16:17:31 +02:00
|
|
|
import org.schabi.newpipe.extractor.stream.Description;
|
2023-04-05 22:56:25 +02:00
|
|
|
import org.schabi.newpipe.fragments.detail.BaseDescriptionFragment;
|
2022-10-23 17:01:39 +02:00
|
|
|
import org.schabi.newpipe.util.Localization;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import icepick.State;
|
2022-10-23 10:27:35 +02:00
|
|
|
|
2023-04-05 22:56:25 +02:00
|
|
|
public class ChannelAboutFragment extends BaseDescriptionFragment {
|
2022-10-23 17:01:39 +02:00
|
|
|
@State
|
|
|
|
protected ChannelInfo channelInfo;
|
2022-10-23 10:27:35 +02:00
|
|
|
|
2023-04-05 22:56:25 +02:00
|
|
|
public static ChannelAboutFragment getInstance(final ChannelInfo channelInfo) {
|
|
|
|
final ChannelAboutFragment fragment = new ChannelAboutFragment();
|
2022-10-23 17:01:39 +02:00
|
|
|
fragment.channelInfo = channelInfo;
|
2022-10-23 10:27:35 +02:00
|
|
|
return fragment;
|
|
|
|
}
|
|
|
|
|
2023-04-05 22:56:25 +02:00
|
|
|
public ChannelAboutFragment() {
|
2022-10-23 10:27:35 +02:00
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
@Nullable
|
2022-10-23 10:27:35 +02:00
|
|
|
@Override
|
2023-04-05 16:17:31 +02:00
|
|
|
protected Description getDescription() {
|
|
|
|
if (channelInfo == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return new Description(channelInfo.getDescription(), Description.PLAIN_TEXT);
|
2022-10-23 10:27:35 +02:00
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
@Nullable
|
2022-10-23 17:01:39 +02:00
|
|
|
@Override
|
2023-04-05 16:17:31 +02:00
|
|
|
protected StreamingService getService() {
|
|
|
|
if (channelInfo == null) {
|
|
|
|
return null;
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
2023-04-05 16:17:31 +02:00
|
|
|
return channelInfo.getService();
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
@Override
|
|
|
|
protected int getServiceId() {
|
|
|
|
return channelInfo.getServiceId();
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
protected String getStreamUrl() {
|
|
|
|
return null;
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public List<String> getTags() {
|
|
|
|
if (channelInfo == null) {
|
|
|
|
return null;
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
2023-04-05 16:17:31 +02:00
|
|
|
return channelInfo.getTags();
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
protected void setupMetadata(final LayoutInflater inflater,
|
|
|
|
final LinearLayout layout) {
|
|
|
|
final Context context = getContext();
|
2022-10-23 17:01:39 +02:00
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
|
|
|
|
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
|
|
|
|
Localization.localizeNumber(context, channelInfo.getSubscriberCount()));
|
|
|
|
}
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
2022-10-23 10:27:35 +02:00
|
|
|
}
|