{"action":"created","issue":{"url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/300","repository_url":"https://api.github.com/repos/alamkanak/Android-Week-View","labels_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/300/labels{/name}","comments_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/300/comments","events_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/300/events","html_url":"https://github.com/alamkanak/Android-Week-View/issues/300","id":143272157,"number":300,"title":"error : \"You must provide a MonthChangeListener\" however I provide this","user":{"login":"GuillaumeBuc","id":18053152,"avatar_url":"https://avatars.githubusercontent.com/u/18053152?v=3","gravatar_id":"","url":"https://api.github.com/users/GuillaumeBuc","html_url":"https://github.com/GuillaumeBuc","followers_url":"https://api.github.com/users/GuillaumeBuc/followers","following_url":"https://api.github.com/users/GuillaumeBuc/following{/other_user}","gists_url":"https://api.github.com/users/GuillaumeBuc/gists{/gist_id}","starred_url":"https://api.github.com/users/GuillaumeBuc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GuillaumeBuc/subscriptions","organizations_url":"https://api.github.com/users/GuillaumeBuc/orgs","repos_url":"https://api.github.com/users/GuillaumeBuc/repos","events_url":"https://api.github.com/users/GuillaumeBuc/events{/privacy}","received_events_url":"https://api.github.com/users/GuillaumeBuc/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-03-24T15:08:49Z","updated_at":"2016-07-11T19:49:04Z","closed_at":"2016-06-30T12:40:17Z","body":"Hello. \r\nI have this error when i want to implement a Fragment with a WeekView :  \"java.lang.IllegalStateException: You must provide a MonthChangeListener\".\r\nI really don't understand because I have a MonthChangeListener !\r\nI looked for the reason of this error on internet but I didn't find... \r\nIt works when I made an activity with WeekView but I don't manage to make a fragment with it, always this error. \r\n\r\nI paste my code, if you know why this error occured, please let me know ! \r\n\r\n```\r\npublic class Cal extends Fragment implements MonthLoader.MonthChangeListener,WeekView.EventClickListener, WeekView.EventLongPressListener,\r\n        WeekView.EmptyViewLongPressListener{\r\n    // TODO: Rename parameter arguments, choose names that match\r\n    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER\r\n    private static final String ARG_PARAM1 = \"param1\";\r\n    private static final String ARG_PARAM2 = \"param2\";\r\n\r\n    // TODO: Rename and change types of parameters\r\n    private String mParam1;\r\n    private String mParam2;\r\n\r\n    private OnFragmentInteractionListener mListener;\r\n\r\n    public Intent impor;\r\n    public Intent settings;\r\n    public Intent compte;\r\n    View v;\r\n    LayoutInflater inflater;\r\n\r\n    private int index;\r\n    private static WeekView mWeekView;\r\n    private static WeekViewEvent e;\r\n    private static ArrayList<WeekViewEvent> mNewEvents;\r\n\r\n    public Cal() {\r\n        // Required empty public constructor\r\n    }\r\n\r\n    /**\r\n     * Use this factory method to create a new instance of\r\n     * this fragment using the provided parameters.\r\n     *\r\n     * @param param1 Parameter 1.\r\n     * @param param2 Parameter 2.\r\n     * @return A new instance of fragment Cal.\r\n     */\r\n    // TODO: Rename and change types and number of parameters\r\n    public static Cal newInstance(String param1, String param2) {\r\n        Cal fragment = new Cal();\r\n        Bundle args = new Bundle();\r\n        args.putString(ARG_PARAM1, param1);\r\n        args.putString(ARG_PARAM2, param2);\r\n        fragment.setArguments(args);\r\n        return fragment;\r\n    }\r\n\r\n    @Override\r\n    public void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        if (getArguments() != null) {\r\n            mParam1 = getArguments().getString(ARG_PARAM1);\r\n            mParam2 = getArguments().getString(ARG_PARAM2);\r\n        }\r\n\r\n        inflater=getActivity().getLayoutInflater();\r\n        v=inflater.inflate(R.layout.weekview, null);\r\n\r\n        // Get a reference for the week view in the layout.\r\n        mWeekView = (WeekView) v.findViewById(R.id.weekView);\r\n\r\n        // The week view has infinite scrolling horizontally. We have to provide the events of a\r\n        // month every time the month changes on the week view.\r\n        mWeekView.setMonthChangeListener(this);\r\n\r\n        // Show a toast message about the touched event.\r\n        mWeekView.setOnEventClickListener(this);\r\n\r\n        // Set up empty view click listener.\r\n        mWeekView.setEmptyViewLongPressListener(this);\r\n\r\n        mWeekView.setEventLongPressListener(this);\r\n\r\n\r\n        // Set up a date time interpreter to interpret how the date and time will be formatted in\r\n        // the week view. This is optional.\r\n        setupDateTimeInterpreter(false);\r\n\r\n        // Initially, there will be no events on the week view because the user has not tapped on\r\n        // it yet.\r\n        mNewEvents = new ArrayList<WeekViewEvent>();\r\n    }\r\n\r\n    @Override\r\n    public View onCreateView(LayoutInflater inflater, ViewGroup container,\r\n                             Bundle savedInstanceState) {\r\n        // Inflate the layout for this fragment\r\n        return inflater.inflate(R.layout.weekview, container, false);\r\n    }\r\n\r\n    // TODO: Rename method, update argument and hook method into UI event\r\n    public void onButtonPressed(Uri uri) {\r\n        if (mListener != null) {\r\n            mListener.onFragmentInteraction(uri);\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void onAttach(Context context) {\r\n        super.onAttach(context);\r\n        if (context instanceof OnFragmentInteractionListener) {\r\n            mListener = (OnFragmentInteractionListener) context;\r\n        } else {\r\n            throw new RuntimeException(context.toString()\r\n                    + \" must implement OnFragmentInteractionListener\");\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void onDetach() {\r\n        super.onDetach();\r\n        mListener = null;\r\n    }\r\n\r\n\r\n    @Override\r\n    public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) {\r\n        // Populate the week view with the events that was added by tapping on empty view.\r\n        List<WeekViewEvent> events = new ArrayList<WeekViewEvent>();\r\n        ArrayList<WeekViewEvent> newEvents = getNewEvents(newYear, newMonth);\r\n        events.addAll(newEvents);\r\n\r\n        Calendar startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.HOUR_OF_DAY, 3);\r\n        startTime.set(Calendar.MINUTE, 0);\r\n        startTime.set(Calendar.MONTH, newMonth - 1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        Calendar endTime = (Calendar) startTime.clone();\r\n        endTime.add(Calendar.HOUR, 1);\r\n        endTime.set(Calendar.MONTH, newMonth - 1);\r\n        WeekViewEvent event = new WeekViewEvent(1, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.red));\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.HOUR_OF_DAY, 3);\r\n        startTime.set(Calendar.MINUTE, 30);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.set(Calendar.HOUR_OF_DAY, 4);\r\n        endTime.set(Calendar.MINUTE, 30);\r\n        endTime.set(Calendar.MONTH, newMonth-1);\r\n        event = new WeekViewEvent(10, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.red));\r\n        event.setName(\"match foot\");\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.HOUR_OF_DAY, 4);\r\n        startTime.set(Calendar.MINUTE, 20);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.set(Calendar.HOUR_OF_DAY, 5);\r\n        endTime.set(Calendar.MINUTE, 0);\r\n        event = new WeekViewEvent(10, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.green));\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.HOUR_OF_DAY, 5);\r\n        startTime.set(Calendar.MINUTE, 30);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.add(Calendar.HOUR_OF_DAY, 2);\r\n        endTime.set(Calendar.MONTH, newMonth-1);\r\n        event = new WeekViewEvent(2, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.green));\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.HOUR_OF_DAY, 5);\r\n        startTime.set(Calendar.MINUTE, 0);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        startTime.add(Calendar.DATE, 1);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.add(Calendar.HOUR_OF_DAY, 3);\r\n        endTime.set(Calendar.MONTH, newMonth - 1);\r\n        event = new WeekViewEvent(3, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.blue));\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.DAY_OF_MONTH, 15);\r\n        startTime.set(Calendar.HOUR_OF_DAY, 3);\r\n        startTime.set(Calendar.MINUTE, 0);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.add(Calendar.HOUR_OF_DAY, 3);\r\n        event = new WeekViewEvent(4, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.yellow));\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.DAY_OF_MONTH, 1);\r\n        startTime.set(Calendar.HOUR_OF_DAY, 3);\r\n        startTime.set(Calendar.MINUTE, 0);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.add(Calendar.HOUR_OF_DAY, 3);\r\n        event = new WeekViewEvent(5, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.red));\r\n        events.add(event);\r\n\r\n        startTime = Calendar.getInstance();\r\n        startTime.set(Calendar.DAY_OF_MONTH, startTime.getActualMaximum(Calendar.DAY_OF_MONTH));\r\n        startTime.set(Calendar.HOUR_OF_DAY, 15);\r\n        startTime.set(Calendar.MINUTE, 0);\r\n        startTime.set(Calendar.MONTH, newMonth-1);\r\n        startTime.set(Calendar.YEAR, newYear);\r\n        endTime = (Calendar) startTime.clone();\r\n        endTime.add(Calendar.HOUR_OF_DAY, 3);\r\n        event = new WeekViewEvent(5, getEventTitle(startTime), startTime, endTime);\r\n        event.setColor(getResources().getColor(R.color.green));\r\n        events.add(event);\r\n\r\n        return events;\r\n    }\r\n\r\n    protected String getEventTitle(Calendar time) {\r\n        return String.format(\"Event of %02d:%02d %s/%d\", time.get(Calendar.HOUR_OF_DAY), time.get(Calendar.MINUTE), time.get(Calendar.MONTH)+1, time.get(Calendar.DAY_OF_MONTH));\r\n    }\r\n\r\n\r\n    private void setupDateTimeInterpreter(final boolean shortDate) {\r\n        mWeekView.setDateTimeInterpreter(new DateTimeInterpreter() {\r\n            @Override\r\n            public String interpretDate(Calendar date) {\r\n                SimpleDateFormat weekdayNameFormat = new SimpleDateFormat(\"EEE\", Locale.getDefault());\r\n                String weekday = weekdayNameFormat.format(date.getTime());\r\n                SimpleDateFormat format = new SimpleDateFormat(\" M/d\", Locale.getDefault());\r\n\r\n                // All android api level do not have a standard way of getting the first letter of\r\n                // the week day name. Hence we get the first char programmatically.\r\n                // Details: http://stackoverflow.com/questions/16959502/get-one-letter-abbreviation-of-week-day-of-a-date-in-java#answer-16959657\r\n                if (shortDate)\r\n                    weekday = String.valueOf(weekday.charAt(0));\r\n                return weekday.toUpperCase() + format.format(date.getTime());\r\n            }\r\n\r\n            @Override\r\n            public String interpretTime(int hour) {\r\n                return hour > 11 ? (hour - 12) + \" PM\" : (hour == 0 ? \"12 AM\" : hour + \" AM\");\r\n            }\r\n        });\r\n    }\r\n    /**\r\n     * Get events that were added by tapping on empty view.\r\n     * @param year The year currently visible on the week view.\r\n     * @param month The month currently visible on the week view.\r\n     * @return The events of the given year and month.\r\n     */\r\n    private ArrayList<WeekViewEvent> getNewEvents(int year, int month) {\r\n\r\n        // Get the starting point and ending point of the given month. We need this to find the\r\n        // events of the given month.\r\n        Calendar startOfMonth = Calendar.getInstance();\r\n        startOfMonth.set(Calendar.YEAR, year);\r\n        startOfMonth.set(Calendar.MONTH, month - 1);\r\n        startOfMonth.set(Calendar.DAY_OF_MONTH, 1);\r\n        startOfMonth.set(Calendar.HOUR_OF_DAY, 0);\r\n        startOfMonth.set(Calendar.MINUTE, 0);\r\n        startOfMonth.set(Calendar.SECOND, 0);\r\n        startOfMonth.set(Calendar.MILLISECOND, 0);\r\n        Calendar endOfMonth = (Calendar) startOfMonth.clone();\r\n        endOfMonth.set(Calendar.DAY_OF_MONTH, endOfMonth.getMaximum(Calendar.DAY_OF_MONTH));\r\n        endOfMonth.set(Calendar.HOUR_OF_DAY, 23);\r\n        endOfMonth.set(Calendar.MINUTE, 59);\r\n        endOfMonth.set(Calendar.SECOND, 59);\r\n\r\n        // Find the events that were added by tapping on empty view and that occurs in the given\r\n        // time frame.\r\n        ArrayList<WeekViewEvent> events = new ArrayList<WeekViewEvent>();\r\n        for (WeekViewEvent event : mNewEvents) {\r\n            if (event.getEndTime().getTimeInMillis() > startOfMonth.getTimeInMillis() &&\r\n                    event.getStartTime().getTimeInMillis() < endOfMonth.getTimeInMillis()) {\r\n                events.add(event);\r\n            }\r\n        }\r\n        return events;\r\n    }\r\n\r\n\r\n    @Override\r\n    public void onEventClick(WeekViewEvent event, RectF eventRect) {\r\n        Toast.makeText(getActivity(), \"Clicked \" + event.getName(), Toast.LENGTH_SHORT).show();\r\n        e=event;\r\n        /*this.getmNewEvents().remove(e);\r\n        this.getmWeekView().notifyDatasetChanged();*/\r\n       /* eventName.setText(\"Match\");\r\n        eventPlace.setText(\"parc\");\r\n        eventSchedule.setText(\"20h-22h\");*/\r\n        EventFragment eventFragment= new EventFragment();\r\n        eventFragment.show(getFragmentManager(), \"EventFragment\");\r\n    }\r\n    @Override\r\n    public void onEventLongPress(WeekViewEvent event, RectF eventRect) {\r\n        Toast.makeText(getActivity(), \"Long pressed event: \" + event.getName(), Toast.LENGTH_SHORT).show();\r\n\r\n    }\r\n\r\n    @Override\r\n    public void onEmptyViewLongPress(Calendar time) {\r\n        // Set the new event with duration one hour.\r\n        Calendar endTime = (Calendar) time.clone();\r\n        // nombre random pour l'id de l'évènement\r\n        Random r = new Random();\r\n        int i1 = r.nextInt(200);\r\n        endTime.add(Calendar.HOUR, 1);\r\n\r\n        // Create a new event.\r\n        e = new WeekViewEvent(i1, \"New event\", time, endTime);\r\n        // appelle la fonction qui lance le dialogView pour récupérer les informations sur l'event\r\n        e=addEvent(e);\r\n    }\r\n\r\n    public WeekViewEvent addEvent(WeekViewEvent e){\r\n\r\n\r\n        Calendar_dialog dialog= new Calendar_dialog();\r\n        dialog.show(getFragmentManager(), \"Calendar_dialog\");\r\n\r\n\r\n        return e;\r\n    }\r\n\r\n    public static WeekViewEvent getE() {\r\n        return e;\r\n    }\r\n\r\n    public static WeekView getmWeekView() {\r\n\r\n        return mWeekView;\r\n    }\r\n    public static ArrayList<WeekViewEvent> getmNewEvents() {\r\n        return mNewEvents;\r\n    }\r\n\r\n    public static void setmWeekView(WeekView mWeekView) {\r\n        Cal.mWeekView = mWeekView;\r\n    }\r\n\r\n    public static void setE(WeekViewEvent e) {\r\n        Cal.e = e;\r\n    }\r\n\r\n    public static void setmNewEvents(ArrayList<WeekViewEvent> mNewEvents) {\r\n        Cal.mNewEvents = mNewEvents;\r\n    }\r\n\r\n    public int getIndex() {\r\n        return index;\r\n    }\r\n\r\n\r\n    /**\r\n     * This interface must be implemented by activities that contain this\r\n     * fragment to allow an interaction in this fragment to be communicated\r\n     * to the activity and potentially other fragments contained in that\r\n     * activity.\r\n     * <p/>\r\n     * See the Android Training lesson <a href=\r\n     * \"http://developer.android.com/training/basics/fragments/communicating.html\"\r\n     * >Communicating with Other Fragments</a> for more information.\r\n     */\r\n    public interface OnFragmentInteractionListener {\r\n        // TODO: Update argument type and name\r\n        void onFragmentInteraction(Uri uri);\r\n    }\r\n\r\n\r\n}\r\n```\r\n\r\nThank you for reading me ! \r\nGuillaume"},"comment":{"url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/comments/231844073","html_url":"https://github.com/alamkanak/Android-Week-View/issues/300#issuecomment-231844073","issue_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/300","id":231844073,"user":{"login":"DrewTAJ","id":6066624,"avatar_url":"https://avatars.githubusercontent.com/u/6066624?v=3","gravatar_id":"","url":"https://api.github.com/users/DrewTAJ","html_url":"https://github.com/DrewTAJ","followers_url":"https://api.github.com/users/DrewTAJ/followers","following_url":"https://api.github.com/users/DrewTAJ/following{/other_user}","gists_url":"https://api.github.com/users/DrewTAJ/gists{/gist_id}","starred_url":"https://api.github.com/users/DrewTAJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrewTAJ/subscriptions","organizations_url":"https://api.github.com/users/DrewTAJ/orgs","repos_url":"https://api.github.com/users/DrewTAJ/repos","events_url":"https://api.github.com/users/DrewTAJ/events{/privacy}","received_events_url":"https://api.github.com/users/DrewTAJ/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T19:49:04Z","updated_at":"2016-07-11T19:49:04Z","body":"Unfortunately that too has not worked. I have two class, the first is the [Basic Activity](https://github.com/DrewTAJ/android-week-view-trial/blob/master/BasicActivity.java) class and the second is called [WeekViewActivity](https://github.com/DrewTAJ/android-week-view-trial/blob/master/WeekViewActivity.java) class. The first is the main class that is abstract, the second is implementing the onMontchChangeListener. It is still giving me the  \"java.lang.IllegalStateException: You must provide a MonthChangeListener\" error."}}
{"actor":{"display_login":"DrewTAJ"}}