use of android.text.TextWatcher 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.TextWatcher 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.TextWatcher in project RSAndroidApp by RailwayStations.
the class AuthActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auth);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
subscribtionStatus();
mUsername = ANONYMOUS;
// Initialize Firebase Auth
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
ChatMessage friendly_chat = new ChatMessage();
mTimeStamp = friendly_chat.setChatTimeStamp();
if (mFirebaseUser == null) {
// Not signed in, launch the Sign In activity
startActivity(new Intent(this, SignInActivity.class));
finish();
return;
} else {
mUsername = mFirebaseUser.getDisplayName();
mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();
}
mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, /* FragmentActivity */
this).addApi(Auth.GOOGLE_SIGN_IN_API).build();
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView);
mLinearLayoutManager = new LinearLayoutManager(this);
mLinearLayoutManager.setStackFromEnd(true);
mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();
mFirebaseAdapter = new FirebaseRecyclerAdapter<ChatMessage, MessageViewHolder>(ChatMessage.class, R.layout.item_message, MessageViewHolder.class, mFirebaseDatabaseReference.child(MESSAGES_CHILD)) {
@Override
protected void populateViewHolder(MessageViewHolder viewHolder, ChatMessage friendlyMessage, int position) {
mProgressBar.setVisibility(ProgressBar.INVISIBLE);
viewHolder.messageTextView.setText(friendlyMessage.getText());
viewHolder.messengerTextView.setText(friendlyMessage.getName());
viewHolder.messengerTimeStamp.setText(friendlyMessage.getChatTimeStamp());
if (friendlyMessage.getPhotoUrl() == null) {
viewHolder.messengerImageView.setImageDrawable(ContextCompat.getDrawable(AuthActivity.this, R.drawable.ic_account_circle_black_36dp));
} else {
Glide.with(AuthActivity.this).load(friendlyMessage.getPhotoUrl()).into(viewHolder.messengerImageView);
}
}
};
mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
super.onItemRangeInserted(positionStart, itemCount);
int friendlyMessageCount = mFirebaseAdapter.getItemCount();
int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition();
// to the bottom of the list to show the newly added message.
if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1) && lastVisiblePosition == (positionStart - 1))) {
mMessageRecyclerView.scrollToPosition(positionStart);
}
}
});
mMessageRecyclerView.setLayoutManager(mLinearLayoutManager);
mMessageRecyclerView.setAdapter(mFirebaseAdapter);
// Initialize Firebase Remote Config.
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
// Define Firebase Remote Config Settings.
FirebaseRemoteConfigSettings firebaseRemoteConfigSettings = new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(true).build();
// Define default config values. Defaults are used when fetched config values are not
// available. Eg: if an error occurred fetching values from the server.
Map<String, Object> defaultConfigMap = new HashMap<>();
defaultConfigMap.put("friendly_msg_length", 10L);
// Apply config settings and default values.
mFirebaseRemoteConfig.setConfigSettings(firebaseRemoteConfigSettings);
mFirebaseRemoteConfig.setDefaults(defaultConfigMap);
// Fetch remote config.
fetchConfig();
mMessageEditText = (EditText) findViewById(R.id.messageEditText);
mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mSharedPreferences.getInt(FRIENDLY_MSG_LENGTH, DEFAULT_MSG_LENGTH_LIMIT)) });
mMessageEditText.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) {
if (charSequence.toString().trim().length() > 0) {
mSendButton.setEnabled(true);
} else {
mSendButton.setEnabled(false);
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
mSendButton = (Button) findViewById(R.id.sendButton);
mSendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ChatMessage chatMessage = new ChatMessage(mMessageEditText.getText().toString(), mUsername, mPhotoUrl, mTimeStamp);
mFirebaseDatabaseReference.child(MESSAGES_CHILD).push().setValue(chatMessage);
mMessageEditText.setText("");
}
});
}
use of android.text.TextWatcher in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimPreferenceDialog method createEditDialog.
private void createEditDialog(Bundle bundle) {
final Resources res = mContext.getResources();
EditText nameText = (EditText) mDialogLayout.findViewById(R.id.sim_name);
nameText.setText(mSubInfoRecord.getDisplayName());
final Spinner tintSpinner = (Spinner) mDialogLayout.findViewById(R.id.spinner);
SelectColorAdapter adapter = new SelectColorAdapter(mContext, R.layout.settings_color_picker_item, mColorStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
tintSpinner.setAdapter(adapter);
for (int i = 0; i < mTintArr.length; i++) {
if (mTintArr[i] == mSubInfoRecord.getIconTint()) {
tintSpinner.setSelection(i);
mTintSelectorPos = i;
break;
}
}
tintSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
tintSpinner.setSelection(pos);
mTintSelectorPos = pos;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
TextView numberView = (TextView) mDialogLayout.findViewById(R.id.number);
final String rawNumber = tm.getLine1Number(mSubInfoRecord.getSubscriptionId());
if (TextUtils.isEmpty(rawNumber)) {
numberView.setText(res.getString(com.android.internal.R.string.unknownName));
} else {
numberView.setText(PhoneNumberUtils.formatNumber(rawNumber));
}
String simCarrierName = tm.getSimOperatorName(mSubInfoRecord.getSubscriptionId());
TextView carrierView = (TextView) mDialogLayout.findViewById(R.id.carrier);
carrierView.setText(!TextUtils.isEmpty(simCarrierName) ? simCarrierName : mContext.getString(com.android.internal.R.string.unknownName));
mBuilder.setTitle(String.format(res.getString(R.string.sim_editor_title), (mSubInfoRecord.getSimSlotIndex() + 1)));
mBuilder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
final EditText nameText = (EditText) mDialogLayout.findViewById(R.id.sim_name);
String displayName = nameText.getText().toString();
int subId = mSubInfoRecord.getSubscriptionId();
mSubInfoRecord.setDisplayName(displayName);
mSubscriptionManager.setDisplayName(displayName, subId, SubscriptionManager.NAME_SOURCE_USER_INPUT);
final int tintSelected = tintSpinner.getSelectedItemPosition();
int subscriptionId = mSubInfoRecord.getSubscriptionId();
int tint = mTintArr[tintSelected];
mSubInfoRecord.setIconTint(tint);
mSubscriptionManager.setIconTint(tint, subscriptionId);
dialog.dismiss();
}
});
mBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
});
mBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
finish();
}
});
AlertDialog dialog = mBuilder.show();
final Button button = dialog.getButton(AlertDialog.BUTTON1);
if (TextUtils.isEmpty(mSubInfoRecord.getDisplayName()) || TextUtils.getTrimmedLength(mSubInfoRecord.getDisplayName()) == 0) {
button.setEnabled(false);
}
nameText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
button.setEnabled(TextUtils.getTrimmedLength(s) > 0);
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
});
}
use of android.text.TextWatcher in project wechat by motianhuo.
the class ChatActivity method initView.
/**
* initView
*/
protected void initView() {
netClient = new NetClient(this);
recordingContainer = findViewById(R.id.view_talk);
txt_title = (TextView) findViewById(R.id.txt_title);
img_right = (ImageView) findViewById(R.id.img_right);
micImage = (ImageView) findViewById(R.id.mic_image);
animationDrawable = (AnimationDrawable) micImage.getBackground();
animationDrawable.setOneShot(false);
recordingHint = (TextView) findViewById(R.id.recording_hint);
listView = (ListView) findViewById(R.id.list);
mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage);
buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
buttonSend = findViewById(R.id.btn_send);
buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
expressionViewpager = (ViewPager) findViewById(R.id.vPager);
emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container);
btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container);
// locationImgview = (ImageView) findViewById(R.id.btn_location);
iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal);
iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked);
loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more);
btnMore = (Button) findViewById(R.id.btn_more);
iv_emoticons_normal.setVisibility(View.VISIBLE);
iv_emoticons_checked.setVisibility(View.INVISIBLE);
more = findViewById(R.id.more);
edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
// 表情list
reslist = getExpressionRes(62);
// 初始化表情viewpager
List<View> views = new ArrayList<View>();
View gv1 = getGridChildView(1);
View gv2 = getGridChildView(2);
View gv3 = getGridChildView(3);
views.add(gv1);
views.add(gv2);
views.add(gv3);
expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));
edittext_layout.requestFocus();
voiceRecorder = new VoiceRecorder(micImageHandler);
buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());
mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
} else {
edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
}
}
});
mEditTextContent.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
more.setVisibility(View.GONE);
iv_emoticons_normal.setVisibility(View.VISIBLE);
iv_emoticons_checked.setVisibility(View.INVISIBLE);
emojiIconContainer.setVisibility(View.GONE);
btnContainer.setVisibility(View.GONE);
}
});
// 监听文字框
mEditTextContent.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!TextUtils.isEmpty(s)) {
btnMore.setVisibility(View.GONE);
buttonSend.setVisibility(View.VISIBLE);
} else {
btnMore.setVisibility(View.VISIBLE);
buttonSend.setVisibility(View.GONE);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
Aggregations