-
Notifications
You must be signed in to change notification settings - Fork 65
test: fix playback updates #501
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,12 +24,14 @@ import us.nineworlds.serenity.emby.moshi.LocalDateJsonAdapter | |
| import us.nineworlds.serenity.emby.server.model.AuthenticateUserByName | ||
| import us.nineworlds.serenity.emby.server.model.AuthenticationResult | ||
| import us.nineworlds.serenity.emby.server.model.Item | ||
| import us.nineworlds.serenity.emby.server.model.PlaybackStartRequest | ||
| import us.nineworlds.serenity.emby.server.model.PublicUserInfo | ||
| import us.nineworlds.serenity.emby.server.model.QueryFilters | ||
| import us.nineworlds.serenity.emby.server.model.QueryResult | ||
| import java.io.File | ||
| import java.io.IOException | ||
| import java.util.UUID | ||
| import kotlin.uuid.Uuid | ||
|
|
||
| class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:8096") : SerenityClient { | ||
|
|
||
|
|
@@ -53,7 +55,7 @@ class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:80 | |
| val cache = Cache(cacheDir, cacheSize.toLong()) | ||
|
|
||
| val okClient = RetrofitUrlManager.getInstance().with(OkHttpClient.Builder()) | ||
| logger.level = HttpLoggingInterceptor.Level.BASIC | ||
| logger.level = HttpLoggingInterceptor.Level.BODY | ||
| okClient.addInterceptor(logger) | ||
|
Comment on lines
57
to
59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logging level Changing from 🔎 Proposed fix-logger.level = HttpLoggingInterceptor.Level.BODY
+logger.level = if (BuildConfig.DEBUG) {
+ HttpLoggingInterceptor.Level.BODY
+} else {
+ HttpLoggingInterceptor.Level.BASIC
+}🤖 Prompt for AI Agents |
||
| okClient.cache(cache) | ||
|
|
||
|
|
@@ -412,14 +414,18 @@ class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:80 | |
| } | ||
|
|
||
| override fun progress(key: String, offset: String): Boolean { | ||
| return progress(key, offset, null) | ||
| } | ||
|
|
||
| override fun progress(key: String, offset: String, playSessionId: String?): Boolean { | ||
| if (userId == null) { | ||
| userId = fetchUserId() | ||
| } | ||
| var position = offset.toLong() | ||
|
|
||
| position = position.times(10000) | ||
|
|
||
| val call = usersService.progress(headerMap(), userId!!, key, null, position) | ||
| val call = usersService.progress(headerMap(), userId!!, key, null, position, playSessionId) | ||
| val result = call.execute() | ||
|
|
||
| return result.isSuccessful | ||
|
|
@@ -475,14 +481,18 @@ class EmbyAPIClient(val context: Context, baseUrl: String = "http://localhost:80 | |
| return "$baseUrl/Users/${user.userId}/Images/Primary?Width=$width&Height=$height" | ||
| } | ||
|
|
||
| override fun startPlaying(itemId: String) { | ||
| override fun startPlaying(itemId: String): String? { | ||
| if (userId == null) { | ||
| userId = fetchUserId() | ||
| } | ||
|
|
||
| val call = usersService.startPlaying(headerMap(), userId!!, itemId) | ||
| val call = usersService.startPlaying(headerMap(), userId!!, itemId, PlaybackStartRequest(true)) | ||
|
|
||
| call.execute() | ||
| val response = call.execute() | ||
| if (response.isSuccessful) { | ||
| return response.body()?.playSessionId ?: UUID.randomUUID().toString() | ||
| } | ||
| return UUID.randomUUID().toString() | ||
| } | ||
|
|
||
| override fun stopPlaying(itemId: String, offset: Long) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ leanbackVersion = "1.2.0" | |
| legacySupportV4Version = "1.0.0" | ||
| lifecycleVersion = "2.9.4" | ||
| materialVersion = "1.12.0" | ||
| minSdkVersion = "27" | ||
| minSdkVersion = "25" | ||
| mockwebserverVersion = "4.9.1" | ||
| moxy = "2.2.2" | ||
| moxyAppCompatVersion = "2.2.2" | ||
|
|
@@ -61,6 +61,7 @@ agpVersion = "8.13.1" | |
| kotlin = "2.2.21" | ||
| coreKtxVersion = "1.17.0" | ||
| espressoCoreVersion = "3.5.1" | ||
| lifecycleProcessVersion = "2.10.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lifecycle-process version 2.10.0 does not exist—use an available version instead. The latest stable release of lifecycle-process is 2.8.6, with 2.9.0-alpha03 as the latest pre-release. Version 2.10.0 is unavailable for this artifact and will cause a dependency resolution failure during the build. Change Also applies to: 144-144 🤖 Prompt for AI Agents |
||
|
|
||
| [libraries] | ||
| androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "annotationVersion" } | ||
|
|
@@ -140,6 +141,7 @@ assertk-jvm = { module = "com.willowtreeapps.assertk:assertk", version.ref = "as | |
| turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine"} | ||
| androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtxVersion" } | ||
| androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCoreVersion" } | ||
| androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleProcessVersion" } | ||
|
|
||
| [plugins] | ||
| ksp = { id = "com.google.devtools.ksp", version.ref = "kotlinKSPVersion" } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -145,7 +145,8 @@ dependencies { | |||||||||
| implementation(libs.moxy.community.moxy) | ||||||||||
| implementation(libs.moxy.ktx) | ||||||||||
| implementation(libs.github.glide) | ||||||||||
| ksp(libs.glide.compiler) | ||||||||||
| implementation(libs.androidx.lifecycle.process) | ||||||||||
| ksp(libs.glide.compiler) | ||||||||||
|
Comment on lines
+148
to
+149
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Fix incorrect indentation. Lines 148-149 have 4 extra spaces of indentation compared to the rest of the dependencies block, making them inconsistent with the file's formatting. 🔎 Proposed fix- implementation(libs.androidx.lifecycle.process)
- ksp(libs.glide.compiler)
+ implementation(libs.androidx.lifecycle.process)
+ ksp(libs.glide.compiler)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| implementation(libs.androidx.appcompat) | ||||||||||
| implementation(libs.androidx.leanback) | ||||||||||
| implementation(libs.androidx.leanback.preference) | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,12 +29,14 @@ import android.content.SharedPreferences | |
| import android.os.Build | ||
| import android.os.Bundle | ||
| import android.preference.PreferenceManager | ||
| import androidx.lifecycle.ProcessLifecycleOwner | ||
| import androidx.lifecycle.lifecycleScope | ||
| import androidx.localbroadcastmanager.content.LocalBroadcastManager | ||
| import com.google.android.exoplayer2.database.ExoDatabaseProvider | ||
| import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor | ||
| import com.google.android.exoplayer2.upstream.cache.SimpleCache | ||
| import com.google.firebase.analytics.FirebaseAnalytics | ||
| import kotlinx.coroutines.MainScope | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.launch | ||
| import net.danlew.android.joda.JodaTimeAndroid | ||
| import org.greenrobot.eventbus.EventBus | ||
|
|
@@ -141,7 +143,7 @@ open class SerenityApplication : Application() { | |
| } | ||
|
|
||
| protected open fun discoverServers() { | ||
| MainScope().launch { | ||
| ProcessLifecycleOwner.get().lifecycleScope.launch(Dispatchers.IO) { | ||
| EmbyServerDiscover().findServers() | ||
| } | ||
| } | ||
|
Comment on lines
145
to
149
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for build.gradle files containing lifecycle-process dependency
find . -type f \( -name "build.gradle" -o -name "build.gradle.kts" \) | head -20Repository: NineWorlds/serenity-android Length of output: 348 🏁 Script executed: #!/bin/bash
# Search for lifecycle-process in all build.gradle files
echo "=== Searching for lifecycle-process ==="
grep -r "lifecycle-process" . --include="*.gradle" --include="*.gradle.kts" 2>/dev/null || echo "Not found in build files"
echo -e "\n=== Searching for androidx.lifecycle in serenity-app/build.gradle.kts ==="
grep -E "androidx\.lifecycle|lifecycle" serenity-app/build.gradle.kts 2>/dev/null || echo "Not found"
echo -e "\n=== Full serenity-app/build.gradle.kts dependencies section ==="
sed -n '/^dependencies/,/^}/p' serenity-app/build.gradle.kts 2>/dev/null | head -100Repository: NineWorlds/serenity-android Length of output: 3515 🏁 Script executed: #!/bin/bash
# Read the SerenityApplication.kt file, especially around lines 145-149
echo "=== SerenityApplication.kt (lines 140-160) ==="
sed -n '140,160p' serenity-app/src/main/java/us/nineworlds/serenity/SerenityApplication.kt
echo -e "\n=== Import statements in SerenityApplication.kt ==="
head -30 serenity-app/src/main/java/us/nineworlds/serenity/SerenityApplication.kt
echo -e "\n=== Check for Toothpick usage in SerenityApplication.kt ==="
grep -E "Toothpick|inject|Inject" serenity-app/src/main/java/us/nineworlds/serenity/SerenityApplication.kt || echo "No Toothpick usage found"Repository: NineWorlds/serenity-android Length of output: 2791 Lifecycle-aware coroutine management is solid, but dependency injection pattern needs adjustment. The lifecycle-process dependency is properly declared, and using 🤖 Prompt for AI Agents |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Remove unused import
kotlin.uuid.Uuid.This import is not used in the file. The code uses
java.util.UUIDthroughout.🔎 Proposed fix
-import kotlin.uuid.Uuid📝 Committable suggestion
🤖 Prompt for AI Agents