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)
/* 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 | |
*/ |
private val userId = MutableLiveData<String>() | |
val userDetails = userId.switchMap { | |
userRepo.getUser(it) | |
} | |
val userFullName = userDetails.map { | |
getFullName(it.firstName, it.lastName) | |
} |
/** | |
* 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; |
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) | |
ActivityA | |
startActivityForResult(intentB, 22); | |
ActivityB | |
intentC.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); | |
startActivity(intentC); | |
finish(); |
// Dagger 1 example | |
@Module( | |
complete = false, | |
library = true | |
) | |
public final class ApiModule { | |
@Provides | |
@Singleton | |
Retrofit provideRetrofit(Gson gson, Application app) { | |
return new Retrofit.Builder() |
import android.content.Context; | |
import android.content.Intent; | |
import android.support.v4.content.WakefulBroadcastReceiver; | |
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 |
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. | |
To use the support version of these attributes, remove the android namespace. | |
For instance, "android:colorControlNormal" becomes "colorControlNormal". | |
These attributes will be propagated to their corresponding attributes within the android namespace | |
for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix. | |
All Clickable Views: | |
----------- |