Lint: fix KotlinNullnessAnnotation warning
This commit is contained in:
parent
0d1fb843b1
commit
0d2fb8e3d0
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.di
|
package org.matrix.android.sdk.internal.di
|
||||||
|
|
||||||
import androidx.annotation.Nullable
|
|
||||||
import com.squareup.moshi.JsonAdapter
|
import com.squareup.moshi.JsonAdapter
|
||||||
import com.squareup.moshi.JsonQualifier
|
import com.squareup.moshi.JsonQualifier
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
|
@ -28,7 +27,6 @@ import java.lang.reflect.Type
|
||||||
internal annotation class SerializeNulls {
|
internal annotation class SerializeNulls {
|
||||||
companion object {
|
companion object {
|
||||||
val JSON_ADAPTER_FACTORY: JsonAdapter.Factory = object : JsonAdapter.Factory {
|
val JSON_ADAPTER_FACTORY: JsonAdapter.Factory = object : JsonAdapter.Factory {
|
||||||
@Nullable
|
|
||||||
override fun create(type: Type, annotations: Set<Annotation>, moshi: Moshi): JsonAdapter<*>? {
|
override fun create(type: Type, annotations: Set<Annotation>, moshi: Moshi): JsonAdapter<*>? {
|
||||||
val nextAnnotations = Types.nextAnnotations(annotations, SerializeNulls::class.java)
|
val nextAnnotations = Types.nextAnnotations(annotations, SerializeNulls::class.java)
|
||||||
?: return null
|
?: return null
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.network.interceptors
|
package org.matrix.android.sdk.internal.network.interceptors
|
||||||
|
|
||||||
import androidx.annotation.NonNull
|
|
||||||
import okhttp3.logging.HttpLoggingInterceptor
|
import okhttp3.logging.HttpLoggingInterceptor
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -38,7 +37,7 @@ internal class FormattedJsonHttpLogger(
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun log(@NonNull message: String) {
|
override fun log(message: String) {
|
||||||
Timber.v(message)
|
Timber.v(message)
|
||||||
|
|
||||||
// Try to log formatted Json only if there is a chance that [message] contains Json.
|
// Try to log formatted Json only if there is a chance that [message] contains Json.
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.network.parsing
|
package org.matrix.android.sdk.internal.network.parsing
|
||||||
|
|
||||||
import androidx.annotation.Nullable
|
|
||||||
import com.squareup.moshi.JsonAdapter
|
import com.squareup.moshi.JsonAdapter
|
||||||
import com.squareup.moshi.JsonReader
|
import com.squareup.moshi.JsonReader
|
||||||
import com.squareup.moshi.JsonWriter
|
import com.squareup.moshi.JsonWriter
|
||||||
|
@ -32,14 +31,12 @@ internal interface CheckNumberType {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val JSON_ADAPTER_FACTORY = object : JsonAdapter.Factory {
|
val JSON_ADAPTER_FACTORY = object : JsonAdapter.Factory {
|
||||||
@Nullable
|
|
||||||
override fun create(type: Type, annotations: Set<Annotation>, moshi: Moshi): JsonAdapter<*>? {
|
override fun create(type: Type, annotations: Set<Annotation>, moshi: Moshi): JsonAdapter<*>? {
|
||||||
if (type !== Any::class.java) {
|
if (type !== Any::class.java) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val delegate: JsonAdapter<Any> = moshi.nextAdapter(this, Any::class.java, emptySet())
|
val delegate: JsonAdapter<Any> = moshi.nextAdapter(this, Any::class.java, emptySet())
|
||||||
return object : JsonAdapter<Any?>() {
|
return object : JsonAdapter<Any?>() {
|
||||||
@Nullable
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
override fun fromJson(reader: JsonReader): Any? {
|
override fun fromJson(reader: JsonReader): Any? {
|
||||||
return if (reader.peek() !== JsonReader.Token.NUMBER) {
|
return if (reader.peek() !== JsonReader.Token.NUMBER) {
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
<issue id="UseValueOf" severity="error" />
|
<issue id="UseValueOf" severity="error" />
|
||||||
<issue id="ObsoleteSdkInt" severity="error" />
|
<issue id="ObsoleteSdkInt" severity="error" />
|
||||||
<issue id="Recycle" severity="error" />
|
<issue id="Recycle" severity="error" />
|
||||||
|
<issue id="KotlinNullnessAnnotation" severity="error" />
|
||||||
<issue id="KotlinPropertyAccess" severity="error" />
|
<issue id="KotlinPropertyAccess" severity="error" />
|
||||||
<issue id="DefaultLocale" severity="error" />
|
<issue id="DefaultLocale" severity="error" />
|
||||||
<issue id="CheckResult" severity="error" />
|
<issue id="CheckResult" severity="error" />
|
||||||
|
|
|
@ -18,7 +18,6 @@ package im.vector.app.core.resources
|
||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import androidx.annotation.ArrayRes
|
import androidx.annotation.ArrayRes
|
||||||
import androidx.annotation.NonNull
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class StringArrayProvider @Inject constructor(private val resources: Resources) {
|
class StringArrayProvider @Inject constructor(private val resources: Resources) {
|
||||||
|
@ -31,7 +30,6 @@ class StringArrayProvider @Inject constructor(private val resources: Resources)
|
||||||
* @return The string array associated with the resource, stripped of styled
|
* @return The string array associated with the resource, stripped of styled
|
||||||
* text information.
|
* text information.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
|
||||||
fun getStringArray(@ArrayRes resId: Int): Array<String> {
|
fun getStringArray(@ArrayRes resId: Int): Array<String> {
|
||||||
return resources.getStringArray(resId)
|
return resources.getStringArray(resId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package im.vector.app.core.resources
|
package im.vector.app.core.resources
|
||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import androidx.annotation.NonNull
|
|
||||||
import androidx.annotation.PluralsRes
|
import androidx.annotation.PluralsRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -32,7 +31,6 @@ class StringProvider @Inject constructor(private val resources: Resources) {
|
||||||
* @return The string data associated with the resource, stripped of styled
|
* @return The string data associated with the resource, stripped of styled
|
||||||
* text information.
|
* text information.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
|
||||||
fun getString(@StringRes resId: Int): String {
|
fun getString(@StringRes resId: Int): String {
|
||||||
return resources.getString(resId)
|
return resources.getString(resId)
|
||||||
}
|
}
|
||||||
|
@ -48,12 +46,10 @@ class StringProvider @Inject constructor(private val resources: Resources) {
|
||||||
* @return The string data associated with the resource, formatted and
|
* @return The string data associated with the resource, formatted and
|
||||||
* stripped of styled text information.
|
* stripped of styled text information.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
|
||||||
fun getString(@StringRes resId: Int, vararg formatArgs: Any?): String {
|
fun getString(@StringRes resId: Int, vararg formatArgs: Any?): String {
|
||||||
return resources.getString(resId, *formatArgs)
|
return resources.getString(resId, *formatArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
fun getQuantityString(@PluralsRes resId: Int, quantity: Int, vararg formatArgs: Any?): String {
|
fun getQuantityString(@PluralsRes resId: Int, quantity: Int, vararg formatArgs: Any?): String {
|
||||||
return resources.getQuantityString(resId, quantity, *formatArgs)
|
return resources.getQuantityString(resId, quantity, *formatArgs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue