use of android.text.TextWatcher in project twicalico by moko256.
the class PostActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post);
model = PostTweetModelCreator.getInstance(GlobalApplication.twitter, getContentResolver());
subscription = new CompositeSubscription();
rootViewGroup = findViewById(R.id.activity_tweet_send_layout_root);
toolbar = findViewById(R.id.activity_tweet_send_toolbar);
setSupportActionBar(toolbar);
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
userIcon = findViewById(R.id.activity_tweet_send_user_icon);
GlideApp.with(this).load(GlobalApplication.userCache.get(GlobalApplication.userId).get400x400ProfileImageURLHttps()).circleCrop().into(userIcon);
counterTextView = findViewById(R.id.tweet_text_edit_counter);
editText = findViewById(R.id.tweet_text_edit);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
model.setTweetText(s.toString());
counterTextView.setText(String.valueOf(model.getTweetLength()) + " / " + String.valueOf(model.getMaxTweetLength()));
counterTextView.setTextColor(model.isValidTweet() ? Color.GRAY : Color.RED);
}
@Override
public void afterTextChanged(Editable s) {
}
});
editText.setImageAddedListener(imageUri -> {
if (model.getUriList().size() < model.getUriListSizeLimit()) {
addedImagesAdapter.getImagesList().add(imageUri);
model.getUriList().add(imageUri);
addedImagesAdapter.notifyItemChanged(addedImagesAdapter.getImagesList().size() - 1);
possiblySensitiveSwitch.setEnabled(true);
return true;
} else {
return false;
}
});
editText.setHint(model.isReply() ? R.string.reply : R.string.post);
imagesRecyclerView = findViewById(R.id.activity_tweet_send_images_recycler_view);
addedImagesAdapter = new AddedImagesAdapter(this);
imagesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
imagesRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.right = Math.round(getResources().getDisplayMetrics().density);
}
});
addedImagesAdapter.setLimit(model.getUriListSizeLimit());
addedImagesAdapter.setOnAddButtonClickListener(v -> startActivityForResult(Intent.createChooser(new Intent(Intent.ACTION_GET_CONTENT).addCategory(Intent.CATEGORY_OPENABLE).putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/*", "video/*" }).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true).setType("*/*"), getString(R.string.add_image)), REQUEST_GET_IMAGE));
addedImagesAdapter.setOnDeleteButtonListener(position -> {
addedImagesAdapter.getImagesList().remove(position);
model.getUriList().remove(position);
addedImagesAdapter.notifyDataSetChanged();
boolean enabled = model.getUriList().size() > 0;
possiblySensitiveSwitch.setEnabled(enabled);
possiblySensitiveSwitch.setChecked(possiblySensitiveSwitch.isChecked() && enabled);
});
addedImagesAdapter.setOnImageClickListener(position -> {
Intent open = new Intent(Intent.ACTION_VIEW).setData(model.getUriList().get(position)).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(open, getString(R.string.open_image)));
});
imagesRecyclerView.setAdapter(addedImagesAdapter);
possiblySensitiveSwitch = findViewById(R.id.activity_tweet_possibly_sensitive_switch);
possiblySensitiveSwitch.setEnabled(addedImagesAdapter.getImagesList().size() > 0);
possiblySensitiveSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> model.setPossiblySensitive(isChecked));
addLocationSwitch = findViewById(R.id.activity_tweet_location_switch);
addLocationSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
if (PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED) {
subscription.add(getLocation().subscribe(it -> {
model.setLocation(new GeoLocation(it.getLatitude(), it.getLongitude()));
locationText.setVisibility(View.VISIBLE);
locationText.setText(getString(R.string.lat_and_lon, it.getLatitude(), it.getLongitude()));
}, Throwable::printStackTrace));
} else {
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 400);
}
} else {
locationText.setVisibility(View.GONE);
}
});
locationText = findViewById(R.id.activity_tweet_location_result);
locationText.setVisibility(View.GONE);
if (getIntent() != null) {
if (!model.isReply()) {
model.setInReplyToStatusId(getIntent().getLongExtra(INTENT_EXTRA_IN_REPLY_TO_STATUS_ID, -1));
}
String text = getIntent().getStringExtra(INTENT_EXTRA_TWEET_TEXT);
if (text != null) {
editText.setText(text);
editText.setSelection(text.length());
} else {
editText.setText("");
}
ArrayList<Uri> uris = getIntent().getParcelableArrayListExtra(INTENT_EXTRA_IMAGE_URI);
if (uris != null) {
addedImagesAdapter.getImagesList().addAll(uris);
model.getUriList().addAll(uris);
possiblySensitiveSwitch.setEnabled(true);
}
}
}
use of android.text.TextWatcher in project J2ME-Loader by nikita36078.
the class ConfigActivity method onCreate.
@SuppressLint({ "StringFormatMatches", "StringFormatInvalid" })
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_config);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ContextHolder.setCurrentActivity(this);
pathToMidletDir = getIntent().getDataString();
String appName = pathToMidletDir.substring(pathToMidletDir.lastIndexOf('/') + 1);
keylayoutFile = new File(DATA_DIR + appName, "VirtualKeyboardLayout");
dataDir = new File(DATA_DIR + appName);
params = new SharedPreferencesContainer(appName, Context.MODE_PRIVATE, this);
System.setProperty("microedition.sensor.version", "1");
System.setProperty("microedition.platform", "Nokia 6233");
System.setProperty("microedition.configuration", "CDLC1.1");
System.setProperty("microedition.profiles", "MIDP2.0");
System.setProperty("microedition.m3g.version", "1.1");
System.setProperty("microedition.media.version", "1.0");
System.setProperty("supports.mixing", "true");
System.setProperty("supports.audio.capture", "false");
System.setProperty("supports.video.capture", "false");
System.setProperty("supports.recording", "false");
System.setProperty("microedition.pim.version", "1.0");
System.setProperty("microedition.io.file.FileConnection.version", "1.0");
System.setProperty("microedition.locale", Locale.getDefault().getCountry().toLowerCase());
System.setProperty("microedition.encoding", "ISO-8859-1");
System.setProperty("user.home", Environment.getExternalStorageDirectory().getPath());
tfScreenWidth = findViewById(R.id.tfScreenWidth);
tfScreenHeight = findViewById(R.id.tfScreenHeight);
tfScreenBack = findViewById(R.id.tfScreenBack);
cxScaleToFit = findViewById(R.id.cxScaleToFit);
sbScaleRatio = findViewById(R.id.sbScaleRatio);
tfScaleRatioValue = findViewById(R.id.tfScaleRatioValue);
spOrientation = findViewById(R.id.spOrientation);
cxKeepAspectRatio = findViewById(R.id.cxKeepAspectRatio);
cxFilter = findViewById(R.id.cxFilter);
cxImmediate = findViewById(R.id.cxImmediate);
cxHwAcceleration = findViewById(R.id.cxHwAcceleration);
tfFontSizeSmall = findViewById(R.id.tfFontSizeSmall);
tfFontSizeMedium = findViewById(R.id.tfFontSizeMedium);
tfFontSizeLarge = findViewById(R.id.tfFontSizeLarge);
cxFontSizeInSP = findViewById(R.id.cxFontSizeInSP);
tfSystemProperties = findViewById(R.id.tfSystemProperties);
cxShowKeyboard = findViewById(R.id.cxIsShowKeyboard);
cxVKFeedback = findViewById(R.id.cxVKFeedback);
cxTouchInput = findViewById(R.id.cxTouchInput);
sbVKAlpha = findViewById(R.id.sbVKAlpha);
tfVKHideDelay = findViewById(R.id.tfVKHideDelay);
tfVKFore = findViewById(R.id.tfVKFore);
tfVKBack = findViewById(R.id.tfVKBack);
tfVKSelFore = findViewById(R.id.tfVKSelFore);
tfVKSelBack = findViewById(R.id.tfVKSelBack);
tfVKOutline = findViewById(R.id.tfVKOutline);
screenWidths = new ArrayList<>();
screenHeights = new ArrayList<>();
screenAdapter = new ArrayList<>();
fillScreenSizePresets(ContextHolder.getDisplayWidth(), ContextHolder.getDisplayHeight());
fontSmall = new ArrayList<>();
fontMedium = new ArrayList<>();
fontLarge = new ArrayList<>();
fontAdapter = new ArrayList<>();
addFontSizePreset("128 x 128", 9, 13, 15);
addFontSizePreset("128 x 160", 13, 15, 20);
addFontSizePreset("176 x 220", 15, 18, 22);
addFontSizePreset("240 x 320", 18, 22, 26);
findViewById(R.id.cmdScreenSizePresets).setOnClickListener(this);
findViewById(R.id.cmdSwapSizes).setOnClickListener(this);
findViewById(R.id.cmdFontSizePresets).setOnClickListener(this);
findViewById(R.id.cmdScreenBack).setOnClickListener(this);
findViewById(R.id.cmdVKBack).setOnClickListener(this);
findViewById(R.id.cmdVKFore).setOnClickListener(this);
findViewById(R.id.cmdVKSelBack).setOnClickListener(this);
findViewById(R.id.cmdVKSelFore).setOnClickListener(this);
findViewById(R.id.cmdVKOutline).setOnClickListener(this);
sbScaleRatio.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
tfScaleRatioValue.setText(String.valueOf(progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
tfScaleRatioValue.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Integer enteredProgress = Integer.valueOf(s.toString());
sbScaleRatio.setProgress(enteredProgress);
}
@Override
public void afterTextChanged(Editable s) {
}
});
loadParams(params);
applyConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cxHwAcceleration.setVisibility(View.VISIBLE);
}
cxVKFeedback.setEnabled(cxShowKeyboard.isChecked());
cxShowKeyboard.setOnClickListener(v -> {
if (!((CheckBox) v).isChecked()) {
cxVKFeedback.setEnabled(false);
} else {
cxVKFeedback.setEnabled(true);
}
});
File appSettings = new File(getFilesDir().getParent() + File.separator + "shared_prefs", appName + ".xml");
if (appSettings.exists() && !getIntent().getBooleanExtra(SHOW_SETTINGS_KEY, false)) {
startMIDlet();
}
}
use of android.text.TextWatcher in project Shuttle by timusus.
the class PlaylistUtils method renamePlaylistDialog.
public static void renamePlaylistDialog(final Context context, final Playlist playlist) {
@SuppressLint("InflateParams") View customView = LayoutInflater.from(context).inflate(R.layout.dialog_playlist, null);
final EditText editText = customView.findViewById(R.id.editText);
editText.setText(playlist.name);
MaterialDialog.Builder builder = DialogUtils.getBuilder(context).title(R.string.create_playlist_create_text_prompt).customView(customView, false).positiveText(R.string.save).onPositive((materialDialog, dialogAction) -> {
String name = editText.getText().toString();
if (name.length() > 0) {
ContentResolver resolver = context.getContentResolver();
ContentValues values = new ContentValues(1);
values.put(MediaStore.Audio.Playlists.NAME, name);
resolver.update(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values, MediaStore.Audio.Playlists._ID + "=?", new String[] { Long.valueOf(playlist.id).toString() });
playlist.name = name;
Toast.makeText(context, R.string.playlist_renamed_message, Toast.LENGTH_SHORT).show();
}
}).negativeText(R.string.cancel);
final MaterialDialog dialog = builder.build();
TextWatcher textWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
// check if playlist with current name exists already, and warn the user if so.
setSaveButton(dialog, playlist, editText.getText().toString());
}
public void afterTextChanged(Editable s) {
}
};
editText.addTextChangedListener(textWatcher);
dialog.show();
}
use of android.text.TextWatcher in project SmartCampus by Vegen.
the class EaseContactListFragment method setUpView.
@Override
protected void setUpView() {
EMClient.getInstance().addConnectionListener(connectionListener);
contactList = new ArrayList<EaseUser>();
getContactList();
// init list
contactListLayout.init(contactList);
if (listItemClickListener != null) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
EaseUser user = (EaseUser) listView.getItemAtPosition(position);
listItemClickListener.onListItemClicked(user);
}
});
}
query.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
contactListLayout.filter(s);
if (s.length() > 0) {
clearSearch.setVisibility(View.VISIBLE);
} else {
clearSearch.setVisibility(View.INVISIBLE);
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
}
});
clearSearch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
query.getText().clear();
hideSoftKeyboard();
}
});
listView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard();
return false;
}
});
}
use of android.text.TextWatcher in project iNGAGE by davis123123.
the class ChatActivity method textChangeListener.
private void textChangeListener() {
textField.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String ss = textField.getText().toString();
// Toast.makeText(getBaseContext(),"itemclick" + haschar,Toast.LENGTH_SHORT).show();
if (ss.contains("@") && !haschar) {
haschar = true;
// Start Tagging here
startTagActivity();
} else if (!(ss.contains("@"))) {
haschar = false;
tagged = false;
// Log.d("STATE", "text: " + ss);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
Aggregations