Skip to content

Instantly share code, notes, and snippets.

View Skyyo's full-sized avatar
🇺🇦

Denis Rudenko Skyyo

🇺🇦
View GitHub Profile
@Skyyo
Skyyo / KeyboardExt.kt
Last active August 16, 2020 11:17
#extensions
package com.skyyo.ext
import android.app.Activity
import android.content.Context
import android.view.inputmethod.InputMethodManager
import androidx.fragment.app.Fragment
fun Fragment?.hideKeyboard() =
(this?.activity?.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager?)?.let {
@Skyyo
Skyyo / SpannableExt.kt
Last active August 16, 2020 11:17
#extensions
package com.skyyo.ext
import android.graphics.Typeface
import android.text.Selection
import android.text.Spannable
import android.text.TextPaint
import android.text.style.*
import android.view.View
import android.widget.TextView
import androidx.annotation.ColorInt
@Skyyo
Skyyo / FadeExt.kt
Last active August 8, 2020 16:49
#extensions
package com.skyyo.ext
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.view.View
fun View.fadeIn(): AnimatorSet {
val animatorSet = AnimatorSet()
val object1: ObjectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0f, 1f)
@Skyyo
Skyyo / BounceExt.kt
Last active August 8, 2020 16:48
#extensions
package com.skyyo.ext
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.view.View
fun View.bounceIn(): AnimatorSet {
val animatorSet = AnimatorSet()
val object1: ObjectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0f, 1f, 1f, 1f)
@Skyyo
Skyyo / SlideExt.kt
Last active August 8, 2020 16:48
#extensions
package com.skyyo.ext
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.view.View
import android.view.ViewGroup
fun View.slideInDown(): AnimatorSet {
val animatorSet = AnimatorSet()
val distance = (top + height).toFloat()
@Skyyo
Skyyo / FlipExt.kt
Last active August 8, 2020 16:48
#extensions
package com.skyyo.ext
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.view.View
fun View.flipInX(): AnimatorSet {
val animatorSet = AnimatorSet()
val object1: ObjectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0.25f, 0.5f, 0.75f, 1f)
@Skyyo
Skyyo / AttentionExt.kt
Last active August 8, 2020 16:48
#extensions
package com.skyyo.ext
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.view.View
fun View.attentionBounce(): AnimatorSet {
val animatorSet = AnimatorSet()
val object1: ObjectAnimator = ObjectAnimator.ofFloat(this, "translationY", 0f, 0f, -30f, 0f, -15f, 0f, 0f)
@Skyyo
Skyyo / Watermark.kt
Last active August 16, 2020 11:17
#image #watermark
package com.skyyo.ext
import android.graphics.*
import android.graphics.Paint.ANTI_ALIAS_FLAG
import android.graphics.Paint.DITHER_FLAG
import androidx.annotation.ColorInt
fun addWatermark(
bitmap: Bitmap,
@Skyyo
Skyyo / RegexExt.kt
Last active August 8, 2020 16:47
#extensions
package com.skyyo.ext
inline val CharSequence?.isEmail: Boolean get() = isMatch(REGEX_EMAIL)
fun CharSequence?.isMatch(regex: String): Boolean =
!this.isNullOrEmpty() && Regex(regex).matches(this)
const val REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"
@Skyyo
Skyyo / MiscellaneousExt.kt
Last active August 8, 2020 16:47
#extensions
package com.skyyo.ext
import android.util.Log
import android.view.View
fun hideViews(vararg views: View) = views.forEach { it.visibility = View.GONE }
fun showViews(vararg views: View) = views.forEach { it.visibility = View.VISIBLE }
fun Any.log(message: String) = Log.d("vv", message)