فهرست منبع

1.添加日历module

王鹏鹏 2 سال پیش
والد
کامیت
3f926ee4a5

+ 1 - 1
.idea/compiler.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="CompilerConfiguration">
-    <bytecodeTargetLevel target="11" />
+    <bytecodeTargetLevel target="1.8" />
   </component>
 </project>

+ 2 - 0
.idea/gradle.xml

@@ -7,11 +7,13 @@
         <option name="testRunner" value="GRADLE" />
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="gradleJvm" value="corretto-1.8" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/app" />
             <option value="$PROJECT_DIR$/baselib" />
+            <option value="$PROJECT_DIR$/calendar" />
             <option value="$PROJECT_DIR$/common" />
             <option value="$PROJECT_DIR$/home" />
             <option value="$PROJECT_DIR$/livebroadcast" />

+ 3 - 2
.idea/misc.xml

@@ -27,6 +27,7 @@
         <entry key="..\:/workspace/hcp-pad/baselib/src/main/res/layout/fragment_task.xml" value="0.152" />
         <entry key="..\:/workspace/hcp-pad/baselib/src/main/res/layout/layout_center_toast.xml" value="0.1" />
         <entry key="..\:/workspace/hcp-pad/baselib/src/main/res/layout/rv_empty.xml" value="0.1" />
+        <entry key="..\:/workspace/hcp-pad/calendar/src/main/res/layout/cbk_list_item_calendar.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/calendarview/src/main/res/drawable-v21/cv_bg_material.xml" value="0.219" />
         <entry key="..\:/workspace/hcp-pad/calendarview/src/main/res/layout/cv_layout_calendar_view.xml" value="0.1" />
         <entry key="..\:/workspace/hcp-pad/calendarview/src/main/res/layout/cv_week_bar.xml" value="0.1" />
@@ -172,7 +173,7 @@
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/dialog_purchase_services.xml" value="0.2962239583333333" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/dialog_tips.xml" value="0.136" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/fragment_brain_ability.xml" value="0.21014492753623187" />
-        <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/fragment_data_monitor.xml" value="0.2" />
+        <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/fragment_data_monitor.xml" value="0.4" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/fragment_free_training.xml" value="0.21014492753623187" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/fragment_task.xml" value="0.4" />
         <entry key="..\:/workspace/hcp-pad/workbenches/src/main/res/layout/fragment_train_content.xml" value="0.33808844507845937" />
@@ -283,7 +284,7 @@
     <option name="priority" value="Medium" />
     <option name="excludeFilter" value="" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">

+ 1 - 0
calendar/.gitignore

@@ -0,0 +1 @@
+/build

+ 25 - 0
calendar/build.gradle

@@ -0,0 +1,25 @@
+apply from: "../module.build.gradle"
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-kapt'
+
+android {
+    defaultConfig {
+        // 如果是独立模块,则使用当前组件的包名
+        if (singleModule.toBoolean()) {
+            applicationId "com.yingyangfly.calendar"
+        }
+    }
+    // 统一资源前缀,规范资源引用
+    resourcePrefix "calendar"
+}
+
+dependencies {
+    implementation project(path: ':baselib')
+    api fileTree(exclude: '*.bak', dir: 'libs')
+    implementation(rootProject.ext.androidx.kotlin_lib)
+    implementation(rootProject.ext.androidx.kotlin_core)
+    implementation(rootProject.ext.androidx.appcompat)
+    implementation(rootProject.ext.androidx.material)
+    implementation(rootProject.ext.androidx.constraintlayout)
+
+}

+ 21 - 0
calendar/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 6 - 0
calendar/src/main/AndroidManifest.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="com.yingyangfly.calendar">
+
+    <application />
+
+</manifest>

+ 14 - 0
calendar/src/main/java/com/yingyangfly/calendar/CaledarAdapter.java

@@ -0,0 +1,14 @@
+package com.yingyangfly.calendar;
+
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * Created by codbking on 2016/12/22.
+ * email:codbking@gmail.com
+ * github:https://github.com/codbking
+ * blog:http://www.jianshu.com/users/49d47538a2dd/latest_articles
+ */
+public interface CaledarAdapter {
+    View getView(View convertView, ViewGroup parentView, CalendarBean bean);
+}

+ 11 - 0
calendar/src/main/java/com/yingyangfly/calendar/CaledarTopViewChangeListener.java

@@ -0,0 +1,11 @@
+package com.yingyangfly.calendar;
+
+/**
+ * Created by codbking on 2016/12/23.
+ * email:codbking@gmail.com
+ * github:https://github.com/codbking
+ * blog:http://www.jianshu.com/users/49d47538a2dd/latest_articles
+ */
+public interface CaledarTopViewChangeListener {
+    void onLayoutChange(CalendarTopView topView);
+}

+ 58 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarBean.java

@@ -0,0 +1,58 @@
+package com.yingyangfly.calendar;
+
+public class CalendarBean {
+
+    public int year;
+    public int moth;
+    public int day;
+    public int week;
+
+    //-1,0,1
+    public int mothFlag;
+
+    //显示
+    public String chinaMonth;
+    public String chinaDay;
+
+    public CalendarBean(int year, int moth, int day) {
+        this.year = year;
+        this.moth = moth;
+        this.day = day;
+    }
+
+    public String getDisplayWeek() {
+        String s = "";
+        switch (week) {
+            case 1:
+                s = "星期日";
+                break;
+            case 2:
+                s = "星期一";
+                break;
+            case 3:
+                s = "星期二";
+                break;
+            case 4:
+                s = "星期三";
+                break;
+            case 5:
+                s = "星期四";
+                break;
+            case 6:
+                s = "星期五";
+                break;
+            case 7:
+                s = "星期六";
+                break;
+
+        }
+        return s;
+    }
+
+    @Override
+    public String toString() {
+//        String s=year+"/"+moth+"/"+day+"\t"+getDisplayWeek()+"\t农历"+":"+chinaMonth+"/"+chinaDay;
+        String s = year + "/" + moth + "/" + day;
+        return s;
+    }
+}

+ 157 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarDateView.java

@@ -0,0 +1,157 @@
+package com.yingyangfly.calendar;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.viewpager.widget.PagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+
+/**
+ * Created by codbking on 2016/12/18.
+ * email:codbking@gmail.com
+ * github:https://github.com/codbking
+ * blog:http://www.jianshu.com/users/49d47538a2dd/latest_articles
+ */
+public class CalendarDateView extends ViewPager implements CalendarTopView {
+
+    HashMap<Integer, CalendarView> views = new HashMap<>();
+    private CaledarTopViewChangeListener mCaledarLayoutChangeListener;
+    private CalendarView.OnItemClickListener onItemClickListener;
+
+    private LinkedList<CalendarView> cache = new LinkedList();
+
+    private int MAXCOUNT = 6;
+
+
+    private int row = 6;
+
+    private CaledarAdapter mAdapter;
+    private int calendarItemHeight = 0;
+
+    public void setAdapter(CaledarAdapter adapter) {
+        mAdapter = adapter;
+        initData();
+    }
+
+    public void setOnItemClickListener(CalendarView.OnItemClickListener onItemClickListener) {
+        this.onItemClickListener = onItemClickListener;
+    }
+
+    public CalendarDateView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CalendarDateView);
+        row = a.getInteger(R.styleable.CalendarDateView_cbd_calendar_row, 6);
+        a.recycle();
+        init();
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        int calendarHeight = 0;
+        if (getAdapter() != null) {
+            CalendarView view = (CalendarView) getChildAt(0);
+            if (view != null) {
+                calendarHeight = view.getMeasuredHeight();
+                calendarItemHeight = view.getItemHeight();
+            }
+        }
+        setMeasuredDimension(widthMeasureSpec, MeasureSpec.makeMeasureSpec(calendarHeight, MeasureSpec.EXACTLY));
+    }
+
+    private void init() {
+        final int[] dateArr = CalendarUtil.getYMD(new Date());
+        setAdapter(new PagerAdapter() {
+            @Override
+            public int getCount() {
+                return Integer.MAX_VALUE;
+            }
+
+            @Override
+            public boolean isViewFromObject(View view, Object object) {
+                return view == object;
+            }
+
+            @Override
+            public Object instantiateItem(ViewGroup container, final int position) {
+
+                CalendarView view;
+
+                if (!cache.isEmpty()) {
+                    view = cache.removeFirst();
+                } else {
+                    view = new CalendarView(container.getContext(), row);
+                }
+
+                view.setOnItemClickListener(onItemClickListener);
+                view.setAdapter(mAdapter);
+
+                view.setData(CalendarFactory.getMonthOfDayList(dateArr[0], dateArr[1] + position - Integer.MAX_VALUE / 2), position == Integer.MAX_VALUE / 2);
+                container.addView(view);
+                views.put(position, view);
+
+                return view;
+            }
+
+            @Override
+            public void destroyItem(ViewGroup container, int position, Object object) {
+                container.removeView((View) object);
+                cache.addLast((CalendarView) object);
+                views.remove(position);
+            }
+        });
+
+        addOnPageChangeListener(new SimpleOnPageChangeListener() {
+            @Override
+            public void onPageSelected(int position) {
+                super.onPageSelected(position);
+
+                if (onItemClickListener != null) {
+                    CalendarView view = views.get(position);
+                    Object[] obs = view.getSelect();
+                    onItemClickListener.onItemClick((View) obs[0], (int) obs[1], (CalendarBean) obs[2]);
+                }
+
+                mCaledarLayoutChangeListener.onLayoutChange(CalendarDateView.this);
+            }
+        });
+    }
+
+
+    private void initData() {
+        setCurrentItem(Integer.MAX_VALUE / 2, false);
+        getAdapter().notifyDataSetChanged();
+
+    }
+
+    @Override
+    public int[] getCurrentSelectPositon() {
+        CalendarView view = views.get(getCurrentItem());
+        if (view == null) {
+            view = (CalendarView) getChildAt(0);
+        }
+        if (view != null) {
+            return view.getSelectPostion();
+        }
+        return new int[4];
+    }
+
+    @Override
+    public int getItemHeight() {
+        return calendarItemHeight;
+    }
+
+    @Override
+    public void setCaledarTopViewChangeListener(CaledarTopViewChangeListener listener) {
+        mCaledarLayoutChangeListener = listener;
+    }
+
+
+}

+ 86 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarFactory.java

@@ -0,0 +1,86 @@
+package com.yingyangfly.calendar;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+
+import static android.R.attr.listDivider;
+import static android.R.attr.max;
+import static android.R.attr.y;
+import static android.R.id.list;
+
+
+/**
+ * Created by codbking on 2016/12/16.
+ */
+
+public class CalendarFactory {
+
+    private static HashMap<String, List<CalendarBean>> cache = new HashMap<>();
+
+    //获取一月中的集合
+    public static List<CalendarBean> getMonthOfDayList(int y, int m) {
+
+        String key=y+""+m;
+        if(cache.containsKey(key)){
+            List<CalendarBean> list=cache.get(key);
+            if(list==null){
+                cache.remove(key);
+            }else{
+                return list;
+            }
+        }
+
+        List<CalendarBean> list = new ArrayList<CalendarBean>();
+        cache.put(key,list);
+
+        //计算出一月第一天是星期几
+        int fweek = CalendarUtil.getDayOfWeek(y, m, 1);
+        int total = CalendarUtil.getDayOfMaonth(y, m);
+
+        //根据星期推出前面还有几个显示
+        for (int i = fweek - 1; i > 0; i--) {
+            CalendarBean bean = geCalendarBean(y, m, 1 - i);
+            bean.mothFlag = -1;
+            list.add(bean);
+        }
+
+        //获取当月的天数
+        for (int i = 0; i < total; i++) {
+            CalendarBean bean = geCalendarBean(y, m, i + 1);
+            list.add(bean);
+        }
+
+        //为了塞满42个格子,显示多出当月的天数
+        for (int i = 0; i < 42 - (fweek - 1) - total; i++) {
+            CalendarBean bean = geCalendarBean(y, m, total + i + 1);
+            bean.mothFlag = 1;
+            list.add(bean);
+        }
+        return list;
+    }
+
+
+    public static CalendarBean geCalendarBean(int year, int month, int day) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(year, month - 1, day);
+        year = calendar.get(Calendar.YEAR);
+        month = calendar.get(Calendar.MONTH) + 1;
+        day = calendar.get(Calendar.DATE);
+
+        CalendarBean bean = new CalendarBean(year, month, day);
+        bean.week = CalendarUtil.getDayOfWeek(year, month, day);
+        String[] chinaDate = ChinaDate.getChinaDate(year, month, day);
+        bean.chinaMonth = chinaDate[0];
+        bean.chinaDay = chinaDate[1];
+
+        return bean;
+    }
+
+    public static void main(String[] args) {
+    }
+
+
+}

+ 379 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarLayout.java

@@ -0,0 +1,379 @@
+package com.yingyangfly.calendar;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.VelocityTracker;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import android.view.animation.Interpolator;
+import android.widget.AbsListView;
+import android.widget.FrameLayout;
+import android.widget.ListView;
+
+import androidx.core.view.VelocityTrackerCompat;
+import androidx.core.view.ViewCompat;
+import androidx.core.widget.ScrollerCompat;
+
+/**
+ * Created by codbking on 2016/12/18.
+ * email:codbking@gmail.com
+ * github:https://github.com/codbking
+ * blog:http://www.jianshu.com/users/49d47538a2dd/latest_articles
+ */
+
+public class CalendarLayout extends FrameLayout {
+
+    private static final String TAG = "CalendarLayout";
+
+    private View view1;
+    private ViewGroup view2;
+    private CalendarTopView mTopView;
+    //展开
+    public static final int TYPE_OPEN = 0;
+    //折叠
+    public static final int TYPE_FOLD = 1;
+    public int type = TYPE_FOLD;
+
+    //是否处于滑动中
+    private boolean isSilde = false;
+
+    private int topHeigth;
+    private int itemHeight;
+    private int bottomViewTopHeight;
+    private int maxDistance;
+
+    private ScrollerCompat mScroller;
+    private float mMaxVelocity;
+    private float mMinVelocity;
+    private int activitPotionerId;
+
+    private static final Interpolator sInterpolator = new Interpolator() {
+        @Override
+        public float getInterpolation(float t) {
+            t -= 1.0f;
+            return t * t * t * t * t + 1.0f;
+        }
+    };
+
+    public CalendarLayout(Context context) {
+        super(context);
+        init();
+    }
+
+    public CalendarLayout(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init();
+    }
+
+    @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+
+        final CalendarTopView viewPager = (CalendarTopView) getChildAt(0);
+
+        mTopView = viewPager;
+        view1 = (View) viewPager;
+        view2 = (ViewGroup) getChildAt(1);
+
+        mTopView.setCaledarTopViewChangeListener(new CaledarTopViewChangeListener() {
+            @Override
+            public void onLayoutChange(CalendarTopView topView) {
+                CalendarLayout.this.requestLayout();
+            }
+        });
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+        itemHeight=mTopView.getItemHeight();
+        topHeigth=view1.getMeasuredHeight();
+        maxDistance = topHeigth - itemHeight;
+
+        switch (type) {
+            case TYPE_FOLD:
+                bottomViewTopHeight = itemHeight;
+                break;
+            case TYPE_OPEN:
+                bottomViewTopHeight = topHeigth;
+                break;
+        }
+        view2.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec) - mTopView.getItemHeight(), MeasureSpec.EXACTLY));
+    }
+
+    @Override
+    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+        super.onLayout(changed, left, top, right, bottom);
+        view2.offsetTopAndBottom(bottomViewTopHeight);
+        int [] selectRct=getSelectRect();
+        if(type==TYPE_FOLD){
+            view1.offsetTopAndBottom(-selectRct[1]);
+        }
+    }
+
+    private void init() {
+
+        final ViewConfiguration vc = ViewConfiguration.get(getContext());
+
+        mMaxVelocity = vc.getScaledMaximumFlingVelocity();
+        mMinVelocity = vc.getScaledMinimumFlingVelocity();
+        mScroller = ScrollerCompat.create(getContext(), sInterpolator);
+    }
+
+    float oy, ox;
+    boolean isClickBtottomView = false;
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+//        mViewDragHelper.shouldInterceptTouchEvent(ev);
+        boolean isflag = false;
+
+        //上下运动进行拦截
+        switch (ev.getAction()) {
+            case MotionEvent.ACTION_DOWN:
+                oy = ev.getY();
+                ox = ev.getX();
+                isClickBtottomView = isClickView(view2, ev);
+                cancel();
+                activitPotionerId = ev.getPointerId(0);
+
+                int top = view2.getTop();
+
+                if (top < topHeigth) {
+                    type = TYPE_FOLD;
+                } else {
+                    type = TYPE_OPEN;
+                }
+                break;
+            case MotionEvent.ACTION_MOVE:
+                float y = ev.getY();
+                float x = ev.getX();
+
+                float xdiff = x - ox;
+                float ydiff = y - oy;
+
+                if (Math.abs(ydiff) > 5 && Math.abs(ydiff) > Math.abs(xdiff)) {
+                    isflag = true;
+
+                    if (isClickBtottomView) {
+                        boolean isScroll = isScroll(view2);
+                        if (ydiff > 0) {
+                            //向下
+                            if (type == TYPE_OPEN) {
+                                return super.onInterceptTouchEvent(ev);
+                            } else {
+                                if (isScroll) {
+                                    return super.onInterceptTouchEvent(ev);
+                                }
+
+                            }
+                        } else {
+                            //向上
+                            if (type == TYPE_FOLD) {
+                                return super.onInterceptTouchEvent(ev);
+                            } else {
+                                if (isScroll) {
+                                    return super.onInterceptTouchEvent(ev);
+                                }
+                            }
+                        }
+
+                    }
+                }
+                ox = x;
+                oy = y;
+                break;
+            case MotionEvent.ACTION_UP:
+
+                break;
+        }
+        return isSilde || isflag || super.onInterceptTouchEvent(ev);
+    }
+
+    private boolean isScroll(ViewGroup view2) {
+        View fistChildView = view2.getChildAt(0);
+        if (fistChildView == null) {
+            return false;
+        }
+
+        if (view2 instanceof ListView) {
+            AbsListView list = (AbsListView) view2;
+            if (fistChildView.getTop() != 0) {
+                return true;
+            } else {
+                if (list.getPositionForView(fistChildView) != 0) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+
+    public boolean isClickView(View view, MotionEvent ev) {
+        Rect rect = new Rect();
+        view.getHitRect(rect);
+        boolean isClick = rect.contains((int) ev.getX(), (int) ev.getY());
+        Log.d(TAG, "isClickView() called with: isClick = [" + isClick + "]");
+        return isClick;
+    }
+
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        processTouchEvent(event);
+        return true;
+    }
+
+    private VelocityTracker mVelocityTracker;
+
+
+    public void processTouchEvent(MotionEvent event) {
+
+        if (mVelocityTracker == null) {
+            mVelocityTracker = VelocityTracker.obtain();
+        }
+        mVelocityTracker.addMovement(event);
+
+        switch (event.getAction()) {
+            case MotionEvent.ACTION_DOWN:
+                break;
+            case MotionEvent.ACTION_MOVE:
+                if (isSilde) {
+                    return;
+                }
+                float cy = event.getY();
+                int dy = (int) (cy - oy);
+
+                if (dy == 0) {
+                    return;
+                }
+                oy = cy;
+                move(dy);
+
+                break;
+            case MotionEvent.ACTION_UP:
+
+                if (isSilde) {
+                    cancel();
+                    return;
+                }
+
+                //判断速度
+                final int pointerId = activitPotionerId;
+                mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
+                float crrentV = VelocityTrackerCompat.getYVelocity(mVelocityTracker, pointerId);
+
+                if (Math.abs(crrentV) > 2000) {
+                    if (crrentV > 0) {
+                        open();
+                    } else {
+                        flod();
+                    }
+                    cancel();
+                    return;
+                }
+
+                int top = view2.getTop() - topHeigth;
+                int maxd = maxDistance;
+
+
+                if (Math.abs(top) < maxd / 2) {
+                    open();
+                } else {
+                    flod();
+                }
+                cancel();
+
+                break;
+            case MotionEvent.ACTION_CANCEL:
+                cancel();
+                break;
+        }
+    }
+
+    public void open() {
+        startScroll(view2.getTop(), topHeigth);
+    }
+
+    public void flod() {
+        startScroll(view2.getTop(), topHeigth - maxDistance);
+    }
+
+    private int[] getSelectRect() {
+        return mTopView.getCurrentSelectPositon();
+    }
+
+    private void move(int dy) {
+
+        int []selectRect = getSelectRect();
+        int itemHeight=mTopView.getItemHeight();
+
+        int dy1 = getAreaValue(view1.getTop(), dy, -selectRect[1], 0);
+        int dy2 = getAreaValue(view2.getTop() - topHeigth, dy, -(topHeigth - itemHeight), 0);
+
+        if (dy1 != 0) {
+            ViewCompat.offsetTopAndBottom(view1, dy1);
+        }
+
+        if (dy2 != 0) {
+            ViewCompat.offsetTopAndBottom(view2, dy2);
+        }
+
+    }
+
+    private int getAreaValue(int top, int dy, int minValue, int maxValue) {
+
+        if (top + dy < minValue) {
+            return minValue - top;
+        }
+
+        if (top + dy > maxValue) {
+            return maxValue - top;
+        }
+        return dy;
+    }
+
+    private void startScroll(int starty, int endY) {
+
+        float distance = endY - starty;
+        float t = distance / maxDistance * 600;
+
+        mScroller.startScroll(0, 0, 0, endY - starty, (int) Math.abs(t));
+        postInvalidate();
+    }
+
+    int oldY = 0;
+
+    @Override
+    public void computeScroll() {
+        super.computeScroll();
+
+        bottomViewTopHeight = view2.getTop();
+        if (mScroller.computeScrollOffset()) {
+            isSilde = true;
+            int cy = mScroller.getCurrY();
+            int dy = cy - oldY;
+            move(dy);
+            oldY = cy;
+            postInvalidate();
+        } else {
+            oldY = 0;
+            isSilde = false;
+        }
+    }
+
+    public void cancel() {
+        if (mVelocityTracker != null) {
+            mVelocityTracker.recycle();
+            mVelocityTracker = null;
+        }
+    }
+
+}

+ 18 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarTopView.java

@@ -0,0 +1,18 @@
+package com.yingyangfly.calendar;
+
+/**
+ * Created by codbking on 2016/12/23.
+ * email:codbking@gmail.com
+ * github:https://github.com/codbking
+ * blog:http://www.jianshu.com/users/49d47538a2dd/latest_articles
+ */
+
+public interface CalendarTopView {
+
+    int[] getCurrentSelectPositon();
+
+    int getItemHeight();
+
+    void setCaledarTopViewChangeListener(CaledarTopViewChangeListener listener);
+
+}

+ 41 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarUtil.java

@@ -0,0 +1,41 @@
+package com.yingyangfly.calendar;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ *
+ * Created by codbking on 2016/6/1.
+ *
+ */
+public class CalendarUtil {
+
+    //获取一月的第一天是星期几
+    public static int getDayOfWeek(int y, int m, int day) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(y, m - 1, day);
+        return calendar.get(Calendar.DAY_OF_WEEK);
+    }
+
+    //获取一月最大天数
+    public static int getDayOfMaonth(int y, int m) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(y, m - 1, 1);
+        int dateOfMonth = cal.getActualMaximum(Calendar.DATE);
+        return dateOfMonth;
+    }
+
+    public static int getMothOfMonth(int y, int m) {
+        Calendar cal = Calendar.getInstance();
+        cal.set(y, m - 1, 1);
+        int dateOfMonth = cal.get(Calendar.MONTH);
+        return dateOfMonth + 1;
+    }
+
+    public static int[] getYMD(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        return new int[]{cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DATE)};
+    }
+
+}

+ 188 - 0
calendar/src/main/java/com/yingyangfly/calendar/CalendarView.java

@@ -0,0 +1,188 @@
+package com.yingyangfly.calendar;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by codbking on 2016/12/18.
+ * email:codbking@gmail.com
+ * github:https://github.com/codbking
+ * blog:http://www.jianshu.com/users/49d47538a2dd/latest_articles
+ */
+public class CalendarView extends ViewGroup {
+
+    private static final String TAG = "CalendarView";
+
+    private int selectPostion = -1;
+
+    private CaledarAdapter adapter;
+    private List<CalendarBean> data;
+    private OnItemClickListener onItemClickListener;
+
+    private int row = 6;
+    private int column = 7;
+    private int itemWidth;
+    private int itemHeight;
+
+    private boolean isToday;
+
+    public interface OnItemClickListener {
+        void onItemClick(View view, int postion, CalendarBean bean);
+    }
+
+    public CalendarView(Context context, int row) {
+        super(context);
+        this.row = row;
+    }
+
+    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
+        this.onItemClickListener = onItemClickListener;
+    }
+
+    public int getItemHeight() {
+        return itemHeight;
+    }
+
+    public CalendarView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        setWillNotDraw(false);
+    }
+
+    public void setAdapter(CaledarAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    public void setData(List<CalendarBean> data,boolean isToday) {
+        this.data = data;
+        this.isToday=isToday;
+        setItem();
+        requestLayout();
+    }
+
+    private void setItem() {
+
+        selectPostion = -1;
+        if (adapter == null) {
+            throw new RuntimeException("adapter is null,please setadapter");
+        }
+
+        for (int i = 0; i < data.size(); i++) {
+            CalendarBean bean = data.get(i);
+            View view = getChildAt(i);
+            View chidView = adapter.getView(view, this, bean);
+
+            if (view == null || view != chidView) {
+                addViewInLayout(chidView, i, chidView.getLayoutParams(), true);
+            }
+
+            if(isToday&&selectPostion==-1){
+                int[]date=CalendarUtil.getYMD(new Date());
+                if(bean.year==date[0]&&bean.moth==date[1]&&bean.day==date[2]){
+                     selectPostion=i;
+                }
+            }else {
+                if (selectPostion == -1 && bean.day == 1) {
+                    selectPostion = i;
+                }
+            }
+
+            chidView.setSelected(selectPostion==i);
+
+            setItemClick(chidView, i, bean);
+
+        }
+    }
+
+    public Object[] getSelect(){
+         return new Object[]{getChildAt(selectPostion),selectPostion,data.get(selectPostion)};
+    }
+
+    public void setItemClick(final View view, final int potsion, final CalendarBean bean) {
+        view.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                if (selectPostion != -1) {
+                    getChildAt(selectPostion).setSelected(false);
+                    getChildAt(potsion).setSelected(true);
+                }
+                selectPostion = potsion;
+
+                if (onItemClickListener != null) {
+                    onItemClickListener.onItemClick(view, potsion, bean);
+                }
+            }
+        });
+    }
+
+    public int[] getSelectPostion() {
+        Rect rect = new Rect();
+        try {
+            getChildAt(selectPostion).getHitRect(rect);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return new int[]{rect.left, rect.top, rect.right, rect.top};
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+        int parentWidth = MeasureSpec.getSize(MeasureSpec.makeMeasureSpec(widthMeasureSpec, MeasureSpec.EXACTLY));
+
+        itemWidth = parentWidth / column;
+        itemHeight = itemWidth;
+
+        View view = getChildAt(0);
+        if (view == null) {
+            return;
+        }
+        LayoutParams params = view.getLayoutParams();
+        if (params != null && params.height > 0) {
+            itemHeight = params.height;
+        }
+        setMeasuredDimension(parentWidth, itemHeight * row);
+
+
+        for(int i=0;i<getChildCount();i++){
+            View childView=getChildAt(i);
+            childView.measure(MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemHeight, MeasureSpec.EXACTLY));
+        }
+
+        Log.i(TAG, "onMeasure() called with: itemHeight = [" + itemHeight + "], itemWidth = [" + itemWidth + "]");
+    }
+
+    @Override
+    protected void onLayout(boolean changed, int l, int t, int r, int b) {
+        for (int i = 0; i <getChildCount(); i++) {
+            layoutChild(getChildAt(i), i, l, t, r, b);
+        }
+    }
+
+    private void layoutChild(View view, int postion, int l, int t, int r, int b) {
+
+        int cc = postion % column;
+        int cr = postion / column;
+
+        int itemWidth = view.getMeasuredWidth();
+        int itemHeight = view.getMeasuredHeight();
+
+        l = cc * itemWidth;
+        t = cr * itemHeight;
+        r = l + itemWidth;
+        b = t + itemHeight;
+        view.layout(l, t, r, b);
+
+    }
+}

+ 437 - 0
calendar/src/main/java/com/yingyangfly/calendar/ChinaDate.java

@@ -0,0 +1,437 @@
+package com.yingyangfly.calendar;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import static android.media.CamcorderProfile.get;
+
+
+public class ChinaDate {
+
+    private static SimpleDateFormat sdf = new SimpleDateFormat(
+            "yyyy年M月d日 EEEEE");
+
+    private final static long[] lunarInfo = new long[]{0x04bd8, 0x04ae0,
+            0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0,
+            0x055d2, 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540,
+            0x0d6a0, 0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5,
+            0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
+            0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3,
+            0x092e0, 0x1c8d7, 0x0c950, 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0,
+            0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, 0x06ca0,
+            0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8,
+            0x0e950, 0x06aa0, 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570,
+            0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, 0x096d0, 0x04dd5,
+            0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0,
+            0x195a6, 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50,
+            0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5, 0x04970, 0x064b0,
+            0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
+            0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7,
+            0x025d0, 0x092d0, 0x0cab5, 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50,
+            0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954,
+            0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260,
+            0x0ea65, 0x0d530, 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0,
+            0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, 0x056d0,
+            0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20,
+            0x0ada0};
+
+    final private static int[] year20 = new int[]{1, 4, 1, 2, 1, 2, 1, 1, 2,
+            1, 2, 1};
+    final private static int[] year19 = new int[]{0, 3, 0, 1, 0, 1, 0, 0, 1,
+            0, 1, 0};
+    final private static int[] year2000 = new int[]{0, 3, 1, 2, 1, 2, 1, 1,
+            2, 1, 2, 1};
+    public final static String[] nStr1 = new String[]{"", "正", "二", "三", "四",
+            "五", "六", "七", "八", "九", "十", "冬月", "腊月"};
+    private final static String[] Gan = new String[]{"甲", "乙", "丙", "丁", "戊",
+            "己", "庚", "辛", "壬", "癸"};
+    private final static String[] Zhi = new String[]{"子", "丑", "寅", "卯", "辰",
+            "巳", "午", "未", "申", "酉", "戌", "亥"};
+    private final static String[] Animals = new String[]{"鼠", "牛", "虎", "兔",
+            "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};
+
+    private final static String[] solarTerm = new String[]{"小寒", "大寒", "立春",
+            "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑",
+            "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"};
+
+    private final static String[] sFtv = new String[]{"0101*元旦", "0214 情人节",
+            "0308 妇女节", "0312 植树节", "0315 消费者权益日", "0401 愚人节", "0501 劳动节",
+            "0504 青年节", "0512 护士节", "0601 儿童节", "0701 建党节", "0801 建军节",
+            "0808 父亲节", "0909 mzd逝世纪念", "0910 教师节", "0928 孔子诞辰", "1001*国庆节",
+            "1006 老人节", "1024 联合国日", "1112 孙中山诞辰", "1220 澳门回归", "1225 圣诞节",
+            "1226 mzd诞辰"};
+
+    private final static String[] lFtv = new String[]{"0101*农历春节",
+            "0115 元宵节", "0505 端午节", "0707 七夕情人节", "0815 中秋节", "0909 重阳节",
+            "1208 腊八节", "1224 小年", "0100*除夕"};
+
+
+    /**
+     * 传回农历 y年的总天数
+     *
+     * @param y
+     * @return
+     */
+    final private static int lYearDays(int y) {
+        int i, sum = 348;
+        for (i = 0x8000; i > 0x8; i >>= 1) {
+            if ((lunarInfo[y - 1900] & i) != 0)
+                sum += 1;
+        }
+        return (sum + leapDays(y));
+    }
+
+
+    /**
+     * 传回农历 y年闰月的天数
+     *
+     * @param y
+     * @return
+     */
+    final private static int leapDays(int y) {
+        if (leapMonth(y) != 0) {
+            if ((lunarInfo[y - 1900] & 0x10000) != 0)
+                return 30;
+            else
+                return 29;
+        } else
+            return 0;
+    }
+
+
+    /**
+     * 传回农历 y年闰哪个月 1-12 , 没闰传回 0
+     *
+     * @param y
+     * @return
+     */
+    final private static int leapMonth(int y) {
+        return (int) (lunarInfo[y - 1900] & 0xf);
+    }
+
+
+    /**
+     * 传回农历 y年m月的总天数
+     *
+     * @param y
+     * @param m
+     * @return
+     */
+    final private static int monthDays(int y, int m) {
+        if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)
+            return 29;
+        else
+            return 30;
+    }
+
+
+    /**
+     * 传回农历 y年的生肖
+     *
+     * @param y
+     * @return
+     */
+    final public static String AnimalsYear(int y) {
+        return Animals[(y - 4) % 12];
+    }
+
+
+    /**
+     * 传入 月日的offset 传回干支,0=甲子
+     *
+     * @param num
+     * @return
+     */
+    final private static String cyclicalm(int num) {
+        return (Gan[num % 10] + Zhi[num % 12]);
+    }
+
+
+    /**
+     * 传入 offset 传回干支, 0=甲子
+     *
+     * @param y
+     * @return
+     */
+    final public static String cyclical(int y) {
+        int num = y - 1900 + 36;
+        return (cyclicalm(num));
+    }
+
+
+    /**
+     * 传出农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6
+     *
+     * @param y
+     * @param m
+     * @return
+     */
+    final private long[] Lunar(int y, int m) {
+        long[] nongDate = new long[7];
+        int i = 0, temp = 0, leap = 0;
+        Date baseDate = new GregorianCalendar(1900 + 1900, 1, 31).getTime();
+        Date objDate = new GregorianCalendar(y + 1900, m, 1).getTime();
+        long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;
+        if (y < 2000)
+            offset += year19[m - 1];
+        if (y > 2000)
+            offset += year20[m - 1];
+        if (y == 2000)
+            offset += year2000[m - 1];
+        nongDate[5] = offset + 40;
+        nongDate[4] = 14;
+        for (i = 1900; i < 2050 && offset > 0; i++) {
+            temp = lYearDays(i);
+            offset -= temp;
+            nongDate[4] += 12;
+        }
+        if (offset < 0) {
+            offset += temp;
+            i--;
+            nongDate[4] -= 12;
+        }
+        nongDate[0] = i;
+        nongDate[3] = i - 1864;
+        leap = leapMonth(i); // 闰哪个月
+        nongDate[6] = 0;
+        for (i = 1; i < 13 && offset > 0; i++) {
+            // 闰月
+            if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) {
+                --i;
+                nongDate[6] = 1;
+                temp = leapDays((int) nongDate[0]);
+            } else {
+                temp = monthDays((int) nongDate[0], i);
+            }
+            // 解除闰月
+            if (nongDate[6] == 1 && i == (leap + 1))
+                nongDate[6] = 0;
+            offset -= temp;
+            if (nongDate[6] == 0)
+                nongDate[4]++;
+        }
+        if (offset == 0 && leap > 0 && i == leap + 1) {
+            if (nongDate[6] == 1) {
+                nongDate[6] = 0;
+            } else {
+                nongDate[6] = 1;
+                --i;
+                --nongDate[4];
+            }
+        }
+        if (offset < 0) {
+            offset += temp;
+            --i;
+            --nongDate[4];
+        }
+        nongDate[1] = i;
+        nongDate[2] = offset + 1;
+        return nongDate;
+    }
+
+
+    /**
+     * 传出y年m月d日对应的农历.year0 .month1 .day2 .yearCyl3 .monCyl4 .dayCyl5 .isLeap6
+     *
+     * @param y
+     * @param m
+     * @param d
+     * @return
+     */
+    final public static long[] calElement(int y, int m, int d) {
+        long[] nongDate = new long[7];
+        int i = 0, temp = 0, leap = 0;
+        Date baseDate = new GregorianCalendar(0 + 1900, 0, 31).getTime();
+        Date objDate = new GregorianCalendar(y, m - 1, d).getTime();
+        long offset = (objDate.getTime() - baseDate.getTime()) / 86400000L;
+        nongDate[5] = offset + 40;
+        nongDate[4] = 14;
+        for (i = 1900; i < 2050 && offset > 0; i++) {
+            temp = lYearDays(i);
+            offset -= temp;
+            nongDate[4] += 12;
+        }
+        if (offset < 0) {
+            offset += temp;
+            i--;
+            nongDate[4] -= 12;
+        }
+        nongDate[0] = i;
+        nongDate[3] = i - 1864;
+        leap = leapMonth(i); // 闰哪个月
+        nongDate[6] = 0;
+        for (i = 1; i < 13 && offset > 0; i++) {
+            // 闰月
+            if (leap > 0 && i == (leap + 1) && nongDate[6] == 0) {
+                --i;
+                nongDate[6] = 1;
+                temp = leapDays((int) nongDate[0]);
+            } else {
+                temp = monthDays((int) nongDate[0], i);
+            }
+            // 解除闰月
+            if (nongDate[6] == 1 && i == (leap + 1))
+                nongDate[6] = 0;
+            offset -= temp;
+            if (nongDate[6] == 0)
+                nongDate[4]++;
+        }
+        if (offset == 0 && leap > 0 && i == leap + 1) {
+            if (nongDate[6] == 1) {
+                nongDate[6] = 0;
+            } else {
+                nongDate[6] = 1;
+                --i;
+                --nongDate[4];
+            }
+        }
+        if (offset < 0) {
+            offset += temp;
+            --i;
+            --nongDate[4];
+        }
+        nongDate[1] = i;
+        nongDate[2] = offset + 1;
+        return nongDate;
+    }
+
+
+    public final static String getChinaDate(int day) {
+        String a = "";
+        if (day == 10)
+            return "初十";
+        if (day == 20)
+            return "二十";
+        if (day == 30)
+            return "三十";
+        int two = (int) ((day) / 10);
+        if (two == 0)
+            a = "初";
+        if (two == 1)
+            a = "十";
+        if (two == 2)
+            a = "廿";
+        if (two == 3)
+            a = "三";
+        int one = (int) (day % 10);
+        switch (one) {
+            case 1:
+                a += "一";
+                break;
+            case 2:
+                a += "二";
+                break;
+            case 3:
+                a += "三";
+                break;
+            case 4:
+                a += "四";
+                break;
+            case 5:
+                a += "五";
+                break;
+            case 6:
+                a += "六";
+                break;
+            case 7:
+                a += "七";
+                break;
+            case 8:
+                a += "八";
+                break;
+            case 9:
+                a += "九";
+                break;
+        }
+        return a;
+    }
+
+
+    public static String today() {
+        Calendar today = Calendar.getInstance(Locale.SIMPLIFIED_CHINESE);
+        int year = today.get(Calendar.YEAR);
+        int month = today.get(Calendar.MONTH) + 1;
+        int date = today.get(Calendar.DATE);
+        long[] l = calElement(year, month, date);
+        StringBuffer sToday = new StringBuffer();
+        try {
+            sToday.append(sdf.format(today.getTime()));
+            sToday.append(" 农历");
+            sToday.append(cyclical(year));
+            sToday.append('(');
+            sToday.append(AnimalsYear(year));
+            sToday.append(")年");
+            sToday.append(nStr1[(int) l[1]]);
+            sToday.append("月");
+            sToday.append(getChinaDate((int) (l[2])));
+            return sToday.toString();
+        } finally {
+            sToday = null;
+        }
+    }
+
+
+    //获取农历的月与日的显示
+    public static String[] getChinaDate(int year, int month, int day) {
+        long[] l = calElement(year, month, day);
+        return new String[]{nStr1[(int) l[1]], getChinaDate((int) (l[2]))};
+    }
+
+
+    public static String oneDay(int year, int month, int day) {
+
+        Calendar today = Calendar.getInstance(Locale.SIMPLIFIED_CHINESE);
+        today.set(year, month - 1, day);
+        long[] l = calElement(year, month, day);
+        StringBuffer sToday = new StringBuffer();
+        try {
+            sToday.append(sdf.format(today.getTime()));
+            sToday.append(" 农历");
+            sToday.append(cyclical(year));
+            sToday.append('(');
+            sToday.append(AnimalsYear(year));
+            sToday.append(")年");
+            sToday.append(nStr1[(int) l[1]]);
+            sToday.append("月");
+            sToday.append(getChinaDate((int) (l[2])));
+            return sToday.toString();
+        } finally {
+            sToday = null;
+        }
+    }
+
+    /**
+     * 农历日历工具使用演示
+     *
+     * @param args
+     */
+    public static void main(String[] args) {
+    }
+
+
+//    //[0-4]、[5-10]
+//    private static int[] getData(int z) {
+//        //判断区间
+//        int j = z / 5;
+//        int[] arr = map.get(j);
+//        if (arr == null) {
+//            arr = new int[5];
+//            map.put(j, arr);
+//            for (int a = 0, b = j * 5; a < 5; a++, b++) {
+//                arr[a] = b;
+//            }
+//        }else {
+//            System.out.println("arr!=null");
+//        }
+//        return arr;
+//
+//
+//    }
+
+
+}

+ 6 - 0
calendar/src/main/manifest/AndroidManifest.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="com.yingyangfly.calendar">
+
+    <application />
+
+</manifest>

+ 20 - 0
calendar/src/main/res/layout/cbk_list_item_calendar.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center"
+    android:orientation="vertical"
+    tools:ignore="ResourceName">
+
+    <TextView
+        android:id="@+id/dateTv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <TextView
+        android:id="@+id/chinaDateTv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>

+ 9 - 0
calendar/src/main/res/values/attr.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:tools="http://schemas.android.com/tools">
+    <attr name="cbd_calendar_row" format="integer" tools:ignore="ResourceName" />
+
+    <declare-styleable name="CalendarDateView">
+        <attr name="cbd_calendar_row" tools:ignore="ResourceName" />
+    </declare-styleable>
+
+</resources>

+ 1 - 0
home/build.gradle

@@ -16,6 +16,7 @@ android {
 
 dependencies {
     implementation project(path: ':baselib')
+    implementation project(path: ':calendar')
     api fileTree(exclude: '*.bak', dir: 'libs')
     implementation(rootProject.ext.androidx.kotlin_lib)
     implementation(rootProject.ext.androidx.kotlin_core)

+ 1 - 0
settings.gradle

@@ -10,3 +10,4 @@ include ':push'
 include ':home'
 include ':superplayerkit'
 include ':common'
+include ':calendar'