Skip to content

Instantly share code, notes, and snippets.

View abircse's full-sized avatar
🏠
Working from My Workstation

Nayeem Shiddiki Abir abircse

🏠
Working from My Workstation
View GitHub Profile
@abircse
abircse / cardanimation.kt
Created May 2, 2024 02:47 — forked from bharath914/cardanimation.kt
Quick Card Animation in Jetpack Compose
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
@abircse
abircse / FlipCard.kt
Created April 21, 2024 14:32 — forked from mo7amd89/FlipCard.kt
Flip Card with Jetpack Compose
@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
)
)
@abircse
abircse / MyCustomDialog.kt
Last active December 25, 2021 08:24
A Custom Wrapper class for handle dialog & bottom sheet dialog including viewbinding.
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)
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")
@abircse
abircse / SearchView.kt
Created June 24, 2021 22:42
Android Searchview Extension
/**
* 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)
@abircse
abircse / countdowntimer.kt
Last active April 17, 2021 16:25
CountDownTimer
// 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
@abircse
abircse / NetworkConnectionCheckerlivetime.kt
Created March 25, 2021 10:22
NetworkConnectionCheckerlive
@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
@abircse
abircse / EdittextSearchListener.kt
Created March 20, 2021 09:57
EdittextSearchListener
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) {
}
})
@abircse
abircse / SearchByKeyboard.txt
Created March 20, 2021 08:54
SearchByKeyboard
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
@abircse
abircse / getYoutubevideidfromurl.kt
Created March 18, 2021 06:13
GetYoutubevideidfromurl
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()