This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // for any errors that should be handled before being handed off to RxJava. | |
| // In other words global error logic. | |
| // An example might be 401 when not logging in | |
| import okhttp3.Interceptor | |
| import okhttp3.Response | |
| class ErrorInterceptor: Interceptor { | |
| override fun intercept(chain: Interceptor.Chain?): Response { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Dagger 1 example | |
| @Module( | |
| complete = false, | |
| library = true | |
| ) | |
| public final class ApiModule { | |
| @Provides | |
| @Singleton | |
| Retrofit provideRetrofit(Gson gson, Application app) { | |
| return new Retrofit.Builder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.lang.annotation.Annotation; | |
| import java.lang.reflect.Type; | |
| import io.reactivex.Completable; | |
| import io.reactivex.Observable; | |
| import io.reactivex.ObservableSource; | |
| import io.reactivex.Single; | |
| import io.reactivex.SingleSource; | |
| import io.reactivex.annotations.NonNull; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Zlib decompress a file and return its contents | |
| * | |
| * @param filePath absolute path to file | |
| * @return unzipped file contents | |
| */ | |
| fun decompress(filePath: String) : String { | |
| val content = File(filePath).readBytes() | |
| val inflater = Inflater() | |
| val outputStream = ByteArrayOutputStream() |