This file contains hidden or 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
val selectedSubcategories = selectedCategories.asSequence().map { it?.subCategories }.fold(mutableSetOf<SubCategoryModel>()) { acc, list -> | |
list?.asSequence()?.filter { it.checked }?.map { acc.add(it) }?.toList() | |
acc | |
} | |
val subcategoriesJoined = selectedSubcategories.asSequence().map { it.name }.joinToString(separator = " • ") | |
editTextProfessionalRegisterCategories.setText(subcategoriesJoined) |
This file contains hidden or 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 example(){ | |
Glide.with(context) | |
.load(items[position]) | |
.apply(RequestOptions() | |
.placeholder(R.drawable.animated_loading_icon) | |
) |
This file contains hidden or 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
long lastYear = 1407869895000L; // August 12, 2014, 8:58PM | |
long before = 1439405895000L; // August 12, 2015, 8:58PM | |
long now = 1442343495000L; // September 15, 2015, 8:58PM | |
// August 12 – September 15 (default) | |
DateUtils.formatDateRange(this, before, now, 0); | |
// August 12, 8:58PM – September 15, 8:58PM (with time) | |
DateUtils.formatDateRange(this, before, now, DateUtils.FORMAT_SHOW_TIME); |
This file contains hidden or 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
listFoo?.singleOrNull { it.id == "oooo" }.let {it...} |
This file contains hidden or 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
/** USAGE -> ('a'..'z').randomString(6) */ | |
fun ClosedRange<Char>.randomString(lenght: Int) = | |
(1..lenght) | |
.map { (Random().nextInt(endInclusive.toInt() - start.toInt()) + start.toInt()).toChar() } | |
.joinToString("") | |
editTextRegisterStepThreeUserName.setText(('a'..'z').randomString(6)) |
This file contains hidden or 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 TextView.afterTextChangedDelayed(afterTextChanged: (String) -> Unit) { | |
this.addTextChangedListener(object : TextWatcher { | |
var timer: CountDownTimer? = null | |
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | |
} | |
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { | |
} |
This file contains hidden or 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 foo(){ | |
myList.any { it -> it.id == valueToCheck } | |
} |
This file contains hidden or 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
semicircleHeader?.animate()?.scaleX(1f)?.scaleY(1f)?.setDuration(100)?.start() |
This file contains hidden or 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
when (layoutEditableMode) { | |
true -> notifyWithAction(message, (R.string.exit), { fun() = activity?.finish() }, circleImageViewProfessionalProfileEditable) | |
false -> notifyWithAction(message, R.string.refresh, ::loadData, circleImageViewProfessionalProfile) | |
} |
This file contains hidden or 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
run breaker@{ | |
collectionModified.forEach { itC -> | |
when { | |
!itC.checked && selectedCount >= 3 -> {maxSizeListener(); return@breaker} | |
else -> { | |
when { | |
itC.id == category.id -> { | |
itC.checked = itemView.switchCategorySelector.isChecked | |
when { | |
!itemView.switchCategorySelector.isChecked -> itC.subCategories?.map { it.checked = false } |