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;
|
|
|
|
|
2023-04-21 15:42:23 +02:00
|
|
|
import android.os.Bundle;
|
2022-10-23 10:27:35 +02:00
|
|
|
import android.view.LayoutInflater;
|
2023-04-21 15:42:23 +02:00
|
|
|
import android.view.View;
|
2022-10-23 17:01:39 +02:00
|
|
|
import android.widget.LinearLayout;
|
2022-10-23 10:27:35 +02:00
|
|
|
|
2024-01-20 22:26:24 +01:00
|
|
|
import androidx.annotation.NonNull;
|
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;
|
2023-04-21 15:42:23 +02:00
|
|
|
import org.schabi.newpipe.util.DeviceUtils;
|
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
|
|
|
|
2024-03-28 22:46:19 +01:00
|
|
|
ChannelAboutFragment(@NonNull final ChannelInfo channelInfo) {
|
|
|
|
this.channelInfo = channelInfo;
|
2022-10-23 10:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-21 15:42:23 +02:00
|
|
|
@Override
|
|
|
|
protected void initViews(final View rootView, final Bundle savedInstanceState) {
|
|
|
|
super.initViews(rootView, savedInstanceState);
|
|
|
|
binding.constraintLayout.setPadding(0, DeviceUtils.dpToPx(8, requireContext()), 0, 0);
|
|
|
|
}
|
|
|
|
|
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() {
|
2024-03-28 22:46:19 +01:00
|
|
|
return new Description(channelInfo.getDescription(), Description.PLAIN_TEXT);
|
2022-10-23 10:27:35 +02:00
|
|
|
}
|
|
|
|
|
2024-01-20 22:26:24 +01:00
|
|
|
@NonNull
|
2022-10-23 17:01:39 +02:00
|
|
|
@Override
|
2023-04-05 16:17:31 +02:00
|
|
|
protected StreamingService getService() {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-01-20 22:26:24 +01:00
|
|
|
@NonNull
|
2023-04-05 16:17:31 +02:00
|
|
|
@Override
|
|
|
|
public List<String> getTags() {
|
|
|
|
return channelInfo.getTags();
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
|
|
|
|
2023-08-22 12:39:27 +02:00
|
|
|
@Override
|
2023-04-05 16:17:31 +02:00
|
|
|
protected void setupMetadata(final LayoutInflater inflater,
|
|
|
|
final LinearLayout layout) {
|
2023-08-22 19:15:45 +02:00
|
|
|
// There is no upload date available for channels, so hide the relevant UI element
|
|
|
|
binding.detailUploadDateView.setVisibility(View.GONE);
|
2022-10-23 17:01:39 +02:00
|
|
|
|
2023-09-18 15:01:17 +02:00
|
|
|
if (channelInfo == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-04-05 16:17:31 +02:00
|
|
|
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
|
|
|
|
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
|
2024-01-20 22:26:24 +01:00
|
|
|
Localization.localizeNumber(
|
|
|
|
requireContext(),
|
|
|
|
channelInfo.getSubscriberCount()));
|
2023-04-05 16:17:31 +02:00
|
|
|
}
|
2023-04-21 15:54:22 +02:00
|
|
|
|
2023-05-02 18:56:02 +02:00
|
|
|
addImagesMetadataItem(inflater, layout, R.string.metadata_avatars,
|
|
|
|
channelInfo.getAvatars());
|
|
|
|
addImagesMetadataItem(inflater, layout, R.string.metadata_banners,
|
|
|
|
channelInfo.getBanners());
|
2022-10-23 17:01:39 +02:00
|
|
|
}
|
2022-10-23 10:27:35 +02:00
|
|
|
}
|