Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Events to CompactCalendar from api call #366

Open
RamintaMisiunaite opened this issue Feb 11, 2022 · 0 comments
Open

Adding Events to CompactCalendar from api call #366

RamintaMisiunaite opened this issue Feb 11, 2022 · 0 comments

Comments

@RamintaMisiunaite
Copy link

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
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant