Skip to content

Commit

Permalink
fix crash when selecting qualities while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Sep 15, 2021
1 parent 0b9ff81 commit d99021b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/report_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ body:
label: Aniyomi version
description: You can find your Aniyomi version in **More → About**.
placeholder: |
Example: "0.12.2.1"
Example: "0.12.2.2"
validations:
required: true

Expand Down Expand Up @@ -97,7 +97,7 @@ body:
required: true
- label: I have tried the [troubleshooting guide](https://tachiyomi.org/help/guides/troubleshooting/).
required: true
- label: I have updated the app to version **[0.12.2.1](https://github.com/jmir1/aniyomi/releases)**.
- label: I have updated the app to version **[0.12.2.2](https://github.com/jmir1/aniyomi/releases)**.
required: true
- label: I have updated all installed extensions.
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/request_feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ body:
required: true
- label: If this is an issue with an extension, I should be opening an issue in the [extensions repository](https://github.com/jmir1/aniyomi-extensions/issues/new/choose).
required: true
- label: I have updated the app to version **[0.12.2.1](https://github.com/jmir1/aniyomi/releases)**.
- label: I have updated the app to version **[0.12.2.2](https://github.com/jmir1/aniyomi/releases)**.
required: true
- label: I will fill out all of the requested information in this form.
required: true
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
targetSdk = AndroidConfig.targetSdk
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
versionCode = 68
versionName = "0.12.2.3"
versionName = "0.12.2.2"

buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
Expand Down
40 changes: 21 additions & 19 deletions app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PlayerActivity : AppCompatActivity() {
private lateinit var source: AnimeSource
private lateinit var userAgentString: String
private lateinit var uri: String
private lateinit var videos: List<Video>
private var videos = emptyList<Video>()
private lateinit var videoListObservable: Observable<Observable<List<Video>>>
private var isBuffering = true
private var isLocal = false
Expand Down Expand Up @@ -361,30 +361,32 @@ class PlayerActivity : AppCompatActivity() {
speedAlert.show()
}
1 -> {
val qualityAlert = AlertDialog.Builder(this)
if (videos.isNotEmpty()) {
val qualityAlert = AlertDialog.Builder(this)

qualityAlert.setTitle(R.string.playback_quality_dialog_title)

var requestedQuality = 0
val qualities = videos.map { it.quality }.toTypedArray()
qualityAlert.setSingleChoiceItems(qualities, currentQuality) { qualityDialog, selectedQuality ->
if (selectedQuality > qualities.lastIndex) {
qualityDialog.cancel()
} else {
requestedQuality = selectedQuality
}
}

qualityAlert.setTitle(R.string.playback_quality_dialog_title)
qualityAlert.setPositiveButton(android.R.string.ok) { qualityDialog, _ ->
if (requestedQuality != currentQuality) changeQuality(requestedQuality)
qualityDialog.dismiss()
}

var requestedQuality = 0
val qualities = videos.map { it.quality }.toTypedArray()
qualityAlert.setSingleChoiceItems(qualities, currentQuality) { qualityDialog, selectedQuality ->
if (selectedQuality > qualities.lastIndex) {
qualityAlert.setNegativeButton(android.R.string.cancel) { qualityDialog, _ ->
qualityDialog.cancel()
} else {
requestedQuality = selectedQuality
}
}

qualityAlert.setPositiveButton(android.R.string.ok) { qualityDialog, _ ->
if (requestedQuality != currentQuality) changeQuality(requestedQuality)
qualityDialog.dismiss()
qualityAlert.show()
}

qualityAlert.setNegativeButton(android.R.string.cancel) { qualityDialog, _ ->
qualityDialog.cancel()
}

qualityAlert.show()
}
else -> {
dialog.cancel()
Expand Down

0 comments on commit d99021b

Please sign in to comment.