NewPipe/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelAboutFragment.java

92 lines
2.7 KiB
Java
Raw Normal View History

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;
import android.os.Bundle;
2022-10-23 08:27:35 +00:00
import android.view.LayoutInflater;
import android.view.View;
2022-10-23 15:01:39 +00:00
import android.widget.LinearLayout;
2022-10-23 08:27:35 +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;
import org.schabi.newpipe.extractor.StreamingService;
2022-10-23 15:01:39 +00:00
import org.schabi.newpipe.extractor.channel.ChannelInfo;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.fragments.detail.BaseDescriptionFragment;
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
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
}
@Override
protected void initViews(final View rootView, final Bundle savedInstanceState) {
super.initViews(rootView, savedInstanceState);
binding.constraintLayout.setPadding(0, DeviceUtils.dpToPx(8, requireContext()), 0, 0);
}
@Nullable
2022-10-23 08:27:35 +00:00
@Override
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
}
@NonNull
2022-10-23 15:01:39 +00:00
@Override
protected StreamingService getService() {
return channelInfo.getService();
2022-10-23 15:01:39 +00:00
}
@Override
protected int getServiceId() {
return channelInfo.getServiceId();
2022-10-23 15:01:39 +00:00
}
@Nullable
@Override
protected String getStreamUrl() {
return null;
2022-10-23 15:01:39 +00:00
}
@NonNull
@Override
public List<String> getTags() {
return channelInfo.getTags();
2022-10-23 15:01:39 +00:00
}
@Override
protected void setupMetadata(final LayoutInflater inflater,
final LinearLayout layout) {
// 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
if (channelInfo == null) {
return;
}
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
Localization.localizeNumber(
requireContext(),
channelInfo.getSubscriberCount()));
}
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
}