{"id":13639031,"url":"https://github.com/Kelin-Hong/CalendarListView","last_synced_at":"2025-04-19T21:35:26.847Z","repository":{"id":72180843,"uuid":"65375706","full_name":"Kelin-Hong/CalendarListView","owner":"Kelin-Hong","description":"A custom ListView combine with CalendarView which interactive each other.","archived":false,"fork":false,"pushed_at":"2017-11-29T07:25:54.000Z","size":11055,"stargazers_count":1069,"open_issues_count":10,"forks_count":198,"subscribers_count":39,"default_branch":"master","last_synced_at":"2024-10-30T05:55:53.787Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kelin-Hong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-08-10T11:04:33.000Z","updated_at":"2024-10-10T06:00:52.000Z","dependencies_parsed_at":"2023-05-31T18:45:33.955Z","dependency_job_id":null,"html_url":"https://github.com/Kelin-Hong/CalendarListView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kelin-Hong%2FCalendarListView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kelin-Hong%2FCalendarListView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kelin-Hong%2FCalendarListView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kelin-Hong%2FCalendarListView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kelin-Hong","download_url":"https://codeload.github.com/Kelin-Hong/CalendarListView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223810238,"owners_count":17206718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:00:56.897Z","updated_at":"2024-11-09T09:30:31.217Z","avatar_url":"https://github.com/Kelin-Hong.png","language":"Java","funding_links":[],"categories":["日历时间"],"sub_categories":[],"readme":"# CalendarListView\n---\nA custom ListView combine with CalendarView which interactive each other. just watch demo to get more detail.\n\n![CalendarListView Demo](art/CalendarViewDemo.gif) \n\n## Demo ##\n\nApk Download:[CalendarListView.apk](art/CalendarListView.apk) \n\n## Download ##\n\n```groovy\n compile 'com.kelin.calendarlistview:library:1.0.1'\n```\n\n\n#### 中文文档：[CalendarListView 日历列表文档](http://www.jianshu.com/p/ca2af05b3a53)\n\n## Usage ##\n\n\n**1、Custom style of your CalendarView (like：add price、tag、icon into your items of CalendarView)**\n```java\n//create a Model extends BaseCalendarItemModel then add your custom field. \npublic class CustomCalendarItemModel  extends BaseCalendarItemModel{     \n   //data count.\n   private int count;\n   private boolean isFav;\n   ...\n   //getXXX \n   //setXXX\n   ...\n}\n//create a custom Adapter extends BaseCalendarItemAdapter\u003cT\u003e (T  extends //BaseCalendarItemModel),then override getView function to custom your \n//calendar item's style. \npublic class CalendarItemAdapter extends BaseCalendarItemAdapter\u003cCustomCalendarItemModel\u003e{\n    //date format:\"yyyy-MM-dd\"\n    @Override\n    public View getView(String date, CustomCalendarItemModel model, View convertView, ViewGroup parent) {\n        // CustomCalendarItemModel model = dayModelList.get(date); is supported.\n        ....\n        ....\n        ViewGroup view = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.custom_calendar_item, null);\n        TextView dayNum = (TextView)  view.findViewById(R.id.day_num);\n        dayNum.setText(model.getDayNumber());\n        ....\n        //get data from model then render your UI.\n        ....\n        ....\n   }\n}\n```\n\n\u003e tips：you can just use BaseCalendarItemAdapter but it is only show date in calendar View.\n\n\n**2、Custom style of your ListView，override getSectionHeaderView and getItemView**\n\n```java\npublic class ListItemAdapter extends BaseCalendarListAdapter\u003cListModel\u003e {\n    //date format:'yyyy-MM-dd'\n    @Override\n    public View getSectionHeaderView(String date, View convertView, ViewGroup parent) {\n       // List\u003cListModel\u003e modelList = dateDataMap.get(date);is supported.\n       .....\n       //custom style of SectionHeader\n       .....\n    }\n   \n    @Override\n    public View getItemView(ListModel model,String date, int pos, View convertView, ViewGroup parent) {\n      //you can get model by follow code. \n      //List\u003cListModel\u003e modelList = dateDataMap.get(date);\n      //model = modelList.get(pos) \n      \n      .....\n      //custom style of List Items\n      .....\n   }\n}\n```\n**3、Initialize CalendarListView and set CalendarItemAdapter and ListItemAdapter**\n```xml\n\u003ccom.kelin.calendarlistview.library.CalendarListView   \n   android:id=\"@+id/calendar_listview\"    \n   android:layout_width=\"match_parent\"    \n   android:layout_height=\"match_parent\"\u003e\n\u003c/com.kelin.calendarlistview.library.CalendarListView\u003e\n```\n \n```java\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n ...\n calendarListView = (CalendarListView) findViewById(R.id.calendar_listview);\n \n listItemAdapter = new ListItemAdapter(this);\n calendarItemAdapter = new CalendarItemAdapter(this);\n\n calendarListView.setCalendarListViewAdapter(calendarItemAdapter, listItemAdapter);\n \n ...\n}\n\n```\n**4、Loading data from server then update DataSet**\n\n- CalendarView \n\n```java\nprivate void onCalendarDataLoadFinish(List\u003cData\u003e datas){\n    ....\n    ....\n    //TreeMap\u003cString, T\u003e，key:'yyyy-MM-dd',value:model of this date.\n    TreeMap\u003cString, CustomCalendarItemModel\u003e dateMap=calendarItemAdapter.getDayModelList();\n    ....\n    CustomCalendarItemModel customCalendarItemModel = dateMap.get(date);\n    //update model\n    customCalendarItemModel.setXXX(data.getXXX());\n    ....\n    calendarItemAdapter.notifyDataSetChanged();\n}\n```\n- ListView\n\n```java\n//key:'yyyy-mm-dd' format date  \nprivate TreeMap\u003cString, List\u003cListModel\u003e\u003e listTreeMap = new TreeMap\u003c\u003e();\n\nprivate void onListDataLoadFinish(List\u003cData\u003e datas){\n   ....\n   ....\n  for（Data item:datas) {\n     String day=item.getDate();\n    //add data\n     if (listTreeMap.get(day) != null) {    \n         List\u003cNewsService.News.StoriesBean\u003e list = listTreeMap.get(day);    \n         list.add(i);\n      } else {    \n         List\u003cNewsService.News.StoriesBean\u003e list = new ArrayList\u003cNewsService.News.StoriesBean\u003e();    \n         list.add(i);   \n         listTreeMap.put(day, list);\n     }\n  }\n ....\n listItemAdapter.setDateDataMap(listTreeMap);\n listItemAdapter.notifyDataSetChanged();\n}\n  ```\n**5、event support**\n- date selected.\n```java\ncalendarListView.setOnCalendarViewItemClickListener(new CalendarListView.OnCalendarViewItemClickListener() {   \n     @Override    \n     public void onDateSelected(View View, String selectedDate, int listSection, SelectedDateRegion selectedDateRegion) {   \n     //do something....\n     }\n});\n```\n- month changed.\n```java\ncalendarListView.setOnMonthChangedListener(new CalendarListView.OnMonthChangedListener() {    \n       @Override    \n       public void onMonthChanged(String yearMonth) {\n       //yearMonth:'yyyy-MM-dd'\n       \n       }\n});\n```\n- refresh and load more.\n```java\ncalendarListView.setOnListPullListener(new CalendarListView.onListPullListener() {    \n    @Override    \n    public void onRefresh() {\n          \n    }    \n    @Override    \n    public void onLoadMore() {\n \n    }\n});\n```\n     \n     \n## License\n   ```\n    Copyright 2016 Kelin Hong\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n       http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n    \n   ``` ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKelin-Hong%2FCalendarListView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKelin-Hong%2FCalendarListView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKelin-Hong%2FCalendarListView/lists"}