mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
style: fix formatting
This commit is contained in:
parent
6a6dbc7ccb
commit
67d82c28ac
@ -23,7 +23,7 @@ data class StreamItem(
|
||||
val uploaded: Long? = null,
|
||||
val shortDescription: String? = null,
|
||||
val isShort: Boolean = false
|
||||
): Parcelable {
|
||||
) : Parcelable {
|
||||
fun toLocalPlaylistItem(playlistId: String): LocalPlaylistItem {
|
||||
return LocalPlaylistItem(
|
||||
playlistId = playlistId.toInt(),
|
||||
|
@ -9,11 +9,11 @@ fun Player.togglePlayPauseState() {
|
||||
play()
|
||||
}
|
||||
|
||||
!isPlaying && playbackState == Player.STATE_ENDED -> {
|
||||
!isPlaying && playbackState == Player.STATE_ENDED -> {
|
||||
seekTo(0)
|
||||
}
|
||||
|
||||
!isPlaying && !isLoading -> play()
|
||||
else -> pause()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,10 @@ object BackgroundHelper {
|
||||
/**
|
||||
* Stop the [OnlinePlayerService] service if it is running.
|
||||
*/
|
||||
fun stopBackgroundPlay(context: Context, serviceClass: Class<*> = OnlinePlayerService::class.java) {
|
||||
fun stopBackgroundPlay(
|
||||
context: Context,
|
||||
serviceClass: Class<*> = OnlinePlayerService::class.java
|
||||
) {
|
||||
if (isBackgroundServiceRunning(context, serviceClass)) {
|
||||
// Intent to stop background mode service
|
||||
val intent = Intent(context, serviceClass)
|
||||
@ -60,7 +63,10 @@ object BackgroundHelper {
|
||||
/**
|
||||
* Check if the [OnlinePlayerService] service is currently running.
|
||||
*/
|
||||
fun isBackgroundServiceRunning(context: Context, serviceClass: Class<*> = OnlinePlayerService::class.java): Boolean {
|
||||
fun isBackgroundServiceRunning(
|
||||
context: Context,
|
||||
serviceClass: Class<*> = OnlinePlayerService::class.java
|
||||
): Boolean {
|
||||
@Suppress("DEPRECATION")
|
||||
return context.getSystemService<ActivityManager>()!!.getRunningServices(Int.MAX_VALUE)
|
||||
.any { serviceClass.name == it.service.className }
|
||||
|
@ -2,13 +2,13 @@ package com.github.libretube.helpers
|
||||
|
||||
import com.github.libretube.api.obj.PipedStream
|
||||
import com.github.libretube.api.obj.Streams
|
||||
import org.w3c.dom.Document
|
||||
import org.w3c.dom.Element
|
||||
import java.io.StringWriter
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
import org.w3c.dom.Document
|
||||
import org.w3c.dom.Element
|
||||
|
||||
// Based off of https://github.com/TeamPiped/Piped/blob/master/src/utils/DashUtils.js
|
||||
|
||||
|
@ -16,9 +16,9 @@ import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.extensions.toAndroidUri
|
||||
import com.github.libretube.extensions.toAndroidUriOrNull
|
||||
import com.github.libretube.util.DataSaverMode
|
||||
import java.nio.file.Path
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.nio.file.Path
|
||||
|
||||
object ImageHelper {
|
||||
lateinit var imageLoader: ImageLoader
|
||||
|
@ -19,11 +19,11 @@ import com.github.libretube.obj.NewPipeSubscription
|
||||
import com.github.libretube.obj.NewPipeSubscriptions
|
||||
import com.github.libretube.obj.PipedImportPlaylist
|
||||
import com.github.libretube.obj.PipedImportPlaylistFile
|
||||
import java.util.Date
|
||||
import java.util.stream.Collectors
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.decodeFromStream
|
||||
import kotlinx.serialization.json.encodeToStream
|
||||
import java.util.Date
|
||||
|
||||
object ImportHelper {
|
||||
/**
|
||||
|
@ -87,7 +87,10 @@ class PlaylistAdapter(
|
||||
val activity = (root.context as BaseActivity)
|
||||
val fragmentManager = activity.supportFragmentManager
|
||||
root.setOnLongClickListener {
|
||||
fragmentManager.setFragmentResultListener(VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||
fragmentManager.setFragmentResultListener(
|
||||
VIDEO_OPTIONS_SHEET_REQUEST_KEY,
|
||||
activity
|
||||
) { _, _ ->
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
val sheet = VideoOptionsBottomSheet()
|
||||
|
@ -102,7 +102,10 @@ class SearchAdapter(
|
||||
val activity = (root.context as BaseActivity)
|
||||
val fragmentManager = activity.supportFragmentManager
|
||||
root.setOnLongClickListener {
|
||||
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||
fragmentManager.setFragmentResultListener(
|
||||
VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY,
|
||||
activity
|
||||
) { _, _ ->
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
val sheet = VideoOptionsBottomSheet()
|
||||
|
@ -151,7 +151,10 @@ class VideosAdapter(
|
||||
}
|
||||
|
||||
root.setOnLongClickListener {
|
||||
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||
fragmentManager.setFragmentResultListener(
|
||||
VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY,
|
||||
activity
|
||||
) { _, _ ->
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
val sheet = VideoOptionsBottomSheet()
|
||||
@ -191,7 +194,10 @@ class VideosAdapter(
|
||||
}
|
||||
|
||||
root.setOnLongClickListener {
|
||||
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||
fragmentManager.setFragmentResultListener(
|
||||
VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY,
|
||||
activity
|
||||
) { _, _ ->
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
val sheet = VideoOptionsBottomSheet()
|
||||
|
@ -73,7 +73,10 @@ class WatchHistoryAdapter(
|
||||
val activity = (root.context as BaseActivity)
|
||||
val fragmentManager = activity.supportFragmentManager
|
||||
root.setOnLongClickListener {
|
||||
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||
fragmentManager.setFragmentResultListener(
|
||||
VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY,
|
||||
activity
|
||||
) { _, _ ->
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
val sheet = VideoOptionsBottomSheet()
|
||||
|
@ -16,7 +16,6 @@ import com.github.libretube.obj.PreferenceItem
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonNull
|
||||
|
@ -16,7 +16,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class DeletePlaylistDialog : DialogFragment() {
|
||||
private lateinit var playlistId: String
|
||||
|
@ -52,8 +52,8 @@ import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
|
||||
import com.github.libretube.util.DataSaverMode
|
||||
import com.github.libretube.util.PlayingQueue
|
||||
import com.google.android.material.elevation.SurfaceColors
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
||||
private var _binding: FragmentAudioPlayerBinding? = null
|
||||
|
@ -121,16 +121,16 @@ import com.github.libretube.util.TextUtils.toTimeInSeconds
|
||||
import com.github.libretube.util.YoutubeHlsPlaylistParser
|
||||
import com.github.libretube.util.deArrow
|
||||
import com.google.android.material.elevation.SurfaceColors
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.encodeToString
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
@ -1012,7 +1012,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
binding.relPlayerDownload.setOnClickListener {
|
||||
if (streams.duration <= 0) {
|
||||
Toast.makeText(context, R.string.cannotDownload, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
} else {
|
||||
val newFragment = DownloadDialog()
|
||||
newFragment.arguments = bundleOf(IntentData.videoId to videoId)
|
||||
newFragment.show(childFragmentManager, DownloadDialog::class.java.name)
|
||||
|
@ -2,8 +2,6 @@ package com.github.libretube.ui.preferences
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commitNow
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.Preference
|
||||
@ -18,8 +16,6 @@ import com.google.android.material.snackbar.Snackbar
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
class MainSettings : BasePreferenceFragment() {
|
||||
override val titleResourceId: Int = R.string.settings
|
||||
|
@ -105,7 +105,10 @@ class PlaylistOptionsBottomSheet(
|
||||
}
|
||||
|
||||
getString(R.string.deletePlaylist) -> {
|
||||
mFragmentManager.setFragmentResultListener(PLAYLIST_OPTIONS_REQUEST_KEY, context as BaseActivity) { _, bundle ->
|
||||
mFragmentManager.setFragmentResultListener(
|
||||
PLAYLIST_OPTIONS_REQUEST_KEY,
|
||||
context as BaseActivity
|
||||
) { _, bundle ->
|
||||
if (bundle.getBoolean(IntentData.playlistTask, true)) onDelete()
|
||||
// forward the result the playlists adapter if visible
|
||||
mFragmentManager.setFragmentResult(PLAYLISTS_ADAPTER_REQUEST_KEY, bundle)
|
||||
@ -119,7 +122,10 @@ class PlaylistOptionsBottomSheet(
|
||||
}
|
||||
|
||||
getString(R.string.renamePlaylist) -> {
|
||||
mFragmentManager.setFragmentResultListener(PLAYLIST_OPTIONS_REQUEST_KEY, context as BaseActivity) { _, bundle ->
|
||||
mFragmentManager.setFragmentResultListener(
|
||||
PLAYLIST_OPTIONS_REQUEST_KEY,
|
||||
context as BaseActivity
|
||||
) { _, bundle ->
|
||||
onRename(bundle.getString(IntentData.playlistName, ""))
|
||||
// forward the result the playlists adapter if visible
|
||||
mFragmentManager.setFragmentResult(PLAYLISTS_ADAPTER_REQUEST_KEY, bundle)
|
||||
@ -133,7 +139,10 @@ class PlaylistOptionsBottomSheet(
|
||||
}
|
||||
|
||||
getString(R.string.change_playlist_description) -> {
|
||||
mFragmentManager.setFragmentResultListener(PLAYLIST_OPTIONS_REQUEST_KEY, context as BaseActivity) { _, bundle ->
|
||||
mFragmentManager.setFragmentResultListener(
|
||||
PLAYLIST_OPTIONS_REQUEST_KEY,
|
||||
context as BaseActivity
|
||||
) { _, bundle ->
|
||||
onChangeDescription(bundle.getString(IntentData.playlistName, ""))
|
||||
// forward the result the playlists adapter if visible
|
||||
mFragmentManager.setFragmentResult(PLAYLISTS_ADAPTER_REQUEST_KEY, bundle)
|
||||
|
@ -13,7 +13,6 @@ import androidx.lifecycle.get
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.AutoplayCountdownBinding
|
||||
import com.github.libretube.ui.activities.MainActivity
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.github.libretube.ui.models.PlayerViewModel
|
||||
|
||||
class AutoplayCountdownView(
|
||||
@ -21,7 +20,9 @@ class AutoplayCountdownView(
|
||||
attributeSet: AttributeSet?
|
||||
) : FrameLayout(context, attributeSet) {
|
||||
private val layoutInflater = LayoutInflater.from(context)
|
||||
private val playerViewModel: PlayerViewModel get() = ViewModelProvider(context as MainActivity).get()
|
||||
private val playerViewModel: PlayerViewModel get() = ViewModelProvider(
|
||||
context as MainActivity
|
||||
).get()
|
||||
|
||||
val binding = AutoplayCountdownBinding.inflate(layoutInflater, this, true)
|
||||
private var onCountdownEnd: () -> Unit = {}
|
||||
|
@ -25,7 +25,13 @@ class OnlineTimeFrameReceiver(
|
||||
val offsetY = previewFrame.positionY * previewFrame.frameHeight
|
||||
|
||||
return runCatching {
|
||||
Bitmap.createBitmap(bitmap, offsetX, offsetY, previewFrame.frameWidth, previewFrame.frameHeight)
|
||||
Bitmap.createBitmap(
|
||||
bitmap,
|
||||
offsetX,
|
||||
offsetY,
|
||||
previewFrame.frameWidth,
|
||||
previewFrame.frameHeight
|
||||
)
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user