Example usage for org.joda.time LocalDateTime isBefore

List of usage examples for org.joda.time LocalDateTime isBefore

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime isBefore.

Prototype

public boolean isBefore(ReadablePartial partial) 

Source Link

Document

Is this partial earlier than the specified partial.

Usage

From source file:ch.eitchnet.android.mabea.activity.TodayFragment.java

License:Open Source License

/**
 * @param expectedState//from ww  w.  j av a2s .  c  om
 * @param currentState
 * @return
 */
private boolean handleCurrentState(State expectedState, MabeaState currentState) {

    // if the state is as expected, then all is good
    if (expectedState.equals(currentState.getState())) {
        return true;
    }

    // we have a mismatch. We can recover from it, if the time stamp is 
    // later than what we have currently registered

    // so check if the server state is later than the current booking
    Today today = MabeaApplication.getContext().getToday();
    Booking latestBooking = today.getLatestBooking();
    LocalDateTime expectedDate = latestBooking.getTimestamp();
    LocalDateTime currentDate = currentState.getStateTime();
    if (expectedDate.isAfter(currentDate) && currentDate.isBefore(LocalDateTime.now())) {

        String title = "State mismatch";
        String msg = "The state on the server is {0} which is not the expected state {1}.\n\nThe local state can't be toggled as the local timestamp {2} is after the new state from the server. Please check your expected state.";
        msg = MessageFormat.format(msg, currentState.getState(), expectedState,
                JodaHelper.toDateHourMinute(expectedDate), JodaHelper.toDateHourMinute(currentDate));
        DialogUtil.showErrorDialog(getActivity(), title, msg);
        return false;
    }

    // fix state mismatch by adding a new booking
    Booking booking = new Booking(currentState.getState(), currentDate, currentState.getBalance());
    today.addBooking(booking);

    // notify user of fix
    String title = "State mismatch";
    String msg = "The state on the server is {0} which is not the expected state {1}.\n\nAs the time stamp of the current state is later than the latest booking, a new booking was added to today. Please check your expected state.";
    msg = MessageFormat.format(msg, currentState.getState(), expectedState,
            JodaHelper.toDateHourMinute(expectedDate), JodaHelper.toDateHourMinute(currentDate));
    DialogUtil.showErrorDialog(getActivity(), title, msg);

    return true;
}

From source file:com.axelor.apps.base.ical.ICalendarService.java

License:Open Source License

protected ICalendar doSync(ICalendar calendar, CalDavCalendarCollection collection) throws IOException,
        URISyntaxException, ParseException, ObjectStoreException, ConstraintViolationException {

    final String[] names = { Property.UID, Property.URL, Property.SUMMARY, Property.DESCRIPTION,
            Property.DTSTART, Property.DTEND, Property.ORGANIZER, Property.ATTENDEE };

    final boolean keepRemote = calendar.getKeepRemote() == Boolean.TRUE;

    final Map<String, VEvent> remoteEvents = new HashMap<>();
    final List<VEvent> localEvents = new ArrayList<>();
    final Set<String> synced = new HashSet<>();

    for (VEvent item : ICalendarStore.getEvents(collection)) {
        remoteEvents.put(item.getUid().getValue(), item);
    }/*from w w  w .  ja  v  a 2s  .  c o m*/

    for (ICalendarEvent item : calendar.getEvents()) {
        VEvent source = createVEvent(item);
        VEvent target = remoteEvents.get(source.getUid().getValue());
        if (target == null && Strings.isNullOrEmpty(item.getUid())) {
            target = source;
        }

        if (target != null) {
            if (keepRemote) {
                VEvent tmp = target;
                target = source;
                source = tmp;
            } else {
                if (source.getLastModified() != null && target.getLastModified() != null) {
                    LocalDateTime lastModifiedSource = new LocalDateTime(
                            source.getLastModified().getDateTime());
                    LocalDateTime lastModifiedTarget = new LocalDateTime(
                            target.getLastModified().getDateTime());
                    if (lastModifiedSource.isBefore(lastModifiedTarget)) {
                        VEvent tmp = target;
                        target = source;
                        source = tmp;
                    }
                } else if (target.getLastModified() != null) {
                    VEvent tmp = target;
                    target = source;
                    source = tmp;
                }
            }
            localEvents.add(target);
            synced.add(target.getUid().getValue());

            if (source == target) {
                continue;
            }

            for (String name : names) {
                Property s = source.getProperty(name);
                Property t = target.getProperty(name);
                if (s == null && t == null) {
                    continue;
                }
                if (t == null) {
                    t = s;
                }
                if (s == null) {
                    target.getProperties().remove(t);
                } else {
                    t.setValue(s.getValue());
                }
            }
        }
    }

    for (String uid : remoteEvents.keySet()) {
        if (!synced.contains(uid)) {
            localEvents.add(remoteEvents.get(uid));
        }
    }

    // update local events
    final List<ICalendarEvent> iEvents = new ArrayList<>();
    for (VEvent item : localEvents) {
        ICalendarEvent iEvent = findOrCreateEvent(item);
        iEvents.add(iEvent);
    }
    calendar.getEvents().clear();
    for (ICalendarEvent event : iEvents) {
        calendar.addEvent(event);
    }

    // update remote events
    for (VEvent item : localEvents) {
        if (!synced.contains(item.getUid().getValue())) {
            continue;
        }
        Calendar cal = newCalendar();
        cal.getComponents().add(item);
        collection.addCalendar(cal);
    }

    return calendar;
}

From source file:com.axelor.apps.crm.service.CalendarService.java

License:Open Source License

protected Calendar doSync(Calendar calendar, CalDavCalendarCollection collection) throws IOException,
        URISyntaxException, ParseException, ObjectStoreException, ConstraintViolationException {

    final String[] names = { Property.UID, Property.URL, Property.SUMMARY, Property.DESCRIPTION,
            Property.DTSTART, Property.DTEND, Property.ORGANIZER, Property.CLASS, Property.TRANSP,
            Property.ATTENDEE };//w  ww.j a  v a 2s.  com

    final boolean keepRemote = calendar.getKeepRemote() == Boolean.TRUE;

    final Map<String, VEvent> remoteEvents = new HashMap<>();
    final List<VEvent> localEvents = new ArrayList<>();
    final Set<String> synced = new HashSet<>();
    for (VEvent item : ICalendarStore.getEvents(collection)) {
        remoteEvents.put(item.getUid().getValue(), item);
    }

    for (ICalendarEvent item : calendar.getEventsCrm()) {
        VEvent source = createVEvent(item);
        VEvent target = remoteEvents.get(source.getUid().getValue());
        if (target == null && Strings.isNullOrEmpty(item.getUid())) {
            target = source;
        }

        if (target != null) {
            if (keepRemote) {
                VEvent tmp = target;
                target = source;
                source = tmp;
            } else {
                if (source.getLastModified() != null && target.getLastModified() != null) {
                    LocalDateTime lastModifiedSource = new LocalDateTime(
                            source.getLastModified().getDateTime());
                    LocalDateTime lastModifiedTarget = new LocalDateTime(
                            target.getLastModified().getDateTime());
                    if (lastModifiedSource.isBefore(lastModifiedTarget)) {
                        VEvent tmp = target;
                        target = source;
                        source = tmp;
                    }
                } else if (target.getLastModified() != null) {
                    VEvent tmp = target;
                    target = source;
                    source = tmp;
                }
            }
            localEvents.add(target);
            synced.add(target.getUid().getValue());

            if (source == target) {
                continue;
            }

            for (String name : names) {
                if (!name.equals(Property.ATTENDEE)) {
                    Property s = source.getProperty(name);
                    Property t = target.getProperty(name);
                    PropertyList items = target.getProperties();
                    if (s == null && t == null) {
                        continue;
                    } else if (t == null) {
                        t = s;
                        items.add(t);
                    } else if (s == null) {
                        target.getProperties().remove(t);
                    } else {
                        t.setValue(s.getValue());
                    }

                } else {
                    PropertyList sourceList = source.getProperties(Property.ATTENDEE);
                    PropertyList targetList = target.getProperties(Property.ATTENDEE);
                    target.getProperties().removeAll(targetList);
                    target.getProperties().addAll(sourceList);
                    target.getProperties();
                }
            }
        }
    }

    for (String uid : remoteEvents.keySet()) {
        if (!synced.contains(uid)) {
            localEvents.add(remoteEvents.get(uid));
        }
    }

    // update local events
    final List<Event> iEvents = new ArrayList<>();
    for (VEvent item : localEvents) {
        Event iEvent = findOrCreateEventCRM(item);
        iEvents.add(iEvent);
    }
    calendar.getEventsCrm().clear();
    for (Event event : iEvents) {
        calendar.addEventsCrm(event);
    }

    // update remote events
    for (VEvent item : localEvents) {
        if (!synced.contains(item.getUid().getValue())) {
            continue;
        }
        net.fortuna.ical4j.model.Calendar cal = newCalendar();
        cal.getComponents().add(item);
        collection.addCalendar(cal);
    }

    return calendar;
}

From source file:com.effektif.workflow.api.model.AfterRelativeTime.java

License:Apache License

public LocalDateTime resolve(LocalDateTime base) {
    if (this.duration == null || this.durationUnit == null) {
        return null;
    }/*from  w w w .ja v a2 s.c o m*/

    ReadablePeriod period = null;
    if (DAYS.equals(durationUnit)) {
        period = Days.days(getDurationAsInt());
    } else if (WEEKS.equals(durationUnit)) {
        period = Weeks.weeks(getDurationAsInt());
    } else if (HOURS.equals(durationUnit)) {
        period = Hours.hours(getDurationAsInt());
    } else if (MONTHS.equals(durationUnit)) {
        period = Months.months(getDurationAsInt());
    } else if (YEARS.equals(durationUnit)) {
        period = Years.years(getDurationAsInt());
    } else if (MINUTES.equals(durationUnit)) {
        period = Minutes.minutes(getDurationAsInt());
    } else {
        return null;
    }

    LocalDateTime time = base.plus(period);

    if (atHour != null) {
        LocalDateTime atTime = time.withTime(atHour, atMinute != null ? atMinute : 0, 0, 0);
        if (atTime.isBefore(time)) {
            time = atTime.plusDays(1);
        } else {
            time = atTime;
        }
    } else if (isDayResolutionOrBigger()) {
        time = time.withTime(23, 59, 59, 999);
    }

    return time;
}

From source file:com.ephemeraldreams.gallyshuttle.ui.MainFragment.java

License:Apache License

/**
 * Calculate time difference in milliseconds between now and next available shuttle arrival time.
 *
 * @param stationId Station id to get times from.
 * @return Duration between now and next arrival time in milliseconds.
 *///from   ww w .  j av  a 2s .  c  om
private long calculateTimeFromNowToNextArrivalAtStation(int stationId) {
    List<String> times = schedule.getTimes(stationId);
    LocalDateTime now = LocalDateTime.now();
    arrivalTime = null;
    LocalDateTime stationTime;
    for (String time : times) {
        stationTime = DateUtils.parseToLocalDateTime(time);
        Timber.d(stationTime.toString());

        //Workaround midnight exception case where station time was converted to midnight of current day instead of next day.
        if (stationTime.getHourOfDay() == 0 && now.getHourOfDay() != 0) {
            stationTime = stationTime.plusDays(1);
        }
        if (now.isBefore(stationTime)) {
            arrivalTime = stationTime;
            break;
        }
    }
    if (arrivalTime == null) {
        arrivalTimeTextView.setText(getString(R.string.arrival_not_available_message));
        return -1;
    } else {
        arrivalTimeTextView.setText(String.format(getString(R.string.until_arrival_time_message),
                DateUtils.formatTime(arrivalTime)));

        Duration duration = new Duration(now.toDateTime(), arrivalTime.toDateTime());
        long milliseconds = duration.getMillis();

        Timber.d("Now: " + DateUtils.formatTime(now));
        Timber.d("Arrival: " + DateUtils.formatTime(arrivalTime));
        Timber.d("Time difference between now and arrival: "
                + DateUtils.convertMillisecondsToTime(milliseconds));

        return milliseconds;
    }
}

From source file:com.gst.infrastructure.campaigns.sms.service.SmsCampaignWritePlatformServiceJpaImpl.java

License:Apache License

@Override
@CronTarget(jobName = JobName.UPDATE_SMS_OUTBOUND_WITH_CAMPAIGN_MESSAGE)
public void storeTemplateMessageIntoSmsOutBoundTable() throws JobExecutionException {
    final Collection<SmsCampaign> smsCampaignDataCollection = this.smsCampaignRepository
            .findByCampaignTypeAndTriggerTypeAndStatus(CampaignType.SMS.getValue(),
                    SmsCampaignTriggerType.SCHEDULE.getValue(), SmsCampaignStatus.ACTIVE.getValue());
    if (smsCampaignDataCollection != null) {
        for (SmsCampaign smsCampaign : smsCampaignDataCollection) {
            LocalDateTime tenantDateNow = tenantDateTime();
            LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate();

            logger.info("tenant time " + tenantDateNow.toString() + " trigger time "
                    + nextTriggerDate.toString() + JobName.UPDATE_SMS_OUTBOUND_WITH_CAMPAIGN_MESSAGE.name());
            if (nextTriggerDate.isBefore(tenantDateNow)) {
                insertDirectCampaignIntoSmsOutboundTable(smsCampaign);
                this.updateTriggerDates(smsCampaign.getId());
            }//from w w w  . j av  a  2s  .com
        }
    }
}

From source file:com.helger.datetime.period.LocalDateTimePeriod.java

License:Apache License

public final boolean isValidFor(@Nonnull final LocalDateTime aDate) {
    if (aDate == null)
        throw new NullPointerException("date");

    final LocalDateTime aStart = getStart();
    if (aStart != null && aStart.isAfter(aDate))
        return false;
    final LocalDateTime aEnd = getEnd();
    if (aEnd != null && aEnd.isBefore(aDate))
        return false;
    return true;/*from ww w .j  a v a2s  .com*/
}

From source file:com.helger.peppol.smpserver.ui.AppCommonUI.java

License:Apache License

@Nonnull
public static BootstrapTable createCertificateDetailsTable(@Nonnull final X509Certificate aX509Cert,
        @Nonnull final LocalDateTime aNowLDT, @Nonnull final Locale aDisplayLocale) {
    final LocalDateTime aNotBefore = PDTFactory.createLocalDateTime(aX509Cert.getNotBefore());
    final LocalDateTime aNotAfter = PDTFactory.createLocalDateTime(aX509Cert.getNotAfter());
    final PublicKey aPublicKey = aX509Cert.getPublicKey();

    final BootstrapTable aCertDetails = new BootstrapTable(HCCol.star(), HCCol.star());
    aCertDetails.addBodyRow().addCell("Version:").addCell(Integer.toString(aX509Cert.getVersion()));
    aCertDetails.addBodyRow().addCell("Subject:").addCell(aX509Cert.getSubjectX500Principal().getName());
    aCertDetails.addBodyRow().addCell("Issuer:").addCell(aX509Cert.getIssuerX500Principal().getName());
    aCertDetails.addBodyRow().addCell("Serial number:").addCell(aX509Cert.getSerialNumber().toString(16));
    aCertDetails.addBodyRow().addCell("Valid from:").addCell(
            new HCTextNode(PDTToString.getAsString(aNotBefore, aDisplayLocale) + " "),
            aNowLDT.isBefore(aNotBefore)
                    ? new BootstrapLabel(EBootstrapLabelType.DANGER).addChild("!!!NOT YET VALID!!!")
                    : null);//from  ww  w  .  j  av  a2  s  .com
    aCertDetails.addBodyRow().addCell("Valid to:").addCell(
            new HCTextNode(PDTToString.getAsString(aNotAfter, aDisplayLocale) + " "),
            aNowLDT.isAfter(aNotAfter)
                    ? new BootstrapLabel(EBootstrapLabelType.DANGER).addChild("!!!NO LONGER VALID!!!")
                    : new HCDiv().addChild("Valid for: " + PeriodFormatMultilingual
                            .getFormatterLong(aDisplayLocale).print(new Period(aNowLDT, aNotAfter))));

    if (aPublicKey instanceof RSAPublicKey) {
        // Special handling for RSA
        aCertDetails.addBodyRow().addCell("Public key:").addCell(aX509Cert.getPublicKey().getAlgorithm() + " ("
                + ((RSAPublicKey) aPublicKey).getModulus().bitLength() + " bits)");
    } else {
        // Usually EC or DSA key
        aCertDetails.addBodyRow().addCell("Public key:").addCell(aX509Cert.getPublicKey().getAlgorithm());
    }
    aCertDetails.addBodyRow().addCell("Signature algorithm:")
            .addCell(aX509Cert.getSigAlgName() + " (" + aX509Cert.getSigAlgOID() + ")");
    return aCertDetails;
}

From source file:com.helger.peppol.smpserver.ui.secure.PageSecureTasks.java

License:Apache License

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
    final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
    final LocalDateTime aNowDT = PDTFactory.getCurrentLocalDateTime();
    final LocalDateTime aNowPlusDT = aNowDT.plusMonths(3);

    aNodeList.addChild(new BootstrapInfoBox().addChild(
            "This page tries to identify upcoming tasks and potential problems in the SMP configuration. It is meant to highlight immediate and upcoming action items as well as potential misconfiguration."));

    final HCOL aOL = new HCOL();

    // check certificate configuration
    {/*  ww  w  .j  a va  2  s .c  o m*/
        final KeyLoadingResult aKeyLoadingResult = KeyLoadingResult.loadConfiguredKey();
        if (aKeyLoadingResult.isFailure())
            aOL.addItem(_createError("Problem with the certificate configuration"),
                    new HCDiv().addChild(aKeyLoadingResult.getErrorMessage()));
    }

    // Check SML configuration
    {
        if (!RegistrationHookFactory.isSMLConnectionActive())
            aOL.addItem(_createWarning("The connection to the SML is not active."), new HCDiv().addChild(
                    "All creations and deletions of service groups needs to be repeated when the SML connection is active!"));
    }

    // check service groups and redirects
    {
        final Collection<? extends ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups();
        final Collection<? extends ISMPRedirect> aRedirects = aRedirectMgr.getAllSMPRedirects();
        if (aServiceGroups.isEmpty() && aRedirects.isEmpty()) {
            aOL.addItem(_createWarning(
                    "Neither a service group nor a redirect is configured. This SMP is currently empty."));
        } else {
            // For all service groups
            for (final ISMPServiceGroup aServiceGroup : CollectionHelper.getSorted(aServiceGroups,
                    new ComparatorSMPServiceGroup())) {
                final HCUL aULPerSG = new HCUL();
                final Collection<? extends ISMPServiceInformation> aServiceInfos = aServiceInfoMgr
                        .getAllSMPServiceInformationsOfServiceGroup(aServiceGroup);
                if (aServiceInfos.isEmpty()) {
                    aULPerSG.addItem(_createWarning("No endpoint is configured for this service group."));
                } else {
                    for (final ISMPServiceInformation aServiceInfo : aServiceInfos) {
                        final HCUL aULPerDocType = new HCUL();
                        final Collection<? extends ISMPProcess> aProcesses = aServiceInfo.getAllProcesses();
                        for (final ISMPProcess aProcess : aProcesses) {
                            final HCUL aULPerProcess = new HCUL();
                            final Collection<? extends ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints();
                            for (final ISMPEndpoint aEndpoint : aEndpoints) {
                                final HCUL aULPerEndpoint = new HCUL();

                                final ESMPTransportProfile eTransportProfile = ESMPTransportProfile
                                        .getFromIDOrNull(aEndpoint.getTransportProfile());
                                if (eTransportProfile == null)
                                    aULPerEndpoint.addItem(_createWarning(
                                            "The endpoint uses the non-standard transport profile '"
                                                    + aEndpoint.getTransportProfile() + "'."));

                                if (aEndpoint.getServiceActivationDateTime() != null) {
                                    if (aEndpoint.getServiceActivationDateTime().isAfter(aNowDT))
                                        aULPerEndpoint.addItem(_createWarning(
                                                "The endpoint is not yet active. It will be active from "
                                                        + PDTToString.getAsString(
                                                                aEndpoint.getServiceActivationDateTime(),
                                                                aDisplayLocale)
                                                        + "."));
                                }

                                if (aEndpoint.getServiceExpirationDateTime() != null) {
                                    if (aEndpoint.getServiceExpirationDateTime().isBefore(aNowDT))
                                        aULPerEndpoint.addItem(_createError(
                                                "The endpoint is not longer active. It was valid until "
                                                        + PDTToString.getAsString(
                                                                aEndpoint.getServiceExpirationDateTime(),
                                                                aDisplayLocale)
                                                        + "."));
                                    else if (aEndpoint.getServiceExpirationDateTime().isBefore(aNowPlusDT))
                                        aULPerEndpoint.addItem(_createWarning(
                                                "The endpoint will be inactive soon. It is only valid until "
                                                        + PDTToString.getAsString(
                                                                aEndpoint.getServiceExpirationDateTime(),
                                                                aDisplayLocale)
                                                        + "."));
                                }

                                X509Certificate aX509Cert = null;
                                try {
                                    aX509Cert = CertificateHelper
                                            .convertStringToCertficate(aEndpoint.getCertificate());
                                } catch (final CertificateException ex) {
                                    // Ignore
                                }
                                if (aX509Cert == null)
                                    aULPerEndpoint.addItem(_createError(
                                            "The X.509 certificate configured at the endpoint is invalid and could not be interpreted as a certificate."));
                                else {
                                    final LocalDateTime aNotBefore = PDTFactory
                                            .createLocalDateTime(aX509Cert.getNotBefore());
                                    if (aNotBefore.isAfter(aNowDT))
                                        aULPerEndpoint.addItem(_createError(
                                                "The endpoint certificate is not yet active. It will be active from "
                                                        + PDTToString.getAsString(aNotBefore, aDisplayLocale)
                                                        + "."));

                                    final LocalDateTime aNotAfter = PDTFactory
                                            .createLocalDateTime(aX509Cert.getNotAfter());
                                    if (aNotAfter.isBefore(aNowDT))
                                        aULPerEndpoint.addItem(_createError(
                                                "The endpoint certificate is already expired. It was valid until "
                                                        + PDTToString.getAsString(aNotAfter, aDisplayLocale)
                                                        + "."));
                                    else if (aNotAfter.isBefore(aNowPlusDT))
                                        aULPerEndpoint.addItem(_createWarning(
                                                "The endpoint certificate will expire soon. It is only valid until "
                                                        + PDTToString.getAsString(aNotAfter, aDisplayLocale)
                                                        + "."));
                                }

                                // Show per endpoint errors
                                if (aULPerEndpoint.hasChildren())
                                    aULPerProcess
                                            .addItem(
                                                    new HCDiv().addChild("Transport profile ")
                                                            .addChild(new HCCode()
                                                                    .addChild(aEndpoint.getTransportProfile())),
                                                    aULPerEndpoint);
                            }
                            // Show per process errors
                            if (aULPerProcess.hasChildren())
                                aULPerDocType.addItem(new HCDiv().addChild("Process ")
                                        .addChild(new HCCode().addClass(CUICoreCSS.CSS_CLASS_NOWRAP)
                                                .addChild(aProcess.getProcessIdentifier().getURIEncoded())),
                                        aULPerProcess);
                        }
                        // Show per document type errors
                        if (aULPerDocType.hasChildren())
                            aULPerSG.addItem(new HCDiv().addChild("Document type ")
                                    .addChild(new HCCode().addClass(CUICoreCSS.CSS_CLASS_NOWRAP).addChild(
                                            aServiceInfo.getDocumentTypeIdentifier().getURIEncoded())),
                                    aULPerDocType);
                    }
                }

                // Show per service group errors
                if (aULPerSG.hasChildren())
                    aOL.addItem(
                            new HCDiv().addChild("Service group ")
                                    .addChild(new HCCode()
                                            .addChild(aServiceGroup.getParticpantIdentifier().getURIEncoded())),
                            aULPerSG);
            }
        }
    }

    // Show results
    if (aOL.hasChildren()) {
        aNodeList.addChild(
                new BootstrapWarnBox().addChild("The following list of tasks and problems were identified:"));
        aNodeList.addChild(aOL);
    } else
        aNodeList.addChild(new BootstrapSuccessBox().addChild("Great job, no tasks or problems identified!"));
}

From source file:com.makotogo.mobile.hoursdroid.HoursDetailFragment.java

License:Apache License

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    final String METHOD = "onActivityResult(" + requestCode + ", " + resultCode + ", " + data + "): ";
    if (resultCode == Activity.RESULT_OK) {
        // Figure out which Result code we are dealing with. This method
        /// handles the results of all dialog fragments used to set the
        /// model data.
        switch (requestCode) {
        case REQUEST_BEGIN_DATE_PICKER:
            Date beginDate = (Date) data.getSerializableExtra(DateTimePickerFragment.RESULT_DATE_TIME);
            LocalDateTime ldtBeginDate = new LocalDateTime(beginDate.getTime());
            if (ldtBeginDate.isBefore(new LocalDateTime(mHours.getEnd().getTime()))) {
                mHours.setBegin(beginDate);
                updateUI();/*  ww  w.  j a  v  a2  s  .c om*/
            } else {
                String message = "End date must be after begin date";
                Log.e(TAG, METHOD + message);
                Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
            }
            break;
        case REQUEST_END_DATE_PICKER:
            Date endDate = (Date) data.getSerializableExtra(DateTimePickerFragment.RESULT_DATE_TIME);
            LocalDateTime ldtEndDate = new LocalDateTime(endDate.getTime());
            if (ldtEndDate.isAfter(new LocalDateTime(mHours.getBegin().getTime()))) {
                mHours.setEnd(endDate);
                updateUI();
            } else {
                String message = "End date must be after begin date";
                Log.e(TAG, METHOD + message);
                Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
            }
            break;
        case REQUEST_BREAK:
            Integer breakTimeInMinutes = (Integer) data
                    .getSerializableExtra(NumberPickerFragment.RESULT_MINUTES);
            mHours.setBreak(renderBreakForStorage(breakTimeInMinutes));
            updateUI();
            break;
        case REQUEST_CODE_MANAGE_PROJECTS:
            Project project = (Project) data.getSerializableExtra(ProjectListActivity.RESULT_PROJECT);
            mHours.setProject(project);
            updateUI();
            break;
        default:
            break;
        }
    }
}