View GetReposManagedRestRequest_usage.kt
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
GetReposManagedRestRequest( | |
workManager = workManager, | |
baseUrl = "https://api.github.com/", | |
user = "RoRoche" | |
).liveData().observe( | |
lifecycleOwner, | |
Observer { workInfo -> | |
if (workInfo != null) { | |
// check with workInfo.state and deal with it | |
} |
View GetReposManagedRestRequest.kt
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 androidx.work.* | |
class GetReposManagedRestRequest(origin: ManagedRestRequest) : ManagedRestRequest.Wrap(origin) { | |
constructor( | |
workManager: WorkManager, | |
worker: OneTimeWorkRequest | |
) : this( | |
SimpleOneTimeWorkRequest(workManager, worker) | |
) |
View SimpleOneTimeWorkRequest.kt
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 androidx.work.OneTimeWorkRequest | |
import androidx.work.Operation | |
import androidx.work.WorkManager | |
class SimpleOneTimeWorkRequest( | |
private val workManager: WorkManager, | |
private val worker: OneTimeWorkRequest, | |
private val operation: Operation | |
) : ManagedRestRequest { |
View ManagedRestRequest.kt
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 androidx.lifecycle.LiveData | |
import androidx.work.Operation | |
import androidx.work.WorkInfo | |
interface ManagedRestRequest { | |
fun operation(): Operation | |
fun liveData(): LiveData<WorkInfo> | |
fun cancel(): Operation | |
abstract class Wrap protected constructor( |
View GetReposWorker.kt
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.content.Context | |
import androidx.work.Worker | |
import androidx.work.WorkerParameters | |
import okhttp3.OkHttpClient | |
class GetReposWorker( | |
appContext: Context, | |
workerParams: WorkerParameters | |
) : Worker(appContext, workerParams) { | |
override fun doWork(): Result { |
View build_rx.gradle
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
implementation group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.14' | |
implementation group: 'io.reactivex.rxjava2', name: 'rxandroid', version: '2.1.1' | |
implementation group: 'io.reactivex.rxjava2', name: 'rxkotlin', version: '2.4.0' |
View RxGetReposRequest_usage.kt
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
RxGetReposRequest( | |
restRequest = WithBodyRestRequest( | |
SuccessfulRestRequest( | |
LoggableRequest( | |
GetReposRequest( | |
client = client, | |
baseUrl = "https://api.github.com/", | |
user = "RoRoche" | |
) | |
) |
View RxGetReposRequest.kt
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 io.reactivex.Single | |
import okhttp3.OkHttpClient | |
class RxGetReposRequest( | |
restRequest: RestRequest | |
) : RxRestRequest.WrapSyncRequest<List<Repo>>(restRequest) { | |
override fun single(): Single<List<Repo>> { | |
return Single.create { emitter -> | |
try { | |
val repos = JsonRepos(restRequest) |
View RxRestRequest.kt
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 io.reactivex.Single | |
interface RxRestRequest<T> { | |
fun single(): Single<T> | |
abstract class WrapSyncRequest<T>(protected val restRequest: RestRequest) : RxRestRequest<T> | |
} |
View NoBodyRestResponseException.kt
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 NoBodyRestResponseException : RuntimeException() |
NewerOlder