Skip to content

Commit

Permalink
自动兼容各时区。
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghaibin-dev committed Feb 27, 2018
1 parent fa7609f commit 098ed50
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Android上一个优雅、高度自定义、性能高效的日历控件,完美

### Gradle
```
compile 'com.haibin:calendarview:3.2.5'
compile 'com.haibin:calendarview:3.2.6'
```
```
<dependency>
<groupId>com.haibin</groupId>
<artifactId>calendarview</artifactId>
<version>3.2.5</version>
<version>3.2.6</version>
<type>pom</type>
</dependency>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -155,7 +154,7 @@ private Calendar getSchemeCalendar(int year, int month, int day, int color, Stri
@SuppressLint("SetTextI18n")
@Override
public void onDateSelected(Calendar calendar, boolean isClick) {
Log.e("onDateSelected", " -- " + calendar.getYear() + " -- " + calendar.getMonth() + " -- " + calendar.getDay());
//Log.e("onDateSelected", " -- " + calendar.getYear() + " -- " + calendar.getMonth() + " -- " + calendar.getDay());
mTextLunar.setVisibility(View.VISIBLE);
mTextYear.setVisibility(View.VISIBLE);
mTextMonthDay.setText(calendar.getMonth() + "月" + calendar.getDay() + "日");
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 15
//noinspection OldTargetApi
targetSdkVersion 23
versionCode 325
versionName "3.2.5"
versionCode 326
versionName "3.2.6"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

final class LunarCalendar {

Expand All @@ -30,7 +29,6 @@ static void init(Context context) {
if (MONTH_STR != null) {
return;
}
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
SolarTermUtil.init(context);
MONTH_STR = context.getResources().getStringArray(R.array.lunar_first_of_month);
TRADITION_FESTIVAL_STR = context.getResources().getStringArray(R.array.tradition_festival);
Expand Down
3 changes: 2 additions & 1 deletion calendarview/src/main/java/com/haibin/calendarview/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static int getWeekFromCalendarBetweenYearAndYear(Calendar calendar, int minYear,
date.set(minYear, 0, 1);//1月1日
long firstTime = date.getTimeInMillis();//获得起始时间戳
int preDiff = date.get(java.util.Calendar.DAY_OF_WEEK) - 1;//1月第一天为星期几,星期天 == 0,也就是偏移量
date.set(calendar.getYear(), calendar.getMonth() - 1, calendar.getDay());
date.set(calendar.getYear(), calendar.getMonth() - 1, calendar.getWeek() == 0? calendar.getDay() + 1 :calendar.getDay());
long curTime = date.getTimeInMillis();//给定时间戳
int c = (int) ((curTime - firstTime) / ONE_DAY);
int count = preDiff + c;
Expand Down Expand Up @@ -368,4 +368,5 @@ static int dipToPx(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}

}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ org.gradle.jvmargs=-Xmx1536m
POM_BINTRAY_NAME=com.haibin:calendarview
POM_DESCRIPTION=A very good CalendarView for Android.
POM_ARTIFACT_ID=calendarview
VERSION_NAME=3.2.5
VERSION_CODE=3.2.5
VERSION_NAME=3.2.6
VERSION_CODE=3.2.6
POM_BINTRAY_PRPO=maven
POM_PACKAGING=aar
POM_NAME=calendarview
Expand Down

0 comments on commit 098ed50

Please sign in to comment.