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
@StringDef({ | |
POP, | |
ROCK, | |
JAZZ | |
}) | |
@Retention(RetentionPolicy.SOURCE) | |
public @interface MusicNameType {} |
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
private const val MIRROR = 180F | |
private const val INITIAL_DELAY = 0.15F | |
private val translucentBlack = Color.argb(50, 0, 0, 0) | |
fun speedDial( | |
anchor: View, | |
@ColorInt tint: Int = anchor.context.themeColorAt(R.attr.colorPrimary), | |
@StyleRes animationStyle: Int = android.R.style.Animation_Dialog, | |
layoutAnimationController: LayoutAnimationController = LayoutAnimationController(speedDialAnimation, INITIAL_DELAY).apply { order = ORDER_NORMAL }, |
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 React, { Component } from 'react'; | |
import firebase from '@firebase/app'; | |
import firestore from './firestore'; // Code: https://gist.github.com/sconstantinides/546a48ba183b1234f750ca6261440199 | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
userId: localStorage.getItem('userId') || '', |
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 getValueAnimator(forward: Boolean = true, duration: Long, interpolator: TimeInterpolator, | |
crossinline updateListener: (progress: Float) -> Unit | |
): ValueAnimator { | |
val a = | |
if (forward) ValueAnimator.ofFloat(0f, 1f) | |
else ValueAnimator.ofFloat(1f, 0f) | |
a.addUpdateListener { updateListener(it.animatedValue as Float) } | |
a.duration = duration | |
a.interpolator = interpolator | |
return a |
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
class ToolbarBehavior : CoordinatorLayout.Behavior<AppBarLayout>() { | |
/** Consume if vertical scroll because we don't care about other scrolls */ | |
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: AppBarLayout, | |
directTargetChild: View, target: View, axes: Int, type: Int): Boolean { | |
getViews(child) | |
return axes == ViewCompat.SCROLL_AXIS_VERTICAL || | |
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type) | |
} |
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
@Suppress("UNCHECKED_CAST") | |
class ViewModelFactory @Inject constructor( | |
private val creators: Map<Class<out ViewModel>, Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
val creator = creators[modelClass] | |
?: creators.asIterable().find { (key, _) -> modelClass.isAssignableFrom(key) }?.value | |
?: throw IllegalArgumentException("Unknown ViewModel class $modelClass") |
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
class OurViewModel(observeGithubReposUseCase: ObserveGithubReposUseCase): ViewModel { | |
val githubRepos: LiveData<List<GithubRepoItem>> | |
get() = observeGithubReposUseCase | |
.observe() | |
.map { reposList -> | |
reposList | |
.sortedByDescending { it.stars } | |
.map { |
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
// domain | |
sealed class ErrorEntity { | |
sealed class ApiError: ErrorEntity() { | |
// ..... | |
} | |
sealed class FileError: ErrorEntity() { | |
object NotFound: FileError() |
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
class LogInModelTest : LogInListener { | |
private lateinit var successTask: Task<AuthResult> | |
private lateinit var failureTask: Task<AuthResult> | |
@Mock | |
private lateinit val mAuth: FirebaseAuth | |
private lateinit var logInModel: LogInModel | |
private var logInResult = UNDEF | |
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
internal class PasswordValidatorTest { | |
private val validator = PasswordValidator() | |
@TestFactory | |
fun `given input password, when validating it, then is should return if it is valid`() = | |
listOf( | |
"Test123!" to true, | |
"#tesT12!" to true, | |
"12Es@t123" to true, |
OlderNewer