use of android.text.Editable in project sharelock-android by auth0.
the class SecretInputFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
secretField = (EditText) view.findViewById(R.id.secret_input);
nextButton = (Button) view.findViewById(R.id.next_button);
secretField.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) {
}
@Override
public void afterTextChanged(Editable s) {
nextButton.setVisibility(s.length() > 0 ? View.VISIBLE : View.INVISIBLE);
SnackbarManager.dismiss();
}
});
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Secret secret = new Secret(secretField.getText().toString());
bus.post(new NewSecretEvent(secret));
}
});
ImageView craftedBy = (ImageView) view.findViewById(R.id.crafted_by);
craftedBy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(getString(R.string.crafted_by_url)));
startActivity(intent);
}
});
final Bundle arguments = getArguments();
if (arguments != null) {
secretField.setText(arguments.getString(SECRET_INPUT_FRAGMENT_SECRET_ARGUMENT));
}
}
use of android.text.Editable in project MusicDNA by harjot-oberai.
the class LocalMusicViewPagerFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
((HomeActivity) getActivity()).onQueryTextChange("");
isSearchboxVisible = false;
backBtn = (ImageView) view.findViewById(R.id.local_fragment_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
fragTitle = (TextView) view.findViewById(R.id.local_fragment_title);
if (SplashActivity.tf4 != null)
fragTitle.setTypeface(SplashActivity.tf4);
searchBox = (EditText) view.findViewById(R.id.local_fragment_search_box);
searchBox.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) {
((HomeActivity) getActivity()).onQueryTextChange(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
searchIcon = (ImageView) view.findViewById(R.id.local_fragment_search_icon);
searchIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isSearchboxVisible) {
searchBox.setText("");
searchBox.setVisibility(View.INVISIBLE);
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(getActivity().INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
searchIcon.setImageResource(R.drawable.ic_search);
fragTitle.setVisibility(View.VISIBLE);
} else {
searchBox.setVisibility(View.VISIBLE);
searchBox.requestFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(getActivity().INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
searchIcon.setImageResource(R.drawable.ic_cross_white);
fragTitle.setVisibility(View.INVISIBLE);
}
isSearchboxVisible = !isSearchboxVisible;
}
});
viewPager = (ViewPager) view.findViewById(R.id.viewpager);
tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.setBackgroundColor(Color.parseColor("#111111"));
tabLayout.setSelectedTabIndicatorColor(HomeActivity.themeColor);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
}
use of android.text.Editable in project MusicDNA by harjot-oberai.
the class NewPlaylistFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
backBtn = (ImageView) view.findViewById(R.id.add_to_playlist_back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
fragTitle = (TextView) view.findViewById(R.id.add_to_playlist_fragment_title);
if (SplashActivity.tf4 != null)
fragTitle.setTypeface(SplashActivity.tf4);
savePlaylist = (FloatingActionButton) view.findViewById(R.id.save_playlist_fab);
savePlaylist.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
savePlaylist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onDone();
}
});
bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
if (HomeActivity.isReloaded)
bottomMarginLayout.getLayoutParams().height = 0;
else
bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
numberSelected = 0;
HomeActivity.finalSelectedTracks.clear();
atpAdapter.notifyDataSetChanged();
clearSearchBtn = (ImageView) view.findViewById(R.id.clear_search_btn);
clearSearchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideKeyboard();
searchBox.setText("");
finalList.clear();
for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
finalList.add(HomeActivity.localTrackList.get(i));
}
atpAdapter.notifyDataSetChanged();
}
});
searchBox = (EditText) view.findViewById(R.id.add_to_playlist_search);
searchBox.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) {
if (s.toString().equals("")) {
finalList.clear();
for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
finalList.add(HomeActivity.localTrackList.get(i));
}
} else {
finalList.clear();
for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
LocalTrack lt = HomeActivity.localTrackList.get(i);
if (lt.getTitle().toLowerCase().contains(s.toString().trim().toLowerCase())) {
finalList.add(lt);
}
}
}
atpAdapter.notifyDataSetChanged();
}
@Override
public void afterTextChanged(Editable s) {
}
});
numberSelectedSongs = (TextView) view.findViewById(R.id.number_selected_songs);
clearText = (TextView) view.findViewById(R.id.clear_selected_songs_text);
clearText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallback.onCancel();
atpAdapter.notifyDataSetChanged();
numberSelected = 0;
numberSelectedSongs.setText(String.valueOf(numberSelected) + " selected");
}
});
rv = (RecyclerView) view.findViewById(R.id.add_to_playlist_recycler);
mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
rv.setLayoutManager(mLayoutManager2);
rv.setItemAnimator(new DefaultItemAnimator());
rv.setAdapter(atpAdapter);
rv.addOnItemTouchListener(new ClickItemTouchListener(rv) {
@Override
public boolean onClick(RecyclerView parent, View view, int position, long id) {
LocalTrack lt = finalList.get(position);
if (HomeActivity.finalSelectedTracks.contains(lt)) {
HomeActivity.finalSelectedTracks.remove(lt);
numberSelected--;
} else {
HomeActivity.finalSelectedTracks.add(lt);
numberSelected++;
}
numberSelectedSongs.setText(String.valueOf(numberSelected) + " selected");
CheckBox cb = (CheckBox) view.findViewById(R.id.is_selected_checkbox);
cb.setChecked(!cb.isChecked());
atpAdapter.notifyItemChanged(position);
return false;
}
@Override
public boolean onLongClick(RecyclerView parent, View view, int position, long id) {
return false;
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
}
use of android.text.Editable in project FBReaderJ by geometer.
the class FileChooserActivity method doCreateNewDir.
// doSwitchViewType()
/**
* Confirms user to create new directory.
*/
private void doCreateNewDir() {
if (mFileProvider instanceof LocalFileProvider && !Utils.hasPermissions(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Dlg.toast(this, R.string.afc_msg_app_doesnot_have_permission_to_create_files, Dlg._LengthShort);
return;
}
if ((getLocation() instanceof File)) {
if (!((File) getLocation()).canWrite()) {
Dlg.toast(this, R.string.afc_msg_app_cant_create_folder, Dlg._LengthShort);
return;
}
}
final AlertDialog _dlg = Dlg.newDlg(this);
View view = getLayoutInflater().inflate(R.layout.afc_simple_text_input_view, null);
final EditText _textFile = (EditText) view.findViewById(R.id.afc_simple_text_input_view_text1);
_textFile.setHint(mTextResources.get("folderNameHint"));
_textFile.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
Ui.hideSoftKeyboard(FileChooserActivity.this, _textFile.getWindowToken());
_dlg.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
return true;
}
return false;
}
});
_dlg.setView(view);
_dlg.setTitle(mTextResources.get("newFolder"));
_dlg.setIcon(android.R.drawable.ic_menu_add);
_dlg.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = _textFile.getText().toString().trim();
if (!FileUtils.isFilenameValid(name)) {
Dlg.toast(FileChooserActivity.this, getString(R.string.afc_pmsg_filename_is_invalid, name), Dlg._LengthShort);
return;
}
final IFileProvider fileProvider = mFileProvider;
final IFile location = getLocation();
if (fileProvider == null || location == null) {
return;
}
IFile dir = fileProvider.fromPath(String.format("%s/%s", location.getAbsolutePath(), name));
if (dir.mkdir()) {
Dlg.toast(FileChooserActivity.this, getString(R.string.afc_msg_done), Dlg._LengthShort);
setLocation(getLocation(), null);
} else
Dlg.toast(FileChooserActivity.this, getString(R.string.afc_pmsg_cannot_create_folder, name), Dlg._LengthShort);
}
});
_dlg.show();
final Button _btnOk = _dlg.getButton(DialogInterface.BUTTON_POSITIVE);
_btnOk.setEnabled(false);
_textFile.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
_btnOk.setEnabled(FileUtils.isFilenameValid(s.toString().trim()));
}
});
}
use of android.text.Editable in project FBReaderJ by geometer.
the class EditBookmarkActivity method onCreate.
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_bookmark);
myBookmark = FBReaderIntents.getBookmarkExtra(getIntent());
if (myBookmark == null) {
finish();
return;
}
final DisplayMetrics dm = getResources().getDisplayMetrics();
final int width = Math.min((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 500, dm), dm.widthPixels * 9 / 10);
final int height = Math.min((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 350, dm), dm.heightPixels * 9 / 10);
final TabHost tabHost = (TabHost) findViewById(R.id.edit_bookmark_tabhost);
tabHost.setLayoutParams(new FrameLayout.LayoutParams(new ViewGroup.LayoutParams(width, height)));
tabHost.setup();
addTab(tabHost, "text", R.id.edit_bookmark_content_text);
addTab(tabHost, "style", R.id.edit_bookmark_content_style);
addTab(tabHost, "delete", R.id.edit_bookmark_content_delete);
final ZLStringOption currentTabOption = new ZLStringOption("LookNFeel", "EditBookmark", "text");
tabHost.setCurrentTabByTag(currentTabOption.getValue());
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
public void onTabChanged(String tag) {
if (!"delete".equals(tag)) {
currentTabOption.setValue(tag);
}
}
});
final EditText editor = (EditText) findViewById(R.id.edit_bookmark_text);
editor.setText(myBookmark.getText());
final int len = editor.getText().length();
editor.setSelection(len, len);
final Button saveTextButton = (Button) findViewById(R.id.edit_bookmark_save_text_button);
saveTextButton.setEnabled(false);
saveTextButton.setText(myResource.getResource("saveText").getValue());
saveTextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myCollection.bindToService(EditBookmarkActivity.this, new Runnable() {
public void run() {
myBookmark.setText(editor.getText().toString());
myCollection.saveBookmark(myBookmark);
saveTextButton.setEnabled(false);
}
});
}
});
editor.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence sequence, int start, int before, int count) {
final String originalText = myBookmark.getText();
saveTextButton.setEnabled(!originalText.equals(editor.getText().toString()));
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
final Button deleteButton = (Button) findViewById(R.id.edit_bookmark_delete_button);
deleteButton.setText(myResource.getResource("deleteBookmark").getValue());
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myCollection.bindToService(EditBookmarkActivity.this, new Runnable() {
public void run() {
myCollection.deleteBookmark(myBookmark);
finish();
}
});
}
});
}
Aggregations