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 { |
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
@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
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
import io.reactivex.Observable | |
import io.reactivex.disposables.CompositeDisposable | |
import io.reactivex.disposables.Disposable | |
import io.reactivex.observers.DisposableObserver | |
import io.reactivex.subjects.BehaviorSubject | |
import io.reactivex.subjects.PublishSubject | |
interface ViewState |
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 java.lang.ref.WeakReference | |
/** | |
* Base Interface for all the presenters. | |
* | |
* @param T The type of view (which extends [View]) the presenter is controlling. | |
*/ | |
interface PresenterApi<in T : View> { | |
fun onAttach(v: T) | |
fun onDetach() |
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
<TextView | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:ellipsize="end" | |
android:maxLines="1"/> |
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
/* --- Log functions with Tag as caller class name --- */ | |
inline fun <reified T: Any> T.logD(text: String) { | |
Log.d(T::class.java.simpleName, text) | |
} | |
inline fun <reified T: Any> T.logE(text: String) { | |
Log.e(T::class.java.simpleName, text) | |
} |
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
/** | |
* Custom matcher that checks if a list is equal to expected when elements don't have equals() | |
* using {@link ReflectionEquals}. | |
*/ | |
public static ArgumentMatcher<List> equalsList(List expectedList) { | |
return new ArgumentMatcher<List>() { | |
@Override | |
public boolean matches(Object argument) { | |
List list = (List) argument; | |
boolean assertion; |
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
Atom settings sync |
NewerOlder