List of usage examples for android.view View requestFocus
public final boolean requestFocus()
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java
@Override public void onWhoCardViewCreated(final EditText nameEditText, final EditText emailEditText, final View viewToFocus) { this.whoCardNameEditText = nameEditText; this.whoCardEmailEditText = emailEditText; if (pendingWhoCardName != null) { nameEditText.onRestoreInstanceState(pendingWhoCardName); pendingWhoCardName = null;//from www.j a v a 2 s .c o m } if (pendingWhoCardEmail != null) { emailEditText.onRestoreInstanceState(pendingWhoCardEmail); pendingWhoCardEmail = null; } messageCenterRecyclerView.setPadding(0, 0, 0, 0); if (viewToFocus != null) { viewToFocus.requestFocus(); if (forceShowKeyboard) { viewToFocus.post(new Runnable() { @Override public void run() { if (forceShowKeyboard) { forceShowKeyboard = false; Util.showSoftKeyboard(hostingActivityRef.get(), viewToFocus); } } }); } } hideFab(); }
From source file:com.android.mail.ui.ConversationViewFragment.java
private void focusAndScrollToView(View v) { // Make sure that v is in view final int[] coords = new int[2]; v.getLocationOnScreen(coords);/*from ww w. java 2 s. com*/ final int bottom = coords[1] + v.getHeight(); if (bottom > mMaxScreenHeight) { mWebView.scrollBy(0, bottom - mMaxScreenHeight); } else if (coords[1] < mTopOfVisibleScreen) { mWebView.scrollBy(0, coords[1] - mTopOfVisibleScreen); } v.requestFocus(); }
From source file:com.sanron.sunweather.view.v4.DrawerLayout.java
void dispatchOnDrawerOpened(View drawerView) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); if (!lp.knownOpen) { lp.knownOpen = true;/* ww w .j a v a 2s . co m*/ if (mListener != null) { mListener.onDrawerOpened(drawerView); } updateChildrenImportantForAccessibility(drawerView, true); drawerView.requestFocus(); } }
From source file:com.yao.zhihudaily.tool.LazyViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null;//from w w w .j a v a2s . co m boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:com.remdo.app.EditDeviceActivity.java
/** * Check if fields match defined rules and if deviceName or url already exist * @return// w ww .java2 s . c om */ public boolean checkFields() { mDeviceName = mDeviceNameView.getText().toString(); mHost = mHostView.getText().toString(); mUser = mUserView.getText().toString(); mPassword = mPasswordView.getText().toString(); boolean cancel = false; View focusView = null; // check device name field if (TextUtils.isEmpty(mDeviceName)) { mDeviceNameView.setError(getString(R.string.error_required_field)); focusView = mDeviceNameView; cancel = true; } if (EditMode == false && dh.DeviceExists(mDeviceName, "name")) { mHostView.setError(getString(R.string.error_existing_device)); if (!cancel) { focusView = mDeviceNameView; cancel = true; } } // check server field if (TextUtils.isEmpty(mHost)) { mHostView.setError(getString(R.string.error_required_field)); if (!cancel) { focusView = mHostView; cancel = true; } } if (!URLUtil.isValidUrl(mHost)) { mHostView.setError(getString(R.string.error_invalid_url)); focusView = mHostView; cancel = true; } if (EditMode == false && dh.DeviceExists(mHost, "url")) { mHostView.setError(getString(R.string.error_existing_device)); if (!cancel) { focusView = mHostView; cancel = true; } } // check user field if (TextUtils.isEmpty(mUser)) { mUserView.setError(getString(R.string.error_required_field)); if (!cancel) { focusView = mUserView; cancel = true; } } // check password field if (TextUtils.isEmpty(mPassword)) { mPasswordView.setError(getString(R.string.error_required_field)); if (!cancel) { focusView = mPasswordView; cancel = true; } } if (cancel) { // on error do not save the device focusView.requestFocus(); return false; } else { return true; } }
From source file:com.oakesville.mythling.MediaActivity.java
protected void setFocusOnActionBar() { int actionBarResId = getResources().getIdentifier("action_bar_container", "id", "android"); View actionBarView = getWindow().getDecorView().findViewById(actionBarResId); if (actionBarView != null) actionBarView.requestFocus(); }
From source file:bw.com.yunifangstore.view.LazyViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null;//from ww w. j a v a 2 s . c o m boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:com.doplgangr.secrecy.views.VaultsListFragment.java
void switchView(final View parentView, final int showView) { getActivity().runOnUiThread(new Runnable() { @Override// w w w . j a v a 2s . c o m public void run() { EditText passwordView = (EditText) parentView.findViewById(R.id.open_password); final View renameView = parentView.findViewById(R.id.rename_name); ViewAnimator viewAnimator = (ViewAnimator) parentView.findViewById(R.id.viewAnimator); viewAnimator.setInAnimation(context, R.anim.slide_down); int viewIndex = 0; switch (showView) { case R.id.vault_name_layout: viewIndex = 0; break; case R.id.vault_decrypt_layout: viewIndex = 1; if (passwordView != null) { passwordView.requestFocus(); passwordView.setText(""); //Reset password field everytime } // Only one vault selected at that time passwordView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { ViewAnimator viewAnimator = (ViewAnimator) parentView .findViewById(R.id.viewAnimator); viewAnimator.setDisplayedChild(0); } } }); kbdView = passwordView; imm.showSoftInput(passwordView, InputMethodManager.SHOW_IMPLICIT); break; case R.id.vault_delete_layout: viewIndex = 2; break; case R.id.vault_rename_layout: viewIndex = 3; if (renameView != null) renameView.requestFocus(); // Only one vault selected at that time renameView.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { ViewAnimator viewAnimator = (ViewAnimator) parentView .findViewById(R.id.viewAnimator); viewAnimator.setDisplayedChild(0); } } }); kbdView = renameView; imm.showSoftInput(renameView, InputMethodManager.SHOW_IMPLICIT); break; } viewAnimator.setDisplayedChild(viewIndex); } }); }
From source file:com.example.show.NoPreloadViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) currentFocused = null;//from w w w .ja v a2s. c om boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }
From source file:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.java
public boolean arrowScroll(int direction) { View currentFocused = findFocus(); if (currentFocused == this) { currentFocused = null;// w w w . ja v a 2 s . com } boolean handled = false; View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction); if (nextFocused != null && nextFocused != currentFocused) { if (direction == View.FOCUS_LEFT) { // If there is nothing to the left, or this is causing us to // jump to the right, then what we really want to do is page left. if (currentFocused != null && nextFocused.getLeft() >= currentFocused.getLeft()) { handled = pageLeft(); } else { handled = nextFocused.requestFocus(); } } else if (direction == View.FOCUS_RIGHT) { // If there is nothing to the right, or this is causing us to // jump to the left, then what we really want to do is page right. if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) { handled = pageRight(); } else { handled = nextFocused.requestFocus(); } } } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) { // Trying to move left and nothing there; try to page. handled = pageLeft(); } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) { // Trying to move right and nothing there; try to page. handled = pageRight(); } if (handled) { playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction)); } return handled; }