Skip to content

Instantly share code, notes, and snippets.

View folkyatina's full-sized avatar

Aleksei Potapkin folkyatina

View GitHub Profile
suspend inline fun <reified T> Task<T>.await(): T = suspendCoroutine {
addOnCompleteListener { task ->
if (task.isSuccessful) {
// Black magic to make it return Unit instead of null
if (Unit is T) {
it.resume(Unit)
} else {
it.resume(task.result!!)
}
@folkyatina
folkyatina / NavigatorFragment.kt
Last active December 6, 2018 12:48
Super simple MVP for Android + Navigator as an example
package com.songsterr.mvp
/**
* Here is a simple navigational module that can only safely start activities for result
*/
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
@folkyatina
folkyatina / NavigatorFragment.kt
Created August 17, 2018 17:00
Super simple MVP for Android + Navigator as an example
package com.songsterr.mvp
/**
* Here is a simple navigational module that can only safely start activities for result
*/
import android.content.Context
import android.content.Intent
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity