Skip to content

Instantly share code, notes, and snippets.

View ELTEGANI's full-sized avatar
🎯
Focusing

Eltegani Mohamed ELTEGANI

🎯
Focusing
View GitHub Profile
1. hiltvm (applicable in top-level)
@dagger.hilt.android.lifecycle.HiltViewModel
class $NAME$ @javax.inject.Inject constructor(
$PARAM$
) : androidx.lifecycle.ViewModel() {
$END$
}
2. vmstatefunc (applicable in class)
private val _$NAME$ = androidx.compose.runtime.mutableStateOf<$TYPE$>($INITIAL_VALUE$)
@ELTEGANI
ELTEGANI / AndroidManifest.xml
Last active January 21, 2022 05:38
How to set an Android notification to a specific date in the future
<? xml version = "1.0" encoding = "utf-8" ?>
<manifest xmlns: android = "http://schemas.android.com/apk/res/android"
package = "app.tutorialspoint.com.notifyme" >
<uses-permission android :name = "android.permission.VIBRATE" />
<application
android :allowBackup = "true"
android :icon = "@mipmap/ic_launcher"
android :label = "@string/app_name"
android :roundIcon = "@mipmap/ic_launcher_round"
android :supportsRtl = "true"
@ELTEGANI
ELTEGANI / AndroidManifest.xml
Created May 14, 2020 21:20 — forked from BrandonSmith/AndroidManifest.xml
Quick example of how to schedule a notification in the future using AlarmManager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cards.notification">
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
@ELTEGANI
ELTEGANI / MainActivity.java
Created April 1, 2020 18:40 — forked from marc0x71/MainActivity.java
BottomSheetDialog example
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openDialog();
}
@ELTEGANI
ELTEGANI / play-auth-proguard-rules.pro
Created January 27, 2020 11:06 — forked from ChanSek/play-auth-proguard-rules.pro
ProGuard rules for Google Play Services (Authentication)
-keepclassmembers class com.google.android.gms.dynamite.DynamiteModule {
** MODULE_ID;
** MODULE_VERSION;
** sClassLoader;
}
-keepclassmembers class com.google.android.gms.internal.in {
** mOrigin;
** mCreationTimestamp;
** mName;
** mValue;
@ELTEGANI
ELTEGANI / BaseUpdateCheckActivity.kt
Created January 12, 2020 17:04 — forked from saikiran91/BaseUpdateCheckActivity.kt
Android officially announced the in-app updates. https://developer.android.com/guide/app-bundle/in-app-updates. This is the code sample for handling both IMMEDIATE and FLEXIBLE updates in a single activity; Kotlin way.
import android.app.Activity
import android.content.Intent
import android.content.IntentSender
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.google.android.material.snackbar.Snackbar
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
@ELTEGANI
ELTEGANI / Random-string
Created December 8, 2019 08:04 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);

screenshot

(prefix == Ctrl+f)

Panes

Navigation

(vim movement keys)
prefix h

prefix j

@ELTEGANI
ELTEGANI / BaseDao.kt
Created October 2, 2019 07:18 — forked from florina-muntenescu/BaseDao.kt
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ELTEGANI
ELTEGANI / Data.kt
Created October 1, 2019 11:27 — forked from florina-muntenescu/Data.kt
Using RoomDatabase#Callback to pre-populate the database - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software