diff --git a/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.java b/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.java index e69de29b..58e3af7c 100644 --- a/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.java +++ b/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.java @@ -0,0 +1,26 @@ +package org.apache.fineract.data.remote; + +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import okhttp3.ResponseBody; +import retrofit2.Converter; +import retrofit2.Retrofit; + +public class NullOnEmptyConverterFactory extends Converter.Factory { + + @Override + public Converter responseBodyConverter(Type type, Annotation[] annotations, + Retrofit retrofit) { + final Converter delegate = retrofit.nextResponseBodyConverter(this, type, + annotations); + return new Converter() { + @Override + public Object convert(ResponseBody body) throws IOException { + if (body.contentLength() == 0) return null; + return delegate.convert(body); + } + }; + } +} diff --git a/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.kt b/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.kt deleted file mode 100644 index 2b0cecee..00000000 --- a/app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.kt +++ /dev/null @@ -1,19 +0,0 @@ -package org.apache.fineract.data.remote - -import okhttp3.ResponseBody -import retrofit2.Converter -import retrofit2.Retrofit -import java.lang.reflect.Type - -/** - * Created by Ahmad Jawid Muhammadi on 1/6/20 - */ - -class NullOnEmptyConverterFactory : Converter.Factory() { - override fun responseBodyConverter(type: Type?, annotations: Array?, - retrofit: Retrofit): Converter { - val delegate: Converter = retrofit.nextResponseBodyConverter(this, type, - annotations) - return Converter { body -> if (body.contentLength() == 0L) null else delegate.convert(body) } - } -} \ No newline at end of file