Skip to content

Commit

Permalink
event displaying issue when event fall on multiple month fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
puskal-khadka committed Aug 31, 2021
1 parent 6531217 commit 2985183
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ object CalendarController {
val calendar = Calendar.getInstance()
calendar.set(Calendar.YEAR, year)
calendar.set(Calendar.MONTH, month.minus(1))
calendar.set(Calendar.DAY_OF_MONTH,1)
val monthNum = calendar.get(Calendar.MONTH).plus(1)
val year = calendar.get(Calendar.YEAR)
val monthYearTitle = when (localizationType) {
Expand All @@ -141,14 +142,13 @@ object CalendarController {
}
}

Log.d("d","data isis $monthYearTitle")
Log.d("d","data is $monthYearTitle")


val dateList = weekNameDateModel(localizationType)

val daysInThisMonth = calendar.getActualMaximum(Calendar.DATE)

calendar.set(Calendar.DAY_OF_MONTH, 1)
val weekNumberOfFirstDayOfMonth = calendar.get(Calendar.DAY_OF_WEEK)

for (i in 1 until weekNumberOfFirstDayOfMonth) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.puskal.merocalendar.enum.CalendarType
import com.puskal.merocalendar.enum.LocalizationType
import com.puskal.merocalendar.model.DateModel
import com.puskal.merocalendar.model.EventModel
import java.text.DecimalFormat
import java.util.*

/**@author Puskal Khadka
Expand Down Expand Up @@ -167,6 +168,7 @@ class MeroCalendarView : LinearLayout {
* Set event to the calendar
* @param eventList arraylist of [EventModel]
*/
val decFormat = DecimalFormat("00")
fun setEvent(eventList: ArrayList<EventModel>): MeroCalendarView {
this.eventList = eventList
if (currentMonthDateList.isNotEmpty()) {
Expand All @@ -187,7 +189,11 @@ class MeroCalendarView : LinearLayout {
val to_m = toDate[1].toInt()
val to_d = toDate[2].toInt()

val fromDateLong="$from_y${decFormat.format(from_m)}${decFormat.format(from_d)}".toLong()
val toDateLong="$to_y${decFormat.format(to_m)}${decFormat.format(to_d)}".toLong()

for (dateModel in currentMonthDateList) {

val date = dateModel.formattedAdDate.split("-")

if (date.size != 3) {
Expand All @@ -197,7 +203,8 @@ class MeroCalendarView : LinearLayout {
val date_m = date[1].toInt()
val date_d = date[2].toInt()

if (date_y in from_y..to_y && date_m in from_m..to_m && date_d in from_d..to_d) {
val currentDateLong="$date_y${decFormat.format(date_m)}${decFormat.format(date_d)}".toLong()
if(currentDateLong in fromDateLong..toDateLong){
dateModel.hasEvent = true
dateModel.eventColorCode = event.colorCode
dateModel.isHoliday = event.isHolidayEvent
Expand Down

0 comments on commit 2985183

Please sign in to comment.