Skip to content

Instantly share code, notes, and snippets.

View SaqibAhmed-hub's full-sized avatar

Saqib Ahmed SaqibAhmed-hub

View GitHub Profile
package com.example.bioMetricApp.utils
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG
import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
import androidx.biometric.BiometricPrompt
import androidx.core.content.ContextCompat
import com.example.bioMetricApp.common.BiometricAuthListener
private fun callbackAPI() {
val started = System.currentTimeMillis()
val parentJob = CoroutineScope(Dispatchers.IO).launch {
val job1 = launch {
val time1 = measureTimeMillis {
val result1 = callAPI1()
setTextOnMainThread(result1)
}
private suspend fun callAPI1(): String {
delay(2000)
val data1 = ApiService.getService().getData()
data1.let {
return if (it.isSuccessful) {
val firstname = callName(it.body())
firstname
} else {
"Unsuccessful#1"
}
@SaqibAhmed-hub
SaqibAhmed-hub / job1.kt
Created February 25, 2022 11:46
Coroutine Job Description
CoroutineScope(Dispatchers.IO).launch {
val job1 = launch{
val result1 = callAPI1()
setTextOnMainThread(result1)
}
}
@SaqibAhmed-hub
SaqibAhmed-hub / gradient.kt
Created February 22, 2022 13:47
Gradient Button
@Composable
fun GradientButton(
text: String,
gradient : Brush,
modifier: Modifier = Modifier,
onClick: () -> Unit = { },
) {
Button(
modifier = modifier,
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent),
@SaqibAhmed-hub
SaqibAhmed-hub / progress_bar.xml
Created February 17, 2022 08:53
Progress Bar using the Material Design
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:trackCornerRadius="8dp"
android:layout_margin="8dp"
app:trackThickness="16dp"
app:trackColor="#86A4F1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@SaqibAhmed-hub
SaqibAhmed-hub / activity_main.xml
Created February 15, 2022 06:52
Bottom Navigation View example
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_fragment_host"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_fragment_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_host" />
@SaqibAhmed-hub
SaqibAhmed-hub / activity_main.xml
Created February 15, 2022 05:57
Bottom Navigation View
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
style="@style/Widget.MaterialComponents.BottomNavigationView.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="16dp"
app:itemRippleColor="@color/white"
app:itemTextAppearanceActive="@color/white"
app:labelVisibilityMode="selected"
app:layout_constraintBottom_toBottomOf="parent"