Example usage for java.util Calendar before

List of usage examples for java.util Calendar before

Introduction

In this page you can find the example usage for java.util Calendar before.

Prototype

public boolean before(Object when) 

Source Link

Document

Returns whether this Calendar represents a time before the time represented by the specified Object.

Usage

From source file:org.kuali.coeus.common.budget.impl.personnel.BudgetPersonServiceImpl.java

/**
 * //from w  w w  .  j  a v a 2 s. co  m
 * Determines if an appointment is applicable to the current budget, currently
 * based solely on whether the budget period matches some part of the appointment
 * period
 * @param budget
 * @param appointment
 * @return true if the appointment start or end date is inside the budget period
 */
protected boolean isAppointmentApplicableToBudget(Budget budget, PersonAppointment appointment) {
    Calendar budgetStart = Calendar.getInstance();
    Calendar budgetEnd = Calendar.getInstance();
    Calendar apptStart = Calendar.getInstance();
    Calendar apptEnd = Calendar.getInstance();
    budgetStart.setTime(budget.getStartDate());
    budgetEnd.setTime(budget.getEndDate());
    if (appointment.getStartDate() != null) {
        apptStart.setTime(appointment.getStartDate());
    } else {
        apptStart.setTime(budget.getStartDate());
    }
    if (appointment.getEndDate() != null) {
        apptEnd.setTime(appointment.getEndDate());
    } else {
        apptEnd.setTime(budget.getEndDate());
    }
    if (budgetStart.before(apptEnd) && budgetEnd.after(apptStart)) {
        return true;
    } else {
        return false;
    }
}

From source file:org.openbravo.advpaymentmngt.ad_actionbutton.Reconciliation.java

private void processReconciliation(HttpServletResponse response, VariablesSecureApp vars, String strTabId,
        String strFinancialAccountId, String strDifference, String strStatementDate, String strBeginBalance,
        String strEndBalance, boolean process) throws IOException, ServletException {

    log4j.debug(//  w ww .  j a v  a 2  s  . co  m
            "Output: Process or Save button pressed on Financial Account || Transaction || Reconciliation manual window");

    dao = new AdvPaymentMngtDao();
    OBError msg = new OBError();
    OBContext.setAdminMode();
    try {

        FIN_FinancialAccount account = OBDal.getInstance().get(FIN_FinancialAccount.class,
                strFinancialAccountId);

        FIN_Reconciliation reconciliation = TransactionsDao.getLastReconciliation(account, "N");

        FIN_Reconciliation lastProcessedReconciliation = TransactionsDao.getLastReconciliation(account, "Y");

        reconciliation.setEndingBalance(new BigDecimal(strEndBalance));
        reconciliation.setTransactionDate(FIN_Utility.getDateTime(strStatementDate));
        reconciliation.setEndingDate(FIN_Utility.getDateTime(strStatementDate));
        reconciliation.setDocumentStatus("DR");
        reconciliation.setProcessed(false);
        reconciliation.setAPRMProcessReconciliation("P");
        reconciliation.setAprmProcessRec("P");
        OBDal.getInstance().save(reconciliation);
        OBDal.getInstance().flush();

        if (process) { // Validations
            String strMessage = "";
            boolean raiseException = false;

            if (new BigDecimal(strDifference).compareTo(BigDecimal.ZERO) != 0) {
                strMessage = "@APRM_ReconciliationDiscrepancy@" + " " + strDifference;
                raiseException = true;
            }

            Calendar calCurrent = Calendar.getInstance();
            calCurrent.setTime(FIN_Utility.getDateTime(strStatementDate));

            if (lastProcessedReconciliation != null) {
                Calendar calLast = Calendar.getInstance();
                calLast.setTime(lastProcessedReconciliation.getEndingDate());
                if (calCurrent.before(calLast)) {
                    strMessage = "@APRM_ReconcileInFutureOrPast@";
                    raiseException = true;
                }
            }

            Calendar tomorrow = Calendar.getInstance();
            tomorrow.add(Calendar.DATE, 1);
            tomorrow.setTime(DateUtils.truncate(tomorrow.getTime(), Calendar.DATE));
            if (calCurrent.after(tomorrow)) {
                strMessage = "@APRM_ReconcileInFutureOrPast@";
                raiseException = true;
            }
            if (raiseException) {
                msg.setType("Error");
                msg.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
                msg.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), strMessage));
                vars.setMessage(strTabId, msg);
                msg = null;
                printPageClosePopUpAndRefreshParent(response, vars);
                return;
            }

            boolean orgLegalWithAccounting = FIN_Utility.periodControlOpened(reconciliation.TABLE_NAME,
                    reconciliation.getId(), reconciliation.TABLE_NAME + "_ID", "LE");
            boolean documentEnabled = getDocumentConfirmation(this, reconciliation.getId());
            if (documentEnabled && !FIN_Utility.isPeriodOpen(reconciliation.getClient().getId(),
                    AcctServer.DOCTYPE_Reconciliation, reconciliation.getOrganization().getId(),
                    strStatementDate) && orgLegalWithAccounting) {
                msg.setType("Error");
                msg.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
                msg.setMessage(
                        Utility.parseTranslation(this, vars, vars.getLanguage(), "@PeriodNotAvailable@"));
                vars.setMessage(strTabId, msg);
                msg = null;
                printPageClosePopUpAndRefreshParent(response, vars);
                return;
            }

            if (documentEnabled && orgLegalWithAccounting) {
                String identifier = linesInNotAvailablePeriod(reconciliation.getId());
                if (!identifier.equalsIgnoreCase("")) {
                    msg.setType("Error");
                    msg.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
                    msg.setMessage(String.format(
                            Utility.messageBD(this, "APRM_PeriodNotAvailableClearedItem", vars.getLanguage()),
                            identifier));
                    vars.setMessage(strTabId, msg);
                    msg = null;
                    printPageClosePopUpAndRefreshParent(response, vars);
                    return;
                }
            }

            for (APRM_FinaccTransactionV finacctrxv : reconciliation.getAPRMFinaccTransactionVList()) {
                if (reconciliation.getEndingDate()
                        .compareTo(finacctrxv.getFinancialAccountTransaction().getTransactionDate()) < 0) {
                    FIN_FinaccTransaction trans = finacctrxv.getFinancialAccountTransaction();
                    // We set processed to false before changing dates to avoid trigger exception
                    boolean posted = "Y".equals(trans.getPosted());
                    if (posted) {
                        trans.setPosted("N");
                        OBDal.getInstance().save(trans);
                        OBDal.getInstance().flush();
                    }
                    trans.setProcessed(false);
                    OBDal.getInstance().save(trans);
                    OBDal.getInstance().flush();
                    trans.setTransactionDate(reconciliation.getEndingDate());
                    trans.setDateAcct(reconciliation.getEndingDate());
                    OBDal.getInstance().save(trans);
                    OBDal.getInstance().flush();
                    // We set processed to true afterwards
                    trans.setProcessed(true);
                    OBDal.getInstance().save(trans);
                    OBDal.getInstance().flush();
                    if (posted) {
                        trans.setPosted("Y");
                        OBDal.getInstance().save(trans);
                        OBDal.getInstance().flush();
                    }
                    // Changing dates for accounting entries as well
                    TransactionsDao.updateAccountingDate(trans);
                }
                Boolean invoicePaidold = false;
                if (finacctrxv.getPayment() != null) {
                    for (FIN_PaymentDetail pd : finacctrxv.getPayment().getFINPaymentDetailList()) {
                        for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
                            invoicePaidold = psd.isInvoicePaid();
                            if (!invoicePaidold) {
                                if ((FIN_Utility
                                        .invoicePaymentStatus(finacctrxv.getPayment().getPaymentMethod(),
                                                reconciliation.getAccount(),
                                                finacctrxv.getPayment().isReceipt())
                                        .equals(finacctrxv.getPayment().getStatus()))) {
                                    psd.setInvoicePaid(true);
                                }
                                if (psd.isInvoicePaid()) {
                                    FIN_Utility.updatePaymentAmounts(psd);
                                }
                            }
                        }
                        FIN_Utility.updateBusinessPartnerCredit(finacctrxv.getPayment());
                    }
                }
            }

            reconciliation.setDocumentStatus("CO");
            reconciliation.setProcessed(true);
            reconciliation.setAPRMProcessReconciliation("R");
            reconciliation.setAprmProcessRec("R");
            OBDal.getInstance().save(reconciliation);
            OBDal.getInstance().flush();

        }

        String strMessage = "@APRM_ReconciliationNo@" + ": " + reconciliation.getDocumentNo();
        msg.setType("Success");
        msg.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
        msg.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), strMessage));
        vars.setMessage(strTabId, msg);
        msg = null;
        printPageClosePopUpAndRefreshParent(response, vars);

    } catch (Exception e) {
        throw new OBException(e);
    } finally {
        OBContext.restorePreviousMode();
    }
}

From source file:org.nuxeo.ecm.platform.rendition.service.TestRenditionService.java

@Test
public void shouldStoreLatestNonVersionedRendition() throws Exception {
    runtimeHarness.deployContrib(RENDITION_CORE, RENDITION_WORKMANAGER_COMPONENT_LOCATION);

    final StorageConfiguration storageConfiguration = coreFeature.getStorageConfiguration();
    final String repositoryName = session.getRepositoryName();
    final String username = session.getPrincipal().getName();
    final String renditionName = "renditionDefinitionWithCustomOperationChain";
    final String sourceDocumentModificationDatePropertyName = "dc:issued";
    DocumentModel folder = session.createDocumentModel("/", "dummy", "Folder");
    folder.setPropertyValue(sourceDocumentModificationDatePropertyName, Calendar.getInstance());
    folder = session.createDocument(folder);
    session.save();//w  w w .  j  av a 2s . c om
    nextTransaction();
    eventService.waitForAsyncCompletion();

    folder = session.getDocument(folder.getRef());
    final String folderId = folder.getId();

    RenditionThread t1 = new RenditionThread(storageConfiguration, repositoryName, username, folderId,
            renditionName, true);
    RenditionThread t2 = new RenditionThread(storageConfiguration, repositoryName, username, folderId,
            renditionName, false);
    t1.start();
    t2.start();

    // Sync #1
    RenditionThread.cyclicBarrier.await();

    // now "update" the folder description
    Calendar modificationDate = Calendar.getInstance();
    String desc = "I have been updated";
    folder = session.getDocument(folder.getRef());
    folder.setPropertyValue("dc:description", desc);
    folder.setPropertyValue(sourceDocumentModificationDatePropertyName, modificationDate);
    folder = session.saveDocument(folder);

    session.save();
    nextTransaction();
    eventService.waitForAsyncCompletion();

    // Sync #2
    RenditionThread.cyclicBarrier.await();

    // Sync #3
    RenditionThread.cyclicBarrier.await();

    t1.join();
    t2.join();

    nextTransaction();
    eventService.waitForAsyncCompletion();

    // get the "updated" folder rendition
    Rendition rendition = renditionService.getRendition(folder, renditionName, true);
    assertNotNull(rendition);
    assertTrue(rendition.isStored());
    Calendar cal = rendition.getModificationDate();
    assertTrue(!cal.before(modificationDate));
    assertNotNull(rendition.getBlob());
    assertTrue(rendition.getBlob().getString().contains(desc));

    // verify the thread renditions
    StorageConfiguration storageConfig = coreFeature.getStorageConfiguration();
    List<Rendition> renditions = Arrays.asList(t1.getDetachedRendition(), t2.getDetachedRendition());
    for (Rendition rend : renditions) {
        assertNotNull(rend);
        assertTrue(rend.isStored());
        storageConfig.assertNotBeforeTimestamp(cal, rend.getModificationDate());
        assertNotNull(rend.getBlob());
        assertTrue(rendition.getBlob().getString().contains(desc));
    }

    runtimeHarness.undeployContrib(RENDITION_CORE, RENDITION_WORKMANAGER_COMPONENT_LOCATION);
}

From source file:se.tillvaxtverket.tsltrust.weblogic.utils.TslCache.java

private boolean isWithinValidityPeriod(AaaCertificate cert) {
    Calendar present = Calendar.getInstance();
    Calendar certNotBefore = Calendar.getInstance();
    certNotBefore.setTime(cert.getNotBefore());
    Calendar certNotAfter = Calendar.getInstance();
    certNotAfter.setTime(cert.getNotAfter());
    if (present.before(certNotBefore)) {
        return false;
    }/*from  w  w w.j a va 2  s  .  c  o m*/
    if (present.after(certNotAfter)) {
        return false;
    }
    return true;
}

From source file:nl.strohalm.cyclos.services.accounts.guarantees.GuaranteeServiceImpl.java

@Override
public List<Guarantee> guaranteesToProcess(Calendar time) {
    time = DateHelper.truncate(time);/*from  www . ja  v a2  s.c  o m*/
    final GuaranteeQuery query = new GuaranteeQuery();
    query.setResultType(ResultType.ITERATOR);
    final Set<Relationship> fetch = new HashSet<Relationship>();
    fetch.add(Guarantee.Relationships.GUARANTEE_TYPE);
    fetch.add(Guarantee.Relationships.LOGS);
    query.setFetch(fetch);
    query.setStatusList(Arrays.asList(Guarantee.Status.PENDING_ADMIN, Guarantee.Status.PENDING_ISSUER));

    final List<Guarantee> result = new ArrayList<Guarantee>();

    final List<Guarantee> guarantees = guaranteeDao.search(query);
    for (final Guarantee guarantee : guarantees) {
        final TimePeriod period = guarantee.getGuaranteeType().getPendingGuaranteeExpiration();
        final Calendar lowerBound = period.remove(time);
        final Calendar registrationDate = DateHelper.truncate(guarantee.getRegistrationDate());
        if (registrationDate.before(lowerBound)) {
            result.add(guarantee);
        }
    }
    return result;
}

From source file:com.wdullaer.materialdatetimepicker.date.DatePickerDialog.java

private boolean isBeforeMin(Calendar calendar) {
    return mMinDate != null && calendar.before(mMinDate);
}

From source file:onl.netfishers.netshot.work.Task.java

/**
 * Gets the next execution date.// w  w  w . j av  a 2 s.  com
 *
 * @return the next execution date
 */
@Transient
@XmlElement
public Date getNextExecutionDate() {
    Calendar reference = Calendar.getInstance();
    reference.setTime(this.scheduleReference);
    Calendar target = Calendar.getInstance();
    Calendar inOneMinute = Calendar.getInstance();
    inOneMinute.add(Calendar.MINUTE, 1);

    switch (this.scheduleType) {
    case AT:
        return this.scheduleReference;
    case DAILY:
        target.set(Calendar.HOUR_OF_DAY, reference.get(Calendar.HOUR_OF_DAY));
        target.set(Calendar.MINUTE, reference.get(Calendar.MINUTE));
        target.set(Calendar.SECOND, reference.get(Calendar.SECOND));
        target.set(Calendar.MILLISECOND, 0);
        if (target.before(inOneMinute)) {
            target.add(Calendar.DAY_OF_MONTH, 1);
        }
        return target.getTime();
    case WEEKLY:
        target.set(Calendar.HOUR_OF_DAY, reference.get(Calendar.HOUR_OF_DAY));
        target.set(Calendar.MINUTE, reference.get(Calendar.MINUTE));
        target.set(Calendar.SECOND, reference.get(Calendar.SECOND));
        target.set(Calendar.MILLISECOND, 0);
        target.set(Calendar.DAY_OF_WEEK, reference.get(Calendar.DAY_OF_WEEK));
        if (target.before(inOneMinute)) {
            target.add(Calendar.WEEK_OF_YEAR, 1);
        }
        return target.getTime();
    case MONTHLY:
        target.set(Calendar.HOUR_OF_DAY, reference.get(Calendar.HOUR_OF_DAY));
        target.set(Calendar.MINUTE, reference.get(Calendar.MINUTE));
        target.set(Calendar.SECOND, reference.get(Calendar.SECOND));
        target.set(Calendar.MILLISECOND, 0);
        target.set(Calendar.DAY_OF_MONTH, reference.get(Calendar.DAY_OF_MONTH));
        if (target.before(inOneMinute)) {
            target.add(Calendar.MONTH, 1);
        }
        return target.getTime();
    case ASAP:
    default:
        return null;
    }
}

From source file:nl.strohalm.cyclos.services.accountfees.AccountFeeServiceImpl.java

@Override
public int chargeScheduledFees(final Calendar time) {
    final AccountFeeQuery query = new AccountFeeQuery();
    query.setReturnDisabled(false);//from www . j  a v  a  2  s. c o m
    query.setResultType(ResultType.LIST);
    query.setHour((byte) time.get(Calendar.HOUR_OF_DAY));
    query.setType(RunMode.SCHEDULED);
    query.fetch(AccountFee.Relationships.LOGS);
    query.setEnabledBefore(time);

    final List<AccountFee> list = new ArrayList<AccountFee>();
    // Get the daily fees
    query.setRecurrence(TimePeriod.Field.DAYS);
    list.addAll(search(query));
    // Get the weekly fees
    query.setRecurrence(TimePeriod.Field.WEEKS);
    query.setDay((byte) time.get(Calendar.DAY_OF_WEEK));
    list.addAll(search(query));
    // Get the monthly fees
    query.setRecurrence(TimePeriod.Field.MONTHS);
    query.setDay((byte) time.get(Calendar.DAY_OF_MONTH));
    list.addAll(search(query));
    int count = 0;
    for (final AccountFee fee : list) {
        final AccountFeeLog lastExecution = fee.getLastExecution();
        boolean charge;
        if (lastExecution == null) {
            // Was never executed. Charge now
            charge = true;
        } else {
            final TimePeriod recurrence = fee.getRecurrence();
            if (recurrence.getNumber() == 1) {
                // When recurrence is every day or week or month, charge now
                charge = true;
            } else {
                // Check the recurrence
                final Calendar lastExecutionDate = lastExecution.getDate();
                if (lastExecutionDate.after(time)) {
                    // Consistency check: don't charge if last execution was after the current time
                    charge = false;
                }
                // Find the number of elapsed periods
                int number = 0;
                final Calendar cal = DateHelper.truncate(lastExecutionDate);
                final int calendarField = recurrence.getField().getCalendarValue();
                final Calendar date = DateHelper.truncate(time);
                while (cal.before(date)) {
                    number++;
                    cal.add(calendarField, 1);
                }
                // Charge each 'x' periods
                charge = number % recurrence.getNumber() == 0;
            }
        }
        // Charge the fee
        if (charge) {
            insertNextExecution(fee);
            count++;
        }
    }
    return count;
}

From source file:org.kalypso.ogc.sensor.timeseries.interpolation.worker.ValueInterpolationWorker.java

/**
 * sets the start value of stack// w ww  . jav a  2s.  c  om
 */
private void setStartValues(final LocalCalculationStack stack, final Calendar calendar) throws SensorException {
    final SimpleTupleModel interpolated = getInterpolatedModel();
    final IAxis dateAxis = getDateAxis();

    final LocalCalculationStackValue[] values = stack.getValues();

    final Date timeSeriesStartDate = (Date) getBaseModel().get(0, dateAxis);
    final Calendar timeSeriesStart = Calendar.getInstance(m_timeZone);
    timeSeriesStart.setTime(timeSeriesStartDate);

    if (getDateRange() != null && isFilled()) {
        calendar.setTime(getDateRange().getFrom());
        stack.setDate1(calendar.getTime());

        for (final LocalCalculationStackValue value : values) {
            final TupleModelDataSet dataSet = toDataSet(getBaseModel(), 0, value);
            value.setValue1(dataSet);
        }

        while (calendar.before(timeSeriesStart)) {
            stack.setDate1(calendar.getTime());
            addDefaultTupple(dateAxis, stack, calendar);
        }
    } else {
        calendar.setTime(timeSeriesStart.getTime());

        final Object[] tuple = new Object[getInterpolatedModel().getAxes().length];
        tuple[interpolated.getPosition(dateAxis)] = calendar.getTime();

        for (final LocalCalculationStackValue value : values) {
            final TupleModelDataSet dataSet = toDataSet(getBaseModel(), 0, value);
            value.setValue1(dataSet);

            final IAxis statusAxis = AxisUtils.findStatusAxis(interpolated.getAxes(), dataSet.getValueAxis());
            final IAxis dataSourceAxis = AxisUtils.findDataSourceAxis(interpolated.getAxes(),
                    dataSet.getValueAxis());

            final int posValueAxis = interpolated.getPosition(dataSet.getValueAxis());
            final int posStatusAxis = Objects.isNotNull(statusAxis) ? interpolated.getPosition(statusAxis) : -1;
            final int posDataSourceAxis = Objects.isNotNull(dataSourceAxis)
                    ? interpolated.getPosition(dataSourceAxis)
                    : -1;

            if (posValueAxis >= 0)
                tuple[posValueAxis] = dataSet.getValue();

            if (posStatusAxis >= 0)
                tuple[posStatusAxis] = dataSet.getStatus();

            if (posDataSourceAxis >= 0) {
                final DataSourceHandler dataSourceHandler = new DataSourceHandler(
                        getFilter().getMetaDataList());

                final String source = dataSet.getSource();
                if (StringUtils.isNotEmpty(source)) {
                    tuple[posDataSourceAxis] = dataSourceHandler.addDataSource(source, source);
                }
            }
        }

        interpolated.addTuple(tuple);

        stack.setDate1(calendar.getTime());
        doStep(calendar);
    }
}

From source file:com.yangtsaosoftware.pebblemessenger.services.MessageProcessingService.java

@Override
public void onCreate() {
    super.onCreate();
    phone_is_ontalking = false;/*ww w . j av a  2s.c o m*/
    loadPrefs();
    Thread proceedthread = new ProcessThread();
    proceedthread.start();
    messageHandler = new MessageHandler(Looper.getMainLooper());
    mMessenger = new Messenger(messageHandler);
    MessageProcessingService._context = getApplicationContext();
    fdb = new FontDbHandler(_context);
    fdb.open();
    mdb = new MessageDbHandler(_context);
    mdb.open();
    bindService(new Intent(this, PebbleCenter.class), connToPebbleCenter, Context.BIND_AUTO_CREATE);
    BroadcastReceiver br = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int command = intent.getIntExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PREFER_CHANGED);
            switch (command) {
            case Constants.BROADCAST_PREFER_CHANGED:
                loadPrefs();
                break;
            case Constants.BROADCAST_CALL_INCOMING:
                String number = intent.getStringExtra(Constants.BROADCAST_PHONE_NUM);
                String name = intent.getStringExtra(Constants.BROADCAST_NAME);

                if (callQuietEnable) {
                    Calendar c = Calendar.getInstance();
                    Calendar now = new GregorianCalendar(0, 0, 0, c.get(Calendar.HOUR_OF_DAY),
                            c.get(Calendar.MINUTE));
                    Constants.log(TAG_NAME, "Checking quiet hours. Now: " + now.toString() + " vs "
                            + quiet_hours_before.toString() + " and " + quiet_hours_after.toString());
                    if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) {
                        Constants.log(TAG_NAME, "Time is before or after the quiet hours time. Returning.");
                        addNewCall(number, name, MessageDbHandler.NEW_ICON);
                    } else {
                        Bundle b = new Bundle();
                        b.putLong(MessageDbHandler.COL_CALL_ID,
                                addNewCall(number, name, MessageDbHandler.OLD_ICON));
                        b.putString(MessageDbHandler.COL_CALL_NUMBER, number);
                        b.putString(MessageDbHandler.COL_CALL_NAME, name);
                        Message innerMsg = processHandler.obtainMessage(INNER_CALL_PROCEED);
                        innerMsg.setData(b);
                        processHandler.sendMessage(innerMsg);
                    }
                } else {
                    Bundle b = new Bundle();
                    if (phone_is_ontalking) {
                        b.putString(MessageDbHandler.COL_MESSAGE_APP, "Call");
                        b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, name + "\n" + number);
                        addNewCall(number, name, MessageDbHandler.NEW_ICON);
                        b.putLong(MessageDbHandler.COL_MESSAGE_ID, addNewMessage(b, MessageDbHandler.OLD_ICON));
                        Message innerMsg = processHandler.obtainMessage(INNER_MESSAGE_PROCEED);
                        innerMsg.setData(b);
                        processHandler.sendMessage(innerMsg);
                    } else {
                        b.putLong(MessageDbHandler.COL_CALL_ID,
                                addNewCall(number, name, MessageDbHandler.OLD_ICON));
                        b.putString(MessageDbHandler.COL_CALL_NUMBER, number);
                        b.putString(MessageDbHandler.COL_CALL_NAME, name);
                        Message innerMsg = processHandler.obtainMessage(INNER_CALL_PROCEED);
                        innerMsg.setData(b);
                        processHandler.sendMessage(innerMsg);
                    }
                }
                break;
            case Constants.BROADCAST_CALL_HOOK:
                phone_is_ontalking = true;
                break;
            case Constants.BROADCAST_CALL_IDLE:
                phone_is_ontalking = false;
                break;
            case Constants.BROADCAST_SMS_INCOMING: {
                Message msg = Message.obtain();
                msg.what = MSG_NEW_MESSAGE;
                Bundle b = new Bundle();
                b.putString(MessageDbHandler.COL_MESSAGE_APP, "SMS");
                b.putString(MessageDbHandler.COL_MESSAGE_CONTENT,
                        intent.getStringExtra(Constants.BROADCAST_SMS_BODY));
                msg.setData(b);
                messageHandler.sendMessage(msg);
            }
            }
        }
    };
    IntentFilter intentFilter = new IntentFilter(MessageProcessingService.class.getName());
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter);

}