Skip to content

Instantly share code, notes, and snippets.

View jerrellmardis's full-sized avatar

Jerrell Mardis jerrellmardis

View GitHub Profile
@jerrellmardis
jerrellmardis / ExponentialBackoff
Last active June 3, 2019 13:10
Exponential Backoff using Rx.retryWhen()
// retries up to 3 times while exponentially backing off with each retry
.retryWhen(errors ->
errors
.zipWith(
Observable.range(1, MAX_RETRIES), (n, i) -> i
)
.flatMap(
retryCount -> Observable.timer((long) Math.pow(4, retryCount), TimeUnit.SECONDS)
)
)
@jerrellmardis
jerrellmardis / DisplayTimeoutTileService.java
Created June 3, 2016 22:10
A quick example demonstrating how to create a Quick Settings Tile using the new Quick Settings Tile API introduced in Android N.
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.widget.Toast;
import java.util.concurrent.TimeUnit;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
/**