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
//Adding a submodule: | |
git submodule add git@github.com:GreenLionSoft/xxxx.git folderName | |
git submodule init | |
git submodule update | |
cd folderName | |
git checkout xxxx | |
//Config for checking submodules before pushing | |
git config push.recurseSubmodules check |
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
//Our function Zips error emissions with a range to limit them to 3, | |
// and emits a 0L with a power of 2 based delay | |
webservice.getRequestSingle() | |
.retryWhen { errors: Flowable<Throwable> -> | |
errors.zipWith( | |
Flowable.range(1,3) | |
BiFunction<Throwable, Int, Int> { error: Throwable, retryCount: Int -> | |
retryCount | |
} | |
).flatMap { retryCount: Int -> |
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
//////////// | |
// Kotlin // | |
//////////// | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1" | |
//////////////// | |
// Unit Tests // | |
//////////////// |
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
grep -rnw '.' -e 'android.support' |
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
// Our function Zips error emissions with a range to limit them to 3, | |
// and emits a 0L with a power of 2 based delay | |
// if limit of retries is reached error is thrown to ensure it reaches | |
// our subscribe block | |
val RETRIES_LIMIT = 3 | |
webservice.getRequestSingle() | |
.retryWhen { errors: Flowable<Throwable> -> | |
errors.zipWith( | |
Flowable.range(1, RETRIES_LIMIT + 1) | |
Bifunction<Throwable, Int, Int> { error: Throwable, retryCount: Int -> |
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
// Our function Zips error emissions with a range to limit them to 3, | |
// and emits a 0L with a power of 2 based delay. | |
// If emitted error is an UnknownHostException no more retries are done and | |
// error is thrown, otherwise if the limit of retries is reached error is | |
// thrown too, in both cases to ensure it reaches our subscribe block | |
val RETRIES_LIMIT = 3 | |
webservice.getRequestSingle() | |
.retryWhen { errors: Flowable<Throwable> -> | |
errors.zipWith( | |
Flowable.range(1, RETRIES_LIMIT + 1) |
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
//This observable timeline would be: | |
//0:00 Subscription takes place | |
//0:02 emits "0L" after 2 seconds | |
//0:04 emits "0L" after 4 seconds | |
//0:08 emits "0L" after 8 seconds | |
Observable.range(1,3).flatMap { retryCount -> | |
Observable.timer(Math.pow(2.toDouble(), retryCount.toDouble()).toLong(), TimeUnit.SECONDS) | |
} |
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
//retryCount is a Long variable value | |
//eg. When retryCount = 1, observable emmits a 0L after 2 sec, then completes | |
//eg. When retryCount = 2, observable emmits a 0L after 4 sec, then completes | |
//eg. When retryCount = 3, observable emmits a 0L after 8 sec, then completes | |
Observable.timer(Math.pow(2.toDouble(), retryCount.toDouble()).toLong(), TimeUnit.SECONDS) |
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
//It emits "1", "2", "3" then signals completion | |
Observable.range(1,3) |
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
class FavoritesProvider : IFavoritesProvider { | |
val database = FirebaseDatabase.getInstance() | |
val gson = Gson() | |
val favoritesCache = FavoritesMemoryCache() | |
override fun saveBusStopFavoritesList(favorites: List<BusStopFavorite>) { | |
//save in cache | |
favoritesCache.saveBusStopFavoritesList(favorites) | |
//save in remote |
NewerOlder