{"id":13643459,"url":"https://github.com/myjoybar/android-calendar-view","last_synced_at":"2025-04-21T01:32:44.170Z","repository":{"id":95636652,"uuid":"66253817","full_name":"myjoybar/android-calendar-view","owner":"myjoybar","description":"显示阳历，农历，节假日和二十四节气 实现对某月日期的单选或者多选的andorid 日历控件库。Easy to use, powerful, easy to expand the android calendar view library.","archived":false,"fork":false,"pushed_at":"2019-02-09T05:33:56.000Z","size":1137,"stargazers_count":436,"open_issues_count":4,"forks_count":88,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-09T15:42:42.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/myjoybar.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-22T08:28:14.000Z","updated_at":"2024-11-02T04:46:51.000Z","dependencies_parsed_at":"2023-03-05T16:30:24.300Z","dependency_job_id":null,"html_url":"https://github.com/myjoybar/android-calendar-view","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/myjoybar%2Fandroid-calendar-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myjoybar%2Fandroid-calendar-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myjoybar%2Fandroid-calendar-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myjoybar%2Fandroid-calendar-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myjoybar","download_url":"https://codeload.github.com/myjoybar/android-calendar-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249982641,"owners_count":21355735,"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:01:47.894Z","updated_at":"2025-04-21T01:32:43.126Z","avatar_url":"https://github.com/myjoybar.png","language":"Java","funding_links":[],"categories":["日历时间"],"sub_categories":[],"readme":"# android-calendar-view\nEasy to use, powerful, easy to expand the android calendar view library.\u003cbr /\u003e\n使用方便，易扩展的andorid 日历控件库\n\n ![image](https://github.com/myjoybar/android-calendar-view/blob/master/screenshots/screenshot.gif) \n  \n## Features\n - 日历左右滑动.\n - 显示阳历，农历，节假日和二十四节气\n - 实现对某月日期的单选或者多选.\n\n\n# 使用步骤\n# Gradle Dependency\n####  Add the library to your project build.gradle\n```gradle\n  compile 'com.joybar.calendar:librarycalendar:1.0.6'\n```\n## Sample Usage\n实现OnPageChangeListener和OnDateClickListener接口，如果实现多选，需要实现 OnDateCancelListener\n\n```java\n  public class MainActivity extends AppCompatActivity implements\n        CalendarViewPagerFragment.OnPageChangeListener,\n        CalendarViewFragment.OnDateClickListener,\n        CalendarViewFragment.OnDateCancelListener {\n\n    private TextView tv_date;\n    private boolean isChoiceModelSingle = false;\n    private List\u003cCalendarDate\u003e mListDate = new ArrayList\u003c\u003e();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        tv_date = (TextView) findViewById(R.id.tv_date);\n        initFragment();\n    }\n\n   private void initFragment(){\n       FragmentManager fm = getSupportFragmentManager();\n       FragmentTransaction tx = fm.beginTransaction();\n       // Fragment fragment = new CalendarViewPagerFragment();\n       Fragment fragment = CalendarViewPagerFragment.newInstance(isChoiceModelSingle);\n       tx.replace(R.id.fl_content, fragment);\n       tx.commit();\n   }\n\n\n    @Override\n    public boolean onCreateOptionsMenu(Menu menu) {\n        getMenuInflater().inflate(R.menu.menu_im, menu);\n        return true;\n    }\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n        switch (item.getItemId()) {\n            case R.id.menu_single:\n                isChoiceModelSingle = true;\n                initFragment();\n                break;\n            case R.id.menu_multi:\n                isChoiceModelSingle = false;\n                initFragment();\n                break;\n            default:\n                break;\n        }\n        return true;\n    }\n    @Override\n    public void onDateClick(CalendarDate calendarDate) {\n\n        int year = calendarDate.getSolar().solarYear;\n        int month = calendarDate.getSolar().solarMonth;\n        int day = calendarDate.getSolar().solarDay;\n        if (isChoiceModelSingle) {\n            tv_date.setText(year + \"-\" + month + \"-\" + day);\n        } else {\n            //System.out.println(calendarDate.getSolar().solarDay);\n            mListDate.add(calendarDate);\n            tv_date.setText(listToString(mListDate));\n        }\n\n    }\n\n    @Override\n    public void onDateCancel(CalendarDate calendarDate) {\n        int count = mListDate.size();\n        for (int i = 0; i \u003c count; i++) {\n            CalendarDate date = mListDate.get(i);\n            if (date.getSolar().solarDay == calendarDate.getSolar().solarDay) {\n                mListDate.remove(i);\n                break;\n            }\n        }\n        tv_date.setText(listToString(mListDate));\n    }\n\n    @Override\n    public void onPageChange(int year, int month) {\n        tv_date.setText(year + \"-\" + month);\n        mListDate.clear();\n    }\n\n    private static String listToString(List\u003cCalendarDate\u003e list) {\n        StringBuffer stringBuffer = new StringBuffer();\n        for (CalendarDate date : list) {\n            stringBuffer.append(date.getSolar().solarYear + \"-\" + date.getSolar().solarMonth + \"-\" + date.getSolar().solarDay).append(\" \");\n        }\n        return stringBuffer.toString();\n    }\n\n}\n```\n## 单选或者多选的实现代码\n```java\n        if (isChoiceModelSingle) {\n            mGridView.setChoiceMode(GridView.CHOICE_MODE_SINGLE);\n        } else {\n            mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE);\n        }\n        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {\n            @Override\n            public void onItemClick(AdapterView\u003c?\u003e parent, View view, int position, long id) {\n                CalendarDate calendarDate = ((CalendarGridViewAdapter) mGridView.getAdapter()).getListData().get(position);\n                if (isChoiceModelSingle) {\n                    //单选\n                    if (finalMListDataCalendar.get(position).isInThisMonth()) {\n                        onDateClickListener.onDateClick(calendarDate);\n                    } else {\n                        mGridView.setItemChecked(position, false);\n                    }\n                } else {\n                    //多选\n                    if (finalMListDataCalendar.get(position).isInThisMonth()) {\n                       // mGridView.getCheckedItemIds()\n                        if(!mGridView.isItemChecked(position)){\n                            onDateCancelListener.onDateCancel(calendarDate);\n                        } else {\n                            onDateClickListener.onDateClick(calendarDate);\n                        }\n\n                    } else {\n                        mGridView.setItemChecked(position, false);\n                    }\n\n                }\n            }\n        });\n\n```\n\n\n## License\n\n    Copyright 2016 MyJoybar\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%2Fmyjoybar%2Fandroid-calendar-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyjoybar%2Fandroid-calendar-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyjoybar%2Fandroid-calendar-view/lists"}