Skip to content

Commit

Permalink
Move properties to BaseRowItem subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed May 21, 2024
1 parent 42b842b commit 6316535
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ class AudioQueueBaseRowItem(
index = index,
item = item,
staticHeight = true,
)
) {
var playing: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import android.content.Context
import org.jellyfin.sdk.model.api.BaseItemPerson

class BaseItemPersonBaseRowItem(
item: BaseItemPerson,
val person: BaseItemPerson,
) : BaseRowItem(
baseRowType = BaseRowType.Person,
staticHeight = true,
basePerson = item,
) {
override fun getPrimaryImageUrl(
context: Context,
fillHeight: Int,
) = imageHelper.getPrimaryImageUrl(basePerson!!, fillHeight)
) = imageHelper.getPrimaryImageUrl(person, fillHeight)

override fun getItemId() = basePerson?.id
override fun getFullName(context: Context) = basePerson?.name
override fun getName(context: Context) = basePerson?.name
override fun getSubText(context: Context) = basePerson?.role
override fun getItemId() = person.id
override fun getFullName(context: Context) = person.name
override fun getName(context: Context) = person.name
override fun getSubText(context: Context) = person.role
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.jellyfin.androidtv.util.ImageHelper
import org.jellyfin.androidtv.util.apiclient.LifecycleAwareResponse
import org.jellyfin.sdk.model.api.BaseItemDto
import org.jellyfin.sdk.model.api.BaseItemKind
import org.jellyfin.sdk.model.api.BaseItemPerson
import org.jellyfin.sdk.model.api.SeriesTimerInfoDto
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
Expand All @@ -26,9 +25,7 @@ abstract class BaseRowItem protected constructor(
val staticHeight: Boolean = false,
val preferParentThumb: Boolean = false,
val selectAction: BaseRowItemSelectAction = BaseRowItemSelectAction.ShowDetails,
var playing: Boolean = false,
var baseItem: BaseItemDto? = null,
val basePerson: BaseItemPerson? = null,
val chapterInfo: ChapterItemInfo? = null,
val seriesTimerInfo: SeriesTimerInfoDto? = null,
val gridButton: GridButton? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void onResponse(List<BaseItemDto> response) {
}
break;
case Person:
navigationRepository.getValue().navigate(Destinations.INSTANCE.itemDetails(rowItem.getBasePerson().getId()));
navigationRepository.getValue().navigate(Destinations.INSTANCE.itemDetails(rowItem.getItemId()));

break;
case Chapter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.jellyfin.androidtv.constant.QueryType
import org.jellyfin.androidtv.ui.itemhandling.AudioQueueBaseRowItem
import org.jellyfin.androidtv.ui.itemhandling.BaseRowItem
import org.jellyfin.androidtv.ui.itemhandling.ItemRowAdapter
import org.jellyfin.androidtv.ui.navigation.Destinations
import org.jellyfin.androidtv.ui.navigation.NavigationRepository
Expand Down Expand Up @@ -106,7 +105,7 @@ class RewriteMediaManager(
private suspend fun watchPlaybackStateChanges() = coroutineScope {
playbackManager.state.playState.onEach { playState ->
notifyListeners {
val firstItem = currentAudioQueue.get(0) as? BaseRowItem
val firstItem = currentAudioQueue.get(0) as? AudioQueueBaseRowItem
firstItem?.playing = playState == PlayState.PLAYING

onPlaybackStateChange(when (playState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jellyfin.androidtv.preference.constant.RatingType;
import org.jellyfin.androidtv.preference.constant.WatchedIndicatorBehavior;
import org.jellyfin.androidtv.ui.card.LegacyImageCardView;
import org.jellyfin.androidtv.ui.itemhandling.AudioQueueBaseRowItem;
import org.jellyfin.androidtv.ui.itemhandling.BaseRowItem;
import org.jellyfin.androidtv.util.ImageHelper;
import org.jellyfin.androidtv.util.Utils;
Expand Down Expand Up @@ -368,7 +369,7 @@ public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
holder.mCardView.setOverlayInfo(rowItem);
}
holder.mCardView.showFavIcon(rowItem.isFavorite());
if (rowItem.getPlaying()) {
if (rowItem instanceof AudioQueueBaseRowItem && ((AudioQueueBaseRowItem) rowItem).getPlaying()) {
holder.mCardView.setPlayingIndicator(true);
} else {
holder.mCardView.setPlayingIndicator(false);
Expand Down

0 comments on commit 6316535

Please sign in to comment.