Make trailer button functional
This commit is contained in:
parent
4a42be9c0c
commit
bc5a6f0723
1 changed files with 12 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
||||||
package dev.jdtech.jellyfin.fragments
|
package dev.jdtech.jellyfin.fragments
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -40,14 +42,22 @@ class MediaInfoFragment : Fragment() {
|
||||||
viewModel = ViewModelProvider(this, viewModelFactory).get(MediaInfoViewModel::class.java)
|
viewModel = ViewModelProvider(this, viewModelFactory).get(MediaInfoViewModel::class.java)
|
||||||
binding.viewModel = viewModel
|
binding.viewModel = viewModel
|
||||||
|
|
||||||
viewModel.item.observe(viewLifecycleOwner, {
|
viewModel.item.observe(viewLifecycleOwner, { item ->
|
||||||
if (it.originalTitle != it.name) {
|
if (item.originalTitle != item.name) {
|
||||||
binding.originalTitle.visibility = View.VISIBLE
|
binding.originalTitle.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
binding.originalTitle.visibility = View.GONE
|
binding.originalTitle.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
if (item.trailerCount != null && item.trailerCount!! < 1) {
|
||||||
|
binding.trailerButton.visibility = View.GONE
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
binding.trailerButton.setOnClickListener {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(viewModel.item.value?.remoteTrailers?.get(0)?.url))
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
binding.seasonsRecyclerView.adapter =
|
binding.seasonsRecyclerView.adapter =
|
||||||
ViewItemListAdapter(ViewItemListAdapter.OnClickListener {
|
ViewItemListAdapter(ViewItemListAdapter.OnClickListener {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
|
|
Loading…
Reference in a new issue