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
```groovy | |
afterEvaluate { | |
// All proguard tasks shall depend on our filter task | |
def proguardTasks = tasks.findAll { task -> | |
task.name.startsWith('transformClassesAndResourcesWithProguardFor') } | |
proguardTasks.each { task -> task.dependsOn filterConsumerRules } | |
} | |
// Let define our custom task that filters some unwanted | |
// consumer proguard rules |
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
internal object DataStoreFactory { | |
private val mapToDataStore = ConcurrentHashMap<String, DataStore<Preferences>>() | |
fun create( | |
name: String, | |
context: Context | |
): DataStore<Preferences> { | |
if (mapToDataStore.containsKey(name).not()) { | |
mapToDataStore[name] = context.getDataStore( |
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 Detail | |
*/ | |
interface FooPresenterContract { | |
interface Presenter { | |
fun doWork() | |
} | |
interface View { | |
fun inflated(message: String) |
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 FooPresenterTest { | |
private val view = mock<FooPresenterContract.View>() | |
private val presenter: FooPresenterContract.Presenter = FooPresenter(view) | |
@Test | |
fun testDoWork() { | |
presenter.doWork() | |
verify(view).inflated("it was success!") |
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
protocol Dao { | |
func insert(key: String, value: Any) -> Bool | |
func find(key: String) -> Any? | |
} | |
protocol StoreAdapterFactory { | |
func create() -> Dao | |
} | |
class StoreMemoryAdapter : Dao { |
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 Contact { | |
private(set) lazy var name: String | |
private(set) lazy var phoneNumber: String | |
private(set) lazy var address: String | |
private(set) lazy var gender: String | |
private init( | |
name: String, | |
phoneNumber: String, | |
address: String, |
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
fun main() { | |
val les = Executors.newFixedThreadPool(5) | |
for (i in 0..9) { | |
val worker: Runnable = WorkerThread("" + i) | |
les.execute(worker) | |
} | |
les.shutdown() | |
while (!les.isTerminated) { } | |
println("Finished all threads") | |
} |
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
{ | |
"success": { | |
"total": 1 | |
}, | |
"contents": { | |
"quotes": [ | |
{ | |
"quote": "I came from a real tough neighborhood. Once a guy pulled a knife on me. I knew he wasn't a professional, the knife had butter on it.", | |
"length": "132", | |
"author": "Rodney Dangerfield", |
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
override fun doSomeWork() { | |
val d = Observable.create(ObservableOnSubscribe<String> { e -> | |
for (i in 0 until 10) { | |
val number = Math.pow(Random().nextInt(100).toDouble(), Random().nextInt(100).toDouble()) | |
e.onNext(number.toString()) | |
} | |
e.onComplete() | |
}).compose(loading { isShow -> | |
if (isShow) { | |
view.showLoading() |
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
interface Universal<in T> { | |
fun addAll(items: Collection<T>) | |
fun add(item: T) | |
fun update(item: T) | |
fun updateRange(vararg items: T) | |
fun remove(item: T, position: Int) |
NewerOlder