Skip to content
Permalink
Browse files

Fix Android Studio inspection warnings.

  • Loading branch information...
ming13 committed Oct 1, 2019
1 parent f5678f5 commit 7e1034c3a45b8cf4d6517b5e423f0e380b8a4410
@@ -111,7 +111,7 @@ class MuzeiProvider : ContentProvider() {

override fun getType(uri: Uri): String? {
// Chooses the MIME type based on the incoming URI pattern
return when (MuzeiProvider.uriMatcher.match(uri)) {
return when (uriMatcher.match(uri)) {
ARTWORK ->
// If the pattern is for artwork, returns the artwork content type.
MuzeiContract.Artwork.CONTENT_TYPE
@@ -153,7 +153,7 @@ class MuzeiProvider : ContentProvider() {
Log.w(TAG, "Queries are not supported until the user is unlocked")
return null
}
return when(MuzeiProvider.uriMatcher.match(uri)) {
return when(uriMatcher.match(uri)) {
ARTWORK -> queryArtwork(uri, projection, selection, selectionArgs, sortOrder)
ARTWORK_ID -> queryArtwork(uri, projection, selection, selectionArgs, sortOrder)
SOURCES -> querySource(uri, projection)
@@ -180,7 +180,7 @@ class MuzeiProvider : ContentProvider() {
DatabaseUtils.concatenateWhere(selection,
"providerAuthority = \"${provider.authority}\"")
} ?: selection
if (MuzeiProvider.uriMatcher.match(uri) == ARTWORK_ID) {
if (uriMatcher.match(uri) == ARTWORK_ID) {
// If the incoming URI is for a single artwork identified by its ID, appends "_ID = <artworkId>"
// to the where clause, so that it selects that single piece of artwork
finalSelection = DatabaseUtils.concatenateWhere(selection,
@@ -236,7 +236,7 @@ class MuzeiProvider : ContentProvider() {

@Throws(FileNotFoundException::class)
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? {
return when(MuzeiProvider.uriMatcher.match(uri)) {
return when(uriMatcher.match(uri)) {
ARTWORK -> openFileArtwork(uri, mode)
ARTWORK_ID -> openFileArtwork(uri, mode)
else -> throw IllegalArgumentException("Unknown URI $uri")
@@ -253,7 +253,7 @@ class MuzeiProvider : ContentProvider() {
}
val artworkDao = MuzeiDatabase.getInstance(context).artworkDao()
val artwork = ensureBackground {
when (MuzeiProvider.uriMatcher.match(uri)) {
when (uriMatcher.match(uri)) {
ARTWORK -> artworkDao.currentArtworkBlocking
else -> artworkDao.getArtworkByIdBlocking(ContentUris.parseId(uri))
}
@@ -25,9 +25,7 @@ fun Float.constrain(min: Float, max: Float): Float = max(min, min(max, this))
fun interpolate(x1: Float, x2: Float, f: Float): Float = x1 + (x2 - x1) * f

fun uninterpolate(x1: Float, x2: Float, v: Float): Float {
if (x2 - x1 == 0f) {
throw IllegalArgumentException("Can't reverse interpolate with domain size of 0")
}
require(x2 - x1 != 0f) { "Can't reverse interpolate with domain size of 0" }
return (v - x1) / (x2 - x1)
}

@@ -51,7 +51,7 @@ internal interface UnsplashService {
}

@Throws(IOException::class)
internal fun popularPhotos(): List<UnsplashService.Photo> {
internal fun popularPhotos(): List<Photo> {
return createService().popularPhotos.execute().body()
?: throw IOException("Response was null")
}
@@ -52,7 +52,7 @@ class NewWallpaperNotificationReceiver : BroadcastReceiver() {
const val PREF_ENABLED = "new_wallpaper_notification_enabled"
private const val PREF_LAST_READ_NOTIFICATION_ARTWORK_ID = "last_read_notification_artwork_id"

internal const val NOTIFICATION_CHANNEL = "new_wallpaper"
private const val NOTIFICATION_CHANNEL = "new_wallpaper"
private const val NOTIFICATION_ID = 1234

private const val ACTION_MARK_NOTIFICATION_READ = "com.google.android.apps.muzei.action.NOTIFICATION_DELETED"
@@ -61,9 +61,9 @@ class DemoRenderController(
if (allowFocus) {
coroutineScope.launch {
delay(FOCUS_DELAY_TIME_MILLIS)
renderer.setIsBlurred(false, false)
renderer.setIsBlurred(isBlurred = false, artDetailMode = false)
delay(FOCUS_TIME_MILLIS)
renderer.setIsBlurred(true, false)
renderer.setIsBlurred(isBlurred = true, artDetailMode = false)
}
}
}

This file was deleted.

@@ -108,9 +108,7 @@ class GalleryProvider : ContentProvider() {
@Throws(FileNotFoundException::class)
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor? {
val context: Context = context ?: return null
if (mode != "r") {
throw IllegalArgumentException("Only reading chosen photos is allowed")
}
require(mode == "r") { "Only reading chosen photos is allowed" }
val id = ContentUris.parseId(uri)
val chosenPhoto = GalleryDatabase.getInstance(context).chosenPhotoDao()
.chosenPhotoBlocking(id) ?: throw FileNotFoundException("Unable to load $uri")
@@ -59,7 +59,7 @@ class MultiSelectionController(
}
}

callbacks?.onSelectionChanged(true, false)
callbacks?.onSelectionChanged(restored = true, fromUser = false)
}

override fun saveState() = bundleOf(STATE_SELECTION to selection.toLongArray())

0 comments on commit 7e1034c

Please sign in to comment.
You can’t perform that action at this time.