Skip to content

Commit

Permalink
Remove usages of Build.VERSION_CODES. (#1907)
Browse files Browse the repository at this point in the history
* Remove usages of Build.VERSION_CODES.

* Spotless.
  • Loading branch information
colinrtwhite authored Oct 25, 2023
1 parent 0f84358 commit 879fb55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions coil-video/src/androidTest/java/coil/FileMediaDataSource.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package coil

import android.media.MediaDataSource
import android.os.Build
import androidx.annotation.RequiresApi
import java.io.File
import java.io.RandomAccessFile

@RequiresApi(Build.VERSION_CODES.M)
@RequiresApi(23)
class FileMediaDataSource(private val file: File) : MediaDataSource() {

private var randomAccessFile: RandomAccessFile? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package coil.fetch

import android.content.Context
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import androidx.test.core.app.ApplicationProvider
import coil.FileMediaDataSource
import coil.ImageLoader
Expand All @@ -10,7 +10,6 @@ import coil.util.assumeTrue
import coil.util.copyAssetToFile
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertTrue
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
Expand All @@ -28,7 +27,8 @@ class MediaDataSourceFetcherTest {

@Test
fun basic() = runTest {
assumeTrue(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
assumeTrue(SDK_INT >= 23)

val file = context.copyAssetToFile("video.mp4")

val dataSource = FileMediaDataSource(file)
Expand All @@ -38,7 +38,7 @@ class MediaDataSourceFetcherTest {

val result = fetcher.fetch()

assertTrue(result is SourceResult)
assertIs<SourceResult>(result)
assertEquals(null, result.mimeType)
assertIs<MediaDataSourceFetcher.MediaSourceMetadata>(result.source.metadata)
}
Expand Down
13 changes: 7 additions & 6 deletions coil-video/src/main/java/coil/fetch/MediaDataSourceFetcher.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package coil.fetch

import android.media.MediaDataSource
import android.os.Build
import androidx.annotation.RequiresApi
import coil.ImageLoader
import coil.decode.DataSource
Expand All @@ -12,7 +11,7 @@ import okio.Source
import okio.Timeout
import okio.buffer

@RequiresApi(Build.VERSION_CODES.M)
@RequiresApi(23)
class MediaDataSourceFetcher(
private val data: MediaDataSource,
private val options: Options,
Expand All @@ -28,7 +27,7 @@ class MediaDataSourceFetcher(
return SourceResult(
source = imageSource,
mimeType = null,
dataSource = DataSource.DISK
dataSource = DataSource.DISK,
)
}

Expand All @@ -43,10 +42,12 @@ class MediaDataSourceFetcher(
}
}

internal class MediaDataSourceOkioSource(private val mediaDataSource: MediaDataSource) : Source {
internal class MediaDataSourceOkioSource(
private val mediaDataSource: MediaDataSource
) : Source {

private var size = mediaDataSource.size
private var position: Long = 0L
private var position = 0L

override fun read(sink: Buffer, byteCount: Long): Long {
if (position >= size) {
Expand All @@ -73,6 +74,6 @@ class MediaDataSourceFetcher(
}
}

@RequiresApi(Build.VERSION_CODES.M)
@RequiresApi(23)
class MediaSourceMetadata(val mediaDataSource: MediaDataSource) : ImageSource.Metadata()
}

0 comments on commit 879fb55

Please sign in to comment.