Search in sources :

Example 31 with Editable

use of android.text.Editable in project android_frameworks_base by ResurrectionRemix.

the class TextView method removeAdjacentSuggestionSpans.

void removeAdjacentSuggestionSpans(final int pos) {
    if (!(mText instanceof Editable))
        return;
    final Editable text = (Editable) mText;
    final SuggestionSpan[] spans = text.getSpans(pos, pos, SuggestionSpan.class);
    final int length = spans.length;
    for (int i = 0; i < length; i++) {
        final int spanStart = text.getSpanStart(spans[i]);
        final int spanEnd = text.getSpanEnd(spans[i]);
        if (spanEnd == pos || spanStart == pos) {
            if (SpellChecker.haveWordBoundariesChanged(text, pos, pos, spanStart, spanEnd)) {
                text.removeSpan(spans[i]);
            }
        }
    }
}
Also used : Editable(android.text.Editable) SuggestionSpan(android.text.style.SuggestionSpan) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 32 with Editable

use of android.text.Editable in project ride-read-android by Ride-Read.

the class MapFragment method initView.

@Override
public void initView() {
    mHandler = new WeakHandler();
    mAMap = mMapView.getMap();
    //实例化UiSettings类对象
    mUiSettings = mAMap.getUiSettings();
    mUiSettings.setZoomControlsEnabled(false);
    mUiSettings.setCompassEnabled(true);
    mCurZoom = 18;
    mAMap.moveCamera(CameraUpdateFactory.zoomBy(mCurZoom));
    // 设置定位监听
    mAMap.setLocationSource(this);
    // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
    mAMap.setMyLocationEnabled(true);
    //        mUiSettings.setMyLocationButtonEnabled(true); //显示默认的定位按钮
    // 设置定位的类型为定位模式,有定位、跟随或地图根据面向方向旋转几种
    //初始化定位蓝点样式类
    MyLocationStyle myLocationStyle = new MyLocationStyle();
    //        myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
    //        myLocationStyle.(2000);
    myLocationStyle.radiusFillColor(getResources().getColor(R.color.blue_a20));
    //连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
    myLocationStyle.strokeColor(getResources().getColor(R.color.blue_a20));
    mAMap.setMyLocationStyle(myLocationStyle);
    mAMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
    AMapLocationUtils.init();
    mEdtSearch.setOnEditorActionListener((v, actionId, event) -> {
        if (KeyEvent.KEYCODE_ENTER == event.getKeyCode()) {
            searchKeyWord();
            KeyboardUtils.hideSoftInput(getActivity());
            return true;
        }
        return false;
    });
    mEdtSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence keyword, int start, int count, int after) {
            if (TextUtils.isEmpty(keyword)) {
                mImgClear.setVisibility(View.GONE);
            } else {
                mImgClear.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mAMap.setOnMarkerClickListener(marker -> {
        Moment moment = (Moment) marker.getObject();
        if (null != moment) {
            Bundle bundle = new Bundle();
            int isFollow = moment.getUser().getIsFollowed();
            bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
            bundle.putInt(MomentDetailActivity.USER_TYPE, 0);
            getBaseActivity().gotoActivity(MomentDetailActivity.class, bundle);
        }
        return false;
    });
    mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {

        @Override
        public void onCameraChange(CameraPosition cameraPosition) {
        }

        @Override
        public void onCameraChangeFinish(CameraPosition cameraPosition) {
            int tempZoom = (int) cameraPosition.zoom;
            if (mIsShowNearby && mCurZoom != tempZoom) {
                mCurZoom = tempZoom;
                loadMapMoments(mCurZoom);
            }
        }
    });
}
Also used : WeakHandler(com.badoo.mobile.util.WeakHandler) CameraPosition(com.amap.api.maps.model.CameraPosition) MyLocationStyle(com.amap.api.maps.model.MyLocationStyle) MapMoment(com.rideread.rideread.data.result.MapMoment) Moment(com.rideread.rideread.data.result.Moment) AMap(com.amap.api.maps.AMap) Bundle(android.os.Bundle) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) LatLonPoint(com.amap.api.services.core.LatLonPoint) Point(android.graphics.Point)

Example 33 with Editable

use of android.text.Editable in project ride-read-android by Ride-Read.

the class SearchActivity method initView.

@Override
public void initView() {
    mSearchUsers = new ArrayList<>();
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        search();
    });
    mRecycleView.setHasFixedSize(true);
    mAdapter = new SearchUserAdapter(this, mSearchUsers);
    mRecycleView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(this);
    mRecycleView.setLayoutManager(mLayoutManager);
    mRecycleView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
            int totalItemCount = mLayoutManager.getItemCount();
            if (lastVisibleItem >= totalItemCount - 1 && dy > 0) {
                if (!isLoadingMore) {
                    search();
                }
            }
        }
    });
    mEdtSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence keyword, int start, int before, int count) {
            search();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}
Also used : SearchUserAdapter(com.rideread.rideread.common.adapter.SearchUserAdapter) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 34 with Editable

use of android.text.Editable in project android_frameworks_base by ResurrectionRemix.

the class BaseInputConnection method sendCurrentText.

private void sendCurrentText() {
    if (!mDummyMode) {
        return;
    }
    Editable content = getEditable();
    if (content != null) {
        final int N = content.length();
        if (N == 0) {
            return;
        }
        if (N == 1) {
            // able to generate normal key events...
            if (mKeyCharacterMap == null) {
                mKeyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
            }
            char[] chars = new char[1];
            content.getChars(0, 1, chars, 0);
            KeyEvent[] events = mKeyCharacterMap.getEvents(chars);
            if (events != null) {
                for (int i = 0; i < events.length; i++) {
                    if (DEBUG)
                        Log.v(TAG, "Sending: " + events[i]);
                    sendKeyEvent(events[i]);
                }
                content.clear();
                return;
            }
        }
        // Otherwise, revert to the special key event containing
        // the actual characters.
        KeyEvent event = new KeyEvent(SystemClock.uptimeMillis(), content.toString(), KeyCharacterMap.VIRTUAL_KEYBOARD, 0);
        sendKeyEvent(event);
        content.clear();
    }
}
Also used : KeyEvent(android.view.KeyEvent) Editable(android.text.Editable)

Example 35 with Editable

use of android.text.Editable in project android_frameworks_base by ResurrectionRemix.

the class BaseInputConnection method deleteSurroundingText.

/**
     * The default implementation performs the deletion around the current selection position of the
     * editable text.
     *
     * @param beforeLength The number of characters before the cursor to be deleted, in code unit.
     *        If this is greater than the number of existing characters between the beginning of the
     *        text and the cursor, then this method does not fail but deletes all the characters in
     *        that range.
     * @param afterLength The number of characters after the cursor to be deleted, in code unit.
     *        If this is greater than the number of existing characters between the cursor and
     *        the end of the text, then this method does not fail but deletes all the characters in
     *        that range.
     */
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
    if (DEBUG)
        Log.v(TAG, "deleteSurroundingText " + beforeLength + " / " + afterLength);
    final Editable content = getEditable();
    if (content == null)
        return false;
    beginBatchEdit();
    int a = Selection.getSelectionStart(content);
    int b = Selection.getSelectionEnd(content);
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    // Ignore the composing text.
    int ca = getComposingSpanStart(content);
    int cb = getComposingSpanEnd(content);
    if (cb < ca) {
        int tmp = ca;
        ca = cb;
        cb = tmp;
    }
    if (ca != -1 && cb != -1) {
        if (ca < a)
            a = ca;
        if (cb > b)
            b = cb;
    }
    int deleted = 0;
    if (beforeLength > 0) {
        int start = a - beforeLength;
        if (start < 0)
            start = 0;
        content.delete(start, a);
        deleted = a - start;
    }
    if (afterLength > 0) {
        b = b - deleted;
        int end = b + afterLength;
        if (end > content.length())
            end = content.length();
        content.delete(b, end);
    }
    endBatchEdit();
    return true;
}
Also used : Editable(android.text.Editable)

Aggregations

Editable (android.text.Editable)881 TextWatcher (android.text.TextWatcher)414 View (android.view.View)293 TextView (android.widget.TextView)217 EditText (android.widget.EditText)144 Paint (android.graphics.Paint)102 ImageView (android.widget.ImageView)94 Intent (android.content.Intent)81 AdapterView (android.widget.AdapterView)81 KeyEvent (android.view.KeyEvent)74 TextPaint (android.text.TextPaint)69 InputMethodManager (android.view.inputmethod.InputMethodManager)64 ListView (android.widget.ListView)64 DialogInterface (android.content.DialogInterface)57 SuppressLint (android.annotation.SuppressLint)56 Spannable (android.text.Spannable)51 AlertDialog (android.app.AlertDialog)46 RecyclerView (android.support.v7.widget.RecyclerView)45 ArrayList (java.util.ArrayList)43 Button (android.widget.Button)41