List of usage examples for org.joda.time LocalDate getMonthOfYear
public int getMonthOfYear()
From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.TimeMLDateTimePoint.java
License:Open Source License
public void seekField(Granulaarsus field, int direction, int soughtValue, boolean excludingCurrent) { // --------------------------------- // DAY_OF_MONTH // --------------------------------- if (field == Granulaarsus.DAY_OF_MONTH && direction != 0 && soughtValue == 0) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); LocalDate nihutatudFookus = ajaFookus.plusDays(1 * dir); ajaFookus = nihutatudFookus;//from www . j a va2s . com this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.DAY_OF_MONTH, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } // --------------------------------- // DAY_OF_WEEK // --------------------------------- if (field == Granulaarsus.DAY_OF_WEEK && soughtValue >= DateTimeConstants.MONDAY && soughtValue <= DateTimeConstants.SUNDAY && direction != 0) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); // Algne p2ev ehk p2ev, millest tahame tingimata m66duda int algneNadalapaev = (excludingCurrent) ? (ajaFookus.getDayOfWeek()) : (-1); if (!excludingCurrent) { // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale p2evale ajaFookus = ajaFookus.plusDays(dir * (-1)); } int count = 0; while (true) { LocalDate nihutatudFookus = ajaFookus.plusDays(1 * dir); ajaFookus = nihutatudFookus; int uusNadalapaev = ajaFookus.getDayOfWeek(); if (algneNadalapaev != -1) { if (algneNadalapaev == uusNadalapaev) { continue; } else { algneNadalapaev = -1; } } if (uusNadalapaev == soughtValue) { algneNadalapaev = uusNadalapaev; count++; if (count == Math.abs(direction)) { break; } } } this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.DAY_OF_MONTH, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } // --------------------------------- // WEEK OF YEAR // --------------------------------- if (field == Granulaarsus.WEEK_OF_YEAR && soughtValue == 0 && direction != 0) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); // Algne n2dal ehk n2dal, millest tahame m88duda int algneNadal = (excludingCurrent) ? (ajaFookus.getWeekOfWeekyear()) : (-1); if (!excludingCurrent) { // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale p2evale ajaFookus = ajaFookus.plusDays(dir * (-1)); } int count = 0; while (true) { LocalDate nihutatudFookus = ajaFookus.plusDays(1 * dir); ajaFookus = nihutatudFookus; int uusNadal = nihutatudFookus.getWeekOfWeekyear(); if (algneNadal != -1) { if (algneNadal == uusNadal) { continue; } else { algneNadal = -1; } } if (soughtValue == 0) { algneNadal = uusNadal; count++; if (count == Math.abs(direction)) { break; } } } this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.WEEK_OF_YEAR, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } // --------------------------------- // MONTH // --------------------------------- if (field == Granulaarsus.MONTH && (soughtValue == 0 || DateTimeConstants.JANUARY <= soughtValue && soughtValue <= DateTimeConstants.DECEMBER) && direction != 0) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); // Algne kuu ehk kuu, millest tahame m88duda int algneKuu = (excludingCurrent) ? (ajaFookus.getMonthOfYear()) : (-1); if (!excludingCurrent) { // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale kuule ajaFookus = ajaFookus.plusMonths(dir * (-1)); } int count = 0; while (true) { LocalDate nihutatudFookus = ajaFookus.plusMonths(1 * dir); ajaFookus = nihutatudFookus; int uusKuu = nihutatudFookus.getMonthOfYear(); if (algneKuu != -1) { if (algneKuu == uusKuu) { continue; } else { algneKuu = -1; } } if (soughtValue == 0 || (soughtValue != 0 && uusKuu == soughtValue)) { algneKuu = uusKuu; count++; if (count == Math.abs(direction)) { break; } } } this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.MONTH, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } // --------------------------------- // YEAR // --------------------------------- if (field == Granulaarsus.YEAR && soughtValue == 0 && direction != 0) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); // Algne aasta ehk aasta, millest tahame m88duda int algneAasta = (excludingCurrent) ? (ajaFookus.getYear()) : (-1); if (!excludingCurrent) { // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale kuule ajaFookus = ajaFookus.plusMonths(dir * (-1)); } int count = 0; while (true) { LocalDate nihutatudFookus = ajaFookus.plusMonths(1 * dir); ajaFookus = nihutatudFookus; int uusAasta = nihutatudFookus.getYear(); if (algneAasta != -1) { if (algneAasta == uusAasta) { continue; } else { algneAasta = -1; } } if (soughtValue == 0) { algneAasta = uusAasta; count++; if (count == Math.abs(direction)) { break; } } } this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.YEAR, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } // --------------------------------- // YEAR_OF_CENTURY // --------------------------------- if (field == Granulaarsus.YEAR_OF_CENTURY && direction != 0) { int minValue = SemLeidmiseAbimeetodid.getLocalDateTimeFieldExtremum(this.underlyingDate, DateTimeFieldType.yearOfCentury(), false); int maxValue = SemLeidmiseAbimeetodid.getLocalDateTimeFieldExtremum(this.underlyingDate, DateTimeFieldType.yearOfCentury(), true); if (minValue <= soughtValue && soughtValue <= maxValue) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); // Algne aasta ehk aasta, millest tahame m88duda int algneAasta = (excludingCurrent) ? (ajaFookus.getYearOfCentury()) : (-1); if (!excludingCurrent) { // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale aastale ajaFookus = ajaFookus.plusYears(dir * (-1)); } int count = 0; int cycleCount = 0; while (true) { LocalDate nihutatudFookus = ajaFookus.plusYears(1 * dir); cycleCount++; ajaFookus = nihutatudFookus; int uusAasta = nihutatudFookus.getYearOfCentury(); if (algneAasta != -1) { if (algneAasta == uusAasta) { continue; } else { algneAasta = -1; } } if (uusAasta == soughtValue) { algneAasta = uusAasta; count++; if (count == Math.abs(direction)) { break; } } } this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.YEAR, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } } // --------------------------------- // CENTURY_OF_ERA // --------------------------------- if (field == Granulaarsus.CENTURY_OF_ERA && soughtValue == 0 && direction != 0) { int dir = (direction > 0) ? (1) : (-1); LocalDate ajaFookus = new LocalDate(this.underlyingDate); // Algne saj ehk sajand, millest tahame m88duda int algneSajand = (excludingCurrent) ? (ajaFookus.getCenturyOfEra()) : (Integer.MIN_VALUE); if (!excludingCurrent) { // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale aastale ajaFookus = ajaFookus.plusYears(dir * (-10)); } int count = 0; while (true) { LocalDate nihutatudFookus = ajaFookus.plusYears(10 * dir); ajaFookus = nihutatudFookus; int uusSajand = nihutatudFookus.getCenturyOfEra(); if (algneSajand != Integer.MIN_VALUE) { if (algneSajand == uusSajand) { continue; } else { algneSajand = Integer.MIN_VALUE; } } if (soughtValue == 0) { algneSajand = uusSajand; count++; if (count == Math.abs(direction)) { break; } } } this.underlyingDate = ajaFookus; updateDateRepresentation(Granulaarsus.CENTURY_OF_ERA, null, false, ADD_TYPE_OPERATION); functionOtherThanSetUsed = true; this.dateModified = true; } }
From source file:energy.usef.brp.workflow.settlement.initiate.BrpInitiateSettlementCoordinator.java
License:Apache License
/** * Preparation of the Initiate Settlement process for the first day of the previous month until the last day of the previous * month. The initiating of settlements will stop if there are no flex orders in the selected period. * * @param event The {@link CollectSmartMeterDataEvent} triggering the process. *///from w ww . jav a 2s . co m @Asynchronous @Lock(LockType.WRITE) public void handleCollectSmartMeterDataEvent( @Observes(during = TransactionPhase.AFTER_COMPLETION) CollectSmartMeterDataEvent event) { LOGGER.debug(USEFConstants.LOG_COORDINATOR_START_HANDLING_EVENT, event); LocalDate dayOneMonthBefore = event.getPeriodInMonth(); if (dayOneMonthBefore == null) { dayOneMonthBefore = DateTimeUtil.getCurrentDate().minusMonths(1); } LocalDate startDate = dayOneMonthBefore.withDayOfMonth(1); LocalDate endDate = dayOneMonthBefore.dayOfMonth().withMaximumValue(); // retrieve a distinct list of all connections valid in given time frame and map them to a string list. Map<LocalDate, Map<ConnectionGroup, List<Connection>>> connectionGroupsWithConnections = corePlanboardBusinessService .findConnectionGroupWithConnectionsWithOverlappingValidity(startDate, endDate); List<LocalDate> daysWithOrders = corePlanboardBusinessService .findPlanboardMessages(DocumentType.FLEX_ORDER, startDate, endDate, DocumentStatus.ACCEPTED) .stream().map(PlanboardMessage::getPeriod).distinct().collect(Collectors.toList()); if (daysWithOrders.isEmpty()) { checkInitiateSettlementDoneEvent .fire(new CheckInitiateSettlementDoneEvent(startDate.getYear(), startDate.getMonthOfYear())); LOGGER.debug(USEFConstants.LOG_COORDINATOR_FINISHED_HANDLING_EVENT, event); return; } // loop through all the MDCs for (MeterDataCompany meterDataCompany : brpBusinessService.findAllMDCs()) { // query meter data company (MDC) for all connections LOGGER.info("Preparing sending MeterDataQuery to Meter Data Company {}", meterDataCompany.getDomain()); for (LocalDate period : connectionGroupsWithConnections.keySet()) { if (!daysWithOrders.contains(period)) { continue; } LocalDateTime expirationDateTime = DateTimeUtil.getCurrentDateTime().plusHours( configBrp.getIntegerProperty(ConfigBrpParam.BRP_METER_DATA_QUERY_EXPIRATION_IN_HOURS)); MessageMetadata messageMetadata = MessageMetadataBuilder .build(meterDataCompany.getDomain(), USEFRole.MDC, config.getProperty(ConfigParam.HOST_DOMAIN), USEFRole.BRP, TRANSACTIONAL) .validUntil(expirationDateTime).build(); // fill the MeterDataQuery message MeterDataQuery meterDataQuery = new MeterDataQuery(); meterDataQuery.setMessageMetadata(messageMetadata); meterDataQuery.setDateRangeStart(period); meterDataQuery.setDateRangeEnd(period); meterDataQuery.getConnections() .addAll(buildConnectionGroups(connectionGroupsWithConnections.get(period))); MeterDataQueryMessageUtil.populateConnectionsInConnectionGroups(meterDataQuery, connectionGroupsWithConnections.get(period)); // Store in PlanboardMessage, no connectionGroup available because query is for the whole grid. // the period should be the startDate of the month. PlanboardMessage meterDataQueryPlanboardMessage = new PlanboardMessage( DocumentType.METER_DATA_QUERY_USAGE, sequenceGeneratorService.next(), DocumentStatus.SENT, meterDataCompany.getDomain(), period, null, null, expirationDateTime); corePlanboardBusinessService.updatePlanboardMessage(meterDataQueryPlanboardMessage); // send the message jmsHelperService.sendMessageToOutQueue(XMLUtil.messageObjectToXml(meterDataQuery)); } } LOGGER.debug(USEFConstants.LOG_COORDINATOR_FINISHED_HANDLING_EVENT, event); }
From source file:energy.usef.brp.workflow.settlement.initiate.BrpInitiateSettlementCoordinator.java
License:Apache License
/** * Handles the event triggering the initiation of the settlement. * * @param finalizeInitiateSettlementEvent {@link FinalizeInitiateSettlementEvent}. */// ww w. java2s . c o m @SuppressWarnings("unchecked") @Asynchronous public void handleBrpInitiateSettlement( @Observes(during = TransactionPhase.AFTER_COMPLETION) FinalizeInitiateSettlementEvent finalizeInitiateSettlementEvent) { LOGGER.debug(USEFConstants.LOG_COORDINATOR_START_HANDLING_EVENT, finalizeInitiateSettlementEvent); // variables final LocalDate startDate = finalizeInitiateSettlementEvent.getStartDate(); final LocalDate endDate = finalizeInitiateSettlementEvent.getEndDate(); // creation of the context and call to the PBC. WorkflowContext inContext = initiateWorkflowContext(startDate, endDate); inContext.setValue(BrpInitiateSettlementParameter.IN.SMART_METER_DATA.name(), MeterDataTransformer.transform(finalizeInitiateSettlementEvent.getConnectionGroupList())); SettlementDto settlementDto = invokeInitiateSettlementPbc(inContext); // Add the settlement prices to the SettlementDto settlementDto = calculateSettlementPrice(settlementDto, inContext.get(FLEX_OFFER_DTO_LIST.name(), List.class)); // invoke the PBC to add penalty data to the ptuSettlementList settlementDto = addPenaltyData(settlementDto); // save the settlement dtos. saveSettlement(settlementDto); LOGGER.info("Settlements are stored in the DB."); checkInitiateSettlementDoneEvent .fire(new CheckInitiateSettlementDoneEvent(startDate.getYear(), startDate.getMonthOfYear())); LOGGER.debug(USEFConstants.LOG_COORDINATOR_FINISHED_HANDLING_EVENT, finalizeInitiateSettlementEvent); }
From source file:energy.usef.dso.workflow.settlement.initiate.DsoInitiateSettlementCoordinator.java
License:Apache License
/** * Preparation of the Initiate Settlement process. * * @param event the {@link CollectSmartMeterDataEvent} that triggers the process. *//*from w ww . j a v a2 s. c om*/ @Asynchronous @Lock(LockType.WRITE) public void handleCollectSmartMeterDataEvent( @Observes(during = TransactionPhase.AFTER_COMPLETION) CollectSmartMeterDataEvent event) { LOGGER.debug(USEFConstants.LOG_COORDINATOR_START_HANDLING_EVENT, event); LocalDate dayOneMonthBefore = event.getPeriodInMonth(); if (dayOneMonthBefore == null) { dayOneMonthBefore = DateTimeUtil.getCurrentDate().minusMonths(1); } LocalDate startDate = dayOneMonthBefore.withDayOfMonth(1); LocalDate endDate = dayOneMonthBefore.dayOfMonth().withMaximumValue(); LOGGER.info("Preparing Initiate Settlement workflow for the start day {} and end day {}.", startDate, endDate); // retrieve a distinct list of all connections valid in given time frame and map them to a string list. Map<LocalDate, Map<ConnectionGroup, List<Connection>>> connectionGroupsWithConnections = corePlanboardBusinessService .findConnectionGroupWithConnectionsWithOverlappingValidity(startDate, endDate); List<LocalDate> daysWithOrders = corePlanboardBusinessService .findPlanboardMessages(DocumentType.FLEX_ORDER, startDate, endDate, DocumentStatus.ACCEPTED) .stream().map(PlanboardMessage::getPeriod).distinct().collect(toList()); if (daysWithOrders.isEmpty()) { checkInitiateSettlementDoneEvent .fire(new CheckInitiateSettlementDoneEvent(startDate.getYear(), startDate.getMonthOfYear())); LOGGER.debug(USEFConstants.LOG_COORDINATOR_FINISHED_HANDLING_EVENT, event); return; } // loop through all the MDCs for (MeterDataCompany meterDataCompany : dsoPlanboardBusinessService.findAllMDCs()) { // query meter data company (MDC) for all connections LOGGER.info("Preparing sending MeterDataQuery to Meter Data Company {}", meterDataCompany.getDomain()); for (LocalDate period : connectionGroupsWithConnections.keySet()) { if (!daysWithOrders.contains(period)) { continue; } LocalDateTime expirationDateTime = DateTimeUtil.getCurrentDateTime().plusHours( configDso.getIntegerProperty(ConfigDsoParam.DSO_METER_DATA_QUERY_EXPIRATION_IN_HOURS)); MessageMetadata messageMetadata = MessageMetadataBuilder .build(meterDataCompany.getDomain(), USEFRole.MDC, config.getProperty(ConfigParam.HOST_DOMAIN), USEFRole.DSO, TRANSACTIONAL) .validUntil(expirationDateTime).build(); // fill the MeterDataQuery message MeterDataQuery meterDataQuery = new MeterDataQuery(); meterDataQuery.setMessageMetadata(messageMetadata); meterDataQuery.setDateRangeStart(period); meterDataQuery.setDateRangeEnd(period); meterDataQuery.getConnections() .addAll(buildConnectionGroups(connectionGroupsWithConnections.get(period))); MeterDataQueryMessageUtil.populateConnectionsInConnectionGroups(meterDataQuery, connectionGroupsWithConnections.get(period)); // Store in PlanboardMessage, no connectionGroup available because query is for the whole grid. // the period should be the startDate of the month. PlanboardMessage meterDataQueryPlanboardMessage = new PlanboardMessage( DocumentType.METER_DATA_QUERY_USAGE, sequenceGeneratorService.next(), DocumentStatus.SENT, meterDataCompany.getDomain(), period, null, null, null); meterDataQueryPlanboardMessage.setExpirationDate(expirationDateTime); corePlanboardBusinessService.updatePlanboardMessage(meterDataQueryPlanboardMessage); // send the message jmsHelperService.sendMessageToOutQueue(XMLUtil.messageObjectToXml(meterDataQuery)); } } LOGGER.debug(USEFConstants.LOG_COORDINATOR_FINISHED_HANDLING_EVENT, event); }
From source file:energy.usef.dso.workflow.settlement.initiate.DsoInitiateSettlementCoordinator.java
License:Apache License
/** * Handles the event triggering the initiation of the settlement. * * @param finalizeInitiateSettlementEvent {@link CollectSmartMeterDataEvent}. *//*from w w w .ja v a 2 s.c o m*/ @SuppressWarnings("unchecked") @Asynchronous public void handleDsoInitiateSettlement( @Observes(during = TransactionPhase.AFTER_COMPLETION) FinalizeInitiateSettlementEvent finalizeInitiateSettlementEvent) { LOGGER.debug(USEFConstants.LOG_COORDINATOR_START_HANDLING_EVENT, finalizeInitiateSettlementEvent); final LocalDate startDate = finalizeInitiateSettlementEvent.getStartDate(); final LocalDate endDate = finalizeInitiateSettlementEvent.getEndDate(); // creation of the context and call to the PBC. WorkflowContext inContext = initiateWorkflowContext(startDate, endDate); if (!finalizeInitiateSettlementEvent.getMeterDataPerCongestionPoint().isEmpty()) { inContext.setValue(DsoInitiateSettlementParameter.IN.SMART_METER_DATA.name(), MeterDataTransformer .transform(finalizeInitiateSettlementEvent.getMeterDataPerCongestionPoint())); } else { inContext.setValue(DsoInitiateSettlementParameter.IN.GRID_MONITORING_DATA.name(), buildGridMonitoringDtos(startDate, endDate)); } SettlementDto settlementDto = invokeInitiateSettlementPbc(inContext); // Add the settlement prices to the SettlementDto settlementDto = calculateSettlementPrice(settlementDto, inContext.get(FLEX_OFFER_DTO_LIST.name(), List.class)); // invoke the PBC to add penalty data to the ptuSettlementList settlementDto = addPenaltyData(settlementDto); // save the settlement dtos. saveSettlement(settlementDto); checkInitiateSettlementDoneEvent .fire(new CheckInitiateSettlementDoneEvent(startDate.getYear(), startDate.getMonthOfYear())); LOGGER.debug(USEFConstants.LOG_COORDINATOR_FINISHED_HANDLING_EVENT, finalizeInitiateSettlementEvent); }
From source file:es.usc.citius.servando.calendula.fragments.HomeProfileMgr.java
License:Open Source License
public void init(View view, final Activity ctx) { this.context = ctx; this.rootView = view; preferences = PreferenceManager.getDefaultSharedPreferences(context); // Animation in = AnimationUtils.loadAnimation(ctx, android.R.anim.fade_in); // Animation out = AnimationUtils.loadAnimation(ctx, android.R.anim.fade_out); moods = ctx.getResources().getStringArray(R.array.moods); monthTv = (TextView) view.findViewById(R.id.month_text); dayTv = (TextView) view.findViewById(R.id.day_text); //clock = (CustomDigitalClock) view.findViewById(R.id.home_clock); bottomShadow = (ImageView) view.findViewById(R.id.bottom_shadow); profileInfo = view.findViewById(R.id.profile_info); blurMask = view.findViewById(R.id.blur_mask); santaContainer = view.findViewById(R.id.santa_container); santaImv = (ImageView) view.findViewById(R.id.image_santa); santaButton = (ImageButton) view.findViewById(R.id.santa_mode_button); santaButton.setImageDrawable(new IconicsDrawable(ctx, CommunityMaterial.Icon.cmd_pine_tree).sizeDp(36) .paddingDp(5).colorRes(R.color.white)); profileUsername = (TextView) view.findViewById(R.id.profile_username); profileContainer = (RelativeLayout) view.findViewById(R.id.profile_container); profileImageContainer = view.findViewById(R.id.profile_image_container); background = (ImageView) view.findViewById(R.id.image_switcher); modFabButton = (RoundedImageView) view.findViewById(R.id.mod_circle); moodImg = (ImageView) view.findViewById(R.id.mood_button); moodImg.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .j a va 2s.co m*/ public void onClick(View v) { showMoodsDialog(); } }); background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateBackground(); } }); updateModButton(); updateProfileInfo(); profileInfo.setVisibility(View.INVISIBLE); background.setVisibility(View.INVISIBLE); bottomShadow.setVisibility(View.INVISIBLE); boolean disableChristmasMode = preferences.getBoolean("disable_christmas_mode", false); LocalDate today = LocalDate.now(); if (!disableChristmasMode && today.getMonthOfYear() == 12 && (today.getDayOfMonth() >= 23 && today.getDayOfMonth() <= 31)) { try { int current = preferences.getInt("current_santa_image", 0); santaImv.setImageDrawable(new GifDrawable(ctx.getAssets(), images.get(current))); santaContainer.setVisibility(View.VISIBLE); blurMask.setAlpha(0.5f); santaButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (t != null) { t.cancel(); } t = Toast.makeText(context, R.string.christmas_remove_message, Toast.LENGTH_SHORT); t.show(); rotateChristmasImage(); } }); santaButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { santaContainer.setVisibility(View.GONE); preferences.edit().putBoolean("disable_christmas_mode", true).apply(); t = Toast.makeText(context, R.string.done, Toast.LENGTH_SHORT); t.show(); return true; } }); if (!preferences.getBoolean("christmas_message_shown_2016", false)) { showChristmasDialog(); preferences.edit().putBoolean("christmas_message_shown_2016", true).apply(); } santaMode = true; } catch (Exception e) { santaContainer.setVisibility(View.GONE); } } else { santaContainer.setVisibility(View.GONE); } Picasso.with(context).load("file:///android_asset/" + getBackgroundPath(ctx)).into(background); background.post(new Runnable() { @Override public void run() { bottomShadow.setVisibility(View.VISIBLE); background.setVisibility(View.VISIBLE); background.animate().alpha(1).setDuration(200); } }); background.postDelayed(new Runnable() { @Override public void run() { profileInfo.setVisibility(View.VISIBLE); profileInfo.setAlpha(0); profileInfo.animate().alpha(santaMode ? 0.5f : 1).setDuration(400); } }, 300); }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
private void setupStartEndDatePickers(View rootView) { if (schedule.start() == null) { schedule.setStart(LocalDate.now()); }/* ww w . java 2s . c o m*/ final LocalDate scheduleStart = schedule.start(); buttonScheduleStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Log.d(TAG, year + " " + monthOfYear); LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleStart(d); } }, scheduleStart.getYear(), scheduleStart.getMonthOfYear() - 1, scheduleStart.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LocalDate scheduleEnd = schedule.end() != null ? schedule.end() : scheduleStart.plusMonths(3); DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleEnd(d); } }, scheduleEnd.getYear(), scheduleEnd.getMonthOfYear() - 1, scheduleEnd.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Do you want this schedule to continue indefinitely?").setCancelable(true) .setPositiveButton(getString(R.string.dialog_yes_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { setScheduleEnd(null); } }) .setNegativeButton(getString(R.string.dialog_no_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); clearStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleStart(null); } }); clearEndButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleEnd(null); } }); setScheduleStart(schedule.start()); if (schedule.end() == null && isNew && hasEnd && daysToEnd > 0) { LocalDate end = schedule.start().plusDays(daysToEnd); setScheduleEnd(end); } else { setScheduleEnd(schedule.end()); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
@Override public void onRecurrenceSet(String s) { EventRecurrence event = new EventRecurrence(); LocalDate now = LocalDate.now(); Time startDate = new Time(Time.getCurrentTimezone()); startDate.set(now.getDayOfMonth(), now.getMonthOfYear(), now.getYear()); startDate.normalize(true);//from w w w . jav a 2 s .c om event.parse(s); event.setStartDate(startDate); Log.d(TAG, "OnRecurrenceSet: " + event.startDate); schedule.setRepetition(new RepetitionRule("RRULE:" + s)); setScheduleStart(schedule.start()); LocalDate end = schedule.end(); Log.d(TAG, "ICAL: " + schedule.rule().toIcal()); setScheduleEnd(end); Log.d(TAG, "ICAL: " + schedule.rule().toIcal()); ruleText.setText(getCurrentSchedule()); }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
void setScheduleEnd(LocalDate end) { if (end == null) { buttonScheduleEnd.setText(getString(R.string.never)); schedule.rule().iCalRule().setUntil(null); clearEndButton.setVisibility(View.INVISIBLE); } else {// w w w. jav a 2 s .c o m DateValue v = new DateTimeValueImpl(end.getYear(), end.getMonthOfYear(), end.getDayOfMonth(), 0, 0, 0); schedule.rule().iCalRule().setUntil(v); buttonScheduleEnd.setText(end.toString(getString(R.string.schedule_limits_date_format))); clearEndButton.setVisibility(View.VISIBLE); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java
License:Open Source License
void setupStartEndDatePickers(View rootView) { if (schedule.start() == null) { schedule.setStart(LocalDate.now()); }/*from w w w.ja v a 2s . c o m*/ final LocalDate scheduleStart = schedule.start(); buttonScheduleStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Log.d(TAG, year + " " + monthOfYear); LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleStart(d); } }, scheduleStart.getYear(), scheduleStart.getMonthOfYear() - 1, scheduleStart.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LocalDate scheduleEnd = schedule.end() != null ? schedule.end() : scheduleStart.plusMonths(3); DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleEnd(d); } }, scheduleEnd.getYear(), scheduleEnd.getMonthOfYear() - 1, scheduleEnd.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Do you want this schedule to continue indefinitely?").setCancelable(true) .setPositiveButton(getString(R.string.dialog_yes_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { setScheduleEnd(null); } }) .setNegativeButton(getString(R.string.dialog_no_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); clearStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleStart(null); } }); clearEndButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleEnd(null); } }); setScheduleStart(schedule.start()); setScheduleEnd(schedule.end()); }