This file contains 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 android.app.Application | |
import android.util.Log | |
import co.myapp.BuildConfig | |
import co.myapp.infrastructure.manager.InternetManager | |
import co.myapp.infrastructure.manager.interfaces.AuthenticationManager | |
import com.facebook.stetho.Stetho | |
import com.facebook.stetho.okhttp3.StethoInterceptor | |
import com.google.gson.Gson | |
import com.readystatesoftware.chuck.ChuckInterceptor | |
import okhttp3.Cache |
This file contains 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 retrofit2.Response | |
import retrofit2.Retrofit | |
import timber.log.Timber | |
import java.io.IOException | |
class ServerException internal constructor( | |
message: String?, | |
/** | |
* The request URL which produced the error. | |
*/ |
This file contains 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
version: 2 | |
jobs: | |
check-build: | |
docker: | |
# specify the version you desire here | |
- image: circleci/android:api-27-alpha | |
working_directory: ~/code | |
steps: | |
- checkout | |
- run: echo "Running..." |
This file contains 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
//------- | |
private ExampleNetwork mExampleNetwork; | |
private void getDetails(String id) { | |
mExampleNetwork.getCachedDetails(id) // From Cache | |
.doFinally(() -> { | |
mExampleNetwork | |
.getDetails(id) // From Network |
This file contains 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
// ------- | |
private IExampleNetwork mIExampleNetwork, mICachedExampleNetwork; | |
ExampleNetwork(RetrofitManager retrofitManager) { | |
mIExampleNetwork = retrofitManager.getRetrofit().create(IExampleNetwork.class); | |
mICachedExampleNetwork = retrofitManager.getCachedRetrofit().create(IExampleNetwork.class); | |
} | |
interface IExampleNetwork { |
This file contains 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
//------- | |
public static final String BASE_URL = "https://lateralview.co"; | |
public static final String HEADER_CACHE_CONTROL = "Cache-Control"; | |
public static final String HEADER_PRAGMA = "Pragma"; | |
private Context mContext; | |
//------- |
This file contains 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
public class RetrofitManager { | |
public static final String TAG = "RetrofitManager"; | |
public static final String BASE_URL = "https://lateralview.co"; | |
public static final String HEADER_CACHE_CONTROL = "Cache-Control"; | |
public static final String HEADER_PRAGMA = "Pragma"; | |
private Context mContext; | |
private Retrofit mRetrofit, mCachedRetrofit; |
This file contains 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 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
//--- | |
Single.create((SingleOnSubscribe<String>) e -> e.onSuccess(makeBlockingTask())) | |
.subscribeOn(Schedulers.io()) //Run on IO Thread | |
.observeOn(AndroidSchedulers.mainThread()) //Run on UI Thread | |
.doOnSubscribe(__ -> showLoadingIndicator()) | |
.doFinally(() -> hideLoadingIndicator()) | |
.subscribe(this::processResult, | |
this::processError); |
This file contains 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
//--- | |
Observable | |
.just(1, 2, 3, 4, 5) | |
.filter(integer -> integer % 2 != 0) | |
.subscribe( | |
integer -> Log.i(TAG, String.valueOf(integer)), | |
error -> Log.e(TAG, "Error"), | |
() -> Log.i(TAG, "No more results") | |
); |
NewerOlder