Skip to content

Instantly share code, notes, and snippets.

View grrigore's full-sized avatar

Grigore Cristian-Andrei grrigore

View GitHub Profile
@ryanamaral
ryanamaral / PaddingItemDecoration.java
Created May 25, 2015 15:18
RecyclerView.ItemDecoration implementation for equal padding between the list items except first and last items.
/**
* ItemDecoration implementation for equal padding between the list items except first and last items.
* @author Ryan Amaral
* @version 1.0
*/
public class PaddingItemDecoration extends RecyclerView.ItemDecoration {
private int mPaddingPx;
private int mPaddingEdgesPx;
@tobioyelekan
tobioyelekan / userViewModel.kt
Last active July 3, 2020 14:47
typical user view model
private val userId = MutableLiveData<String>()
val userDetails = userId.switchMap {
userRepo.getUser(it)
}
val userFullName = userDetails.map {
getFullName(it.firstName, it.lastName)
}
/* 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
*/
@iChintanSoni
iChintanSoni / SharedPreferenceUtils.java
Last active December 5, 2018 01:52
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) {