Skip to content

Instantly share code, notes, and snippets.

View nfaycel's full-sized avatar

Nouar Faiçal nfaycel

  • ANEM
  • Mascara, Mohammadia
View GitHub Profile
@nfaycel
nfaycel / ProgressButton.kt
Created April 4, 2023 10:14 — forked from qamarelsafadi/ProgressButton.kt
This gist will help ypu doing ypur progress button via Compose
@Composable
fun ProgressButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
loading: Boolean = false,
color: Int,
progressColor: Int,
content: @Composable () -> Unit,
) {
val contentAlpha by animateFloatAsState(targetValue = if (loading) 0f else 1f)
@nfaycel
nfaycel / BaseBottomSheet.kt
Created April 4, 2023 10:13 — forked from qamarelsafadi/BaseBottomSheet.kt
This class is a generic class for BottomSheetDialogFragment using Kotlin, it will helps you to use one class for all ur bottom sheets on your app.
/*
* Copyright (c) 2022. Qamar A. Safadi
*/
package com.qamar.test.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
@nfaycel
nfaycel / BaseDialog.kt
Created April 4, 2023 10:09 — forked from qamarelsafadi/BaseDialog.kt
This class is generic class for creating your custom dialogs, it will helps you to use one class for all ur custom dialogs.
/*
* Created by Qamar A. Safadi on 6/13/22, 9:50 PM
* Copyright (c) 2022 .
*/
package com.example.qamar.ui.base
import android.app.Dialog
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
@nfaycel
nfaycel / OnBackPressedAlternativeWay.kt
Created April 4, 2023 10:09 — forked from qamarelsafadi/OnBackPressedAlternativeWay.kt
OnBackPressed Alternative way for fragments and activities
/* ----------------------------------------- Activity ------------------------------------------ */
/* make sure you have at least 'androidx.activity:activity-ktx:1.6.0-rc01' at your dependencies
(just to let you know this dependency is not stable yet )
*/
implementation 'androidx.activity:activity-ktx:1.6.0-rc01'
fun AppCompatActivity.onBackPressed(isEnabled: Boolean, callback: () -> Unit) {
onBackPressedDispatcher.addCallback(this,
import android.app.LocaleManager
import android.content.Context
import android.os.Build
import android.os.LocaleList
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import java.util.Locale
/// Change Langauage Extenstion
/**
* Default implementation of [LocaleHelperKt].
*/
class DefaultLocaleHelper private constructor(context: Context) : BaseLocaleHelper(context) {
companion object {
/* Mark the instance as Volatile*/
@Volatile
private var instance: LocaleHelperKt? = null
private var LOCK: Any = Any()
@nfaycel
nfaycel / MyContextWrapper.java
Created September 22, 2022 13:07 — forked from sud007/MyContextWrapper.java
A simple gist to demonstrate How to change the App Language in Android.
public class MyContextWrapper extends ContextWrapper {
public MyContextWrapper(Context base) {
super(base);
}
@SuppressWarnings("deprecation")
public static ContextWrapper wrap(Context context, String language) {
Configuration config = context.getResources().getConfiguration();
Locale sysLocale = null;
@nfaycel
nfaycel / SimpleDemoGA.java
Created October 31, 2018 08:24 — forked from Vini2/SimpleDemoGA.java
A simple implementation of a genetic algorithm
import java.util.Random;
/**
*
* @author Vijini
*/
//Main class
public class SimpleDemoGA {