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.app.Activity | |
import android.content.Intent | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
abstract class CompositionActivity : AppCompatActivity() { | |
private val onCreateFeatures = mutableListOf<CompositionActivity.OnCreateFeature>() | |
private val onStartFeatures = mutableListOf<CompositionActivity.OnStartFeature>() | |
private val onResumeFeatures = mutableListOf<CompositionActivity.OnResumeFeature>() |
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
@ColorInt fun Context.color(@ColorRes id: Int, theme: Resources.Theme? = getTheme()): Int = | |
if (Build.VERSION.SDK_INT >= 23) | |
resources.getColor(id, theme) | |
else | |
resources.getColor(id) |
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 View.createSnackbar(text: String, | |
duration: Int = Snackbar.LENGTH_SHORT, | |
actionLabel: String = "Action", | |
dismissOnAction: Boolean = true, | |
action: ((View) -> Unit)? = null): Snackbar { | |
val snackbar = Snackbar.make(this, text, duration) | |
action?.let { | |
snackbar.setAction(actionLabel, { | |
action(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
/** Set the View visibility to VISIBLE and eventually animate the View alpha till 100% */ | |
fun View.visible(animate: Boolean = true) { | |
if (animate) { | |
animate().alpha(1f).setDuration(300).setListener(object : AnimatorListenerAdapter() { | |
override fun onAnimationStart(animation: Animator) { | |
super.onAnimationStart(animation) | |
visibility = View.VISIBLE | |
} | |
}) | |
} else { |
OlderNewer