Skip to content

Commit 8b04b13

Browse files
committed
Fix linting errors
1 parent 6cb500f commit 8b04b13

File tree

10 files changed

+48
-31
lines changed

10 files changed

+48
-31
lines changed

app/src/androidTest/java/de/xikolo/testing/instrumented/unit/download/BaseDownloadTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ abstract class BaseDownloadTest : BaseTest() {
1919
@Rule
2020
@JvmField
2121
var permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
22-
2322
}

app/src/androidTest/java/de/xikolo/testing/instrumented/unit/download/DownloadHandlerTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ abstract class DownloadHandlerTest<T : DownloadHandler<I, R>,
9292

9393
// wait for download to start
9494
waitWhile({
95-
status?.state?.equals(DownloadStatus.State.DELETED) != false ||
96-
(status?.state?.equals(DownloadStatus.State.PENDING) != true &&
97-
status?.state?.equals(DownloadStatus.State.RUNNING) != true)
95+
status?.state?.equals(DownloadStatus.State.DELETED) != false || (
96+
status?.state?.equals(DownloadStatus.State.PENDING) != true &&
97+
status?.state?.equals(DownloadStatus.State.RUNNING) != true
98+
)
9899
})
99100

100101
// test status after start
@@ -179,7 +180,7 @@ abstract class DownloadHandlerTest<T : DownloadHandler<I, R>,
179180

180181
var downloaded = false
181182
downloadHandler.listen(downloadHandler.identify(successfulTestRequest)) {
182-
if(it.state == DownloadStatus.State.DOWNLOADED){
183+
if (it.state == DownloadStatus.State.DOWNLOADED) {
183184
downloaded = true
184185
}
185186
}
@@ -195,7 +196,7 @@ abstract class DownloadHandlerTest<T : DownloadHandler<I, R>,
195196
// wait for result
196197
waitWhile({ nextCount == null }, 1000)
197198

198-
assertEquals(count!! + 1, nextCount);
199+
assertEquals(count!! + 1, nextCount)
199200
}
200201

201202
@Test

app/src/androidTest/java/de/xikolo/testing/instrumented/unit/download/hlsvideodownload/AbstractHlsVideoDownloadHandlerTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ abstract class AbstractHlsVideoDownloadHandlerTest : DownloadHandlerTest<HlsVide
1818

1919
override val successfulTestRequest
2020
get() = HlsVideoDownloadRequest(
21-
"https://open.hpi.de/playlists/93a84211-e40a-416a-b224-4d3ecdbb12f9.m3u8?embed_subtitles_for_video=d7e056da-756f-4437-b64a-16970a33d5ef",
21+
"https://open.hpi.de/playlists/93a84211-e40a-416a-b224-4d3ecdbb12f9.m3u8?" +
22+
"embed_subtitles_for_video=d7e056da-756f-4437-b64a-16970a33d5ef",
2223
VideoSettingsHelper.VideoQuality.LOW.qualityFraction,
2324
context.preferredStorage,
2425
"Video 1",
2526
true,
2627
DownloadCategory.Other
2728
)
2829
override val successfulTestRequest2 = HlsVideoDownloadRequest(
29-
"https://open.hpi.de/playlists/04012fde-be48-47b6-a742-0edc69a9c2a9.m3u8?embed_subtitles_for_video=d7e056da-756f-4437-b64a-16970a33d5ef",
30+
"https://open.hpi.de/playlists/04012fde-be48-47b6-a742-0edc69a9c2a9.m3u8?" +
31+
"embed_subtitles_for_video=d7e056da-756f-4437-b64a-16970a33d5ef",
3032
VideoSettingsHelper.VideoQuality.BEST.qualityFraction,
3133
context.preferredStorage,
3234
"Video 2",

app/src/androidTest/java/de/xikolo/testing/instrumented/unit/download/hlsvideodownload/AbstractHlsVideoDownloadItemTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ abstract class AbstractHlsVideoDownloadItemTest : DownloadItemTest<HlsVideoDownl
1616

1717
override val testDownloadItem
1818
get() = HlsVideoDownloadItem(
19-
"https://open.hpi.de/playlists/93a84211-e40a-416a-b224-4d3ecdbb12f9.m3u8?embed_subtitles_for_video=d7e056da-756f-4437-b64a-16970a33d5ef",
19+
"https://open.hpi.de/playlists/93a84211-e40a-416a-b224-4d3ecdbb12f9.m3u8?" +
20+
"embed_subtitles_for_video=d7e056da-756f-4437-b64a-16970a33d5ef",
2021
DownloadCategory.Other,
2122
VideoSettingsHelper.VideoQuality.HIGH.qualityFraction,
2223
emptyMap(),

app/src/main/java/de/xikolo/controllers/helper/DownloadViewHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class DownloadViewHelper(
288288
DownloadStatus.State.DOWNLOADED -> showEndState()
289289
DownloadStatus.State.DELETED -> {
290290
showStartState()
291-
if(status.error != null){
291+
if (status.error != null) {
292292
activity.showToast(R.string.error)
293293
}
294294
}

app/src/main/java/de/xikolo/controllers/video/VideoStreamPlayerFragment.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ open class VideoStreamPlayerFragment : BaseFragment() {
602602
}
603603
VideoSettingsHelper.PlaybackMode.LOW -> {
604604
playerView.setHLSVideoUri(Uri.parse(videoStream.hlsUrl))
605-
playerView.setDesiredQuality(VideoSettingsHelper.VideoQuality.LOW.qualityFraction)
605+
playerView.setDesiredQuality(
606+
VideoSettingsHelper.VideoQuality.LOW.qualityFraction
607+
)
606608
}
607609
VideoSettingsHelper.PlaybackMode.MEDIUM -> {
608610
playerView.setHLSVideoUri(Uri.parse(videoStream.hlsUrl))
@@ -612,11 +614,15 @@ open class VideoStreamPlayerFragment : BaseFragment() {
612614
}
613615
VideoSettingsHelper.PlaybackMode.HIGH -> {
614616
playerView.setHLSVideoUri(Uri.parse(videoStream.hlsUrl))
615-
playerView.setDesiredQuality(VideoSettingsHelper.VideoQuality.HIGH.qualityFraction)
617+
playerView.setDesiredQuality(
618+
VideoSettingsHelper.VideoQuality.HIGH.qualityFraction
619+
)
616620
}
617621
VideoSettingsHelper.PlaybackMode.BEST -> {
618622
playerView.setHLSVideoUri(Uri.parse(videoStream.hlsUrl))
619-
playerView.setDesiredQuality(VideoSettingsHelper.VideoQuality.BEST.qualityFraction)
623+
playerView.setDesiredQuality(
624+
VideoSettingsHelper.VideoQuality.BEST.qualityFraction
625+
)
620626
}
621627
VideoSettingsHelper.PlaybackMode.LEGACY_HD -> {
622628
playerView.setProgressiveVideoUri(Uri.parse(videoStream.hdUrl))
@@ -842,12 +848,7 @@ open class VideoStreamPlayerFragment : BaseFragment() {
842848
if (setVideo(videoSettingsHelper.currentMode)) {
843849
updateSubtitles()
844850
updatePlaybackSpeed()
845-
if (isOfflineVideo) {
846-
// ToDo
847-
/*playerView.uri?.let {
848-
playerView.setPreviewUri(it)
849-
}*/
850-
} else if (context.isOnline) {
851+
if (!isOfflineVideo && context.isOnline) {
851852
if (videoStream.sdUrl != null) {
852853
playerView.setPreviewUri(Uri.parse(videoStream.sdUrl))
853854
} else if (videoStream.hdUrl != null) {

app/src/main/java/de/xikolo/download/hlsvideodownload/HlsVideoDownloadHandler.kt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,11 @@ object HlsVideoDownloadHandler :
218218
}
219219
val closestBitrate = closestFormat?.bitrate
220220

221-
val estimatedSize = (closestFormat?.averageBitrate
222-
?.takeUnless { it == Format.NO_VALUE }
223-
?: closestBitrate)
221+
val estimatedSize = (
222+
closestFormat?.averageBitrate
223+
?.takeUnless { it == Format.NO_VALUE }
224+
?: closestBitrate
225+
)
224226
?.times(manifest.mediaPlaylist.durationUs)
225227
?.div(8000000) // to bytes and seconds
226228

@@ -274,15 +276,17 @@ object HlsVideoDownloadHandler :
274276
if (request.storage == context.internalStorage) {
275277
Log.i(
276278
TAG,
277-
"Starting downloading to internal storage: ${request.url} aka $identifier"
279+
"Starting downloading to internal storage: " +
280+
"${request.url} aka $identifier"
278281
)
279282
HlsVideoDownloadInternalStorageForegroundService::class.java
280283
} else if (request.storage == context.sdcardStorage &&
281284
getSdcardStorageCache(context) != null
282285
) {
283286
Log.i(
284287
TAG,
285-
"Starting downloading to sdcard storage: ${request.url} aka $identifier"
288+
"Starting downloading to sdcard storage: " +
289+
"${request.url} aka $identifier"
286290
)
287291
HlsVideoDownloadSdcardStorageForegroundService::class.java
288292
} else {
@@ -409,7 +413,8 @@ object HlsVideoDownloadHandler :
409413
private fun getDownloadStatus(download: Download?): DownloadStatus {
410414
if (download == null) {
411415
Log.w(
412-
TAG, "getDownloadStatus(): Download not found, default status is generated: " +
416+
TAG,
417+
"getDownloadStatus(): Download not found, default status is generated: " +
413418
"${download?.request?.id}"
414419
)
415420
return DownloadStatus(null, null, DownloadStatus.State.DELETED, null)
@@ -423,7 +428,9 @@ object HlsVideoDownloadHandler :
423428
?: download.bytesDownloaded * 100 / download.percentDownloaded
424429
}.toLong()
425430
val state = when (download.state) {
426-
Download.STATE_QUEUED, Download.STATE_RESTARTING, Download.STATE_REMOVING -> DownloadStatus.State.PENDING
431+
Download.STATE_QUEUED,
432+
Download.STATE_RESTARTING,
433+
Download.STATE_REMOVING -> DownloadStatus.State.PENDING
427434
Download.STATE_DOWNLOADING -> DownloadStatus.State.RUNNING
428435
Download.STATE_COMPLETED -> DownloadStatus.State.DOWNLOADED
429436
else -> DownloadStatus.State.DELETED
@@ -434,8 +441,9 @@ object HlsVideoDownloadHandler :
434441
} else null
435442

436443
Log.d(
437-
TAG, "getDownloadStatus(): Generated download status [${state.name}]" +
438-
"${downloaded}/${totalSize} B (error: ${error}) for ${download.request.id}"
444+
TAG,
445+
"getDownloadStatus(): Generated download status [${state.name}]" +
446+
"$downloaded/$totalSize B (error: ${error}) for ${download.request.id}"
439447
)
440448
return DownloadStatus(totalSize, downloaded, state, error)
441449
}

app/src/main/java/de/xikolo/download/hlsvideodownload/HlsVideoDownloadItem.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ open class HlsVideoDownloadItem(
5050
)
5151
}
5252

53-
private fun getMediaSource(storage: Storage): Pair<HlsMediaSource, Map<String, SingleSampleMediaSource>>? {
53+
private fun getMediaSource(storage: Storage)
54+
: Pair<HlsMediaSource, Map<String, SingleSampleMediaSource>>? {
5455
return getIndexEntry(storage)?.let { indexEntry ->
5556
HlsMediaSource.Factory(
5657
CacheDataSource.Factory()

app/src/main/java/de/xikolo/models/Video.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ open class Video : RealmObject() {
105105
val streamToPlay: VideoStream?
106106
get() {
107107
return if (singleStream != null && (
108-
singleStream?.hlsUrl != null || singleStream?.hdUrl != null ||
108+
singleStream?.hlsUrl != null ||
109+
singleStream?.hdUrl != null ||
109110
singleStream?.sdUrl != null
110111
)
111112
) {
112113
singleStream
113114
} else if (lecturerStream != null && (
114-
lecturerStream?.hlsUrl != null || lecturerStream?.hdUrl != null ||
115+
lecturerStream?.hlsUrl != null ||
116+
lecturerStream?.hdUrl != null ||
115117
lecturerStream?.sdUrl != null
116118
)
117119
) {

app/src/main/java/de/xikolo/views/ExoPlayerVideoView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ open class ExoPlayerVideoView : PlayerView {
261261
false
262262
}
263263
}
264+
} finally {
265+
mediaMetadataRetriever?.release()
264266
}
265267
}
266268
previewPrepareThread.start()

0 commit comments

Comments
 (0)