Add some documentation and javadocs
Also further simplify CommentRepliesInfo and RelatedItemsInfo
This commit is contained in:
parent
f41ab8b086
commit
3f37e27852
10 changed files with 83 additions and 62 deletions
|
|
@ -217,6 +217,12 @@ public final class Localization {
|
|||
String.valueOf(replyCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context the Android context
|
||||
* @param likeCount the like count, possibly negative if unknown
|
||||
* @return if {@code likeCount} is smaller than {@code 0}, the string {@code "-"}, otherwise
|
||||
* the result of calling {@link #shortCount(Context, long)} on the like count
|
||||
*/
|
||||
public static String likeCount(final Context context, final int likeCount) {
|
||||
if (likeCount < 0) {
|
||||
return "-";
|
||||
|
|
@ -344,9 +350,20 @@ public final class Localization {
|
|||
return prettyTime.formatUnrounded(offsetDateTime);
|
||||
}
|
||||
|
||||
public static String relativeTimeOrTextual(final DateWrapper parsed,
|
||||
final String textual,
|
||||
@Nullable final Context context) {
|
||||
/**
|
||||
* @param context the Android context; if {@code null} then even if in debug mode and the
|
||||
* setting is enabled, {@code textual} will not be shown next to {@code parsed}
|
||||
* @param parsed the textual date or time ago parsed by NewPipeExtractor, or {@code null} if
|
||||
* the extractor could not parse it
|
||||
* @param textual the original textual date or time ago string as provided by services
|
||||
* @return {@link #relativeTime(OffsetDateTime)} is used if {@code parsed != null}, otherwise
|
||||
* {@code textual} is returned. If in debug mode, {@code context != null},
|
||||
* {@code parsed != null} and the relevant setting is enabled, {@code textual} will
|
||||
* be appended to the returned string for debugging purposes.
|
||||
*/
|
||||
public static String relativeTimeOrTextual(@Nullable final Context context,
|
||||
@Nullable final DateWrapper parsed,
|
||||
final String textual) {
|
||||
if (parsed == null) {
|
||||
return textual;
|
||||
} else if (DEBUG && context != null && PreferenceManager
|
||||
|
|
|
|||
|
|
@ -482,6 +482,13 @@ public final class NavigationHelper {
|
|||
item.getServiceId(), uploaderUrl, item.getUploaderName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the comment author channel fragment, if the {@link CommentsInfoItem#getUploaderUrl()}
|
||||
* of {@code comment} is non-null. Shows a UI-error snackbar if something goes wrong.
|
||||
*
|
||||
* @param activity the activity with the fragment manager and in which to show the snackbar
|
||||
* @param comment the comment whose uploader/author will be opened
|
||||
*/
|
||||
public static void openCommentAuthorIfPresent(@NonNull final FragmentActivity activity,
|
||||
final CommentsInfoItem comment) {
|
||||
if (isEmpty(comment.getUploaderUrl())) {
|
||||
|
|
|
|||
|
|
@ -144,6 +144,11 @@ public final class ServiceHelper {
|
|||
.orElse("<unknown>");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serviceId the id of the service
|
||||
* @return the service corresponding to the provided id
|
||||
* @throws java.util.NoSuchElementException if there is no service with the provided id
|
||||
*/
|
||||
@NonNull
|
||||
public static StreamingService getServiceById(final int serviceId) {
|
||||
return ServiceList.all().stream()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue