mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-22 16:10:31 +00:00
Apply review
Co-Authored-By: Audric V <74829229+AudricV@users.noreply.github.com>
This commit is contained in:
parent
109d06b4bb
commit
57eaa1bbe1
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public abstract class BaseDescriptionFragment extends BaseFragment {
|
public abstract class BaseDescriptionFragment extends BaseFragment {
|
||||||
final CompositeDisposable descriptionDisposables = new CompositeDisposable();
|
private final CompositeDisposable descriptionDisposables = new CompositeDisposable();
|
||||||
protected FragmentDescriptionBinding binding;
|
protected FragmentDescriptionBinding binding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,7 +75,7 @@ public abstract class BaseDescriptionFragment extends BaseFragment {
|
|||||||
protected abstract int getServiceId();
|
protected abstract int getServiceId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URL of the described video. Used for generating description links.
|
* Get the URL of the described video or audio, used to generate description links.
|
||||||
* @return stream URL
|
* @return stream URL
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -52,6 +52,9 @@ public class DescriptionFragment extends BaseDescriptionFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getServiceId() {
|
protected int getServiceId() {
|
||||||
|
if (streamInfo == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return streamInfo.getServiceId();
|
return streamInfo.getServiceId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,13 +79,17 @@ public class DescriptionFragment extends BaseDescriptionFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void setupMetadata(final LayoutInflater inflater,
|
protected void setupMetadata(final LayoutInflater inflater,
|
||||||
final LinearLayout layout) {
|
final LinearLayout layout) {
|
||||||
if (streamInfo.getUploadDate() != null) {
|
if (streamInfo != null && streamInfo.getUploadDate() != null) {
|
||||||
binding.detailUploadDateView.setText(Localization
|
binding.detailUploadDateView.setText(Localization
|
||||||
.localizeUploadDate(activity, streamInfo.getUploadDate().offsetDateTime()));
|
.localizeUploadDate(activity, streamInfo.getUploadDate().offsetDateTime()));
|
||||||
} else {
|
} else {
|
||||||
binding.detailUploadDateView.setVisibility(View.GONE);
|
binding.detailUploadDateView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (streamInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
addMetadataItem(inflater, layout, false, R.string.metadata_category,
|
addMetadataItem(inflater, layout, false, R.string.metadata_category,
|
||||||
streamInfo.getCategory());
|
streamInfo.getCategory());
|
||||||
|
|
||||||
|
@ -233,8 +233,6 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
|||||||
showListFooter(hasMoreItems());
|
showListFooter(hasMoreItems());
|
||||||
} else {
|
} else {
|
||||||
infoListAdapter.clearStreamItemList();
|
infoListAdapter.clearStreamItemList();
|
||||||
// showEmptyState should be called only if there is no item as
|
|
||||||
// well as no header in infoListAdapter
|
|
||||||
showEmptyState();
|
showEmptyState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,9 @@ public class ChannelAboutFragment extends BaseDescriptionFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getServiceId() {
|
protected int getServiceId() {
|
||||||
|
if (channelInfo == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return channelInfo.getServiceId();
|
return channelInfo.getServiceId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,10 +86,14 @@ public class ChannelAboutFragment extends BaseDescriptionFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void setupMetadata(final LayoutInflater inflater,
|
protected void setupMetadata(final LayoutInflater inflater,
|
||||||
final LinearLayout layout) {
|
final LinearLayout layout) {
|
||||||
final Context context = getContext();
|
|
||||||
// There is no upload date available for channels, so hide the relevant UI element
|
// There is no upload date available for channels, so hide the relevant UI element
|
||||||
binding.detailUploadDateView.setVisibility(View.GONE);
|
binding.detailUploadDateView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (channelInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Context context = getContext();
|
||||||
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
|
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
|
||||||
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
|
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
|
||||||
Localization.localizeNumber(context, channelInfo.getSubscriberCount()));
|
Localization.localizeNumber(context, channelInfo.getSubscriberCount()));
|
||||||
|
@ -125,7 +125,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(final @NonNull Context context) {
|
public void onAttach(@NonNull final Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
subscriptionManager = new SubscriptionManager(activity);
|
subscriptionManager = new SubscriptionManager(activity);
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // called from onViewCreated in {@link BaseFragment#onViewCreated}
|
@Override // called from onViewCreated in BaseFragment.onViewCreated
|
||||||
protected void initViews(final View rootView, final Bundle savedInstanceState) {
|
protected void initViews(final View rootView, final Bundle savedInstanceState) {
|
||||||
super.initViews(rootView, savedInstanceState);
|
super.initViews(rootView, savedInstanceState);
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(final @NonNull Menu menu) {
|
public void onPrepareOptionsMenu(@NonNull final Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
menuRssButton = menu.findItem(R.id.menu_item_rss);
|
menuRssButton = menu.findItem(R.id.menu_item_rss);
|
||||||
menuNotifyButton = menu.findItem(R.id.menu_item_notify);
|
menuNotifyButton = menu.findItem(R.id.menu_item_notify);
|
||||||
@ -210,7 +210,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_item_notify:
|
case R.id.menu_item_notify:
|
||||||
final boolean value = !item.isChecked();
|
final boolean value = !item.isChecked();
|
||||||
@ -561,8 +561,8 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
|||||||
.subscribe(result -> {
|
.subscribe(result -> {
|
||||||
isLoading.set(false);
|
isLoading.set(false);
|
||||||
handleResult(result);
|
handleResult(result);
|
||||||
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
|
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_CHANNEL,
|
||||||
url == null ? "no url" : url, serviceId)));
|
url == null ? "No URL" : url, serviceId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,12 +34,15 @@ import io.reactivex.rxjava3.core.Single;
|
|||||||
public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTabInfo>
|
public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTabInfo>
|
||||||
implements PlaylistControlViewHolder {
|
implements PlaylistControlViewHolder {
|
||||||
|
|
||||||
|
// states must be protected and not private for IcePick being able to access them
|
||||||
@State
|
@State
|
||||||
protected ListLinkHandler tabHandler;
|
protected ListLinkHandler tabHandler;
|
||||||
@State
|
@State
|
||||||
protected String channelName;
|
protected String channelName;
|
||||||
|
|
||||||
private PlaylistControlBinding playlistControlBinding;
|
private PlaylistControlBinding playlistControlBinding;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public static ChannelTabFragment getInstance(final int serviceId,
|
public static ChannelTabFragment getInstance(final int serviceId,
|
||||||
final ListLinkHandler tabHandler,
|
final ListLinkHandler tabHandler,
|
||||||
final String channelName) {
|
final String channelName) {
|
||||||
@ -99,11 +102,16 @@ public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTitle(final String title) {
|
public void setTitle(final String title) {
|
||||||
|
// The channel name is displayed as title in the toolbar.
|
||||||
|
// The title is always a description of the content of the tab fragment.
|
||||||
|
// It should be unique for each channel because multiple channel tabs
|
||||||
|
// can be added to the main page. Therefore, the channel name is used.
|
||||||
|
// Using the title variable would cause the title to be the same for all channel tabs.
|
||||||
super.setTitle(channelName);
|
super.setTitle(channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleResult(final @NonNull ChannelTabInfo result) {
|
public void handleResult(@NonNull final ChannelTabInfo result) {
|
||||||
super.handleResult(result);
|
super.handleResult(result);
|
||||||
|
|
||||||
if (playlistControlBinding != null) {
|
if (playlistControlBinding != null) {
|
||||||
|
@ -7,7 +7,5 @@ import org.schabi.newpipe.player.playqueue.PlayQueue;
|
|||||||
* to give access to the play queue.
|
* to give access to the play queue.
|
||||||
*/
|
*/
|
||||||
public interface PlaylistControlViewHolder {
|
public interface PlaylistControlViewHolder {
|
||||||
|
|
||||||
PlayQueue getPlayQueue();
|
PlayQueue getPlayQueue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,7 @@ class FeedLoadManager(private val context: Context) {
|
|||||||
subscriptionEntity: SubscriptionEntity,
|
subscriptionEntity: SubscriptionEntity,
|
||||||
useFeedExtractor: Boolean,
|
useFeedExtractor: Boolean,
|
||||||
defaultSharedPreferences: SharedPreferences
|
defaultSharedPreferences: SharedPreferences
|
||||||
):
|
): Notification<FeedUpdateInfo> {
|
||||||
Notification<FeedUpdateInfo> {
|
|
||||||
var error: Throwable? = null
|
var error: Throwable? = null
|
||||||
val storeOriginalErrorAndRethrow = { e: Throwable ->
|
val storeOriginalErrorAndRethrow = { e: Throwable ->
|
||||||
// keep original to prevent blockingGet() from wrapping it into RuntimeException
|
// keep original to prevent blockingGet() from wrapping it into RuntimeException
|
||||||
|
@ -29,9 +29,12 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<? extends InfoItem>>
|
|||||||
|
|
||||||
protected AbstractInfoPlayQueue(final T info) {
|
protected AbstractInfoPlayQueue(final T info) {
|
||||||
this(info.getServiceId(), info.getUrl(), info.getNextPage(),
|
this(info.getServiceId(), info.getUrl(), info.getNextPage(),
|
||||||
info.getRelatedItems().stream().filter(StreamInfoItem.class::isInstance)
|
info.getRelatedItems()
|
||||||
.map(StreamInfoItem.class::cast).collect(
|
.stream()
|
||||||
Collectors.toList()), 0);
|
.filter(StreamInfoItem.class::isInstance)
|
||||||
|
.map(StreamInfoItem.class::cast)
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractInfoPlayQueue(final int serviceId,
|
protected AbstractInfoPlayQueue(final int serviceId,
|
||||||
@ -76,10 +79,11 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<? extends InfoItem>>
|
|||||||
}
|
}
|
||||||
nextPage = result.getNextPage();
|
nextPage = result.getNextPage();
|
||||||
|
|
||||||
append(extractListItems(result.getRelatedItems().stream()
|
append(extractListItems(result.getRelatedItems()
|
||||||
|
.stream()
|
||||||
.filter(StreamInfoItem.class::isInstance)
|
.filter(StreamInfoItem.class::isInstance)
|
||||||
.map(StreamInfoItem.class::cast).collect(
|
.map(StreamInfoItem.class::cast)
|
||||||
Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
|
|
||||||
fetchReactor.dispose();
|
fetchReactor.dispose();
|
||||||
fetchReactor = null;
|
fetchReactor = null;
|
||||||
@ -114,10 +118,11 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<? extends InfoItem>>
|
|||||||
}
|
}
|
||||||
nextPage = result.getNextPage();
|
nextPage = result.getNextPage();
|
||||||
|
|
||||||
append(extractListItems(result.getItems().stream()
|
append(extractListItems(result.getItems()
|
||||||
|
.stream()
|
||||||
.filter(StreamInfoItem.class::isInstance)
|
.filter(StreamInfoItem.class::isInstance)
|
||||||
.map(StreamInfoItem.class::cast).collect(
|
.map(StreamInfoItem.class::cast)
|
||||||
Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
|
|
||||||
fetchReactor.dispose();
|
fetchReactor.dispose();
|
||||||
fetchReactor = null;
|
fetchReactor = null;
|
||||||
|
@ -135,10 +135,10 @@ public final class ExtractorHelper {
|
|||||||
ChannelTabInfo.getInfo(NewPipe.getService(serviceId), listLinkHandler)));
|
ChannelTabInfo.getInfo(NewPipe.getService(serviceId), listLinkHandler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<InfoItemsPage<InfoItem>> getMoreChannelTabItems(final int serviceId,
|
public static Single<InfoItemsPage<InfoItem>> getMoreChannelTabItems(
|
||||||
final ListLinkHandler
|
final int serviceId,
|
||||||
listLinkHandler,
|
final ListLinkHandler listLinkHandler,
|
||||||
final Page nextPage) {
|
final Page nextPage) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(() ->
|
return Single.fromCallable(() ->
|
||||||
ChannelTabInfo.getMoreItems(NewPipe.getService(serviceId),
|
ChannelTabInfo.getMoreItems(NewPipe.getService(serviceId),
|
||||||
|
@ -22,13 +22,13 @@ public final class PlayButtonHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Initialize {@link android.view.View.OnClickListener OnClickListener}
|
* Initialize {@link android.view.View.OnClickListener OnClickListener}
|
||||||
* and {@link android.view.View.OnLongClickListener OnLongClickListener} for playlist control
|
* and {@link android.view.View.OnLongClickListener OnLongClickListener} for playlist control
|
||||||
* buttons defined in {@code R.layout.playlist_control}.</p>
|
* buttons defined in {@link R.layout#playlist_control}.
|
||||||
*
|
*
|
||||||
* @param activity The activity to use for the {@link android.widget.Toast Toast}.
|
* @param activity The activity to use for the {@link android.widget.Toast Toast}.
|
||||||
* @param playlistControlBinding The binding of the
|
* @param playlistControlBinding The binding of the
|
||||||
* {@link R.layout.playlist_control playlist control layout}.
|
* {@link R.layout#playlist_control playlist control layout}.
|
||||||
* @param fragment The fragment to get the play queue from.
|
* @param fragment The fragment to get the play queue from.
|
||||||
*/
|
*/
|
||||||
public static void initPlaylistControlClickListener(
|
public static void initPlaylistControlClickListener(
|
||||||
@ -61,7 +61,7 @@ public final class PlayButtonHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Show the "hold to append" toast if the corresponding preference is enabled.</p>
|
* Show the "hold to append" toast if the corresponding preference is enabled.
|
||||||
*
|
*
|
||||||
* @param context The context to show the toast.
|
* @param context The context to show the toast.
|
||||||
*/
|
*/
|
||||||
@ -73,7 +73,7 @@ public final class PlayButtonHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Check if the "hold to append" toast should be shown.</p>
|
* Check if the "hold to append" toast should be shown.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The tip is shown if the corresponding preference is enabled.
|
* The tip is shown if the corresponding preference is enabled.
|
||||||
|
@ -47,4 +47,4 @@
|
|||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:background="?attr/toolbar_shadow" />
|
android:background="?attr/toolbar_shadow" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user