use of io.jawg.osmcontributor.ui.events.map.PleaseApplyNewComment in project osm-contributor by jawg.
the class NoteActivity method addCommentOnClick.
@OnClick(R.id.send_comment)
void addCommentOnClick() {
if (newCommentEditText.getText().toString().isEmpty()) {
Toast.makeText(this, R.string.comment_text_cant_be_null, Toast.LENGTH_SHORT).show();
} else {
if (note.getStatus().equals(Note.STATUS_SYNC)) {
Toast.makeText(this, R.string.comment_synchronizing, Toast.LENGTH_SHORT).show();
} else {
eventBus.post(new PleaseApplyNewComment(note, newCommentActionSpinner.getSelectedItem().toString(), newCommentEditText.getText().toString()));
newCommentEditText.getText().clear();
closeKeyboard();
}
}
}
use of io.jawg.osmcontributor.ui.events.map.PleaseApplyNewComment in project osm-contributor by jawg.
the class NoteCommentDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
((OsmTemplateApplication) getActivity().getApplication()).getOsmTemplateComponent().inject(this);
lat = getArguments().getDouble(LAT);
lng = getArguments().getDouble(LNG);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final EditText input = new EditText(this.getActivity());
input.setMaxLines(5);
openKeyboard();
String title = getResources().getString(R.string.title_creation_note);
builder.setTitle(title).setView(input).setPositiveButton(R.string.create_note, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String comment = input.getText().toString();
if (!comment.isEmpty()) {
Note note = new Note();
note.setStatus(Note.STATUS_SYNC);
note.setLatitude(lat);
note.setLongitude(lng);
note.setUpdated(true);
eventBus.post(new PleaseApplyNewComment(note, Comment.ACTION_OPEN, comment));
closeKeyboard();
}
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
final AlertDialog dialog = builder.create();
dialog.show();
// Initially disable the button
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
input.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
// Check if edittext is empty
if (TextUtils.isEmpty(s)) {
// Disable ok button
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
} else {
// Something into edit text. Enable the button.
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
}
}
});
return dialog;
}
Aggregations