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 kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.async | |
import kotlinx.coroutines.suspendCancellableCoroutine | |
import kotlinx.coroutines.withContext | |
import java.io.File | |
class UploadFilesUseCase : BaseBusyObservable<UploadFilesUseCase.Listener>() { | |
interface Listener { | |
fun onFilesUploaded() |
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 UploadFilesUseCase( | |
private val schedulerProvider: SchedulerProvider, | |
private val httpManager: HttpManager | |
) { | |
private var operation: Completable? = null | |
fun uploadFiles(): Completable = synchronized(this) { | |
operation | |
?: (doUploadFiles() |
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
public abstract class BaseBusyObservable<LISTENER_CLASS> extends BaseObservable<LISTENER_CLASS> { | |
private final AtomicBoolean mIsBusy = new AtomicBoolean(false); | |
public final boolean isBusy() { | |
return mIsBusy.get(); | |
} | |
/** | |
* Atomically assert not busy and become busy |
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
public abstract class BaseObservable<LISTENER_CLASS> { | |
private final Object MONITOR = new Object(); | |
private final Set<LISTENER_CLASS> mListeners = new HashSet<>(); | |
public void registerListener(LISTENER_CLASS listener) { | |
synchronized (MONITOR) { | |
boolean hadNoListeners = mListeners.size() == 0; | |
mListeners.add(listener); |
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
#!/bin/bash | |
directory=_site | |
branch=gh-pages | |
build_command() { | |
jekyll build | |
} | |
echo -e "\033[0;32mDeleting existing $branch...\033[0m" | |
git push origin --delete $branch | |
git branch -D $branch |
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
/* Copyright 2019 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, |
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
@ExperimentalCoroutinesApi | |
class CoroutinesTestRule( | |
val testDispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher() | |
) : TestWatcher() { | |
override fun starting(description: Description?) { | |
super.starting(description) | |
Dispatchers.setMain(testDispatcher) | |
} |
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
@Module | |
abstract class FragmentBindingModule { | |
@Binds | |
abstract fun bindFragmentFactory(factory: FragmentInjectionFactory): FragmentFactory | |
@Binds | |
@IntoMap | |
@FragmentKey(MainFragment::class) | |
abstract fun bindMainFragment(fragment: MainFragment): Fragment |
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 kotlinx.coroutines.experimental.android.Main | |
import kotlinx.coroutines.experimental.CoroutineScope | |
class ExampleActivity : Activity(), CoroutineScope by CoroutineScope(Dispatchers.Main) { | |
override fun onCreate(savedInstanceState: Bundle?) | |
super.onCreate(savedInstanceState) | |
val ui = Ui(this) // bind views, etc | |
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
#!/bin/bash | |
directory=_site | |
branch=gh-pages | |
build_command() { | |
jekyll build | |
} | |
echo -e "\033[0;32mDeleting old content...\033[0m" | |
rm -rf $directory |
NewerOlder