Skip to content

Instantly share code, notes, and snippets.

View cutiko's full-sized avatar

Erick Navarro cutiko

View GitHub Profile
@cutiko
cutiko / SetOnEditorActionListener.java
Created July 27, 2016 13:42
Common Keyboard Listener for Android
userInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE) {
//some method
return true;
}
return false;
}
});
@cutiko
cutiko / HideDisplaySoftKeyboard.java
Last active April 23, 2018 17:56
Hide and Display keyboard for Android (softkeyabord)
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
//show
inputMethodManager.showSoftInput(someView, InputMethodManager.SHOW_FORCED);
//Hide
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
//Piss off? Fuck it! Just force it to hidde
inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
//To be safe dont forget to wrap in try/catch
@cutiko
cutiko / styles.xml
Last active January 31, 2019 23:39
TextInputLayout white theme
<style name="WhiteAccent" parent="AppTheme">
<item name="colorAccent">@android:color/white</item>
<item name="colorControlActivated">@android:color/white</item>
<item name="colorControlHighlight">@android:color/white</item>
<item name="android:textColorHint">@android:color/white</item>
<item name="android:textColor">@android:color/white</item>
<item name="colorControlNormal">@android:color/white</item>
<item name="android:textColorPrimary">@android:color/white</item>
</style>
@cutiko
cutiko / activity_main.xml
Last active April 27, 2021 15:27
Ripple Effect Android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
@cutiko
cutiko / SharedPreferences.java
Created August 12, 2016 15:25
Simpiest Android SharedPreferences
public void set(String string) {
SharedPreferences sPref = context.getSharedPreferences(GROUP_KEY, Context.MODE_PRIVATE);
SharedPreferences.Editor prefEditor = sPref.edit();
prefEditor.putString(VALUE_KEY, string);
prefEditor.commit();
}
public String get() {
SharedPreferences sPref = context.getSharedPreferences(GROUP_KEY, Context.MODE_PRIVATE);
return sPref.getString(VALUE_KEY, null);
@cutiko
cutiko / cb_background_custom.xml
Created August 30, 2016 19:54
Checkbox background covering most commont states, true/false and enabled
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_checked="true" android:drawable="@mipmap/cb_check_dark_primary_disable_24dp" />
<item android:state_enabled="false" android:state_checked="false" android:drawable="@mipmap/cb_outline_dark_primary_disable_24dp" />
<item android:state_checked="true" android:drawable="@mipmap/cb_check_dark_primary_24dp" />
<item android:state_checked="false" android:drawable="@mipmap/cb_outline_dark_primary_24dp" />
</selector>
@cutiko
cutiko / AndroidLibraries.md
Last active July 8, 2018 20:26
Android libraries (dependencies) selection

Welcome

Thanks for visiting this is my personal selection of Android libraries. I have choose them very carefully, each of these have being tested and are selected after ruling out other similars. If for any reason you can't find something that suit your needs I have to recommend Android Arsenal

Bottom Navigation

I have seen a couple of Bottom Navigation, this is very simple cause is ment to be use with a ViewPager, so there is nothing only a new few things to know. Is very customizable and the animations included are very nice SpaceTabLayout

Code Injection

I'm not a big fan of libraries such as Butterknife, cause view binding despite being tedious, should be done manually to handle the accesibility to the variable. I know there is an Android Studio plugin called Zelesny but when I try it, didnt worked. My favorite library

@cutiko
cutiko / LoginActivity.java
Last active August 29, 2022 14:53
How to customize firebase-ui-auth for Android
public class LoginActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 343;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@cutiko
cutiko / ExampleActivity.java
Last active August 24, 2021 10:58
Take photo using camera and gallery selection for Android (please see readme first)
public class ExampleActivity extends AppCompatActivity {
private static final int CAMERA_INTENT = 111;
private static final int GALLERY_INTENT = 222;
private PhotoData photoData;
private ImageView photoPreview;
@Override
protected void onCreate(Bundle savedInstanceState) {
@cutiko
cutiko / AsyncImplementation.java
Last active October 29, 2018 05:16
How to use Retrofit in Android
public clas AsyncImplementation extends AsyncTask<Void, Void, Void> {
/*Please read the rest of the explanation in the DefaultImplementation.java file. The difference between a default http request
and one using an AsyncTask is the enqeue() or the .execute() method*/
/*If you are passing params to the url, like it would be the case of the method post(long theDynamicParameter) you can
do it using replacing the void in the AsyncTask, in this case we are passing a Map so is passed in the constructor. Some times,
you would want the AsyncTask solve all the logic, then implements methods here to do it. Create the request http in a loop.
Use getter and setter to extends this to another class, etc.
Now in activity you can new AsyncImplementation(map).execute();*/