Remove left over search hint code
This commit is contained in:
committed by
Niels van Velzen
parent
61324816d7
commit
59472ba7b0
@@ -22,8 +22,6 @@ import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.imageApi
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
import org.jellyfin.sdk.model.api.ImageType
|
||||
import org.jellyfin.sdk.model.api.SearchHint
|
||||
import org.jellyfin.sdk.model.serializer.toUUID
|
||||
import timber.log.Timber
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ExecutionException
|
||||
@@ -84,26 +82,6 @@ class BackgroundService(
|
||||
loadBackgrounds(backdropUrls)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use backdrop from [searchHint] as background.
|
||||
*/
|
||||
fun setBackground(searchHint: SearchHint) {
|
||||
// Check if item is set and backgrounds are enabled
|
||||
if (!userPreferences[UserPreferences.backdropEnabled])
|
||||
return clearBackgrounds()
|
||||
|
||||
// Manually grab the backdrop URL
|
||||
val backdropUrls = setOfNotNull(searchHint.backdropImageItemId?.let { itemId ->
|
||||
api.imageApi.getItemImageUrl(
|
||||
itemId = itemId.toUUID(),
|
||||
imageType = ImageType.BACKDROP,
|
||||
tag = searchHint.backdropImageTag,
|
||||
)
|
||||
})
|
||||
|
||||
loadBackgrounds(backdropUrls)
|
||||
}
|
||||
|
||||
/**
|
||||
* Use splashscreen from [server] as background.
|
||||
*/
|
||||
|
||||
@@ -28,13 +28,12 @@ import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.userLibraryApi
|
||||
import org.jellyfin.sdk.model.api.BaseItemKind
|
||||
import org.jellyfin.sdk.model.api.BaseItemPerson
|
||||
import org.jellyfin.sdk.model.api.SearchHint
|
||||
import org.jellyfin.sdk.model.extensions.ticks
|
||||
import org.jellyfin.sdk.model.serializer.toUUID
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
import timber.log.Timber
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.temporal.ChronoUnit
|
||||
import org.jellyfin.apiclient.interaction.ApiClient as LegacyApiClient
|
||||
|
||||
open class BaseRowItem protected constructor(
|
||||
@@ -47,7 +46,6 @@ open class BaseRowItem protected constructor(
|
||||
var baseItem: org.jellyfin.sdk.model.api.BaseItemDto? = null,
|
||||
val basePerson: BaseItemPerson? = null,
|
||||
val chapterInfo: ChapterItemInfo? = null,
|
||||
val searchHint: SearchHint? = null,
|
||||
val seriesTimerInfo: SeriesTimerInfoDto? = null,
|
||||
val gridButton: GridButton? = null,
|
||||
) : KoinComponent {
|
||||
@@ -124,13 +122,6 @@ open class BaseRowItem protected constructor(
|
||||
basePerson = item,
|
||||
)
|
||||
|
||||
constructor(
|
||||
item: SearchHint,
|
||||
) : this(
|
||||
baseRowType = BaseRowType.SearchHint,
|
||||
searchHint = item,
|
||||
)
|
||||
|
||||
constructor(
|
||||
item: ChapterItemInfo,
|
||||
) : this(
|
||||
@@ -183,11 +174,6 @@ open class BaseRowItem protected constructor(
|
||||
BaseRowType.LiveTvChannel -> ImageUtils.getPrimaryImageUrl(baseItem!!)
|
||||
BaseRowType.GridButton -> gridButton?.imageRes?.let { ImageUtils.getResourceUrl(context, it) }
|
||||
BaseRowType.SeriesTimer -> ImageUtils.getResourceUrl(context, R.drawable.tile_land_series_timer)
|
||||
BaseRowType.SearchHint -> when {
|
||||
!searchHint?.primaryImageTag.isNullOrBlank() -> ImageUtils.getImageUrl(searchHint!!.itemId.toString(), org.jellyfin.apiclient.model.entities.ImageType.Primary, searchHint.primaryImageTag!!)
|
||||
!searchHint?.thumbImageItemId.isNullOrBlank() -> ImageUtils.getImageUrl(searchHint!!.thumbImageItemId!!, org.jellyfin.apiclient.model.entities.ImageType.Thumb, searchHint.thumbImageTag!!)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun getBaseItemType() = baseItem?.type
|
||||
@@ -211,7 +197,6 @@ open class BaseRowItem protected constructor(
|
||||
BaseRowType.LiveTvChannel -> baseItem?.name
|
||||
BaseRowType.GridButton -> gridButton?.text
|
||||
BaseRowType.SeriesTimer -> seriesTimerInfo?.name
|
||||
BaseRowType.SearchHint -> listOfNotNull(searchHint?.series, searchHint?.name).joinToString(" - ")
|
||||
}
|
||||
|
||||
fun getName(context: Context) = when (baseRowType) {
|
||||
@@ -223,7 +208,6 @@ open class BaseRowItem protected constructor(
|
||||
}
|
||||
BaseRowType.Person -> basePerson?.name
|
||||
BaseRowType.Chapter -> chapterInfo?.name
|
||||
BaseRowType.SearchHint -> searchHint?.name
|
||||
BaseRowType.LiveTvChannel -> baseItem?.name
|
||||
BaseRowType.GridButton -> gridButton?.text
|
||||
BaseRowType.SeriesTimer -> seriesTimerInfo?.name
|
||||
@@ -237,14 +221,13 @@ open class BaseRowItem protected constructor(
|
||||
BaseRowType.Person -> basePerson?.id?.toString()
|
||||
BaseRowType.Chapter -> chapterInfo?.itemId?.toString()
|
||||
BaseRowType.GridButton -> null
|
||||
BaseRowType.SearchHint -> searchHint?.itemId?.toString()
|
||||
BaseRowType.SeriesTimer -> seriesTimerInfo?.id
|
||||
}
|
||||
|
||||
fun getSubText(context: Context) = when (baseRowType) {
|
||||
BaseRowType.BaseItem -> baseItem?.getSubName(context)
|
||||
BaseRowType.Person -> basePerson?.role
|
||||
BaseRowType.Chapter -> chapterInfo?.startPositionTicks?.div(10000)?.let(TimeUtils::formatMillis)
|
||||
BaseRowType.Chapter -> chapterInfo?.startPositionTicks?.ticks?.inWholeMilliseconds?.let(TimeUtils::formatMillis)
|
||||
BaseRowType.LiveTvChannel -> baseItem?.number
|
||||
BaseRowType.LiveTvProgram -> baseItem?.episodeTitle ?: baseItem?.channelName
|
||||
BaseRowType.LiveTvRecording -> {
|
||||
@@ -263,7 +246,6 @@ open class BaseRowItem protected constructor(
|
||||
|
||||
"$title $timestamp"
|
||||
}
|
||||
BaseRowType.SearchHint -> searchHint?.type
|
||||
BaseRowType.SeriesTimer -> {
|
||||
val channelName = if (seriesTimerInfo?.recordAnyChannel == true) "All Channels"
|
||||
else seriesTimerInfo?.channelName
|
||||
@@ -281,24 +263,11 @@ open class BaseRowItem protected constructor(
|
||||
else -> null
|
||||
}.orEmpty()
|
||||
|
||||
fun getRuntimeTicks() = when (baseRowType) {
|
||||
BaseRowType.LiveTvRecording,
|
||||
BaseRowType.BaseItem -> baseItem?.runTimeTicks ?: 0
|
||||
BaseRowType.LiveTvProgram -> {
|
||||
val start = baseItem?.startDate
|
||||
val end = baseItem?.endDate
|
||||
|
||||
if (start != null && end != null) (start.until(end, ChronoUnit.MILLIS)) * 10000
|
||||
else 0
|
||||
}
|
||||
else -> 0
|
||||
}
|
||||
|
||||
fun getChildCountStr(): String? {
|
||||
// Playlist
|
||||
if (baseItem?.type == BaseItemKind.PLAYLIST) {
|
||||
val childCount = baseItem?.cumulativeRunTimeTicks?.let {
|
||||
TimeUtils.formatMillis(it / 10000)
|
||||
val childCount = baseItem?.cumulativeRunTimeTicks?.ticks?.inWholeMilliseconds?.let {
|
||||
TimeUtils.formatMillis(it)
|
||||
}
|
||||
if (childCount != null) return childCount
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ enum class BaseRowType {
|
||||
BaseItem,
|
||||
Person,
|
||||
Chapter,
|
||||
SearchHint,
|
||||
LiveTvChannel,
|
||||
LiveTvRecording,
|
||||
GridButton,
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jellyfin.apiclient.interaction.Response;
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||
import org.jellyfin.sdk.model.api.BaseItemKind;
|
||||
import org.jellyfin.sdk.model.api.PlayAccess;
|
||||
import org.jellyfin.sdk.model.api.SearchHint;
|
||||
import org.jellyfin.sdk.model.constant.CollectionType;
|
||||
import org.jellyfin.sdk.model.serializer.UUIDSerializerKt;
|
||||
import org.koin.java.KoinJavaComponent;
|
||||
@@ -196,34 +195,6 @@ public class ItemLauncher {
|
||||
|
||||
break;
|
||||
|
||||
case SearchHint:
|
||||
final SearchHint hint = rowItem.getSearchHint();
|
||||
//Retrieve full item for display and playback
|
||||
KoinJavaComponent.<ApiClient>get(ApiClient.class).GetItemAsync(hint.getItemId().toString(), KoinJavaComponent.<UserRepository>get(UserRepository.class).getCurrentUser().getValue().getId().toString(), new Response<BaseItemDto>() {
|
||||
@Override
|
||||
public void onResponse(BaseItemDto response) {
|
||||
if (response.getIsFolderItem() && ModelCompat.asSdk(response).getType() != BaseItemKind.SERIES) {
|
||||
navigationRepository.navigate(Destinations.INSTANCE.libraryBrowser(ModelCompat.asSdk(response)));
|
||||
} else if (ModelCompat.asSdk(response).getType() == BaseItemKind.AUDIO) {
|
||||
PlaybackHelper.retrieveAndPlay(response.getId(), false, context);
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (ModelCompat.asSdk(response).getType() == BaseItemKind.PROGRAM) {
|
||||
navigationRepository.navigate(Destinations.INSTANCE.channelDetails(UUIDSerializerKt.toUUID(response.getId()), UUIDSerializerKt.toUUID(response.getChannelId()), ModelCompat.asSdk(response)));
|
||||
} else {
|
||||
navigationRepository.navigate(Destinations.INSTANCE.itemDetails(UUIDSerializerKt.toUUID(response.getId())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
Timber.e(exception, "Error retrieving full object");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case LiveTvProgram:
|
||||
org.jellyfin.sdk.model.api.BaseItemDto program = rowItem.getBaseItem();
|
||||
switch (rowItem.getSelectAction()) {
|
||||
|
||||
@@ -293,25 +293,6 @@ public class CardPresenter extends Presenter {
|
||||
mCardView.setMainImageDimensions(cardWidth, cardHeight);
|
||||
mDefaultCardImage = ContextCompat.getDrawable(mCardView.getContext(), R.drawable.tile_chapter);
|
||||
break;
|
||||
case SearchHint:
|
||||
switch (mItem.getSearchHint().getType()) {
|
||||
case "Episode":
|
||||
cardWidth = (int) (ImageUtils.ASPECT_RATIO_16_9 * cardHeight);
|
||||
mCardView.setMainImageDimensions(cardWidth, cardHeight);
|
||||
mDefaultCardImage = ContextCompat.getDrawable(mCardView.getContext(), R.drawable.tile_port_tv);
|
||||
break;
|
||||
case "Person":
|
||||
cardWidth = (int) (ImageUtils.ASPECT_RATIO_7_9 * cardHeight);
|
||||
mCardView.setMainImageDimensions(cardWidth, cardHeight);
|
||||
mDefaultCardImage = ContextCompat.getDrawable(mCardView.getContext(), R.drawable.tile_port_person);
|
||||
break;
|
||||
default:
|
||||
cardWidth = (int) (ImageUtils.ASPECT_RATIO_7_9 * cardHeight);
|
||||
mCardView.setMainImageDimensions(cardWidth, cardHeight);
|
||||
mDefaultCardImage = ContextCompat.getDrawable(mCardView.getContext(), R.drawable.tile_port_video);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GridButton:
|
||||
cardHeight = !m.getStaticHeight() ? pHeight : sHeight;
|
||||
cardWidth = (int) (ImageUtils.ASPECT_RATIO_7_9 * cardHeight);
|
||||
|
||||
@@ -92,14 +92,14 @@ public class KeyProcessor {
|
||||
case SERIES:
|
||||
case SEASON:
|
||||
case BOX_SET:
|
||||
createPlayMenu(rowItem.getBaseItem(), true, false, activity);
|
||||
createPlayMenu(rowItem.getBaseItem(), false, activity);
|
||||
return true;
|
||||
case MUSIC_ALBUM:
|
||||
case MUSIC_ARTIST:
|
||||
createPlayMenu(rowItem.getBaseItem(), true, true, activity);
|
||||
createPlayMenu(rowItem.getBaseItem(), true, activity);
|
||||
return true;
|
||||
case PLAYLIST:
|
||||
createPlayMenu(rowItem.getBaseItem(), true, MediaType.Audio.equals(item.getMediaType()), activity);
|
||||
createPlayMenu(rowItem.getBaseItem(), MediaType.Audio.equals(item.getMediaType()), activity);
|
||||
return true;
|
||||
case PHOTO:
|
||||
NavigationRepository navigationRepository = KoinJavaComponent.get(NavigationRepository.class);
|
||||
@@ -116,23 +116,6 @@ public class KeyProcessor {
|
||||
break;
|
||||
case Chapter:
|
||||
break;
|
||||
case SearchHint:
|
||||
switch (rowItem.getSearchHint().getType()) {
|
||||
case "Movie":
|
||||
case "Episode":
|
||||
case "TvChannel":
|
||||
case "Video":
|
||||
case "Program":
|
||||
// retrieve full item and play
|
||||
PlaybackHelper.retrieveAndPlay(rowItem.getItemId(), false, activity);
|
||||
return true;
|
||||
case "Series":
|
||||
case "Season":
|
||||
case "BoxSet":
|
||||
createPlayMenu(rowItem.getBaseItem(), true, false, activity);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case LiveTvChannel:
|
||||
case LiveTvRecording:
|
||||
// retrieve full item and play
|
||||
@@ -183,8 +166,6 @@ public class KeyProcessor {
|
||||
break;
|
||||
case Chapter:
|
||||
break;
|
||||
case SearchHint:
|
||||
break;
|
||||
case LiveTvChannel:
|
||||
break;
|
||||
case LiveTvRecording:
|
||||
@@ -289,7 +270,7 @@ public class KeyProcessor {
|
||||
return menu;
|
||||
}
|
||||
|
||||
private static void createPlayMenu(BaseItemDto item, boolean isFolder, boolean isMusic, Activity activity) {
|
||||
private static void createPlayMenu(BaseItemDto item, boolean isMusic, Activity activity) {
|
||||
PopupMenu menu = new PopupMenu(activity, activity.getCurrentFocus(), Gravity.END);
|
||||
int order = 0;
|
||||
if (!isMusic && item.getType() != BaseItemKind.PLAYLIST) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.jellyfin.sdk.model.serializer.toUUIDOrNull
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.util.Date
|
||||
import java.util.UUID
|
||||
import org.jellyfin.apiclient.model.dlna.SubtitleDeliveryMethod as LegacySubtitleDeliveryMethod
|
||||
import org.jellyfin.apiclient.model.drawing.ImageOrientation as LegacyImageOrientation
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto as LegacyBaseItemDto
|
||||
@@ -43,7 +42,6 @@ import org.jellyfin.apiclient.model.livetv.SeriesTimerInfoDto as LegacySeriesTim
|
||||
import org.jellyfin.apiclient.model.mediainfo.MediaProtocol as LegacyMediaProtocol
|
||||
import org.jellyfin.apiclient.model.mediainfo.TransportStreamTimestamp as LegacyTransportStreamTimestamp
|
||||
import org.jellyfin.apiclient.model.providers.ExternalUrl as LegacyExternalUrl
|
||||
import org.jellyfin.apiclient.model.search.SearchHint as LegacySearchHint
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto as ModernBaseItemDto
|
||||
import org.jellyfin.sdk.model.api.BaseItemPerson as ModernBaseItemPerson
|
||||
import org.jellyfin.sdk.model.api.ChannelType as ModernChannelType
|
||||
@@ -67,7 +65,6 @@ import org.jellyfin.sdk.model.api.NameGuidPair as ModernNameGuidPair
|
||||
import org.jellyfin.sdk.model.api.NameIdPair as ModernNameIdPair
|
||||
import org.jellyfin.sdk.model.api.PlayAccess as ModernPlayAccess
|
||||
import org.jellyfin.sdk.model.api.ProgramAudio as ModernProgramAudio
|
||||
import org.jellyfin.sdk.model.api.SearchHint as ModernSearchHint
|
||||
import org.jellyfin.sdk.model.api.SeriesTimerInfoDto as ModernSeriesTimerInfoDto
|
||||
import org.jellyfin.sdk.model.api.SortOrder as ModernSortOrder
|
||||
import org.jellyfin.sdk.model.api.SubtitleDeliveryMethod as ModernSubtitleDeliveryMethod
|
||||
@@ -613,38 +610,6 @@ fun LegacyDayPattern.asSdk(): ModernDayPattern = when (this) {
|
||||
|
||||
fun Array<LegacyBaseItemPerson>.asSdk() = map(LegacyBaseItemPerson::asSdk).toTypedArray()
|
||||
|
||||
fun LegacySearchHint.asSdk(): ModernSearchHint = ModernSearchHint(
|
||||
itemId = this.itemId.toUUID(),
|
||||
id = this.itemId.toUUID(),
|
||||
name = this.name,
|
||||
matchedTerm = this.matchedTerm,
|
||||
indexNumber = this.indexNumber,
|
||||
productionYear = this.productionYear,
|
||||
parentIndexNumber = this.parentIndexNumber,
|
||||
primaryImageTag = this.primaryImageTag,
|
||||
thumbImageTag = this.thumbImageTag,
|
||||
thumbImageItemId = this.thumbImageItemId,
|
||||
backdropImageTag = this.backdropImageTag,
|
||||
backdropImageItemId = this.backdropImageItemId,
|
||||
type = this.type,
|
||||
isFolder = null, // this.isFolder
|
||||
runTimeTicks = this.runTimeTicks,
|
||||
mediaType = this.mediaType,
|
||||
startDate = null, // this.startDate
|
||||
endDate = null, // this.endDate
|
||||
series = this.series,
|
||||
status = null, // this.status
|
||||
album = this.album,
|
||||
albumId = UUID.randomUUID(), // this.albumId
|
||||
albumArtist = this.albumArtist,
|
||||
artists = this.artists?.toList(),
|
||||
songCount = this.songCount,
|
||||
episodeCount = this.episodeCount,
|
||||
channelId = this.channelId.toUUID(),
|
||||
channelName = this.channelName,
|
||||
primaryImageAspectRatio = this.primaryImageAspectRatio,
|
||||
)
|
||||
|
||||
fun LegacyChannelInfoDto.asSdk() = ModernBaseItemDto(
|
||||
name = this.name,
|
||||
serverId = this.serverId,
|
||||
|
||||
Reference in New Issue
Block a user