Example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_DONE

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Prototype

int IME_ACTION_DONE

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_DONE.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "done" operation, typically meaning there is nothing more to input and the IME will be closed.

Usage

From source file:de.tum.frm2.nicos_android.gui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   w  w  w .jav  a 2s  .  c  o m*/

    // Set up the container and its adapter for devices.
    _moveables = new ArrayList<>();
    View content_main = findViewById(R.id.content_main);
    _devicesAdapter = new DeviceViewAdapter(MainActivity.this, _moveables);
    final ListView deviceListView = (ListView) content_main.findViewById(R.id.deviceListView);
    deviceListView.setAdapter(_devicesAdapter);

    // Set up _uiThread to be a handler that runs runnables on the UI thread.
    // advantage over runOnUiThread() is that we can actually control the state of the thread
    // and cancel it, if needed.
    _uiThread = new Handler(Looper.getMainLooper());

    // Default boolean values: Activity is visible, devices not yet fetched
    _visible = true;
    _canAccessDevices = false;

    ConnectionData connData = (ConnectionData) getIntent()
            .getSerializableExtra(LoginActivity.MESSAGE_CONNECTION_DATA);
    _uniquePrefix = connData.getHost() + connData.getUser();

    // References to the 'steps' views.
    _coarseStepEditText = (EditText) findViewById(R.id.coarseStepEditText);
    _fineStepEditText = (EditText) findViewById(R.id.fineStepEditText);

    TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
            if (actionID == EditorInfo.IME_ACTION_DONE) {
                _fineStepEditText.clearFocus();
                // Hide keyboard.
                InputMethodManager manager = (InputMethodManager) getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                manager.hideSoftInputFromWindow(textView.getWindowToken(), 0);
            }
            return false;
        }
    };

    // When hitting 'enter' or 'ok' on the keyboard while in EditText, apply changes and hide
    // keyboard.
    _coarseStepEditText.setOnEditorActionListener(onEditorActionListener);
    _fineStepEditText.setOnEditorActionListener(onEditorActionListener);

    TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            saveSteps();
        }
    };

    _coarseStepEditText.addTextChangedListener(textWatcher);
    _fineStepEditText.addTextChangedListener(textWatcher);

    // Reference to the bottom slider panel + initial height.
    _slidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

    // Change behavior of Panel when state changes.
    _slidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
        }

        @Override
        public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState,
                SlidingUpPanelLayout.PanelState newState) {
            if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
                // When hiding the panel, also hide the keyboard and clear all focuses.
                InputMethodManager manager = (InputMethodManager) getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                manager.hideSoftInputFromWindow(panel.getWindowToken(), 0);
                _coarseStepEditText.clearFocus();
                _coarseStepEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
                _fineStepEditText.clearFocus();
                _fineStepEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
            }

        }
    });

    // Reference to current device and the 3 subviews of currentDeviceView.
    // That means the name label, value label and status image.
    _currentDevice = null;
    _currentDeviceTextView = (TextView) findViewById(R.id.deviceNameTextView);
    _currentDeviceValueTextView = (TextView) findViewById(R.id.deviceValueTextView);
    _currentDeviceStatusImageView = (ImageView) findViewById(R.id.statusledView);

    // References to the 5 control buttons.
    _coarseStepLeftButton = (Button) findViewById(R.id.coarseStepLeftButton);
    _coarseStepLeftButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onStepButtonClicked(_coarseStepLeftButton);
        }
    });
    _fineStepLeftButton = (Button) findViewById(R.id.fineStepLeftButton);
    _fineStepLeftButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onStepButtonClicked(_fineStepLeftButton);
        }
    });
    _stopButton = (Button) findViewById(R.id.stopButton);
    _stopButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onStopButtonClicked();
        }
    });
    _fineStepRightButton = (Button) findViewById(R.id.fineStepRightButton);
    _fineStepRightButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onStepButtonClicked(_fineStepRightButton);
        }
    });
    _coarseStepRightButton = (Button) findViewById(R.id.coarseStepRightButton);
    _coarseStepRightButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onStepButtonClicked(_coarseStepRightButton);
        }
    });
    _slidingUpPanelLayout.setEnabled(false);

    // Change behavior when clicking/tapping on a device.
    deviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            Device device = (Device) deviceListView.getItemAtPosition(position);
            onDeviceSelected(device);
        }
    });

    NicosClient.getClient().registerCallbackHandler(this);
    new Thread(new Runnable() {
        @Override
        public void run() {
            on_client_connected();
        }
    }).start();
}

From source file:com.mercandalli.android.apps.files.user.ConversationActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_conversation);

    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);/*from  ww  w  .  jav a  2 s  . com*/
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        Log.e("" + getClass().getName(), "extras == null");
        this.finish();
        this.overridePendingTransition(R.anim.right_in, R.anim.right_out);
        return;
    }

    mInputEditText = (EditText) findViewById(R.id.input);

    mIdConversation = extras.getString("ID_CONVERSATION");
    mUrl = Constants.URL_DOMAIN + Config.ROUTE_USER_MESSAGE + "/" + mIdConversation;

    mProgressBar = (ProgressBar) findViewById(R.id.circularProgressBar);
    mMessageTextView = (TextView) findViewById(R.id.message);

    mRecyclerView = (RecyclerView) findViewById(R.id.listView);
    mRecyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setStackFromEnd(true);
    mRecyclerView.setLayoutManager(linearLayoutManager);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    this.mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshList();
        }
    });

    mAdapterModelConversationMessage = new AdapterModelConversationMessage(mUserConversationMessageModels);
    mRecyclerView.setAdapter(mAdapterModelConversationMessage);
    mRecyclerView.setItemAnimator(/*new SlideInFromLeftItemAnimator(mRecyclerView)*/new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));

    mAdapterModelConversationMessage
            .setOnItemClickListener(new AdapterModelConversationMessage.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {

                }
            });

    mAdapterModelConversationMessage
            .setOnItemLongClickListener(new AdapterModelConversationMessage.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(View view, int position) {

                    return true;
                }
            });

    mInputEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                String url = Constants.URL_DOMAIN + Config.ROUTE_USER_MESSAGE + "/" + mIdConversation;
                List<StringPair> parameters = new ArrayList<>();
                parameters.add(new StringPair("message", "" + mInputEditText.getText().toString()));
                mInputEditText.setText("");

                new TaskPost(ConversationActivity.this, url, new IPostExecuteListener() {
                    @Override
                    public void onPostExecute(JSONObject json, String body) {
                        refreshList();
                    }
                }, parameters).execute();

                return true;
            }
            return false;
        }
    });

    refreshList();
}

From source file:com.luke.lukef.lukeapp.fragments.NewSubmissionFragment.java

/**
 * Finds the fragmen't views// w w w  .  j a  v a 2 s  . c o  m
 */
private void findViews() {
    this.makeSubmissionButton = (ImageButton) this.fragmentView.findViewById(R.id.button_tick_submit);
    this.backButton = (ImageButton) this.fragmentView.findViewById(R.id.button_back);
    this.categoriesLinearLayout = (LinearLayout) this.fragmentView.findViewById(R.id.categoriesLinearLayout);
    this.submissionDescription = (EditText) this.fragmentView
            .findViewById(R.id.newSubmissionEditTextDescrption);
    this.submissionTitle = (EditText) this.fragmentView.findViewById(R.id.newSubmissionEditTextTitle);
    this.submissionDescription.setImeOptions(EditorInfo.IME_ACTION_DONE);
    submissionTitle.setImeOptions(EditorInfo.IME_ACTION_DONE);
    this.categorySelectButton = (Button) fragmentView.findViewById(R.id.categorySelectButtonNewSubmission);
    this.photoThumbnail = (ImageView) this.fragmentView.findViewById(R.id.photoThumbnail);
    this.mapThumbnail = (ImageView) this.fragmentView.findViewById(R.id.newSubmissionMapThumbnail);
}

From source file:com.ternup.caddisfly.fragment.FormFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_form, container, false);
    /*/*from  w  ww .ja va 2  s .co  m*/
            TextView textView = (TextView) rootView.findViewById(R.id.section_label);
            textView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
    */
    LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.rootLayout);

    //mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (mAddress == null) {
                MainApp mainApp = (MainApp) getActivity().getApplicationContext();
                mainApp.address = new Address(Locale.getDefault());
                mAddress = mainApp.address;

            }
            mAddress.setFeatureName(mPlaceEditText.getEditText().getText().toString());

        }
    };

    mPlaceEditText = new FormEditText(getActivity(), getString(R.string.place));
    mPlaceEditText.getEditText().requestFocus();
    linearLayout.addView(mPlaceEditText.getView());
    mPlaceEditText.getEditText().addTextChangedListener(textWatcher);

    mThoroughfareEditText = new FormEditText(getActivity(), getString(R.string.street));
    linearLayout.addView(mThoroughfareEditText.getView());

    mSubLocalityEditText = new FormEditText(getActivity(), getString(R.string.town));
    linearLayout.addView(mSubLocalityEditText.getView());

    mLocalityEditText = new FormEditText(getActivity(), getString(R.string.city));
    linearLayout.addView(mLocalityEditText.getView());

    mStateEditText = new FormEditText(getActivity(), getString(R.string.state));
    linearLayout.addView(mStateEditText.getView());

    mCountryEditText = new FormEditText(getActivity(), getString(R.string.country));
    mCountryEditText.getEditText().setImeActionLabel(getString(R.string.done), EditorInfo.IME_ACTION_DONE);
    linearLayout.addView(mCountryEditText.getView());
    mCountryEditText.getEditText().setOnEditorActionListener(this);

    return rootView;
}

From source file:com.auth0.lock.fragment.SignUpFormFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    emailField = (CredentialField) view.findViewById(R.id.com_auth0_db_signup_email_field);
    usernameField = (CredentialField) view.findViewById(R.id.com_auth0_db_signup_username_field);
    if (!requiresUsername && useEmail) {
        usernameField.setVisibility(View.GONE);
        View separator = view.findViewById(R.id.com_auth0_db_signup_username_separator);
        separator.setVisibility(View.GONE);
    }//  w w w .  jav  a  2 s  .  co  m
    if (!useEmail && !requiresUsername) {
        emailField.setVisibility(View.GONE);
        usernameField.setNextFocusDownId(R.id.com_auth0_db_signup_password_field);
        View separator = view.findViewById(R.id.com_auth0_db_signup_email_separator);
        separator.setVisibility(View.GONE);
    }
    passwordField = (CredentialField) view.findViewById(R.id.com_auth0_db_signup_password_field);
    accessButton = (Button) view.findViewById(R.id.com_auth0_db_access_button);
    progressBar = (ProgressBar) view.findViewById(R.id.com_auth0_db_signup_progress_indicator);

    passwordField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                signUp();
            }
            return false;
        }
    });

    accessButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            signUp();
        }
    });
}

From source file:com.dvdprime.mobile.android.ui.WriteDocumentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_write_document);
    getActionBar().setTitle(R.string.action_bar_write_document);

    // Checking Authorization
    if (PrefUtil.getInstance().getString("account_id", null) == null) {
        AndroidUtil.showToast(this, getString(R.string.toast_need_login_message));
        finish();/* w w w . j  ava 2  s  . co m*/
    }
    mContext = this;

    // Initialize Parameters
    Bundle bundle = getIntent().getExtras();
    String id = bundle.getString("id");
    String title = bundle.getString("title", null);
    String content = bundle.getString("content", null);
    String tag = bundle.getString("tag", null);
    bbsId = bundle.getString("bbsId", "");
    date = bundle.getString("date", "");
    mBbsList = DBAdapter.getInstance().selectBbsList(-1);

    ArrayList<String> categoryList = new ArrayList<String>();
    Iterator<Bbs> iter = mBbsList.iterator();
    if (iter.hasNext()) {
        while (iter.hasNext()) {
            Bbs bbs = (Bbs) iter.next();
            if (StringUtil.equals(id, bbs.getUniqId())) {
                mSelectionIndex = mBbsList.indexOf(bbs);
            }
            categoryList.add("[" + bbs.getGroupTitle() + "] " + bbs.getTitle());
        }
    }

    mCategory = ((Spinner) findViewById(R.id.bbs_category_spinner));
    mCategoryAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categoryList);
    mCategoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mCategory.setAdapter(mCategoryAdapter);
    mCategory.setSelection(mSelectionIndex);
    mCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> paramAdapterView, View paramView, int paramInt,
                long paramLong) {
        }

        public void onNothingSelected(AdapterView<?> paramAdapterView) {
        }
    });
    mCategory.setVisibility(View.GONE);
    mTitleView = ((EditText) findViewById(R.id.title_editText));
    mContentView = ((EditText) findViewById(R.id.content_editText));
    mTagView = ((EditText) findViewById(R.id.tag_editText));
    mTagView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView view, int which, KeyEvent event) {
            if (which == EditorInfo.IME_ACTION_DONE) {
                attemptSend();
                return true;
            }
            return false;
        }
    });
    if (title != null) {
        isModify = true;
        mTitleView.setText(title);
        mContentView.setText(content);
        mTagView.setText(tag);
        getActionBar().setTitle(getString(R.string.view_menu_modify));
    }
    mAttachButtonView = ((ImageButton) findViewById(R.id.attach_imageButton));
    mAttachButtonView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            AndroidUtil.setKeyboardVisible(mContext, mContentView, false);
            if (PrefUtil.getInstance().getString("flickr_access_token", null) == null) {
                AndroidUtil.showConfim(mContext, getString(R.string.alert_dialog_alert),
                        getString(R.string.flickr_auth_alert_message), new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                new OAuthTask(mContext).execute(new Void[0]);
                            }
                        });
                return;
            }
            startActivityForResult(new Intent(WriteDocumentActivity.this, WriteGalleryActivity.class),
                    RequestCode.WRITE_GALLERY);
        }
    });
    mWriteFormView = findViewById(R.id.write_form);
    mWriteStatusView = findViewById(R.id.write_status);

    // Initialize Google Analytics
    EasyTracker.getInstance().setContext(this);
    EasyTracker.getTracker().sendView("WriteDocument");
    LOGD("Tracker", "WriteDocument");
}

From source file:com.shalzz.attendance.fragment.CaptchaDialogFragment.java

/**
 * Called when the DialogView is started. Used to setup the onClick listeners.
 *///from  ww w .  j av  a 2  s  .c  o  m
@Override
public void onStart() {
    super.onStart();

    // Reference the views from the layout
    Dialog dialogView = CaptchaDialogFragment.this.getDialog();
    Button bRefreshCaptcha = (Button) dialogView.findViewById(R.id.bRefresh);
    Captxt = (EditText) dialogView.findViewById(R.id.etCapTxt);
    ivCapImg = (ImageView) dialogView.findViewById(R.id.ivCapImg);
    pbar = (ProgressBar) dialogView.findViewById(R.id.progressBar1);

    AlertDialog alertDialog = (AlertDialog) getDialog();
    final Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);

    // Get the Captcha Image
    getImg();

    // OnClickListener event for the Reload captcha Button
    bRefreshCaptcha.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(LoginActivity.class.toString(), "Refreshing Captcha...");
            getImg();
            Captxt.setText("");
        }
    });

    // logs in when user press done on keyboard.
    Captxt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                positiveButton.performClick();
                return true;
            }
            return false;
        }
    });
}

From source file:com.waz.zclient.newreg.fragments.EmailAddPhoneFragment.java

@Override
public void onResume() {
    super.onResume();

    buttonCountryChooser.setOnClickListener(this);
    editTextPhone.addTextChangedListener(this);
    phoneConfirmationButton.setOnClickListener(this);
    textViewCountryCode.setOnClickListener(this);
    textViewNotNow.setOnClickListener(this);

    editTextPhone.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//from   w  ww .j  ava 2 s  .  com
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                confirmPhoneNumber();
                return true;
            } else {
                return false;
            }
        }
    });
}

From source file:com.markupartist.sthlmtraveling.PlaceSearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.place_search_layout);

    registerScreen("Place Search");

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.containsKey(ARG_ONLY_STOPS)) {
            mSearchOnlyStops = extras.getBoolean(ARG_ONLY_STOPS);
        }/*  ww  w . j av  a  2  s  . co m*/
    }

    initGoogleApiClient(false);

    createSearchHandler();

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(STATE_SEARCH_FILTER)) {
            mCurrentSearchFilterType = savedInstanceState.getInt(STATE_SEARCH_FILTER);
        }
    }

    mHistoryDbAdapter = new HistoryDbAdapter(this).open();

    ImageButton backButton = (ImageButton) findViewById(R.id.search_back);
    ViewHelper.tint(backButton, ContextCompat.getColor(this, R.color.primary_dark));
    ViewHelper.flipIfRtl(backButton);

    backButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mSearchEdit = (EditText) findViewById(R.id.search_edit);
    mSearchEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                mSearchResultAdapter.getFilter().filter(mSearchEdit.getText());
            }
            return false;
        }
    });
    mSearchEdit.requestFocus();

    mClearButton = (ImageButton) findViewById(R.id.search_clear);
    ViewHelper.tintIcon(mClearButton.getDrawable(), Color.GRAY);
    mClearButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSearchEdit.setText("");
            mSearchResultAdapter.clear();
        }
    });

    mSearchFailed = findViewById(R.id.search_result_error);
    mProgressBar = (ContentLoadingProgressBar) findViewById(R.id.search_progress_bar);

    setupHistoryViews();
    if (!mSearchOnlyStops) {
        getSupportLoaderManager().initLoader(LOADER_HISTORY, null, this);
    }
    setupSearchResultViews();

    if (!shouldSearchGooglePlaces()) {
        setSearchFilter(FILTER_TYPE_STHLM_TRAVELING);
    }

    mMyLocationManager = new LocationManager(this, getGoogleApiClient());
    mMyLocationManager.setLocationListener(this);
    mMyLocationManager.setAccuracy(false);
    registerPlayService(mMyLocationManager);
    if (!mSearchOnlyStops) {
        verifyLocationPermission();
        mMyLocationManager.requestLocation();
    }
}

From source file:com.kinvey.sample.kitchensink.account.LoginFragment.java

protected void addEditListeners() {
    login.setEnabled(validateInput());//  w w w. jav  a  2  s. c o m

    username.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            login.setEnabled(validateInput());
        }
    });

    username.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE
                    || (event.getAction() == KeyEvent.ACTION_DOWN
                            && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    && username.getText().length() < MIN_USERNAME_LENGTH) {

                CharSequence text = "User name must contain at least " + MIN_USERNAME_LENGTH + " characters";
                Toast.makeText(getSherlockActivity().getApplicationContext(), text, Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });

    password.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            login.setEnabled(validateInput());
        }
    });

    password.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE
                    || (event.getAction() == KeyEvent.ACTION_DOWN
                            && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    && password.getText().length() < MIN_USERNAME_LENGTH) {
                CharSequence text = "Password must contain at least " + MIN_PASSWORD_LENGTH + " characters";
                Toast.makeText(getSherlockActivity(), text, Toast.LENGTH_SHORT).show();
                return true;
            }
            return false;
        }
    });

}