Skip to content

Instantly share code, notes, and snippets.


Grigore Cristian-Andrei grrigore

View GitHub Profile
tobioyelekan / userViewModel.kt
Last active Jul 3, 2020
typical user view model
View userViewModel.kt
private val userId = MutableLiveData<String>()
val userDetails = userId.switchMap {
val userFullName = {
getFullName(it.firstName, it.lastName)
nikhilmufc7 / auth.dart
Last active Aug 12, 2022
Firebase Flutter Platform Exception Codes and example
View auth.dart
// Error Codes for SignUp
ERROR_OPERATION_NOT_ALLOWED` - Indicates that Anonymous accounts are not enabled.
ERROR_WEAK_PASSWORD - If the password is not strong enough.
ERROR_INVALID_EMAIL` - If the email address is malformed.
ERROR_EMAIL_ALREADY_IN_USE - If the email is already in use by a different account.
ERROR_INVALID_CREDENTIAL` - If the [email] address is malformed.
// sending password reset email
ERROR_INVALID_EMAIL` - If the [email] address is malformed.
/* We create an interface with one method */
public interface TextWatcherWithInstance {
void onTextChanged(EditText editText, CharSequence s, int start, int before, int count);
/* We create a custom class called MultiTextWatcher.
* And pass the interface here
msangel /
Last active Jul 27, 2019 — forked from koesie10/
Retrofit 1 error handling behaviour in Retrofit 2.3.0
// Dagger 1 example
complete = false,
library = true
public final class ApiModule {
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
Antarix /
Created Nov 21, 2016
Firebase Android Sample for managing notification
import android.content.Context;
import android.content.Intent;
import android.util.Log;
* This is called whenever app receives notification
* in background/foreground state so you can
* apply logic for background task, but still Firebase notification
* will be shown in notification tray
iChintanSoni /
Last active Dec 5, 2018
Utility class for working with SharedPreferences
import android.content.Context;
import android.content.SharedPreferences;
public class SharedPreferenceUtils {
private static SharedPreferenceUtils mSharedPreferenceUtils;
protected Context mContext;
private SharedPreferences mSharedPreferences;
private SharedPreferences.Editor mSharedPreferencesEditor;
private SharedPreferenceUtils(Context context) {
lopspower /
Last active Aug 17, 2022
Hexadecimal color code for transparency

Hexadecimal color code for transparency


How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

mcelotti / android_forward_result
Last active May 9, 2022
View android_forward_result
Nav flow is: A => B => C => A with results from C
If you're using fragments please note that "onActivityResult" will be called according to where "startActivityForResult" is called (method "startActivityForResult" is available in both, activity and fragment)
startActivityForResult(intentB, 22);
cesarferreira /
Last active Feb 2, 2022
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
yqritc / gist:ccca77dc42f2364777e1
Last active May 23, 2022
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration
View gist:ccca77dc42f2364777e1


public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;