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
// Somewhere on the UI thread | |
class MyActivity : Activity { | |
val repo: ArtistRepository | |
//... | |
fun getData() { | |
showProgress() | |
disposable = repo.fetchEvents(artist) | |
.subscribe { | |
hideProgress |
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
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 |
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
// Somewhere on the UI thread | |
class MyActivity : Activity { | |
val eventBus: EventBus | |
//... | |
fun getData() { | |
showProgress() | |
eventBus.post(FetchArtistEventsEvent(artist)) | |
} | |
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
// Somewhere on the UI thread | |
class MyActivity : Activity { | |
//... | |
fun getData() { | |
showProgress() | |
GetArtistEvents(database, api, sharedPreferences).execute(artist) | |
} | |
} |