List of usage examples for android.text Editable length
int length();
From source file:com.barak.pix.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override// ww w. ja v a2s . c o m protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Author author = comment.getAuthor(); viewHolder.commentAuthor.setText(author.getFull_name()); GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto); viewHolder.authorRef = author.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Author author = new Author(user.getDisplayName(), "", user.getUid()); Comment comment = new Comment(author, commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.akalizakeza.apps.ishusho.activity.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.activity_comments_item, CommentViewHolder.class, commentsRef) { @Override//ww w .j a va 2 s. c o m protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Artist artist = comment.getArtist(); viewHolder.commentAuthor.setText(artist.getFull_name()); GlideUtil.loadProfileIcon(artist.getProfile_picture(), viewHolder.commentPhoto); viewHolder.authorRef = artist.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Artist artist = new Artist(user.getDisplayName(), user.getPhotoUrl().toString(), user.getUid()); Comment comment = new Comment(artist, commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.edicon.firebase.devs.firepix.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override// w ww . j a va2 s.co m protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Author author = comment.getAuthor(); viewHolder.commentAuthor.setText(author.getFull_name()); GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto); viewHolder.authorRef = author.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Author author = new Author(user.getDisplayName(), user.getPhotoUrl().toString(), user.getUid()); Comment comment = new Comment(author, commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:Rangoli.testapp.Feed.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override/*w w w . j a v a 2 s.c o m*/ protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Author author = comment.getAuthor(); viewHolder.commentAuthor.setText(author.getFull_name()); PicassoUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto); viewHolder.authorRef = author.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint("add text here"); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), "user_logged_out_error", Toast.LENGTH_SHORT).show(); } Author author = new Author(user.getDisplayName(), user.getPhotoUrl().toString(), user.getUid()); Comment comment = new Comment(author, commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.bloodtolife.bloodapp.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); db = new SQLiteHandler(getActivity()); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override//from www .j a v a 2s . c o m protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { user_ = db.getUserDetails(); viewHolder.commentAuthor.setText(user_.get("name")); GlideUtil.loadProfileIcon(user_.get("profile_pic_url"), viewHolder.commentPhoto); viewHolder.authorRef = user_.get("uid"); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Comment comment = new Comment(user.getDisplayName(), commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.janardhan.blood2life.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_comments, container, false); Log.d("mPostRef", mPostRef); db = new SQLiteHandler(getActivity()); user_ = db.getUserDetails();/* w ww. j ava2s . com*/ RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list); mEditText = (EditText) rootView.findViewById(R.id.editText); final Button sendButton = (Button) rootView.findViewById(R.id.send_comment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item, CommentViewHolder.class, commentsRef) { @Override protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { String aurth = comment.getAuthor(); viewHolder.commentAuthor.setText(comment.getAuthor()); GlideUtil.loadProfileIcon(comment.getUser_propic(), viewHolder.commentPhoto); viewHolder.authorRef = comment.getUser_id(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Comment comment = new Comment(user.getDisplayName(), commentText.toString(), ServerValue.TIMESTAMP, user_.get("uid"), user_.get("profile_pic_url")); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, getString(R.string.error_posting) + error.getMessage()); Toast.makeText(getActivity(), R.string.error_posting, Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:com.myapps.upesse.upes_spefest.ui.activity.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.activity_comments, container, false); RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.rvComments); mEditText = (EditText) rootView.findViewById(R.id.etComment); final Button sendButton = (Button) rootView.findViewById(R.id.btnSendComment); final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef); mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.item_comment, CommentViewHolder.class, commentsRef) { @Override/* w w w. j a v a 2 s.c om*/ protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) { Author author = comment.getAuthor(); viewHolder.commentAuthor.setText(author.getFull_name()); if (author.getProfile_picture() == null) { viewHolder.commentPhoto.setImageResource(R.drawable.ic_person_outline_black); } else { try { GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto); } catch (Exception e) { } } viewHolder.authorRef = author.getUid(); viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp())); viewHolder.commentText.setText(comment.getText()); } }; sendButton.setEnabled(false); mEditText.setHint(R.string.new_comment_hint); mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); mEditText.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) { } @Override public void afterTextChanged(Editable editable) { if (editable.length() > 0) { sendButton.setEnabled(true); } else { sendButton.setEnabled(false); } } }); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear input box and hide keyboard. final Editable commentText = mEditText.getText(); mEditText.setText(""); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user == null) { Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show(); } Author author = new Author(user.getDisplayName(), user.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null, user.getUid()); Comment comment = new Comment(author, commentText.toString(), ServerValue.TIMESTAMP); commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError error, DatabaseReference firebase) { if (error != null) { Log.w(TAG, "Error posting comment: " + error.getMessage()); Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show(); mEditText.setText(commentText); } } }); } }); mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity())); mCommentsView.setAdapter(mAdapter); return rootView; }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileNameDialogFragment.java
public Dialog onCreateDialog(Bundle savedInstanceState) { // Init File//from www. j a v a 2 s .com if (getArguments().containsKey(ARGUMENT_FILE_RENAME)) { fileToRename = (File) getArguments().get(ARGUMENT_FILE_RENAME); } parentFile = (File) getArguments().get(ARGUMENT_FOLDER); String title = null; if (fileToRename != null) { title = getString(R.string.action_rename) + " : " + fileToRename.getName(); } else { title = getString(R.string.folder_create); } LayoutInflater inflater = LayoutInflater.from(getActivity()); final View v = inflater.inflate(R.layout.app_create_document, (ViewGroup) this.getView()); final MaterialEditText textName = ((MaterialEditText) v.findViewById(R.id.document_name)); if (fileToRename != null) { textName.setText("." + IOUtils.extractFileExtension(fileToRename.getName())); } textName.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { if (s.length() > 0) { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(true); if (UIUtils.hasInvalidName(s.toString().trim())) { textName.setError(getString(R.string.filename_error_character)); ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); } else if ((new File(parentFile, s.toString().trim()).exists())) { textName.setError(getString(R.string.create_document_filename_error)); ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); } else { textName.setError(null); } } else { ((MaterialDialog) getDialog()).getActionButton(DialogAction.POSITIVE).setEnabled(false); textName.setError(null); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).iconRes(R.drawable.ic_application_logo) .title(title).customView(v, true) .positiveText((fileToRename != null) ? R.string.ok : R.string.create).negativeText(R.string.cancel) .callback(new MaterialDialog.ButtonCallback() { @Override public void onNegative(MaterialDialog dialog) { dialog.dismiss(); } @Override public void onPositive(MaterialDialog dialog) { UIUtils.hideKeyboard(getActivity()); if (fileToRename != null) { String operationId = Operator.with(getActivity()) .load(new RenameFileRequest.Builder(fileToRename, textName.getText().toString().trim()) .setNotificationVisibility(OperationRequest.VISIBILITY_DIALOG)); OperationWaitingDialogFragment .newInstance(CreateDirectoryRequest.TYPE_ID, R.drawable.ic_edit, getString(R.string.action_rename), null, null, 0, operationId) .show(getActivity().getSupportFragmentManager(), OperationWaitingDialogFragment.TAG); } else { String operationId = Operator.with(getActivity()) .load(new CreateDirectoryRequest.Builder( (File) getArguments().get(ARGUMENT_FOLDER), textName.getText().toString().trim()) .setNotificationVisibility(OperationRequest.VISIBILITY_DIALOG)); OperationWaitingDialogFragment .newInstance(CreateDirectoryRequest.TYPE_ID, R.drawable.ic_add_folder, getString(R.string.folder_create), null, null, 0, operationId) .show(getActivity().getSupportFragmentManager(), OperationWaitingDialogFragment.TAG); } dismiss(); } }).build(); dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false); return dialog; }
From source file:it.scoppelletti.mobilepower.app.MarketTagHandler.java
/** * Gestisce un tag.//from w w w . j a v a 2s.c o m * * @param opening Indicatore di tag aperto. * @param tag Tag. * @param output Testo di output. * @param xmlReader Flusso di lettura. */ public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { if (!MarketTagHandler.TAG.equalsIgnoreCase(tag)) { return; } if (opening) { if (myStartPos < 0) { myStartPos = output.length(); } } else { if (myStartPos >= 0 && myEndPos < 0) { myEndPos = output.length(); } } }
From source file:org.peterbaldwin.client.android.delicious.WebPageTitleRequest.java
/** * {@inheritDoc}/*from w ww . j a va 2 s. com*/ */ public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { if ("title".equalsIgnoreCase(tag)) { if (opening) { mStart = output.length(); } else { int end = output.length(); String title = output.subSequence(mStart, end).toString(); // Collapse internal whitespace title = title.replaceAll("\\s+", " "); // Remove leading/trailing space title = title.trim(); mTitle = title; throw new TerminateParser(); } } }