use of com.polito.mad17.madmax.entities.Comment in project MadMax by deviz92.
the class NewCommentDialogFragment method onCreateDialog.
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments();
final String groupID = arguments.getString("groupID");
final String expenseID = arguments.getString("expenseID");
final String expenseName = arguments.getString("expenseName");
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.prompt_comment).setView(R.layout.new_comment_dialog).setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
User currentUser = MainActivity.getCurrentUser();
EditText message = (EditText) getDialog().findViewById(R.id.comment_message);
// add comment
Comment comment = new Comment(expenseID, currentUser.getName() + " " + currentUser.getSurname(), currentUser.getProfileImage(), message.getText().toString());
comment.setDate(new SimpleDateFormat("yyyy.MM.dd").format(new java.util.Date()));
comment.setTime(new SimpleDateFormat("HH:mm").format(new java.util.Date()));
FirebaseUtils.getInstance().addComment(comment);
// add event for USER_COMMENT_ADD
Event event = new Event(groupID, Event.EventType.USER_COMMENT_ADD, // instead of the username the subject must be the ID of the user
currentUser.getID(), expenseName);
event.setDate(new SimpleDateFormat("yyyy.MM.dd").format(new java.util.Date()));
event.setTime(new SimpleDateFormat("HH:mm").format(new java.util.Date()));
FirebaseUtils.getInstance().addEvent(event);
// Send the positive button event back to the host activity
newCommentDialogListener.onDialogPositiveClick(NewCommentDialogFragment.this);
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
// Send the negative button event back to the host activity
//newCommentDialogListener.onDialogNegativeClick(NewCommentDialogFragment.this);
}
});
// Create the AlertDialog object and return it
return builder.create();
}
use of com.polito.mad17.madmax.entities.Comment in project MadMax by deviz92.
the class ExpenseCommentsViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ExpenseCommentsViewHolder expenseCommentsViewHolder, int position) {
Comment comment = getItem(position).getValue();
// loading author profile photo
Glide.with(context).load(comment.getAuthorPhoto()).centerCrop().bitmapTransform(new CropCircleTransformation(context)).diskCacheStrategy(DiskCacheStrategy.ALL).into(expenseCommentsViewHolder.authorPhoto);
expenseCommentsViewHolder.authorTextView.setText(comment.getAuthor());
expenseCommentsViewHolder.commentTextView.setText(comment.getMessage());
expenseCommentsViewHolder.timestampTextView.setText(context.getString(R.string.day) + " " + comment.getDate() + " " + context.getString(R.string.at) + " " + comment.getTime());
}
Aggregations