Tibolte / AgendaCalendarView

[DEPRECATED] An Android project providing easy navigation between a calendar and an agenda. This library replicates the basic features from the Sunrise Calendar (now Outlook) app, coupled with some small design touch from the Google Calendar app.
1.23k stars 340 forks source link

NullPointerException in Fragment #45

Open marcoserafini2 opened 8 years ago

marcoserafini2 commented 8 years ago

Hi.I'm trying to move the agenda from the activity in a fragment But I get a nullPointer as the result

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.tibolte.agendacalendarview.calendar.CalendarView.init(com.github.tibolte.agendacalendarview.CalendarManager, int, int, int)' on a null object reference In my project I'm not using ButterKnife

This is my Fragment code:

@Nullable
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_appointment, null);

        mAgendaCalendarView = (AgendaCalendarView) view.findViewById(R.id.agenda_calendar_view);

        mAgendaCalendarView = new AgendaCalendarView(getContext());

        Calendar minDate = Calendar.getInstance();
        Calendar maxDate = Calendar.getInstance();

        minDate.add(Calendar.MONTH, -2);
        minDate.set(Calendar.DAY_OF_MONTH, 1);
        maxDate.add(Calendar.YEAR, 1);

        List<CalendarEvent> eventList = new ArrayList<>();

        mAgendaCalendarView.init(eventList, minDate, maxDate, Locale.getDefault(), this);

        return view;
    }

This is the layout

<LinearLayout xmlns:agendaCalendar="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

    <com.github.tibolte.agendacalendarview.AgendaCalendarView
        android:id="@+id/agenda_calendar_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        agendaCalendar:agendaCurrentDayTextColor="@color/theme_primary"
        agendaCalendar:calendarColor="@color/theme_primary"
        agendaCalendar:calendarCurrentDayTextColor="@color/calendar_text_current_day"
        agendaCalendar:calendarDayTextColor="@color/theme_text_icons"
        agendaCalendar:calendarHeaderColor="@color/theme_primary_dark"
        agendaCalendar:calendarPastDayTextColor="@color/theme_light_primary"
        agendaCalendar:fabColor="@color/theme_accent" />

</LinearLayout>
legalimpurity commented 8 years ago

+1 same issue here

legalimpurity commented 8 years ago

ok, so even though it was working perfectly on my phone before, it is not working now ! my guess is that its breaking on 6.0.1 because i updated my phone from 4.4 to 6.0.1 ! so any one with any solution please come up !

legalimpurity commented 8 years ago

FYI : the issue is not in the github code, apparently he has not updated the code on jitpack, compile it from here and it works!

albert0m commented 7 years ago

I spent the whole morning trying to import it and my eyes are still bleeding. I compiled the github code in an aar file but I still get this error. If in a fragment, the agendaView is null.