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;
|
||||
|
||||
public abstract class BaseDescriptionFragment extends BaseFragment {
|
||||
final CompositeDisposable descriptionDisposables = new CompositeDisposable();
|
||||
private final CompositeDisposable descriptionDisposables = new CompositeDisposable();
|
||||
protected FragmentDescriptionBinding binding;
|
||||
|
||||
@Override
|
||||
@ -75,7 +75,7 @@ public abstract class BaseDescriptionFragment extends BaseFragment {
|
||||
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
|
||||
*/
|
||||
@Nullable
|
||||
|
@ -52,6 +52,9 @@ public class DescriptionFragment extends BaseDescriptionFragment {
|
||||
|
||||
@Override
|
||||
protected int getServiceId() {
|
||||
if (streamInfo == null) {
|
||||
return -1;
|
||||
}
|
||||
return streamInfo.getServiceId();
|
||||
}
|
||||
|
||||
@ -76,13 +79,17 @@ public class DescriptionFragment extends BaseDescriptionFragment {
|
||||
@Override
|
||||
protected void setupMetadata(final LayoutInflater inflater,
|
||||
final LinearLayout layout) {
|
||||
if (streamInfo.getUploadDate() != null) {
|
||||
if (streamInfo != null && streamInfo.getUploadDate() != null) {
|
||||
binding.detailUploadDateView.setText(Localization
|
||||
.localizeUploadDate(activity, streamInfo.getUploadDate().offsetDateTime()));
|
||||
} else {
|
||||
binding.detailUploadDateView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (streamInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
addMetadataItem(inflater, layout, false, R.string.metadata_category,
|
||||
streamInfo.getCategory());
|
||||
|
||||
|
@ -233,8 +233,6 @@ public abstract class BaseListInfoFragment<I extends InfoItem, L extends ListInf
|
||||
showListFooter(hasMoreItems());
|
||||
} else {
|
||||
infoListAdapter.clearStreamItemList();
|
||||
// showEmptyState should be called only if there is no item as
|
||||
// well as no header in infoListAdapter
|
||||
showEmptyState();
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ public class ChannelAboutFragment extends BaseDescriptionFragment {
|
||||
|
||||
@Override
|
||||
protected int getServiceId() {
|
||||
if (channelInfo == null) {
|
||||
return -1;
|
||||
}
|
||||
return channelInfo.getServiceId();
|
||||
}
|
||||
|
||||
@ -83,10 +86,14 @@ public class ChannelAboutFragment extends BaseDescriptionFragment {
|
||||
@Override
|
||||
protected void setupMetadata(final LayoutInflater inflater,
|
||||
final LinearLayout layout) {
|
||||
final Context context = getContext();
|
||||
// There is no upload date available for channels, so hide the relevant UI element
|
||||
binding.detailUploadDateView.setVisibility(View.GONE);
|
||||
|
||||
if (channelInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Context context = getContext();
|
||||
if (channelInfo.getSubscriberCount() != UNKNOWN_SUBSCRIBER_COUNT) {
|
||||
addMetadataItem(inflater, layout, false, R.string.metadata_subscribers,
|
||||
Localization.localizeNumber(context, channelInfo.getSubscriberCount()));
|
||||
|
@ -125,7 +125,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(final @NonNull Context context) {
|
||||
public void onAttach(@NonNull final Context context) {
|
||||
super.onAttach(context);
|
||||
subscriptionManager = new SubscriptionManager(activity);
|
||||
}
|
||||
@ -138,7 +138,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
||||
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) {
|
||||
super.initViews(rootView, savedInstanceState);
|
||||
|
||||
@ -202,7 +202,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(final @NonNull Menu menu) {
|
||||
public void onPrepareOptionsMenu(@NonNull final Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
menuRssButton = menu.findItem(R.id.menu_item_rss);
|
||||
menuNotifyButton = menu.findItem(R.id.menu_item_notify);
|
||||
@ -210,7 +210,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_item_notify:
|
||||
final boolean value = !item.isChecked();
|
||||
@ -561,8 +561,8 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
|
||||
.subscribe(result -> {
|
||||
isLoading.set(false);
|
||||
handleResult(result);
|
||||
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_STREAM,
|
||||
url == null ? "no url" : url, serviceId)));
|
||||
}, throwable -> showError(new ErrorInfo(throwable, UserAction.REQUESTED_CHANNEL,
|
||||
url == null ? "No URL" : url, serviceId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,12 +34,15 @@ import io.reactivex.rxjava3.core.Single;
|
||||
public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTabInfo>
|
||||
implements PlaylistControlViewHolder {
|
||||
|
||||
// states must be protected and not private for IcePick being able to access them
|
||||
@State
|
||||
protected ListLinkHandler tabHandler;
|
||||
@State
|
||||
protected String channelName;
|
||||
|
||||
private PlaylistControlBinding playlistControlBinding;
|
||||
|
||||
@NonNull
|
||||
public static ChannelTabFragment getInstance(final int serviceId,
|
||||
final ListLinkHandler tabHandler,
|
||||
final String channelName) {
|
||||
@ -99,11 +102,16 @@ public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTa
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleResult(final @NonNull ChannelTabInfo result) {
|
||||
public void handleResult(@NonNull final ChannelTabInfo result) {
|
||||
super.handleResult(result);
|
||||
|
||||
if (playlistControlBinding != null) {
|
||||
|
@ -7,7 +7,5 @@ import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||
* to give access to the play queue.
|
||||
*/
|
||||
public interface PlaylistControlViewHolder {
|
||||
|
||||
PlayQueue getPlayQueue();
|
||||
|
||||
}
|
||||
|
@ -140,8 +140,7 @@ class FeedLoadManager(private val context: Context) {
|
||||
subscriptionEntity: SubscriptionEntity,
|
||||
useFeedExtractor: Boolean,
|
||||
defaultSharedPreferences: SharedPreferences
|
||||
):
|
||||
Notification<FeedUpdateInfo> {
|
||||
): Notification<FeedUpdateInfo> {
|
||||
var error: Throwable? = null
|
||||
val storeOriginalErrorAndRethrow = { e: Throwable ->
|
||||
// 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) {
|
||||
this(info.getServiceId(), info.getUrl(), info.getNextPage(),
|
||||
info.getRelatedItems().stream().filter(StreamInfoItem.class::isInstance)
|
||||
.map(StreamInfoItem.class::cast).collect(
|
||||
Collectors.toList()), 0);
|
||||
info.getRelatedItems()
|
||||
.stream()
|
||||
.filter(StreamInfoItem.class::isInstance)
|
||||
.map(StreamInfoItem.class::cast)
|
||||
.collect(Collectors.toList()),
|
||||
0);
|
||||
}
|
||||
|
||||
protected AbstractInfoPlayQueue(final int serviceId,
|
||||
@ -76,10 +79,11 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<? extends InfoItem>>
|
||||
}
|
||||
nextPage = result.getNextPage();
|
||||
|
||||
append(extractListItems(result.getRelatedItems().stream()
|
||||
append(extractListItems(result.getRelatedItems()
|
||||
.stream()
|
||||
.filter(StreamInfoItem.class::isInstance)
|
||||
.map(StreamInfoItem.class::cast).collect(
|
||||
Collectors.toList())));
|
||||
.map(StreamInfoItem.class::cast)
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
fetchReactor.dispose();
|
||||
fetchReactor = null;
|
||||
@ -114,10 +118,11 @@ abstract class AbstractInfoPlayQueue<T extends ListInfo<? extends InfoItem>>
|
||||
}
|
||||
nextPage = result.getNextPage();
|
||||
|
||||
append(extractListItems(result.getItems().stream()
|
||||
append(extractListItems(result.getItems()
|
||||
.stream()
|
||||
.filter(StreamInfoItem.class::isInstance)
|
||||
.map(StreamInfoItem.class::cast).collect(
|
||||
Collectors.toList())));
|
||||
.map(StreamInfoItem.class::cast)
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
fetchReactor.dispose();
|
||||
fetchReactor = null;
|
||||
|
@ -135,10 +135,10 @@ public final class ExtractorHelper {
|
||||
ChannelTabInfo.getInfo(NewPipe.getService(serviceId), listLinkHandler)));
|
||||
}
|
||||
|
||||
public static Single<InfoItemsPage<InfoItem>> getMoreChannelTabItems(final int serviceId,
|
||||
final ListLinkHandler
|
||||
listLinkHandler,
|
||||
final Page nextPage) {
|
||||
public static Single<InfoItemsPage<InfoItem>> getMoreChannelTabItems(
|
||||
final int serviceId,
|
||||
final ListLinkHandler listLinkHandler,
|
||||
final Page nextPage) {
|
||||
checkServiceId(serviceId);
|
||||
return Single.fromCallable(() ->
|
||||
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
|
||||
* 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 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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -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>
|
||||
* The tip is shown if the corresponding preference is enabled.
|
||||
|
@ -47,4 +47,4 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="?attr/toolbar_shadow" />
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user