Merge pull request #4747 from Bnyro/master

style: fix formatting
This commit is contained in:
Bnyro 2023-09-10 14:35:31 +02:00 committed by GitHub
commit 344eb5be5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 63 additions and 32 deletions

View File

@ -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(),

View File

@ -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 }

View File

@ -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

View File

@ -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

View File

@ -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 {
/**

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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)

View File

@ -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 = {}

View File

@ -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()
}