diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/HomeFragment.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/HomeFragment.kt
index 4112b484..adc990a7 100644
--- a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/HomeFragment.kt
+++ b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/HomeFragment.kt
@@ -209,9 +209,9 @@ class HomeFragment : Fragment() {
private fun navigateToLibraryFragment(view: dev.jdtech.jellyfin.models.View) {
findNavController().navigate(
HomeFragmentDirections.actionNavigationHomeToLibraryFragment(
- view.id,
- view.name,
- view.type
+ libraryId = view.id,
+ libraryName = view.name,
+ libraryType = view.type
)
)
}
diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/LibraryFragment.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/LibraryFragment.kt
index 42445f69..3272e1d9 100644
--- a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/LibraryFragment.kt
+++ b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/LibraryFragment.kt
@@ -25,7 +25,6 @@ import dev.jdtech.jellyfin.core.R as CoreR
import dev.jdtech.jellyfin.databinding.FragmentLibraryBinding
import dev.jdtech.jellyfin.dialogs.ErrorDialogFragment
import dev.jdtech.jellyfin.dialogs.SortDialogFragment
-import dev.jdtech.jellyfin.models.CollectionType
import dev.jdtech.jellyfin.models.FindroidBoxSet
import dev.jdtech.jellyfin.models.FindroidItem
import dev.jdtech.jellyfin.models.FindroidMovie
@@ -116,11 +115,7 @@ class LibraryFragment : Fragment() {
binding.itemsRecyclerView.adapter =
ViewItemPagingAdapter(
ViewItemPagingAdapter.OnClickListener { item ->
- if (args.libraryType == CollectionType.BoxSets.type) {
- navigateToItem(item)
- } else {
- navigateToItem(item)
- }
+ navigateToItem(item)
}
)
diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MediaFragment.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MediaFragment.kt
index c47699b1..89f5ed54 100644
--- a/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MediaFragment.kt
+++ b/app/phone/src/main/java/dev/jdtech/jellyfin/fragments/MediaFragment.kt
@@ -149,9 +149,9 @@ class MediaFragment : Fragment() {
private fun navigateToLibraryFragment(library: FindroidCollection) {
findNavController().navigate(
MediaFragmentDirections.actionNavigationMediaToLibraryFragment(
- library.id,
- library.name,
- library.type.type,
+ libraryId = library.id,
+ libraryName = library.name,
+ libraryType = library.type,
)
)
}
diff --git a/app/phone/src/main/res/navigation/app_navigation.xml b/app/phone/src/main/res/navigation/app_navigation.xml
index 6d008d52..4b8b44e6 100644
--- a/app/phone/src/main/res/navigation/app_navigation.xml
+++ b/app/phone/src/main/res/navigation/app_navigation.xml
@@ -98,9 +98,7 @@
app:argType="java.util.UUID" />
+ app:argType="string" />
+ app:argType="dev.jdtech.jellyfin.models.CollectionType" />
? = null,
- val type: String?
+ val type: CollectionType
)
diff --git a/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt b/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt
index 8a9f805d..923fc7f5 100644
--- a/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt
+++ b/core/src/main/java/dev/jdtech/jellyfin/utils/CoreExtensions.kt
@@ -9,6 +9,7 @@ import android.os.Bundle
import android.util.TypedValue
import androidx.annotation.AttrRes
import com.google.android.material.button.MaterialButton
+import dev.jdtech.jellyfin.models.CollectionType
import dev.jdtech.jellyfin.models.View
import java.io.Serializable
import org.jellyfin.sdk.model.api.BaseItemDto
@@ -16,8 +17,8 @@ import org.jellyfin.sdk.model.api.BaseItemDto
fun BaseItemDto.toView(): View {
return View(
id = id,
- name = name,
- type = collectionType
+ name = name ?: "",
+ type = valueOf(collectionType, CollectionType.Movies)
)
}
@@ -44,3 +45,15 @@ fun Activity.restart() {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
}
+
+inline fun > valueOf(type: String?, default: T): T {
+ if (type == null) {
+ return default
+ }
+
+ return try {
+ java.lang.Enum.valueOf(T::class.java, type)
+ } catch (e: Exception) {
+ default
+ }
+}
\ No newline at end of file
diff --git a/core/src/main/java/dev/jdtech/jellyfin/viewmodels/LibraryViewModel.kt b/core/src/main/java/dev/jdtech/jellyfin/viewmodels/LibraryViewModel.kt
index 5d06ff89..e2859b5a 100644
--- a/core/src/main/java/dev/jdtech/jellyfin/viewmodels/LibraryViewModel.kt
+++ b/core/src/main/java/dev/jdtech/jellyfin/viewmodels/LibraryViewModel.kt
@@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import dagger.hilt.android.lifecycle.HiltViewModel
+import dev.jdtech.jellyfin.models.CollectionType
import dev.jdtech.jellyfin.models.FindroidItem
import dev.jdtech.jellyfin.models.SortBy
import dev.jdtech.jellyfin.repository.JellyfinRepository
@@ -37,16 +38,16 @@ constructor(
fun loadItems(
parentId: UUID,
- libraryType: String?,
+ libraryType: CollectionType,
sortBy: SortBy = SortBy.defaultValue,
sortOrder: SortOrder = SortOrder.ASCENDING
) {
itemsloaded = true
Timber.d("$libraryType")
val itemType = when (libraryType) {
- "movies" -> listOf(BaseItemKind.MOVIE)
- "tvshows" -> listOf(BaseItemKind.SERIES)
- "boxsets" -> listOf(BaseItemKind.BOX_SET)
+ CollectionType.Movies -> listOf(BaseItemKind.MOVIE)
+ CollectionType.TvShows -> listOf(BaseItemKind.SERIES)
+ CollectionType.BoxSets -> listOf(BaseItemKind.BOX_SET)
else -> null
}
viewModelScope.launch {