@Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { if (mFocusChangeListener != null) { mFocusChangeListener.onFocusChange(this, gainFocus); } super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); }
@Override public void onRestoreInstanceState(Parcelable state) { if (!(state instanceof ClearIconSavedState)) { super.onRestoreInstanceState(state); return; } ClearIconSavedState savedState = (ClearIconSavedState) state; super.onRestoreInstanceState(savedState.getSuperState()); mIsClearIconShown = savedState.isClearIconShown(); showClearIcon(mIsClearIconShown); }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); return mIsClearIconShown ? new ClearIconSavedState(superState, true) : superState; }
regTypeEditText.setOnEditorActionListener(this); portEditText.setOnEditorActionListener(this); regTypeEditText.setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.select_dialog_item, regTypes));
private void requestFiltering(CharSequence constraint, int keyCode) { super.performFiltering(constraint, keyCode); } }
@Override protected void onScrollChanged(int x, int y, int oldX, int oldY) { super.onScrollChanged(x, y, oldX, oldY); mPositionX = x; requestLayout(); }
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (getView() == null || actionId != EditorInfo.IME_ACTION_DONE) { return false; } switch (v.getId()) { case R.id.service_name: regTypeEditText.requestFocus(); return true; case R.id.reg_type: portEditText.requestFocus(); return true; case R.id.port: InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getView().getWindowToken(), 0); return true; } return false; }
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { if (isClearIconTouched(event)) { setText(null); event.setAction(MotionEvent.ACTION_CANCEL); showClearIcon(false); if(textClearedListener != null) textClearedListener.onTextCleared(); return false; } return super.onTouchEvent(event); }
@Override public void onDraw(Canvas canvas) { float lineWidth = getLayout().getLineWidth(0); float width = getMeasuredWidth(); if (getText() == null || getText().length() == 0 || lineWidth <= width) { getPaint().setShader(null); super.onDraw(canvas); return; } int textColor = getCurrentTextColor(); float widthEnd = width + mPositionX; float percent = (int) (width * 0.2); float fadeStart = mPositionX / widthEnd; float stopStart = mPositionX > 0 ? ((mPositionX + percent) / widthEnd) : 0; float stopEnd = (widthEnd - (lineWidth > widthEnd ? percent : 0)) / widthEnd; getPaint().setShader(getGradient(widthEnd, fadeStart, stopStart, stopEnd, textColor)); super.onDraw(canvas); } }
@Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { showClearIcon( (!mClearIconDrawWhenFocused || focused) && !TextUtils.isEmpty(getText().toString())); super.onFocusChanged(focused, direction, previouslyFocusedRect); }