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]);
}
}
}
}
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);
}
}
});
}
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) {
}
});
}
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();
}
}
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;
}
Aggregations