Skip to content

Instantly share code, notes, and snippets.

View emitchel's full-sized avatar
🏠
Working from home

Elliot Mitchell emitchel

🏠
Working from home
View GitHub Profile
// Somewhere on the UI thread
class MyActivity : Activity {
val repo: ArtistRepository
//...
fun getData() {
showProgress()
disposable = repo.fetchEvents(artist)
.subscribe {
hideProgress
object RepositoryUtil {
fun getSecondsSinceEpoch() = OffsetDateTime.now().toEpochSecond()
/**
*
* @param cacheKey String - A unique string to represent the cache, ex: GetArtist
* @param keyDescriptor String - A string to give a secondary description ex: ACDC
* @param cacheLengthSeconds Long - How long is the cache considered fresh (use TimeUnit.[MINUTES/HOURS/DAYS].toSeconds(x))
* @return Boolean
// Somewhere on the UI thread
class MyActivity : Activity {
val eventBus: EventBus
//...
fun getData() {
showProgress()
eventBus.post(FetchArtistEventsEvent(artist))
}
// Somewhere on the UI thread
class MyActivity : Activity {
//...
fun getData() {
showProgress()
GetArtistEvents(database, api, sharedPreferences).execute(artist)
}
}