Clean up some code

This commit is contained in:
Jarne Demeulemeester 2022-06-11 21:51:30 +02:00
parent 8c039a3c81
commit 7467f89f82
No known key found for this signature in database
GPG key ID: 65C6006F2032DD14
7 changed files with 8 additions and 23 deletions

View file

@ -27,11 +27,11 @@ internal class MainActivityTv : FragmentActivity() {
loadDownloadLocation(applicationContext) loadDownloadLocation(applicationContext)
viewModel.navigateToAddServer.observe(this, { viewModel.navigateToAddServer.observe(this) {
if (it) { if (it) {
navController.navigate(HomeFragmentDirections.actionHomeFragmentToAddServerFragment()) navController.navigate(HomeFragmentDirections.actionHomeFragmentToAddServerFragment())
viewModel.doneNavigateToAddServer() viewModel.doneNavigateToAddServer()
} }
}) }
} }
} }

View file

@ -8,7 +8,7 @@ import java.util.*
@Dao @Dao
interface DownloadDatabaseDao { interface DownloadDatabaseDao {
@Insert() @Insert
fun insertItem(downloadItem: DownloadItem) fun insertItem(downloadItem: DownloadItem)
@Query("select * from downloads where id = :id limit 1") @Query("select * from downloads where id = :id limit 1")

View file

@ -207,7 +207,7 @@ class MPVPlayer(
when (property) { when (property) {
"eof-reached" -> { "eof-reached" -> {
if (value && isPlayerReady) { if (value && isPlayerReady) {
if (currentIndex < internalMediaItems?.size ?: 0) { if (currentIndex < (internalMediaItems?.size ?: 0)) {
currentIndex += 1 currentIndex += 1
prepareMediaItem(currentIndex) prepareMediaItem(currentIndex)
play() play()

View file

@ -61,9 +61,9 @@ internal class TvPlayerActivity : BasePlayerActivity() {
private fun bind() = with(binding.playerView) { private fun bind() = with(binding.playerView) {
val videoNameTextView = findViewById<TextView>(R.id.video_name) val videoNameTextView = findViewById<TextView>(R.id.video_name)
viewModel.currentItemTitle.observe(this@TvPlayerActivity, { title -> viewModel.currentItemTitle.observe(this@TvPlayerActivity) { title ->
videoNameTextView.text = title videoNameTextView.text = title
}) }
findViewById<ImageButton>(R.id.exo_play_pause).apply { findViewById<ImageButton>(R.id.exo_play_pause).apply {
setOnClickListener { setOnClickListener {

View file

@ -1,8 +0,0 @@
package dev.jdtech.jellyfin.utils
import android.view.View
import androidx.core.view.isVisible
fun View.toggleVisibility() {
isVisible = !isVisible
}

View file

@ -1,14 +1,11 @@
package dev.jdtech.jellyfin.utils package dev.jdtech.jellyfin.utils
import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.Resources import android.content.res.Resources
import android.util.TypedValue import android.util.TypedValue
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.Toast
import androidx.annotation.AttrRes import androidx.annotation.AttrRes
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import dev.jdtech.jellyfin.AppNavigationDirections import dev.jdtech.jellyfin.AppNavigationDirections
@ -33,11 +30,7 @@ fun Fragment.checkIfLoginRequired(error: String?) {
} }
} }
inline fun Context.toast(@StringRes text: Int, duration: Int = Toast.LENGTH_SHORT) = fun Resources.dip(px: Int) = (px * displayMetrics.density).toInt()
Toast.makeText(this, text, duration).show()
inline fun Resources.dip(px: Int) = (px * displayMetrics.density).toInt()
fun ImageButton.setTintColor(@ColorRes colorId: Int, theme: Resources.Theme) { fun ImageButton.setTintColor(@ColorRes colorId: Int, theme: Resources.Theme) {
this.imageTintList = ColorStateList.valueOf( this.imageTintList = ColorStateList.valueOf(

View file

@ -183,7 +183,7 @@ constructor(
viewModelScope.launch { viewModelScope.launch {
try { try {
for (item in items) { for (item in items) {
if (item.itemId.toString() == player.currentMediaItem?.mediaId ?: "") { if (item.itemId.toString() == (player.currentMediaItem?.mediaId ?: "")) {
if (sp.getBoolean( if (sp.getBoolean(
"display_extended_title", "display_extended_title",
false false