package com.shundaojia.rxcommand;

import android.view.View;

import io.reactivex.ObservableTransformer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * Created by listen on 2017/3/16.
 * Helper to bind a view with a command;
 */

public class RxCommandBinder {

    @Deprecated
    public static <T>Disposable bind(final View view, final RxCommand<T> command) {
        view.setClickable(true);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                command.execute(null);
            }
        });

        return command.enabled()
                    .subscribe(new Consumer<Boolean>() {
                        @Override
                        public void accept(Boolean enabled) throws Exception {
                            view.setEnabled(enabled);
                        }
                    });
    }

    public static <T> void bind(final View view, final RxCommand<T> command, ObservableTransformer<Boolean, Boolean> takeUntil) {
        view.setClickable(true);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                command.execute(null);
            }
        });
        command.enabled()
                .compose(takeUntil)
                .subscribe(new Consumer<Boolean>() {
            @Override
            public void accept(Boolean enabled) throws Exception {
                view.setEnabled(enabled);
            }
        });
    }

}

@@ -337,16 +337,17 @@
 atic %3CT%3E
+ 
 Disposab
@@ -470,167 +470,37 @@
 ner(
-new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                command.execute(null);%0A            %7D%0A        %7D
+v -%3E command.execute(null)
 );%0A
-%0A
     
@@ -536,36 +536,32 @@
                 
-    
 .subscribe(new C
@@ -559,880 +559,363 @@
 ibe(
-new Consumer%3CBoolean%3E() %7B%0A                        @Override%0A                        public void accept(Boolean enabled) throws Exception %7B%0A                            view.setEnabled(enabled);%0A                        %7D%0A                    %7D);%0A    %7D%0A%0A    public static %3CT%3E void bind(final View view, final RxCommand%3CT%3E command, ObservableTransformer%3CBoolean, Boolean%3E takeUntil) %7B%0A        view.setClickable(true);%0A        view.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                command.execute(null);%0A            %7D%0A        %7D);%0A        command.enabled()%0A                .compose(takeUntil)%0A                .subscribe(new Consumer%3CBoolean%3E() %7B%0A            @Override%0A            public void accept(Boolean enabled) throws Exception %7B%0A                view.setEnabled(enabled);%0A            %7D%0A        %7D
+view::setEnabled);%0A    %7D%0A%0A    public static %3CT%3E void bind(final View view, final RxCommand%3CT%3E command, ObservableTransformer%3CBoolean, Boolean%3E takeUntil) %7B%0A        view.setClickable(true);%0A        view.setOnClickListener(v -%3E command.execute(null));%0A        command.enabled()%0A                .compose(takeUntil)%0A                .subscribe(view::setEnabled
 );%0A 

use lambda for the missing file