Last active
January 20, 2016 19:52
-
-
Save ygorbarboza/491eb6361c534a1e288e to your computer and use it in GitHub Desktop.
RxJava Click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.os.Build; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.TextView; | |
import rx.Observable; | |
import rx.subjects.PublishSubject; | |
/** | |
* Created by ygorbarboza on 1/7/15. | |
*/ | |
public class RxClickTextView extends TextView { | |
private PublishSubject<View> mClickSubject = PublishSubject.create(); | |
public RoundedCheckView(Context context) { | |
super(context); | |
init(null); | |
} | |
public RoundedCheckView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
init(attrs); | |
} | |
public RoundedCheckView(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
init(attrs); | |
} | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
public RoundedCheckView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
super(context, attrs, defStyleAttr, defStyleRes); | |
init(attrs); | |
} | |
private void init(AttributeSet attrs) { | |
setClickable(true); | |
} | |
@Override | |
public boolean performClick() { | |
mClickSubject.onNext(this); | |
return super.performClick(); | |
} | |
public Observable<View> getClickObservable() { | |
return mClickSubject.asObservable(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment