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