Skip to content

Instantly share code, notes, and snippets.

View nomanr's full-sized avatar
🎯
Focusing

nomanr nomanr

🎯
Focusing
View GitHub Profile
@nomanr
nomanr / example3.kt
Last active September 21, 2020 12:57
class ExampleFragment: Fragment(){
val args by navArgs<ExampleFragmentArgs>()
//If we don't use Hilt, then create factory for each ViewModel and pass arguments
// Which is even worse
val viewModel by viewModels<ExampleViewModel> {
InjectorUtils.provideExampleViewModelFactory(args.argumentA, args.argumentB)
}
}
import androidx.hilt.Assisted
import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
class ExampleViewModel @ViewModelInject constructor(
private val someUseCase: SomeUseCase,
@Assisted private val savedStateHandle: SavedStateHandle
) : ViewModel() {
@nomanr
nomanr / example1.kt
Last active September 21, 2020 12:45
ViewModelInject Simple Example
class ExampleViewModel @ViewModelInject constructor(
private val someUseCase: SomeUseCase,
@Assisted private val savedStateHandle: SavedStateHandle
) : ViewModel() {
}
@nomanr
nomanr / introrx.md
Created August 27, 2018 06:41 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@nomanr
nomanr / gist:cb43eda486a562f879784e29b2a7e683
Created July 11, 2018 11:49 — forked from khakimov/gist:3558086
Matrix Effect in you terminal
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
@nomanr
nomanr / CounterExampleActivity.java
Last active November 14, 2023 10:49
A simple Android class that can start continuous counter when pressed and hold on a view.
package noman.counterhelper;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by Noman on 11/8/2016.
*/
@nomanr
nomanr / AndroidManifest.xml
Created February 10, 2016 09:20 — forked from bjoernQ/AndroidManifest.xml
Creating a System Overlay (Always on Top over all Apps) in Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.mobilej.overlay"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application android:label="SystemOverlay" >
<activity
@nomanr
nomanr / AccessStorageApi
Created January 29, 2016 14:12 — forked from prasad091/AccessStorageApi
Access Storage In Android KITKAT
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;