Java Code Examples for android.view.View.OnFocusChangeListener

The following are Jave code examples for showing how to use OnFocusChangeListener of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: IM_Here   File: Animation.java   View Source Code Vote up 6 votes
private static View.OnFocusChangeListener editTextFocusChange(final EditText editText, final Context context){
    return new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if(hasFocus || !editText.getText().toString().equals("")){
                editText.setBackgroundTintList(
                        ColorStateList.valueOf(
                                context.getResources()
                                        .getColor(FOCUS_COLOR)));
            }else{
                editText.setBackgroundTintList(
                        ColorStateList.valueOf(
                                context.getResources()
                                        .getColor(LEAVE_COLOR)));

            }
        }
    };
}
 
Example 2
Project: LaunchEnr   File: ViewGroupFocusHelper.java   View Source Code Vote up 5 votes
/**
 * Sets the alpha of this FocusIndicatorHelper to 0 when a view with this listener
 * receives focus.
 */
public View.OnFocusChangeListener getHideIndicatorOnFocusListener() {
    return new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                endCurrentAnimation();
                setCurrentView(null);
                setAlpha(0);
                invalidateDirty();
            }
        }
    };
}
 
Example 3
Project: TextFieldBoxes   File: CompositeListener.java   View Source Code Vote up 5 votes
@Override
public void onFocusChange(View view, boolean b) {

    for(View.OnFocusChangeListener listener:registeredListeners) {
        listener.onFocusChange(view, b);
    }
}
 
Example 4
Project: JKApp   File: EventHelper.java   View Source Code Vote up 5 votes
public static void focus(IPresent li,View...views)
{
    if(!(li instanceof View.OnFocusChangeListener))
    {
        return;
    }
    focus((View.OnFocusChangeListener)li,views);
}
 
Example 5
Project: SimpleUILauncher   File: ViewGroupFocusHelper.java   View Source Code Vote up 5 votes
/**
 * Sets the alpha of this FocusIndicatorHelper to 0 when a view with this listener
 * receives focus.
 */
public View.OnFocusChangeListener getHideIndicatorOnFocusListener() {
    return new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                endCurrentAnimation();
                setCurrentView(null);
                setAlpha(0);
                invalidateDirty();
            }
        }
    };
}
 
Example 6
Project: LeCatApp   File: EventHelper.java   View Source Code Vote up 5 votes
public static void focus(IPresent li,View...views)
{
    if(!(li instanceof View.OnFocusChangeListener))
    {
        return;
    }
    focus((View.OnFocusChangeListener)li,views);
}
 
Example 7
Project: Android-Code-Demos   File: CustomPopupWindow.java   View Source Code Vote up 4 votes
public void setOnFocusListener(int viewId, View.OnFocusChangeListener listener) {
    View view = findView(viewId);
    view.setOnFocusChangeListener(listener);
}
 
Example 8
Project: ZeroKit-Android-Sample   File: RegistrationViewModel.java   View Source Code Vote up 4 votes
@Inject
public RegistrationViewModel(final Zerokit zerokit, AdminApi adminApi, final EventBus eventBus, SharedPreferences sharedPreferences, final Resources resources) {
    this.zerokit = zerokit;
    this.adminApi = adminApi;
    this.eventBus = eventBus;
    this.sharedPreferences = sharedPreferences;

    inProgress = new ObservableField<>(false);
    userName = new ObservableField<>("");
    passwordError = new ObservableField<>("");
    passwordConfirmError = new ObservableField<>("");
    userNameError = new ObservableField<>("");
    passwordStrength = new ObservableInt();
    seekbarColor = new ObservableField<>(resources.getDrawable(R.drawable.progress));
    colorRes = new int[]{R.color.red, R.color.deep_orange, R.color.orange, R.color.light_green, R.color.green};

    clickListenerRegistration = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptRegistration();
        }
    };
    errorResponseHandlerAdmin = new Action<ResponseAdminApiError>() {
        @Override
        public void call(ResponseAdminApiError responseAdminApiError) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(responseAdminApiError.getMessage()));
        }
    };
    errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
        @Override
        public void call(ResponseZerokitError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.getDescription()));
        }
    };
    focusChangeListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            passwordError.set("");
            userNameError.set("");
            passwordConfirmError.set("");
        }
    };

    passwordExporter = new PasswordEditText.PasswordExporter();
    passwordExporterConfirm = new PasswordEditText.PasswordExporter();

    passwordExporter.setOnChangeListener(new PasswordEditText.OnChangeListener() {
        @Override
        public void onChanged() {
            zerokit.getPasswordStrength(passwordExporter).enqueue(new Action<ResponseZerokitPasswordStrength>() {
                @Override
                public void call(ResponseZerokitPasswordStrength responseZerokitPasswordStrength) {
                    int score = responseZerokitPasswordStrength.getScore();
                    passwordStrength.set((score + 1) * 20);
                    ((LayerDrawable) seekbarColor.get()).findDrawableByLayerId(android.R.id.progress).setColorFilter(resources.getColor(colorRes[score]), PorterDuff.Mode.SRC_IN);
                }
            });
        }
    });
}
 
Example 9
Project: PartyBuildingStudies   File: CustomPopupWindow.java   View Source Code Vote up 4 votes
public void setOnFocusListener(int viewId, View.OnFocusChangeListener listener) {
    View view = findView(viewId);
    view.setOnFocusChangeListener(listener);
}
 
Example 10
Project: ZeroKit-Android-Sample   File: LoginViewModel.java   View Source Code Vote up 4 votes
@Inject
public LoginViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) {
    this.zerokit = zerokit;
    this.adminApi = adminApi;
    this.eventBus = eventBus;

    this.passwordExporter = new PasswordEditText.PasswordExporter();

    this.clickListenerLogin = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptLogin();
        }
    };

    userName = new ObservableField<>("");
    passwordError = new ObservableField<>("");
    usernameError = new ObservableField<>("");
    inProgress = new ObservableField<>(false);
    errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
        @Override
        public void call(ResponseZerokitError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
    errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
        @Override
        public void call(ResponseAdminApiError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
    focusChangeListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            passwordError.set("");
            usernameError.set("");
        }
    };
}
 
Example 11
Project: SuperRecyclerViewAdapter   File: SuperRecyclerHolder.java   View Source Code Vote up 4 votes
public SuperRecyclerHolder setOnFocusChangeListener(
    @NonNull View.OnFocusChangeListener listener) {
    getItemView().setOnFocusChangeListener(listener);
    return this;
}
 
Example 12
Project: ZeroKit-Android-SDK   File: RegistrationViewModel.java   View Source Code Vote up 4 votes
@Inject
public RegistrationViewModel(final Zerokit zerokit, AdminApi adminApi, final EventBus eventBus, SharedPreferences sharedPreferences, final Resources resources) {
    this.zerokit = zerokit;
    this.adminApi = adminApi;
    this.eventBus = eventBus;
    this.sharedPreferences = sharedPreferences;

    inProgress = new ObservableField<>(false);
    userName = new ObservableField<>("");
    passwordError = new ObservableField<>("");
    passwordConfirmError = new ObservableField<>("");
    userNameError = new ObservableField<>("");
    passwordStrength = new ObservableInt();
    seekbarColor = new ObservableField<>(resources.getDrawable(R.drawable.progress));
    colorRes = new int[]{R.color.red, R.color.deep_orange, R.color.orange, R.color.light_green, R.color.green};

    clickListenerRegistration = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptRegistration();
        }
    };
    errorResponseHandlerAdmin = new Action<ResponseAdminApiError>() {
        @Override
        public void call(ResponseAdminApiError responseAdminApiError) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(responseAdminApiError.getMessage()));
        }
    };
    errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
        @Override
        public void call(ResponseZerokitError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.getDescription()));
        }
    };
    focusChangeListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            passwordError.set("");
            userNameError.set("");
            passwordConfirmError.set("");
        }
    };

    passwordExporter = new PasswordEditText.PasswordExporter();
    passwordExporterConfirm = new PasswordEditText.PasswordExporter();

    passwordExporter.setOnChangeListener(new PasswordEditText.OnChangeListener() {
        @Override
        public void onChanged() {
            zerokit.getPasswordStrength(passwordExporter).enqueue(new Action<ResponseZerokitPasswordStrength>() {
                @Override
                public void call(ResponseZerokitPasswordStrength responseZerokitPasswordStrength) {
                    int score = responseZerokitPasswordStrength.getScore();
                    passwordStrength.set((score + 1) * 20);
                    ((LayerDrawable) seekbarColor.get()).findDrawableByLayerId(android.R.id.progress).setColorFilter(resources.getColor(colorRes[score]), PorterDuff.Mode.SRC_IN);
                }
            });
        }
    });
}
 
Example 13
Project: ZeroKit-Android-SDK   File: LoginViewModel.java   View Source Code Vote up 4 votes
@Inject
public LoginViewModel(Zerokit zerokit, AdminApi adminApi, final EventBus eventBus) {
    this.zerokit = zerokit;
    this.adminApi = adminApi;
    this.eventBus = eventBus;

    this.passwordExporter = new PasswordEditText.PasswordExporter();

    this.clickListenerLogin = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            attemptLogin();
        }
    };

    userName = new ObservableField<>("");
    passwordError = new ObservableField<>("");
    usernameError = new ObservableField<>("");
    inProgress = new ObservableField<>(false);
    errorResponseHandlerSdk = new Action<ResponseZerokitError>() {
        @Override
        public void call(ResponseZerokitError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
    errorResponseHandlerAdminapi = new Action<ResponseAdminApiError>() {
        @Override
        public void call(ResponseAdminApiError errorResponse) {
            inProgress.set(false);
            eventBus.post(new ShowMessageMessage(errorResponse.toString()));
        }
    };
    focusChangeListener = new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            passwordError.set("");
            usernameError.set("");
        }
    };
}
 
Example 14
Project: PhoneMask   File: PhoneMaskManager.java   View Source Code Vote up 4 votes
public PhoneMaskManager withOnFocusChangeListener(View.OnFocusChangeListener onFocusChangeListener) {
    this.onFocusChangeListener = onFocusChangeListener;
    return this;
}
 
Example 15
Project: JKApp   File: EventHelper.java   View Source Code Vote up 4 votes
public static void focus(View.OnFocusChangeListener li, View...views) {
    if(views == null || views.length == 0) return;
    for(View v : views) v.setOnFocusChangeListener(li);
}
 
Example 16
Project: LeCatApp   File: EventHelper.java   View Source Code Vote up 4 votes
public static void focus(View.OnFocusChangeListener li, View...views) {
    if(views == null || views.length == 0) return;
    for(View v : views) v.setOnFocusChangeListener(li);
}
 
Example 17
Project: FamilyBond   File: CustomPopupWindow.java   View Source Code Vote up 4 votes
public void setOnFocusListener(int viewId, View.OnFocusChangeListener listener) {
    View view = findView(viewId);
    view.setOnFocusChangeListener(listener);
}
 
Example 18
Project: TextFieldBoxes   File: CompositeListener.java   View Source Code Vote up 4 votes
void registerListener (View.OnFocusChangeListener listener) {
    registeredListeners.add(listener);
}
 
Example 19
Project: leoapp-sources   File: InfoButton.java   View Source Code Vote up 2 votes
/**
 * Delegiert von android.widget.Button
 *
 * @return siehe {@link Button}
 */
public View.OnFocusChangeListener getOnFocusChangeListener() {
    return b.getOnFocusChangeListener();
}
 
Example 20
Project: leoapp-sources   File: InfoButton.java   View Source Code Vote up 2 votes
/**
 * Delegiert von android.widget.Button
 *
 * @param l siehe {@link Button}
 */
public void setOnFocusChangeListener(View.OnFocusChangeListener l) {
    b.setOnFocusChangeListener(l);
}