Pip and aniskip fixes (#921)

* fix pip

* fix aniskip when offline
This commit is contained in:
Quickdesh 2023-02-27 15:19:58 +09:00 committed by GitHub
parent aea88aa3b0
commit 2ab5b64796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View file

@ -1237,7 +1237,7 @@ class PlayerActivity :
override fun onResume() {
super.onResume()
setVisibilities()
if (deviceSupportsPip && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) player.paused?.let { updatePictureInPictureActions(!it) }
if (deviceSupportsPip && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isInPipMode) player.paused?.let { updatePictureInPictureActions(!it) }
}
@Deprecated("Deprecated in Java")

View file

@ -647,7 +647,7 @@ class PlayerViewModel(
val animeId = anime?.id ?: return null
val trackManager = Injekt.get<TrackManager>()
var malId: Long?
val episodeNumber = getCurrentEpisodeIndex() + 1
val episodeNumber = currentEpisode?.episode_number?.toInt() ?: return null
if (getTracks.await(animeId).isEmpty()) {
logcat { "AniSkip: No tracks found for anime $animeId" }
return null

View file

@ -46,12 +46,17 @@ class AniSkipApi {
Media(id:$id){idMal}
}
""".trimMargin()
val response = client.newCall(
POST(
"https://graphql.anilist.co",
body = buildJsonObject { put("query", query) }.toString().toRequestBody(jsonMime),
),
).execute()
val response = try {
client.newCall(
POST(
"https://graphql.anilist.co",
body = buildJsonObject { put("query", query) }.toString()
.toRequestBody(jsonMime),
),
).execute()
} catch (e: Exception) {
return 0
}
return response.body.string().substringAfter("idMal\":").substringBefore("}")
.toLongOrNull() ?: 0
}