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 animatable = remember { | |
Animatable(0.5f) | |
} | |
LaunchedEffect(key1 = true) { | |
animatable.animateTo(1f, tween(350, easing = FastOutSlowInEasing)) | |
// you can tweak out and customize these animations. | |
} | |
// add this animatable to your card's modifier graphics layer. | |
BookItem(modifier = cardMod.graphicsLayer { | |
this.scaleX = animatable.value |
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
@Composable | |
fun FlipActionScreen() { | |
var flippedState by remember { mutableStateOf(false) } | |
val rotationY by animateFloatAsState( | |
targetValue = if (flippedState) 180f else 0f, | |
animationSpec = spring( | |
dampingRatio = Spring.DampingRatioHighBouncy, | |
stiffness = Spring.StiffnessVeryLow | |
) | |
) |
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
object MyCustomDialog { | |
fun <V : ViewDataBinding> showCustomBottomSheetDialog( | |
activity: Activity, | |
@LayoutRes layoutId: Int, | |
setCancelable: Boolean = false, | |
onSuccess: (Dialog, V) -> Unit | |
) { | |
val layout = | |
DataBindingUtil.inflate<V>(LayoutInflater.from(activity), layoutId, null, false) |
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
object PasswordEncryptor { | |
private const val SECRET_KEY = "aesEncryptionKey" | |
private const val INIT_VECTOR = "encryptionIntVec" | |
fun encrypt(value: String): String? { | |
try { | |
val iv = IvParameterSpec(INIT_VECTOR.toByteArray(charset("UTF-8"))) | |
val skeySpec = SecretKeySpec(SECRET_KEY.toByteArray(charset("UTF-8")), "AES") | |
val cipher: Cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING") |
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
/** | |
* Add an action which will be invoked when the text is changing. | |
* | |
* @return the [SearchView.OnQueryTextListener] added to the [SearchView] | |
*/ | |
inline fun SearchView.doAfterTextChanged( | |
delay: Long = 500, | |
crossinline onTextChangedDelayed: (text: String) -> Unit | |
) = doOnQueryTextListener(delay, onTextChangedDelayed) |
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
// Simple Date Format | |
val dateformat = SimpleDateFormat("hh:mm:ss",Locale.getDefault()) | |
// Get Current time like dateformat above | |
val currentTime = dateformat.format(Date()) | |
// Counter Endtime with Second | |
val endTime = "10:30:00" | |
// Format time as Parse to Milisecond for run counter |
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
@file:Suppress("DEPRECATION") | |
import android.annotation.TargetApi | |
import android.content.BroadcastReceiver | |
import android.content.Context | |
import android.content.Intent | |
import android.content.IntentFilter | |
import android.net.* | |
import android.os.Build | |
import androidx.lifecycle.LiveData |
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
YOUR_SEARCH_EDITTEXT.addTextChangedListener(object : TextWatcher { | |
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} | |
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {} | |
override fun afterTextChanged(s: Editable) { | |
} | |
}) |
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
XML EDITTEXT NEEDS BELOW LINES OF CODE | |
-------------------------------------- | |
android:imeOptions="actionSearch" | |
android:inputType="text" | |
IN ACTIVITY OR FRAGMENT FILE | |
---------------------------- | |
YOUR_EDITTEXT_OBJECT.setOnEditorActionListener(OnEditorActionListener { v, actionId, event -> | |
if (actionId == EditorInfo.IME_ACTION_SEARCH) { | |
// Call your search functionality or method here |
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
inline fun getYoutubevideidfromurl(youtubeurl: String) : String? | |
{ | |
if (youtubeurl.toLowerCase().contains("youtu.be")){ | |
return youtubeurl.substring(youtubeurl.lastIndexOf("/") + 1) | |
} | |
val pattern = "(?<=youtu.be/|watch\\?v=|/videos/|embed\\/)[^#\\&\\?]*" | |
val compiledPattern: Pattern = Pattern.compile(pattern) | |
val matcher: Matcher = compiledPattern.matcher(youtubeurl) | |
return if (matcher.find()) { | |
matcher.group() |
NewerOlder