Search in sources :

Example 1 with DateTimeParseException

use of org.threeten.bp.format.DateTimeParseException in project open-event-orga-app by fossasia.

the class CreateTicketPresenter method verify.

private boolean verify() {
    try {
        ZonedDateTime start = DateUtils.getDate(ticket.getSalesStartsAt().get());
        ZonedDateTime end = DateUtils.getDate(ticket.getSalesEndsAt().get());
        if (!end.isAfter(start)) {
            getView().showError("End time should be after start time");
            return false;
        }
        if (ticket.minOrder != null && ticket.maxOrder != null && ticket.minOrder > ticket.maxOrder) {
            getView().showError("Minimum order should be greater than Maximum order");
            return false;
        }
        return true;
    } catch (DateTimeParseException pe) {
        getView().showError("Please enter date in correct format");
        return false;
    }
}
Also used : DateTimeParseException(org.threeten.bp.format.DateTimeParseException) ZonedDateTime(org.threeten.bp.ZonedDateTime)

Example 2 with DateTimeParseException

use of org.threeten.bp.format.DateTimeParseException in project open-event-orga-app by fossasia.

the class CreateEventPresenter method verify.

private boolean verify() {
    try {
        ZonedDateTime start = DateUtils.getDate(event.getStartsAt().get());
        ZonedDateTime end = DateUtils.getDate(event.getEndsAt().get());
        if (!end.isAfter(start)) {
            getView().showError("End time should be after start time");
            return false;
        }
        return true;
    } catch (DateTimeParseException pe) {
        getView().showError("Please enter date in correct format");
        return false;
    }
}
Also used : DateTimeParseException(org.threeten.bp.format.DateTimeParseException) ZonedDateTime(org.threeten.bp.ZonedDateTime)

Example 3 with DateTimeParseException

use of org.threeten.bp.format.DateTimeParseException in project open-event-android by fossasia.

the class TwitterFeedAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
    final TwitterFeedItem feedItem = twitterFeedItems.get(position);
    String createdTime = feedItem.getCreatedAt();
    try {
        holder.timeStamp.setText(DateConverter.getRelativeTimeFromUTCTimeStamp(createdTime));
    } catch (DateTimeParseException e) {
        Timber.e(e);
    }
    if (!TextUtils.isEmpty(feedItem.getText())) {
        holder.statusMsg.setText(feedItem.getText());
        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);
    }
    if (feedItem.getImages().size() > 0) {
        // In case of more than one image show the first.
        String feedImageUri = Utils.parseImageUri(feedItem.getImages().get(0));
        Drawable placeholder = VectorDrawableCompat.create(context.getResources(), R.drawable.ic_placeholder_24dp, 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);
    }
}
Also used : DateTimeParseException(org.threeten.bp.format.DateTimeParseException) Drawable(android.graphics.drawable.Drawable) TwitterFeedItem(org.fossasia.openevent.core.feed.twitter.api.TwitterFeedItem)

Example 4 with DateTimeParseException

use of org.threeten.bp.format.DateTimeParseException in project open-event-android by fossasia.

the class NotificationsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerViewHolder holder, int position) {
    final Notification notificationItem = notificationsList.get(position);
    holder.title.setText(notificationItem.getTitle());
    holder.message.setText(Views.fromHtml(notificationItem.getMessage()));
    // making links in the message clickable.
    holder.message.setMovementMethod(LinkMovementMethod.getInstance());
    String receivedAt = notificationItem.getReceivedAt();
    try {
        holder.receivedAt.setText(AndroidDateConverter.getRelativeTimeFromOffsetDateTime(receivedAt));
    } catch (DateTimeParseException e) {
        Timber.e(e);
    }
}
Also used : DateTimeParseException(org.threeten.bp.format.DateTimeParseException) Notification(org.fossasia.openevent.data.Notification)

Example 5 with DateTimeParseException

use of org.threeten.bp.format.DateTimeParseException in project open-event-android by fossasia.

the class AboutFragmentViewModel method getSessionsList.

private List<Object> getSessionsList(List<Session> bookmarked) {
    List<Object> sessionsList = new ArrayList<>();
    for (String eventDate : getDateList()) {
        boolean headerCheck = false;
        for (Session bookmarkedSession : bookmarked) {
            if (bookmarkedSession.getStartDate() != null && bookmarkedSession.getStartDate().equals(eventDate)) {
                if (!headerCheck) {
                    String headerDate = "Invalid";
                    try {
                        headerDate = DateConverter.formatDay(eventDate);
                    } catch (DateTimeParseException e) {
                        e.printStackTrace();
                    }
                    sessionsList.add(headerDate);
                    headerCheck = true;
                }
                sessionsList.add(bookmarkedSession);
            }
        }
    }
    return sessionsList;
}
Also used : DateTimeParseException(org.threeten.bp.format.DateTimeParseException) ArrayList(java.util.ArrayList) Session(org.fossasia.openevent.data.Session)

Aggregations

DateTimeParseException (org.threeten.bp.format.DateTimeParseException)9 ZonedDateTime (org.threeten.bp.ZonedDateTime)3 Drawable (android.graphics.drawable.Drawable)2 ArrayList (java.util.ArrayList)1 CommentItem (org.fossasia.openevent.core.feed.facebook.api.CommentItem)1 FeedItem (org.fossasia.openevent.core.feed.facebook.api.FeedItem)1 TwitterFeedItem (org.fossasia.openevent.core.feed.twitter.api.TwitterFeedItem)1 Event (org.fossasia.openevent.data.Event)1 Notification (org.fossasia.openevent.data.Notification)1 Session (org.fossasia.openevent.data.Session)1