Skip to content

Instantly share code, notes, and snippets.

View dharmakshetri's full-sized avatar

Dharma Kshetri dharmakshetri

View GitHub Profile
Converter Library
Gson com.squareup.retrofit2:converter-gson:2.1.0
Jackson com.squareup.retrofit2:converter-jackson:2.1.0
Moshi com.squareup.retrofit2:converter-moshi:2.1.0
Protobuf com.squareup.retrofit2:converter-protobuf:2.1.0
Wire com.squareup.retrofit2:converter-wire:2.1.0
Simple XML com.squareup.retrofit2:converter-simplexml:2.1.0
dependencies {
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
/**
* Created by dharma kshetri(@[email protected]) on 12/14/16.
*/
public class MainActivity extends AppCompatActivity {
public static final String TAG="FIREBASE";
public RecyclerView recyclerListView;
public UserAdapter myAdapter;
public EditText editTextName;
public EditText editTextCountry;
{
"rules": {
".read": "true",
".write": "true"
}
}
compile 'com.google.firebase:firebase-database:10.0.1'
@dharmakshetri
dharmakshetri / RxJava.md
Created December 13, 2016 08:50 — forked from cesarferreira/RxJava.md
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

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private final Context mContext;
private final List<String> nameList = new ArrayList<>();
public MyAdapter(Context context){mContext=context;}
public void setData(List<String> names){
nameList.clear();
nameList.addAll(names);
public class MainActivity extends AppCompatActivity {
public final String TAG="RXANDROID";
RecyclerView recyclerListView;
MyAdapter myAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// creating layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
>
<TextView
android:id="@+id/tvName"
android:layout_width="match_parent"