/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package rx.android.view;

import android.view.View;
import android.widget.TextView;
import rx.functions.Action1;

/**
 * Utility class for the Action interfaces for use with Android {@link View}s.
 */
public final class ViewActions {

    private ViewActions() {
        throw new IllegalStateException("No instances!");
    }

    /**
     * Set whether a view is enabled based on {@code boolean} values that are emitted by an
     * Observable.
     *
     * @param view
     *            to modify
     * @return an {@link Action1} that sets the enabled of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setEnabled(View view) {
        return new ViewActionSetEnabled(view);
    }

    /**
     * Set whether a view is activated based on {@code boolean} values that are emitted by an
     * Observable.
     *
     * @param view
     *            to modify
     * @return an {@link Action1} that sets the activated of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setActivated(View view) {
        return new ViewActionSetActivated(view);
    }

    /**
     * Set whether a view is clickable based on {@code boolean} values that are emitted by an
     * Observable.
     *
     * @param view
     *            to modify
     * @return an {@link Action1} that sets the clickable of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setClickable(View view) {
        return new ViewActionSetClickable(view);
    }

    /**
     * Set whether a view is focusable based on {@code boolean} values that are emitted by an
     * Observable.
     *
     * @param view
     *            to modify
     * @return an {@link Action1} that sets the focusable of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setFocusable(View view) {
        return new ViewActionSetFocusable(view);
    }

    /**
     * Set whether a view is selected based on {@code boolean} values that are emitted by an
     * Observable.
     *
     * @param view
     *            to modify
     * @return an {@link Action1} that sets the selected of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setSelected(View view) {
        return new ViewActionSetSelected(view);
    }

    /**
     * Set the visibility of a view based on {@code boolean} values that are emitted by an
     * Observable. When {@code false} is emitted, visibility is set to {@link View#GONE}.
     *
     * @param view
     *            to modify
     * @return an {@link Action1} that sets the visibility of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setVisibility(View view) {
        return new ViewActionSetVisibility(view);
    }

    /**
     * Set the visibility of a view based on {@code boolean} values that are emitted by an
     * Observable.
     *
     * @param view
     *            to modify
     * @param visibilityOnFalse
     *            value to use on {@link View#setVisibility(int)} when a {@code false} is emitted by
     *            the {@link rx.Observable}
     * @return an {@link Action1} that sets the visibility of a view when boolean values are emitted.
     */
    public static Action1<? super Boolean> setVisibility(View view, int visibilityOnFalse) {
        return new ViewActionSetVisibility(view, visibilityOnFalse);
    }

    /**
     * Set the text of a {@link TextView} based on values emitted by an Observable.
     */
    public static Action1<? super CharSequence> setText(final TextView textView) {
        return new Action1<CharSequence>() {
            @Override
            public void call(CharSequence charSequence) {
                textView.setText(charSequence);
            }
        };
    }

    /**
     * Set the text of a {@link TextView} based on values emitted by an Observable.
     */
    public static Action1<? super Integer> setTextResource(final TextView textView) {
        return new Action1<Integer>() {
            @Override
            public void call(Integer integer) {
                textView.setText(integer);
            }
        };
    }
}

@@ -4177,22 +4177,16 @@
 setText(
-final 
 TextView
@@ -4217,24 +4217,28 @@
 urn new 
+View
 Action1%3C
 CharSequ
@@ -4229,16 +4229,26 @@
 Action1%3C
+TextView, 
 CharSequ
@@ -4253,16 +4253,24 @@
 quence%3E(
+textView
 ) %7B%0A    
@@ -4320,22 +4320,24 @@
 all(
-CharSequence c
+TextView view, C
 harS
@@ -4343,16 +4343,21 @@
 Sequence
+ text
 ) %7B%0A    
@@ -4360,37 +4360,33 @@
                 
-textV
+v
 iew.setText(char
@@ -4385,20 +4385,12 @@
 ext(
-charSequence
+text
 );%0A 
@@ -4579,22 +4579,16 @@
 esource(
-final 
 TextView
@@ -4619,24 +4619,28 @@
 urn new 
+View
 Action1%3C
 Integer%3E
@@ -4631,16 +4631,26 @@
 Action1%3C
+TextView, 
 Integer%3E
@@ -4650,16 +4650,24 @@
 nteger%3E(
+textView
 ) %7B%0A    
@@ -4717,23 +4717,36 @@
 all(
-Integer integer
+TextView view, Integer resId
 ) %7B%0A
@@ -4761,21 +4761,17 @@
         
-textV
+v
 iew.setT
@@ -4778,15 +4778,13 @@
 ext(
-integer
+resId
 );%0A 

Use ViewAction1 in ViewAction.setText and setTextResource.