Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes some deprecated code #398

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@ class PlaybackActivity : FragmentActivity() {
PreferenceManager.getDefaultSharedPreferences(this).getInt("maxPlayPercent", 98)
}

@OptIn(UnstableApi::class)
@Deprecated("Deprecated in Java")
override fun onBackPressed() {
// TODO: deprecated, so use https://stackoverflow.com/a/72634975/608317 eventually
if (fragment == null) {
super.onBackPressed()
} else if (!fragment!!.hideControlsIfVisible()) {
returnPosition()
super.onBackPressed()
}
}

@OptIn(UnstableApi::class)
@SuppressLint("RestrictedApi")
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
Expand All @@ -84,10 +72,10 @@ class PlaybackActivity : FragmentActivity() {
}
}

/**
* Return the video's current position to the previous Activity
*/
private fun returnPosition() {
override fun onStop() {
super.onStop()

// Return the video's current position to the previous Activity
val sceneDuration = scene.duration ?: Double.MIN_VALUE
val position = fragment!!.currentVideoPosition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.activity.addCallback
import androidx.annotation.LayoutRes
import androidx.annotation.OptIn
import androidx.core.view.isVisible
Expand Down Expand Up @@ -286,14 +287,27 @@ abstract class PlaybackFragment(
debugView.visibility = View.VISIBLE
}

val backCallback =
requireActivity().onBackPressedDispatcher.addCallback(
viewLifecycleOwner,
enabled = false,
) {
hideControlsIfVisible()
}

videoView = view.findViewById(R.id.video_view)
videoView.controllerShowTimeoutMs =
manager.getInt("controllerShowTimeoutMs", PlayerControlView.DEFAULT_SHOW_TIMEOUT_MS)
videoView.setControllerVisibilityListener(
PlayerView.ControllerVisibilityListener {
PlayerView.ControllerVisibilityListener { vis ->
if (!exoCenterControls.isVisible) {
hideControlsIfVisible()
}
if (vis == View.VISIBLE) {
backCallback.isEnabled = true
} else {
backCallback.isEnabled = false
}
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ class PlaylistActivity : FragmentActivity() {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}

@OptIn(UnstableApi::class)
@Deprecated("Deprecated in Java")
override fun onBackPressed() {
// TODO: deprecated, so use https://stackoverflow.com/a/72634975/608317 eventually
if (fragment == null) {
super.onBackPressed()
} else if (!fragment!!.hideControlsIfVisible()) {
super.onBackPressed()
}
}

@OptIn(UnstableApi::class)
@SuppressLint("RestrictedApi")
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.damontecres.stashapp.util

import android.util.Log
import androidx.leanback.widget.DiffCallback
import androidx.recyclerview.widget.DiffUtil
import com.github.damontecres.stashapp.api.fragment.FullSceneData
import com.github.damontecres.stashapp.api.fragment.GalleryData
import com.github.damontecres.stashapp.api.fragment.ImageData
import com.github.damontecres.stashapp.api.fragment.MarkerData
Expand All @@ -17,12 +19,21 @@ object StashComparator : DiffUtil.ItemCallback<Any>() {
oldItem: Any,
newItem: Any,
): Boolean {
Log.v("StashComparator", "areItemsTheSame")
if (oldItem.javaClass != newItem.javaClass) {
return false
} else {
return when (oldItem) {
is GalleryData -> (oldItem as GalleryData).id == (newItem as GalleryData).id
is ImageData -> (oldItem as ImageData).id == (newItem as ImageData).id
is MarkerData -> (oldItem as MarkerData).id == (newItem as MarkerData).id
is MovieData -> (oldItem as MovieData).id == (newItem as MovieData).id
is PerformerData -> (oldItem as PerformerData).id == (newItem as PerformerData).id
is SlimSceneData -> (oldItem as SlimSceneData).id == (newItem as SlimSceneData).id
else -> TODO()
is FullSceneData -> (oldItem as FullSceneData).id == (newItem as FullSceneData).id
is StudioData -> (oldItem as StudioData).id == (newItem as StudioData).id
is TagData -> (oldItem as TagData).id == (newItem as TagData).id
else -> throw IllegalStateException("Cannot compare ${oldItem::class.java.name} and ${newItem::class.java.name}")
}
}
}
Expand All @@ -35,8 +46,16 @@ object StashComparator : DiffUtil.ItemCallback<Any>() {
return false
} else {
return when (oldItem) {
is GalleryData -> (oldItem as GalleryData) == (newItem as GalleryData)
is ImageData -> (oldItem as ImageData) == (newItem as ImageData)
is MarkerData -> (oldItem as MarkerData) == (newItem as MarkerData)
is MovieData -> (oldItem as MovieData) == (newItem as MovieData)
is PerformerData -> (oldItem as PerformerData) == (newItem as PerformerData)
is SlimSceneData -> (oldItem as SlimSceneData) == (newItem as SlimSceneData)
else -> TODO()
is FullSceneData -> (oldItem as FullSceneData) == (newItem as FullSceneData)
is StudioData -> (oldItem as StudioData) == (newItem as StudioData)
is TagData -> (oldItem as TagData) == (newItem as TagData)
else -> throw IllegalStateException("Cannot compare ${oldItem::class.java.name} and ${newItem::class.java.name}")
}
}
}
Expand Down