Add seasons to the MediaInfoFragment
This commit is contained in:
parent
71ae0a886a
commit
2ce0755cf3
5 changed files with 48 additions and 0 deletions
|
@ -31,6 +31,7 @@ class JellyfinApi(context: Context, baseUrl: String) {
|
||||||
val viewsApi = UserViewsApi(api)
|
val viewsApi = UserViewsApi(api)
|
||||||
val itemsApi = ItemsApi(api)
|
val itemsApi = ItemsApi(api)
|
||||||
val userLibraryApi = UserLibraryApi(api)
|
val userLibraryApi = UserLibraryApi(api)
|
||||||
|
val showsApi = TvShowsApi(api)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Volatile
|
@Volatile
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.navigation.fragment.navArgs
|
import androidx.navigation.fragment.navArgs
|
||||||
import dev.jdtech.jellyfin.adapters.PersonListAdapter
|
import dev.jdtech.jellyfin.adapters.PersonListAdapter
|
||||||
|
import dev.jdtech.jellyfin.adapters.ViewItemListAdapter
|
||||||
import dev.jdtech.jellyfin.viewmodels.MediaInfoViewModel
|
import dev.jdtech.jellyfin.viewmodels.MediaInfoViewModel
|
||||||
import dev.jdtech.jellyfin.databinding.FragmentMediaInfoBinding
|
import dev.jdtech.jellyfin.databinding.FragmentMediaInfoBinding
|
||||||
import dev.jdtech.jellyfin.viewmodels.MediaInfoViewModelFactory
|
import dev.jdtech.jellyfin.viewmodels.MediaInfoViewModelFactory
|
||||||
|
@ -45,6 +46,7 @@ class MediaInfoFragment : Fragment() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
binding.seasonsRecyclerView.adapter = ViewItemListAdapter(ViewItemListAdapter.OnClickListener {}, fixedWidth = true)
|
||||||
binding.peopleRecyclerView.adapter = PersonListAdapter()
|
binding.peopleRecyclerView.adapter = PersonListAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,9 @@ class MediaInfoViewModel(application: Application, itemId: UUID) : AndroidViewMo
|
||||||
private val _dateString = MutableLiveData<String>()
|
private val _dateString = MutableLiveData<String>()
|
||||||
val dateString: LiveData<String> = _dateString
|
val dateString: LiveData<String> = _dateString
|
||||||
|
|
||||||
|
private val _seasons = MutableLiveData<List<BaseItemDto>>()
|
||||||
|
val seasons: LiveData<List<BaseItemDto>> = _seasons
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
_item.value = getItemDetails(itemId)
|
_item.value = getItemDetails(itemId)
|
||||||
|
@ -53,6 +56,9 @@ class MediaInfoViewModel(application: Application, itemId: UUID) : AndroidViewMo
|
||||||
_runTime.value = "${_item.value?.runTimeTicks?.div(600000000)} min"
|
_runTime.value = "${_item.value?.runTimeTicks?.div(600000000)} min"
|
||||||
_dateString.value = getDateString(_item.value!!)
|
_dateString.value = getDateString(_item.value!!)
|
||||||
_item.value!!.status?.let { Log.i("MediaInfoViewModel", it) }
|
_item.value!!.status?.let { Log.i("MediaInfoViewModel", it) }
|
||||||
|
if (_item.value!!.type == "Series") {
|
||||||
|
_seasons.value = getSeasons(itemId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +70,14 @@ class MediaInfoViewModel(application: Application, itemId: UUID) : AndroidViewMo
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun getSeasons(itemId: UUID): List<BaseItemDto>? {
|
||||||
|
val seasons: List<BaseItemDto>?
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
seasons = jellyfinApi.showsApi.getSeasons(itemId, jellyfinApi.userId!!).content.items
|
||||||
|
}
|
||||||
|
return seasons
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun getActors(item: BaseItemDto): List<BaseItemPerson>? {
|
private suspend fun getActors(item: BaseItemDto): List<BaseItemPerson>? {
|
||||||
val actors: List<BaseItemPerson>?
|
val actors: List<BaseItemPerson>?
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
|
|
|
@ -181,6 +181,36 @@
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
tools:text="An angel falls. A warrior rises. When Alita awakens with no memory of who she is in a future world she does not recognize, she is taken in by Ido, a compassionate doctor who realizes that somewhere in this abandoned cyborg shell is the heart and soul of a young woman with an extraordinary past." />
|
tools:text="An angel falls. A warrior rises. When Alita awakens with no memory of who she is in a future world she does not recognize, she is taken in by Ido, a compassionate doctor who realizes that somewhere in this abandoned cyborg shell is the heart and soul of a young woman with an extraordinary past." />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:visibility="@{viewModel.seasons != null ? View.VISIBLE : View.GONE}"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:text="@string/seasons"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/seasons_recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
app:items="@{viewModel.seasons}"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:itemCount="3"
|
||||||
|
tools:listitem="@layout/base_item" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -25,4 +25,5 @@
|
||||||
<string name="director">Director</string>
|
<string name="director">Director</string>
|
||||||
<string name="writers">Writers</string>
|
<string name="writers">Writers</string>
|
||||||
<string name="cast_amp_crew"><![CDATA[Cast & Crew]]></string>
|
<string name="cast_amp_crew"><![CDATA[Cast & Crew]]></string>
|
||||||
|
<string name="seasons">Seasons</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue