Skip to content

Instantly share code, notes, and snippets.

View AliAzaz's full-sized avatar
🇵🇰
Passion to help others 😊

Ali Azaz Alam AliAzaz

🇵🇰
Passion to help others 😊
View GitHub Profile
@jorgevila
jorgevila / android-sqlite-table-names
Created March 5, 2014 09:13
Android SQLite Get Table Names
SQLiteDatabase database = dbHelper.getWritableDatabase();
Cursor c = database.rawQuery(
"SELECT name FROM sqlite_master WHERE type='table'", null);
Assert.assertNotNull(c);
String actual = "";
if (c.moveToFirst()) {
while (!c.isAfterLast()) {
actual += c.getString(0) + ",";
c.moveToNext();
@ishitcno1
ishitcno1 / MainActivity.java
Last active April 20, 2024 12:34
multiple row radio button in android.
package com.edinstudio.app.samples.multiplerowradiobuttons;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@Pulimet
Pulimet / AdbCommands
Last active May 4, 2024 04:56
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@naturalwarren
naturalwarren / AccessTokenAuthenticator.kt
Last active October 30, 2023 15:14
An OkHttp Authenticator that performs token refreshes.
/**
* Authenticator that attempts to refresh the client's access token.
* In the event that a refresh fails and a new token can't be issued an error
* is delivered to the caller. This authenticator blocks all requests while a token
* refresh is being performed. In-flight requests that fail with a 401 are
* automatically retried.
*/
class AccessTokenAuthenticator(
private val tokenProvider: AccessTokenProvider
) : Authenticator {
@chibatching
chibatching / FlowThrottleDebounce.kt
Last active March 7, 2024 00:02
Throttle and Debounce on Flow Kotlin Coroutines
fun <T> Flow<T>.throttle(waitMillis: Int) = flow {
coroutineScope {
val context = coroutineContext
var nextMillis = 0L
var delayPost: Deferred<Unit>? = null
collect {
val current = SystemClock.uptimeMillis()
if (nextMillis < current) {
nextMillis = current + waitMillis
@faruktoptas
faruktoptas / debounce.kt
Created March 5, 2020 06:28
Kotlin coroutine debounce for EditText
fun <T> debounce(
waitMs: Long = 300L,
scope: CoroutineScope,
destinationFunction: (T) -> Unit
): (T) -> Unit {
var debounceJob: Job? = null
return { param: T ->
debounceJob?.cancel()
debounceJob = scope.launch {
delay(waitMs)
@bmc08gt
bmc08gt / SwipeToDelete.kt
Last active December 15, 2023 03:40
Jetpack Compose Modifier extension to implement swipe-to-delete via Modifier.draggable
import androidx.animation.IntToVectorConverter
import androidx.animation.tween
import androidx.compose.Composable
import androidx.compose.mutableStateOf
import androidx.compose.remember
import androidx.ui.animation.animatedFloat
import androidx.ui.animation.animatedValue
import androidx.ui.core.*
import androidx.ui.core.gesture.scrollorientationlocking.Orientation
import androidx.ui.foundation.animation.FlingConfig
@bmc08gt
bmc08gt / TransientSnackbar.kt
Last active February 1, 2021 10:12
Auto-dismissing Snackbar for Jetpack Compose
class SnackbarState {
var show by mutableStateOf(false)
}
@Composable
fun TransientSnackbar(
modifier: Modifier = Modifier,
snackbarState: SnackbarState,
text: String,
actionLabel: String,
inline fun <reified T : Fragment> launchFragmentInHiltContainer(
fragmentArgs: Bundle? = null,
@StyleRes themeResId: Int = R.style.SomeTheme,
fragmentFactory: FragmentFactory? = null,
crossinline action: Fragment.() -> Unit = {}
) {
val startActivityIntent = Intent.makeMainActivity(
ComponentName(
ApplicationProvider.getApplicationContext(),
HiltTestActivity::class.java