use of org.threeten.bp.format.DateTimeParseException in project open-event-android by fossasia.
the class FacebookFeedAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
final FeedItem feedItem = feedItems.get(position);
String createdTime = feedItem.getCreatedTime();
try {
holder.timeStamp.setText(DateConverter.getRelativeTimeFromTimestamp(createdTime));
} catch (DateTimeParseException e) {
Timber.e(e);
}
if (!TextUtils.isEmpty(feedItem.getMessage())) {
String statusMsg = feedItem.getMessage();
// Checking for null feed url
if (feedItem.getLink() != null)
// Removing url in status message
statusMsg = statusMsg.replace(feedItem.getLink(), "");
holder.statusMsg.setText(statusMsg);
holder.statusMsg.setVisibility(View.VISIBLE);
} else {
// status is empty, remove from view
holder.statusMsg.setVisibility(View.GONE);
}
// Checking for null feed url
if (feedItem.getLink() != null) {
holder.url.setText(Html.fromHtml("<a href=\"" + feedItem.getLink() + "\">" + feedItem.getLink() + "</a> "));
// Making url clickable
holder.url.setOnClickListener(view -> Utils.setUpCustomTab(context, feedItem.getLink()));
holder.url.setVisibility(View.VISIBLE);
} else {
// url is null, remove from the view
holder.url.setVisibility(View.GONE);
}
String feedImageUri = Utils.parseImageUri(feedItem.getFullPicture());
Drawable placeholder = VectorDrawableCompat.create(context.getResources(), R.drawable.ic_placeholder_24dp, null);
if (feedImageUri != null) {
holder.feedImageView.setVisibility(View.VISIBLE);
Picasso.with(holder.feedImageView.getContext()).load(Uri.parse(feedImageUri)).placeholder(placeholder).into(holder.feedImageView);
} else {
holder.feedImageView.setVisibility(View.GONE);
}
int comments = feedItem.getComments() != null ? feedItem.getComments().getData().size() : 0;
holder.getComments.setText(context.getString(R.string.comments_value, comments));
}
use of org.threeten.bp.format.DateTimeParseException in project open-event-android by fossasia.
the class CommentsListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
final CommentItem commentItem = commentItems.get(position);
if (commentItem.getCreatedTime() != null) {
String createdTime = commentItem.getCreatedTime();
try {
holder.commentTime.setText(DateConverter.getRelativeTimeFromTimestamp(createdTime));
} catch (DateTimeParseException e) {
Timber.e(e);
}
}
if (!TextUtils.isEmpty(commentItem.getMessage())) {
holder.comment.setText(commentItem.getMessage());
holder.comment.setVisibility(View.VISIBLE);
} else {
// status is empty, remove from view
holder.comment.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(commentItem.getFrom().getName())) {
holder.commenter.setText(commentItem.getFrom().getName());
holder.commenter.setVisibility(View.VISIBLE);
} else {
// status is empty, remove from view
holder.commenter.setVisibility(View.GONE);
}
}
use of org.threeten.bp.format.DateTimeParseException in project open-event-android by fossasia.
the class SettingsActivity method updateEventDates.
private void updateEventDates() {
Event event = RealmDataRepository.getDefaultInstance().getEventSync();
String startTime = event.getStartsAt();
String endTime = event.getEndsAt();
try {
RealmDataRepository.getDefaultInstance().saveEventDates(DateConverter.getDaysInBetween(startTime, endTime)).subscribe();
} catch (DateTimeParseException pe) {
Toast.makeText(this, "DateTimeParseException : Error updating event dates", Toast.LENGTH_SHORT).show();
Timber.e("Error updating event dates : enable to parse start date: %s and end date: %s in ISO format", startTime, endTime);
}
}
use of org.threeten.bp.format.DateTimeParseException in project open-event-orga-app by fossasia.
the class DateBindings method bindTemporal.
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
private static void bindTemporal(Button button, ObservableField<String> date, String format, Function<ZonedDateTime, AlertDialog> dialogProvider) {
if (date == null)
return;
String isoDate = date.get();
button.setText(DateUtils.formatDateWithDefault(format, isoDate));
button.setOnClickListener(view -> {
ZonedDateTime zonedDateTime = ZonedDateTime.now();
try {
zonedDateTime = DateUtils.getDate(isoDate);
} catch (DateTimeParseException pe) {
Timber.e(pe);
}
dialogProvider.apply(zonedDateTime).show();
});
}
Aggregations