mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2026-10-26 16:45:26 +00:00
Cleanup code and fix warnings
This commit is contained in:
1 parent
d44021397c
commit
56dab17394
6 files changed
+15
-13
No files matched your search
@@ -97,9 +97,6 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
// Bind player service
|
||||
bindService(Intent(this, RemotePlayerService::class.java), serviceConnection, Service.BIND_AUTO_CREATE)
|
||||
|
||||
// Check WebView support
|
||||
if (!isWebViewSupported()) {
|
||||
AlertDialog.Builder(this).apply {
|
||||
@@ -120,6 +117,9 @@ class MainActivity : AppCompatActivity() {
|
||||
return
|
||||
}
|
||||
|
||||
// Bind player service
|
||||
bindService(Intent(this, RemotePlayerService::class.java), serviceConnection, Service.BIND_AUTO_CREATE)
|
||||
|
||||
// Subscribe to activity events
|
||||
with(activityEventHandler) { subscribe() }
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ sealed class ActivityEvent {
|
||||
class DownloadFile(val uri: Uri, val title: String, val filename: String) : ActivityEvent()
|
||||
class CastMessage(val action: String, val args: JSONArray) : ActivityEvent()
|
||||
data object RequestBluetoothPermission : ActivityEvent()
|
||||
object OpenSettings : ActivityEvent()
|
||||
object SelectServer : ActivityEvent()
|
||||
object ExitApp : ActivityEvent()
|
||||
data object OpenSettings : ActivityEvent()
|
||||
data object SelectServer : ActivityEvent()
|
||||
data object ExitApp : ActivityEvent()
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class ActivityEventHandler(
|
||||
}
|
||||
|
||||
@Suppress("CyclomaticComplexMethod", "LongMethod")
|
||||
private suspend fun MainActivity.handleEvent(event: ActivityEvent) {
|
||||
private fun MainActivity.handleEvent(event: ActivityEvent) {
|
||||
when (event) {
|
||||
is ActivityEvent.ChangeFullscreen -> {
|
||||
val fullscreenHelper = PlayerFullscreenHelper(window)
|
||||
@@ -73,7 +73,9 @@ class ActivityEventHandler(
|
||||
}
|
||||
}
|
||||
is ActivityEvent.DownloadFile -> {
|
||||
with(event) { requestDownload(uri, title, filename) }
|
||||
lifecycleScope.launch {
|
||||
with(event) { requestDownload(uri, title, filename) }
|
||||
}
|
||||
}
|
||||
is ActivityEvent.CastMessage -> {
|
||||
val action = event.action
|
||||
|
||||
@@ -45,7 +45,7 @@ fun Activity.requestPermission(vararg permissions: String, callback: PermissionR
|
||||
}
|
||||
|
||||
if (skipRequest) {
|
||||
callback(permissions.map { Pair(it, PackageManager.PERMISSION_GRANTED) }.toMap())
|
||||
callback(permissions.associateWith { PackageManager.PERMISSION_GRANTED })
|
||||
} else {
|
||||
val helper = getKoin().get<PermissionRequestHelper>()
|
||||
val code = helper.getRequestCode()
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.os.Environment
|
||||
import android.os.PowerManager
|
||||
import android.provider.Settings
|
||||
import android.provider.Settings.System.ACCELEROMETER_ROTATION
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.content.getSystemService
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -37,7 +36,7 @@ import kotlin.coroutines.suspendCoroutine
|
||||
|
||||
fun WebViewFragment.requestNoBatteryOptimizations(rootView: CoordinatorLayout) {
|
||||
if (AndroidVersion.isAtLeastM) {
|
||||
val powerManager: PowerManager = requireContext().getSystemService(AppCompatActivity.POWER_SERVICE) as PowerManager
|
||||
val powerManager: PowerManager = requireContext().getSystemService(Activity.POWER_SERVICE) as PowerManager
|
||||
if (
|
||||
!appPreferences.ignoreBatteryOptimizations &&
|
||||
!powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)
|
||||
@@ -145,7 +144,6 @@ fun Context.createMediaNotificationChannel(notificationManager: NotificationMana
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun Context.getDownloadsPaths(): List<String> = ArrayList<String>().apply {
|
||||
for (directory in getExternalFilesDirs(null)) {
|
||||
// Ignore currently unavailable shared storage
|
||||
|
||||
@@ -166,7 +166,9 @@ class RemotePlayerService : Service(), CoroutineScope {
|
||||
}
|
||||
|
||||
private fun handleIntent(intent: Intent?) {
|
||||
if (intent == null || intent.action == null) return
|
||||
if (intent?.action == null) {
|
||||
return
|
||||
}
|
||||
val action = intent.action
|
||||
if (action == Constants.ACTION_REPORT) {
|
||||
notify(intent)
|
||||
|
||||
Reference in new issue
Block a user