Skip to content

Commit

Permalink
fix some api and lunar
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghaibin-dev committed Jun 21, 2019
1 parent da27d68 commit 59e5b6e
Show file tree
Hide file tree
Showing 23 changed files with 341 additions and 83 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ You can't think of the calendar can be so elegant!

### Gradle
```
compile 'com.haibin:calendarview:3.6.2'
compile 'com.haibin:calendarview:3.6.3'
```

```
<dependency>
<groupId>com.haibin</groupId>
<artifactId>calendarview</artifactId>
<version>3.6.2</version>
<version>3.6.3</version>
<type>pom</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Android上一个优雅、高度自定义、性能高效的日历控件,完美

### Gradle
```
compile 'com.haibin:calendarview:3.6.2'
compile 'com.haibin:calendarview:3.6.3
```
```
<dependency>
<groupId>com.haibin</groupId>
<artifactId>calendarview</artifactId>
<version>3.6.2</version>
<version>3.6.3</version>
<type>pom</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ dependencies {
//noinspection GradleDependency
compile 'com.github.bumptech.glide:glide:3.7.0'
testCompile 'junit:junit:4.12'
//compile 'com.haibin:calendarview:1.6.2'
compile project(':calendarview')
compile 'com.haibin:calendarview:3.6.3'
//compile project(':calendarview')
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<activity android:name=".pager.ViewPagerActivity" />
<activity android:name=".full.FullActivity" />
<activity android:name=".TestActivity" />
<activity android:name=".CalendarActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.haibin.calendarviewproject;

import android.content.Context;
import android.content.Intent;

import com.haibin.calendarviewproject.base.activity.BaseActivity;

/**
* Only calendar
* Created by haibin on 2019/6/12.
*/

public class CalendarActivity extends BaseActivity {

public static void show(Context context) {
context.startActivity(new Intent(context, CalendarActivity.class));
}

@Override
protected int getLayoutId() {
return R.layout.activity_calendar;
}

@Override
protected void initView() {
setStatusBarDarkMode();
}

@Override
protected void initData() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ public void onClick(View v) {
switch (v.getId()) {
case R.id.ll_flyme:
MeiZuActivity.show(this);
//TestActivity.show(this);
//CalendarActivity.show(this);

break;
case R.id.ll_custom:
CustomActivity.show(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.RelativeLayout;
Expand Down
127 changes: 127 additions & 0 deletions app/src/main/res/layout/activity_calendar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:ignore="RtlHardcoded,RtlSymmetry">

<RelativeLayout
android:id="@+id/rl_tool"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="@color/colorPrimary">

<TextView
android:id="@+id/tv_month_day"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:textColor="#000000"
android:textSize="26sp"
android:textStyle="bold" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/tv_month_day"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="12dp"
tools:ignore="RelativeOverlap">

<TextView
android:id="@+id/tv_year"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:textColor="#000000"
android:textSize="10sp"
tools:ignore="SmallSp" />

<TextView
android:id="@+id/tv_lunar"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:textColor="#000000"
android:textSize="10sp"
tools:ignore="SmallSp" />
</LinearLayout>

<FrameLayout
android:id="@+id/fl_current"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:background="@drawable/bg_ripple">

<ImageView
android:id="@+id/ib_calendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:scaleType="centerInside"
android:src="@mipmap/ic_calendar"
android:tint="#000000" />

<TextView
android:id="@+id/tv_current_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:gravity="center"
android:text="13"
android:textColor="#000000"
android:textSize="12sp"
tools:ignore="HardcodedText" />
</FrameLayout>
</RelativeLayout>


<com.haibin.calendarview.CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
app:calendar_padding="10dp"
app:current_month_lunar_text_color="#CFCFCF"
app:current_month_text_color="#333333"
app:max_year="2020"
app:min_year="2004"
app:month_view="com.haibin.calendarviewproject.custom.CustomMonthView"
app:month_view_show_mode="mode_fix"
app:other_month_lunar_text_color="#e1e1e1"
app:other_month_text_color="#e1e1e1"
app:scheme_text=""
app:scheme_text_color="#333"
app:scheme_theme_color="#128c4b"
app:selected_lunar_text_color="#fff"
app:selected_text_color="#fff"
app:selected_theme_color="#046cea"
app:week_background="#fff"
app:week_start_with="sun"
app:week_text_color="#e1e1e1"
app:week_view="com.haibin.calendarviewproject.custom.CustomWeekView"
app:year_view="com.haibin.calendarviewproject.custom.CustomYearView"
app:year_view_day_text_color="#333333"
app:year_view_day_text_size="7sp"
app:year_view_month_text_color="#ff0000"
app:year_view_month_text_size="20sp"
app:year_view_scheme_color="#f17706"
app:year_view_select_text_color="#fff"
app:year_view_week_height="12dp"
app:year_view_week_text_color="#e1e1e1"
app:year_view_week_text_size="6sp" />
</LinearLayout>
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
android:background="#fff"
android:orientation="vertical"
app:calendar_content_view_id="@+id/nestedScrollView"
app:calendar_show_mode="both_month_week_view"
app:default_status="shrink">
app:calendar_show_mode="both_month_week_view">

<com.haibin.calendarview.CalendarView
android:id="@+id/calendarView"
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.2.0'
//noinspection GradleDependency
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
//noinspection GradleDependency
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions calendarview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdkVersion 14
//noinspection OldTargetApi
targetSdkVersion 23
versionCode 362
versionName "3.6.2"
versionCode 363
versionName "3.6.3"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public void getTermsOffset() throws Exception {

}


/**
* 测试每个月农历有多少天,也可适用于除夕算法
*
* @throws Exception Exception
*/
@Test
public void daysInLunarMonth() throws Exception {
int d = LunarCalendar.daysInLunarMonth(2019,12);
assertEquals(30,d);
}

/**
* 测试每年冬至是具体几日
*
Expand Down
61 changes: 32 additions & 29 deletions calendarview/src/main/java/com/haibin/calendarview/BaseView.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,41 +225,44 @@ private void initPaint(Context context) {
*
* @param delegate delegate
*/
void setup(CalendarViewDelegate delegate) {
final void setup(CalendarViewDelegate delegate) {
this.mDelegate = delegate;
updateStyle();
updateItemHeight();

this.mCurDayTextPaint.setColor(delegate.getCurDayTextColor());
this.mCurDayLunarTextPaint.setColor(delegate.getCurDayLunarTextColor());
this.mCurMonthTextPaint.setColor(delegate.getCurrentMonthTextColor());
this.mOtherMonthTextPaint.setColor(delegate.getOtherMonthTextColor());
this.mCurMonthLunarTextPaint.setColor(delegate.getCurrentMonthLunarTextColor());
this.mSelectedLunarTextPaint.setColor(delegate.getSelectedLunarTextColor());
this.mSelectTextPaint.setColor(delegate.getSelectedTextColor());
this.mOtherMonthLunarTextPaint.setColor(delegate.getOtherMonthLunarTextColor());
this.mSchemeLunarTextPaint.setColor(delegate.getSchemeLunarTextColor());

this.mSchemePaint.setColor(delegate.getSchemeThemeColor());
this.mSchemeTextPaint.setColor(delegate.getSchemeTextColor());

initPaint();
}

this.mCurMonthTextPaint.setTextSize(delegate.getDayTextSize());
this.mOtherMonthTextPaint.setTextSize(delegate.getDayTextSize());
this.mCurDayTextPaint.setTextSize(delegate.getDayTextSize());
this.mSchemeTextPaint.setTextSize(delegate.getDayTextSize());
this.mSelectTextPaint.setTextSize(delegate.getDayTextSize());

this.mCurMonthLunarTextPaint.setTextSize(delegate.getLunarTextSize());
this.mSelectedLunarTextPaint.setTextSize(delegate.getLunarTextSize());
this.mCurDayLunarTextPaint.setTextSize(delegate.getLunarTextSize());
this.mOtherMonthLunarTextPaint.setTextSize(delegate.getLunarTextSize());
this.mSchemeLunarTextPaint.setTextSize(delegate.getLunarTextSize());
final void updateStyle(){
if(mDelegate == null){
return;
}
this.mCurDayTextPaint.setColor(mDelegate.getCurDayTextColor());
this.mCurDayLunarTextPaint.setColor(mDelegate.getCurDayLunarTextColor());
this.mCurMonthTextPaint.setColor(mDelegate.getCurrentMonthTextColor());
this.mOtherMonthTextPaint.setColor(mDelegate.getOtherMonthTextColor());
this.mCurMonthLunarTextPaint.setColor(mDelegate.getCurrentMonthLunarTextColor());
this.mSelectedLunarTextPaint.setColor(mDelegate.getSelectedLunarTextColor());
this.mSelectTextPaint.setColor(mDelegate.getSelectedTextColor());
this.mOtherMonthLunarTextPaint.setColor(mDelegate.getOtherMonthLunarTextColor());
this.mSchemeLunarTextPaint.setColor(mDelegate.getSchemeLunarTextColor());
this.mSchemePaint.setColor(mDelegate.getSchemeThemeColor());
this.mSchemeTextPaint.setColor(mDelegate.getSchemeTextColor());
this.mCurMonthTextPaint.setTextSize(mDelegate.getDayTextSize());
this.mOtherMonthTextPaint.setTextSize(mDelegate.getDayTextSize());
this.mCurDayTextPaint.setTextSize(mDelegate.getDayTextSize());
this.mSchemeTextPaint.setTextSize(mDelegate.getDayTextSize());
this.mSelectTextPaint.setTextSize(mDelegate.getDayTextSize());

this.mCurMonthLunarTextPaint.setTextSize(mDelegate.getLunarTextSize());
this.mSelectedLunarTextPaint.setTextSize(mDelegate.getLunarTextSize());
this.mCurDayLunarTextPaint.setTextSize(mDelegate.getLunarTextSize());
this.mOtherMonthLunarTextPaint.setTextSize(mDelegate.getLunarTextSize());
this.mSchemeLunarTextPaint.setTextSize(mDelegate.getLunarTextSize());

this.mSelectedPaint.setStyle(Paint.Style.FILL);
this.mSelectedPaint.setColor(delegate.getSelectedThemeColor());

updateItemHeight();

initPaint();
this.mSelectedPaint.setColor(mDelegate.getSelectedThemeColor());
}

void updateItemHeight() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ public boolean onTouchEvent(MotionEvent event) {
mDelegate.mViewChangeListener.onViewChange(false);
}
isWeekView = true;
//shrink(0);
return false;
}
hideWeek(false);
Expand Down
Loading

0 comments on commit 59e5b6e

Please sign in to comment.