Apply review
Co-Authored-By: Audric V <74829229+AudricV@users.noreply.github.com>
This commit is contained in:
parent
b134d75549
commit
60a97b0486
12 changed files with 58 additions and 36 deletions
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue