Skip to content

Adding Events to CompactCalendar from api call #366

Description

@RamintaMisiunaite

In my code, I have calenderFragment (where the main compactCalnder is) and a DayActivity. When a day in the calendar is clicked, the DayActivity is started. What I'm trying to do is, when 'submit' button in DayActivity is pressed an event with the day's date should be created and a dot under the day should appear. However, that doesn't happen. It works when I manually create an event using hardcoded dates and call the addEvent method on the calendar. Am I missing something? I'm relatively new to Android

calenderFragment.java:

        compactCalendar.setListener(new CompactCalendarView.CompactCalendarViewListener() {

        @Override
        public void onDayClick(Date dateClicked) {
           
            String fullDateStr = dateFormatForFullDate.format(dateClicked); 
            try {
                Date fullDate = dateFormatForFullDate.parse(fullDateStr);
                timeInMillis = fullDate.getTime();

            } catch (ParseException e) {
                e.printStackTrace();
            }

            Intent intent = new Intent(getActivity(),DayActivity.class);
         
            intent.putExtra("dateInMills", timeInMillis);  // here I'm just passing the days date in milliseconds to DayActivity
            startActivity(intent);
        }

<...>

DayActivity.java:
<...>

     Intent intent = getIntent();
    long dateInMills = intent.getLongExtra("dateInMills", 0);
    dateTv.setText(date);

    doneBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

        //                Event ev = new Event(Color.parseColor("#613DC1"), dateInMills, "Cried");
       //                compactCalendar.addEvent(ev);
      //                this part doesn't work

         //   Toast.makeText(getApplicationContext(), "date: " + dateInMills, Toast.LENGTH_SHORT).show();
            //  date passed is correct
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions