2929import com .example .sqlbrite .todo .R ;
3030import com .example .sqlbrite .todo .TodoApp ;
3131import com .example .sqlbrite .todo .db .TodoList ;
32+ import com .jakewharton .rxbinding .widget .RxTextView ;
3233import com .squareup .sqlbrite .BriteDatabase ;
3334import javax .inject .Inject ;
3435import rx .Observable ;
35- import rx .android .schedulers .AndroidSchedulers ;
36- import rx .android .widget .OnTextChangeEvent ;
37- import rx .android .widget .WidgetObservable ;
3836import rx .functions .Action1 ;
3937import rx .functions .Func2 ;
4038import rx .schedulers .Schedulers ;
@@ -61,15 +59,12 @@ public static NewListFragment newInstance() {
6159 View view = LayoutInflater .from (context ).inflate (R .layout .new_list , null );
6260
6361 EditText name = findById (view , android .R .id .input );
64- Observable <OnTextChangeEvent > nameText = WidgetObservable .text (name );
65-
66- Observable .combineLatest (createClicked , nameText ,
67- new Func2 <String , OnTextChangeEvent , String >() {
68- @ Override public String call (String ignored , OnTextChangeEvent event ) {
69- return event .text ().toString ();
62+ Observable .combineLatest (createClicked , RxTextView .textChanges (name ),
63+ new Func2 <String , CharSequence , String >() {
64+ @ Override public String call (String ignored , CharSequence text ) {
65+ return text .toString ();
7066 }
7167 }) //
72- .subscribeOn (AndroidSchedulers .mainThread ())
7368 .observeOn (Schedulers .io ())
7469 .subscribe (new Action1 <String >() {
7570 @ Override public void call (String name ) {
@@ -86,7 +81,7 @@ public static NewListFragment newInstance() {
8681 }
8782 })
8883 .setNegativeButton (R .string .cancel , new DialogInterface .OnClickListener () {
89- @ Override public void onClick (DialogInterface dialog , int which ) {
84+ @ Override public void onClick (@ NonNull DialogInterface dialog , int which ) {
9085 }
9186 })
9287 .create ();
0 commit comments