* Add person detail screen Displays actor/actresses portrait and text info + list of movies/show this person starred in. Text info is max 5 lines with View More button if ellipsized. View More toggle is reset upon orientation change since in landscape mode ellipsize might not be necessary. * Remove useless StarredInAdapter.kt * Fix image view shape * Improve UI Not exactly how I would like it but will do for now * Add error handling Adds a lot of LiveData which may not be ideal, but is better than crashing due to connection errors. Co-authored-by: jarnedemeulemeester <jarnedemeulemeester@gmail.com>
30 lines
No EOL
831 B
Kotlin
30 lines
No EOL
831 B
Kotlin
package dev.jdtech.jellyfin.utils
|
|
|
|
import androidx.fragment.app.Fragment
|
|
import androidx.navigation.fragment.findNavController
|
|
import dev.jdtech.jellyfin.MainNavigationDirections
|
|
import dev.jdtech.jellyfin.models.ContentType
|
|
import dev.jdtech.jellyfin.models.View
|
|
import org.jellyfin.sdk.model.api.BaseItemDto
|
|
import timber.log.Timber
|
|
|
|
fun BaseItemDto.toView(): View {
|
|
return View(
|
|
id = id,
|
|
name = name,
|
|
type = collectionType
|
|
)
|
|
}
|
|
|
|
fun BaseItemDto.contentType() = when (type) {
|
|
"Movie" -> ContentType.MOVIE
|
|
"Series" -> ContentType.TVSHOW
|
|
else -> ContentType.UNKNOWN
|
|
}
|
|
|
|
fun Fragment.checkIfLoginRequired(error: String) {
|
|
if (error.contains("401")) {
|
|
Timber.d("Login required!")
|
|
findNavController().navigate(MainNavigationDirections.actionGlobalLoginFragment())
|
|
}
|
|
} |