Skip to content

Instantly share code, notes, and snippets.

View MostafaGad1911's full-sized avatar
💭
Android Developer @SystemsEgypt

Mostafa Gad MostafaGad1911

💭
Android Developer @SystemsEgypt
View GitHub Profile
@gabrielbmoro
gabrielbmoro / PieChart.kt
Last active March 12, 2023 00:39
PieChart example using compose
package com.example.composecharts.ui.widgets
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
// Usage
// PingPongSwitch(
// textFirst = "Ping",
// textSecond = "Pong"
// )
@Composable
fun PingPongSwitch(
state: PingPongSwitchState = rememberPingPongSwitchState(),
textFirst: String,
@wesleybliss
wesleybliss / simple_observer.kt
Created March 4, 2020 16:42
Simple Kotlin Observer Pattern
interface Observer<T> {
fun onChange(newValue: T?)
}
class Observable<T>(initialValue: T? = null) {
// List ov observers watching this value for changes
private val observers = mutableListOf<Observer<T>>()
// The real value of this observer
@iamnaran
iamnaran / activity_layout.xml
Last active September 20, 2023 17:21
Layout And RecyclerView Animation Android (Made Simple with XML only)
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation"
android:orientation="vertical">
</ScrollView>
@MeNiks
MeNiks / RealPathUtil.kt
Last active July 10, 2024 08:57
Kotlin code to get real path / sd card path from intent data while browsing file.
import android.annotation.SuppressLint
import android.content.ContentUris
import android.content.Context
import android.content.CursorLoader
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
@hleinone
hleinone / CreditCardNumberFormattingTextWatcher.kt
Last active November 30, 2023 14:03
Android EditText TextWatcher for formatting credit card number made with Kotlin
class CreditCardNumberFormattingTextWatcher : TextWatcher {
private var current = ""
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
}
override fun afterTextChanged(s: Editable) {