List of usage examples for android.view View requestFocus
public final boolean requestFocus()
From source file:com.libreteam.driver.Driver_RideOffer.java
@SuppressLint("InflateParams") @SuppressWarnings({ "unchecked", "rawtypes" }) @Override/*w w w.j av a2s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); View view = inflater.inflate(R.layout.driver_rideoffer, null); context = view.getContext(); ride_id = getArguments().getStringArray("rideid")[0]; customer_id = getArguments().getStringArray("rideid")[1]; address = getArguments().getStringArray("rideid")[2]; latlng = getArguments().getStringArray("rideid")[3]; ArrayList aList = new ArrayList(Arrays.asList(latlng.split(","))); driverLatLng = new LatLng(Driver_Status.getLatitude(), Driver_Status.getLongitude()); customerLatLng = new LatLng(Double.parseDouble(aList.get(0).toString()), Double.parseDouble(aList.get(1).toString())); if (savedInstanceState == null) initComponents(view); view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (((Driver_Fragment_Activity) getActivity()).isMenu) { ((Driver_Fragment_Activity) getActivity()).didHideMenu(); return true; } didSendMessage(); ((Driver_Fragment_Activity) getActivity()).didFinish(); return false; } else { return false; } } }); return view; }
From source file:prince.app.ccm.Fragment_Log.java
/** * Attempts to sign in or register the account specified by the login form. * If there are form errors (invalid email, missing fields, etc.), the * errors are presented and no actual login attempt is made. *///w w w . ja v a 2s .c o m public void attemptLogin() { if (mAuthTask != null) { return; } Log.e(TAG, "Attempting Login"); // Reset errors. mUserEditText.setError(null); mPasswordEditText.setError(null); // Store values at the time of the login attempt. mUserName = mUserEditText.getText().toString(); mPassword = mPasswordEditText.getText().toString(); boolean cancel = false; View focusView = null; // Check for a valid password. if (TextUtils.isEmpty(mPassword)) { mPasswordEditText.setError(getString(R.string.error_field_required)); focusView = mPasswordEditText; cancel = true; } else if (mPassword.length() < 4) { mPasswordEditText.setError(getString(R.string.error_incorrect_password)); focusView = mPasswordEditText; cancel = true; } // Check for a valid email address. if (TextUtils.isEmpty(mUserName)) { mUserEditText.setError(getString(R.string.error_field_required)); focusView = mUserEditText; cancel = true; } if (cancel) { // There was an error; don't attempt login and focus the first // form field with an error. focusView.requestFocus(); } else { // Show a progress spinner, and kick off a background task to // perform the user login attempt. showProgress(true); mAuthTask = new AsyncSession(mUserEditText.getText().toString().trim(), mPasswordEditText.getText().toString().trim()); mAuthTask.execute(); } }
From source file:android.support.v7.widget.BaseRecyclerViewInstrumentationTest.java
public boolean requestFocus(final View view, boolean waitForScroll) throws Throwable { final boolean[] result = new boolean[1]; try {/*from w w w .ja v a 2 s. c om*/ runTestOnUiThread(new Runnable() { @Override public void run() { result[0] = view.requestFocus(); } }); } catch (Throwable throwable) { fail(throwable.getMessage()); } if (waitForScroll && result[0]) { waitForIdleScroll(mRecyclerView); } return result[0]; }
From source file:com.scoreflex.Scoreflex.java
/** * A helper method that submits turn data and directly show challenge * detail./* w w w .j a va 2 s. c om*/ * * @param activity * The activity that will host the view. * @param challengeInstanceId * The challenge instance id. * @param turn * The turn data. */ public static void submitTurnAndShowChallengeDetail(final Activity activity, final String challengeInstanceId, RequestParams turn) { final String resource = "/web/challenges/instances/" + challengeInstanceId; submitTurn(challengeInstanceId, turn, new Scoreflex.ResponseHandler() { @Override public void onFailure(Throwable e, Response errorResponse) { Log.d("Scoreflex", "Could not submit score, Chalenge detail wont be shown"); } @Override public void onSuccess(Response response) { View view = Scoreflex.view(activity, resource, null, true); activity.addContentView(view, view.getLayoutParams()); view.requestFocus(); view.requestFocusFromTouch(); } }); }
From source file:com.locution.hereyak.LoginActivity.java
public void attemptLogin() { if (mAuthTask != null) { return;/*www . j a v a2s . c o m*/ } // Reset errors. mEmailView.setError(null); mPasswordView.setError(null); // Store values at the time of the login attempt. mEmail = mEmailView.getText().toString(); mPassword = mPasswordView.getText().toString(); boolean cancel = false; View focusView = null; // Check for a valid password. if (TextUtils.isEmpty(mPassword)) { mPasswordView.setError(getString(R.string.error_field_required)); focusView = mPasswordView; cancel = true; } else if (mPassword.length() < 6) { mPasswordView.setError(getString(R.string.error_invalid_password)); focusView = mPasswordView; cancel = true; } // Check for a valid email address. if (TextUtils.isEmpty(mEmail)) { mEmailView.setError(getString(R.string.error_field_required)); focusView = mEmailView; cancel = true; } else if (!mEmail.contains("@")) { mEmailView.setError(getString(R.string.error_invalid_email)); focusView = mEmailView; cancel = true; } if (cancel) { // There was an error; don't attempt login and focus the first // form field with an error. focusView.requestFocus(); } else { // Show a progress spinner, and kick off a background task to // perform the user login attempt. mLoginStatusMessageView.setText(R.string.login_progress_signing_in); showProgress(true); mAuthTask = new UserLoginTask(); mAuthTask.execute((Void) null); } }
From source file:org.cm.podd.report.activity.ReportActivity.java
@Override public boolean onSoftKeyAction(TextView view, int actionId, KeyEvent event) { switch (actionId) { case EditorInfo.IME_ACTION_NEXT: Log.d(TAG, "action NEXT"); View nextTextView = view.focusSearch(View.FOCUS_DOWN); if (nextTextView != null) { nextTextView.requestFocus(); if (!(nextTextView instanceof EditText)) { hideKeyboard();/*from w ww .j av a 2s .com*/ } return true; } case EditorInfo.IME_ACTION_DONE: Log.d(TAG, "action DONE"); nextScreen(); hideKeyboard(); return true; } return false; }
From source file:com.alivenet.dmvtaxi.fragment.Fragment_ride_list.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_ride_list, container, false); mPref = getActivity().getSharedPreferences(MYPREF, Context.MODE_PRIVATE); mUserId = mPref.getString("userId", null); progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("Please wait..."); progressDialog.setCancelable(false); recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true);// w w w .j av a 2 s. c om LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.addItemDecoration(new SpacesItemDecoration(VERTICAL_ITEM_SPACE)); recyclerView.setLayoutManager(llm); recyclerView.setItemAnimator(new DefaultItemAnimator()); mnorides = (TextView) view.findViewById(R.id.tv_norides); RequestParams params = new RequestParams(); params.put("userId", mUserId); rideListWs(params); view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { // handle back button's click listener if (keyCode == KeyEvent.KEYCODE_BACK) { Fragment homeFragment = new FragmentMainScreen(); FragmentManager frgManager; frgManager = getFragmentManager(); frgManager.beginTransaction().replace(R.id.fragment_switch, homeFragment).commit(); return true; } return true; } return false; } }); return view; }
From source file:cx.ring.fragments.AccountCreationFragment.java
/** * Attempts to sign in or register the account specified by the login form. If there are form errors (invalid email, missing fields, etc.), the * errors are presented and no actual login attempt is made. *//*from w ww .jav a 2 s .com*/ public void attemptCreation() { // Reset errors. mAliasView.setError(null); mPasswordView.setError(null); // Store values at the time of the login attempt. boolean cancel = false; boolean warningIPAccount = false; View focusView = null; // Alias is mandatory if (TextUtils.isEmpty(mAlias)) { mAliasView.setError(getString(R.string.error_field_required)); focusView = mAliasView; cancel = true; } if (TextUtils.isEmpty(mHostname)) { warningIPAccount = true; } if (!warningIPAccount && TextUtils.isEmpty(mPassword)) { mPasswordView.setError(getString(R.string.error_field_required)); focusView = mPasswordView; cancel = true; } if (!warningIPAccount && TextUtils.isEmpty(mUsername)) { mUsernameView.setError(getString(R.string.error_field_required)); focusView = mUsernameView; cancel = true; } if (cancel) { focusView.requestFocus(); } else if (warningIPAccount) { showIP2IPDialog(); } else { initAccountCreation(); } }
From source file:com.sefford.beauthentic.activities.LoginActivity.java
/** * Attempts to sign in or register the account specified by the login form. * If there are form errors (invalid email, missing fields, etc.), the * errors are presented and no actual login attempt is made. *///from w w w . j a v a2s . c o m void attemptLogin() { // Reset errors. etUsername.setError(null); etPassword.setError(null); // Store values at the time of the login attempt. String email = etUsername.getText().toString(); String password = etPassword.getText().toString(); boolean cancel = false; View focusView = null; // Check for a valid password, if the user entered one. if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) { etPassword.setError(getString(R.string.error_invalid_password)); focusView = etPassword; cancel = true; } // Check for a valid email address. if (TextUtils.isEmpty(email)) { etUsername.setError(getString(R.string.error_field_required)); focusView = etUsername; cancel = true; } else if (!isUsernameValid(email)) { etUsername.setError(getString(R.string.error_invalid_email)); focusView = etUsername; cancel = true; } if (cancel) { // There was an error; don't attempt login and focus the first // form field with an error. focusView.requestFocus(); } else { // Show a progress spinner, and kick off a background task to // perform the user login attempt. showProgress(true); performLogin(); } }
From source file:com.arya.portfolio.view_controller.fragment.UseCasesFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { try {//from www. ja v a 2 s. co m if (requestCode == REQUEST_CODE) { if (resultCode == getActivity().RESULT_OK) { int selectedPosition = data.getExtras().getInt("position"); // gvProductEngineering.setItemChecked(selectedPosition, true); // gvProductEngineering.smoothScrollToPosition(selectedPosition); gvProductEngineering.setSelection(selectedPosition); View v = gvProductEngineering.getChildAt(selectedPosition); if (v != null) { v.requestFocus(); } } } } catch (Exception e) { e.printStackTrace(); } }