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
| /** 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
| 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
| 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
| 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
| 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
| <androidx.constraintlayout.widget.ConstraintLayout | |
| android:id="@+id/layoutHeaderNavView" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="?attr/selectableItemBackground" | |
| android:clickable="true" | |
| android:focusable="true"> |
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
| private fun printKeyHash() { | |
| try { | |
| val info = activity?.packageManager?.getPackageInfo("com.s", PackageManager.GET_SIGNATURES) | |
| for (signature in info!!.signatures!!) { | |
| val md = MessageDigest.getInstance("SHA") | |
| md.update(signature.toByteArray()) | |
| Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)) | |
| } | |
| } catch (e: PackageManager.NameNotFoundException) { |
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
| values-sw720dp 10.1” tablet 1280x800 mdpi | |
| values-sw600dp 7.0” tablet 1024x600 mdpi | |
| values-sw480dp 5.4” 480x854 mdpi | |
| values-sw480dp 5.1” 480x800 mdpi | |
| values-xxhdpi 5.5" 1080x1920 xxhdpi | |
| values-xxxhdpi 5.5" 1440x2560 xxxhdpi |
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 View.changeColorAnimatedly(duration: Long, repeatable: Boolean, startColor: Int, endColor: Int) { | |
| val anim = ObjectAnimator.ofInt(this, "backgroundColor", startColor, endColor) | |
| anim.duration = duration | |
| anim.setEvaluator(ArgbEvaluator()) | |
| if (repeatable) { | |
| anim.repeatCount = ValueAnimator.INFINITE | |
| anim.repeatMode = ValueAnimator.REVERSE | |
| } | |
| anim.start() | |
| } |