Instead of the verbose setOnClickListener
:
RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));
Observable
.just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
function get_avatar_from_service(service, userid, size) { | |
// this return the url that redirects to the according user image/avatar/profile picture | |
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback | |
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px ) | |
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word ) | |
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px ) | |
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word ) | |
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px ) | |
// everything else will go to the fallback | |
// google and gravatar scale the avatar to any site, others will guided to the next best version |
boolean hasUpdated = false; | |
boolean doneBuffering = false; | |
long bufferTimeout = 500; | |
// put this somewhere smart | |
new Thread(new Runnable() { | |
public void run() { | |
while(!doneBuffering) { | |
Thread.sleep(bufferTimeout); |
compile 'com.android.support:recyclerview-v7:25.0.1' | |
compile 'io.reactivex:rxandroid:1.2.1' | |
compile 'io.reactivex:rxjava:1.1.6' | |
<?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="match_parent"> | |
<android.support.v7.widget.RecyclerView | |
android:id="@+id/recylerview_list" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> | |
</FrameLayout> |
<?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" |
<?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" |
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 |
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); |
compile 'com.google.firebase:firebase-database:10.0.1' |