val user = User(id = "id", name = "Ruby")
val userFragment: UserFragment = newFragment<User, UserFragment>(user)
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
@Target(AnnotationTarget.CLASS) | |
@Retention(AnnotationRetention.SOURCE) | |
/** | |
* Friendly reminder that this might not be the best place to do major changes. Or any changes at all. | |
* Use the [reason] arg to point your teammates and your future-self to some documentation. | |
*/ | |
annotation class HereBeDragons(val reason: 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
interface TasksRepository { | |
suspend fun tasks(user: User): Either<RepositoryError, List<Task>> | |
} | |
fun tasks(tasksRepository: TasksRepository, userRepository: UserRepository): | |
() -> Either<RepositoryError, List<Task>> = { | |
runBlocking { tasksRepository.tasks(userRepository.currentUser()) } // This is b | |
} | |
UseCase<RepositoryError, List<Task>>().bg(tasks(tasksRepository, userRepository)) |
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
inline fun <A> A.logWith(logger: Logger, block: Logger.(A) -> Unit) : A = | |
this.also { logger.block(it) } | |
// With interface injection | |
interface HasLog { | |
val log: Logger | |
fun <A> A.log(block: Logger.(A) -> Unit) : A = | |
logWith(logger, block) | |
} |
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
package com.sloydev.macookbuk.infrastructure.extensions | |
import android.arch.lifecycle.* | |
fun <T, R> LiveData<T>.map(transformation: (T) -> R): LiveData<R> { | |
return Transformations.map(this, transformation) | |
} | |
fun <A, B, C> LiveData<A>.zipWith(other: LiveData<B>, zipFunc: (A, B) -> C): LiveData<C> { | |
return ZippedLiveData<A, B, C>(this, other, zipFunc) |
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 android.content.res.Resources | |
import android.graphics.drawable.Drawable | |
import android.support.annotation.AnyRes | |
import android.support.v4.app.Fragment | |
import android.support.v4.content.res.ResourcesCompat.* | |
import android.view.View | |
val Context.animations | |
get() = ResourceMapper { resources.getAnimation(it) } |
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
package be.brol | |
import android.os.Binder | |
import android.os.Bundle | |
import android.support.v4.app.BundleCompat | |
import android.support.v4.app.Fragment | |
/** | |
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate | |
* Just write the property in newInstance and read it like any other property after the fragment has been created |
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
/** | |
_____ _____ _ | |
| __ \ / ____| | | | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __ | |
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__| | |
| |__| | __/ |____| | | |_| | |_) | || (_) | | | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_| | |
__/ | | | |
|___/|_| | |
*/ |
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 class LoginActivity extends AppCompatActivity { | |
private static final int RC_SIGN_IN = 343; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); |
NewerOlder