Skip to content

Instantly share code, notes, and snippets.

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

raditya gumay radityagumay

🏠
Working from home
View GitHub Profile
@radityagumay
radityagumay / NetworkBuilder.swift
Created September 10, 2020 15:57
Network Builder in Swift based on Android Retrofit Builder Pattern
protocol Dao {
func insert(key: String, value: Any) -> Bool
func find(key: String) -> Any?
}
protocol StoreAdapterFactory {
func create() -> Dao
}
class StoreMemoryAdapter : Dao {
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!")
/**
* Implementation Detail
*/
interface FooPresenterContract {
interface Presenter {
fun doWork()
}
interface View {
fun inflated(message: String)
@radityagumay
radityagumay / DataStoreFactory.kt
Last active March 30, 2021 00:05
Singleton Class to Manage DataStore
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(
@radityagumay
radityagumay / proguard-aftertask.gradle
Created July 20, 2021 23:19
Delete certain proguard rule
```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