Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar committed Dec 21, 2017
1 parent 46e7dce commit be4a490
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* 9、......

#### [基本原理](http://www.jianshu.com/p/304c8e70d0bd)
#### [demo体验](https://fir.im/vehj?release_id=59fabc7fca87a80715000620)
#### [demo体验](https://fir.im/vehj?release_id=5a3b59f3959d691cc2000583)

### 效果图:
|![](screenshot/1.gif)|![](screenshot/2.gif)|![](screenshot/3.gif)|
Expand All @@ -32,7 +32,7 @@ allprojects {
**Step 2. 添加项目依赖**
``` gradle
dependencies {
compile 'com.github.Othershe:CalendarView:1.1.0'
compile 'com.github.Othershe:CalendarView:1.2.0'
}
```
**Step 3. 在布局文件中添加WeekView、CalendarView**
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.othershe.calendarview"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@
import com.othershe.calendarview.bean.DateBean;
import com.othershe.calendarview.listener.OnSingleChooseListener;
import com.othershe.calendarview.listener.OnPagerChangeListener;
import com.othershe.calendarview.utils.CalendarUtil;
import com.othershe.calendarview.weiget.CalendarView;

import java.util.HashMap;

public class MainActivity extends AppCompatActivity {

private CalendarView calendarView;
TextView chooseDate;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView title = (TextView) findViewById(R.id.title);
//当前选中的日期
chooseDate = findViewById(R.id.choose_date);

calendarView = (CalendarView) findViewById(R.id.calendar);
HashMap<String, String> map = new HashMap<>();
map.put("2017.10.30", "qaz");
Expand All @@ -38,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) {
map.put("2017.11.11", "tgb");
calendarView
// .setSpecifyMap(map)
.setStartEndDate("2010.7", "2018.12")
.setStartEndDate("2010.7", "2019.12")
.setInitDate("2017.11")
.setSingleDate("2017.12.12")
.init();
Expand All @@ -53,6 +58,7 @@ protected void onCreate(Bundle savedInstanceState) {
// }).init();

title.setText("2017年11月");
chooseDate.setText("当前选中的日期:2017年12月12日");

calendarView.setOnPagerChangeListener(new OnPagerChangeListener() {
@Override
Expand All @@ -65,6 +71,9 @@ public void onPagerChanged(int[] date) {
@Override
public void onSingleChoose(View view, DateBean date) {
title.setText(date.getSolar()[0] + "年" + date.getSolar()[1] + "月");
if (date.getType() == 1) {
chooseDate.setText("当前选中的日期:" + date.getSolar()[0] + "年" + date.getSolar()[1] + "月" + date.getSolar()[2] + "日");
}
}
});
}
Expand All @@ -86,6 +95,7 @@ public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this, "请完善日期!", Toast.LENGTH_SHORT).show();
return;
}
chooseDate.setText("当前选中的日期:" + year.getText() + "年" + month.getText() + "月" + day.getText() + "日");
calendarView.toSpecifyDate(Integer.valueOf(year.getText().toString()),
Integer.valueOf(month.getText().toString()),
Integer.valueOf(day.getText().toString()));
Expand All @@ -97,6 +107,8 @@ public void onClick(DialogInterface dialog, int which) {

public void today(View view) {
calendarView.today();
int[] date = CalendarUtil.getCurrentDate();
chooseDate.setText("当前选中的日期:" + date[0] + "年" + date[1] + "月" + date[2] + "日");
}

public void lastMonth(View view) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,10 @@

</LinearLayout>

<TextView
android:id="@+id/choose_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />

</LinearLayout>
4 changes: 2 additions & 2 deletions calendarview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 2
versionName "2.0"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static int getYearDays(int year) {
*/
private static int getLeapMonthDays(int year) {
if (getLeapMonth(year) != 0) {
if ((LUNAR_INFO[year - 1900] & 0xf0000) == 0) {
if ((LUNAR_INFO[year - MIN_YEAR] & 0xf0000) == 0) {
return 29;
} else {
return 30;
Expand Down Expand Up @@ -309,7 +309,7 @@ private static String getLunarHoliday(int year, int month, int day) {
}

public static int daysInLunarMonth(int year, int month) {
if ((LUNAR_INFO[year - MIN_YEAR] & (0x100000 >> month)) == 0)
if ((LUNAR_INFO[year - MIN_YEAR] & (0x10000 >> month)) == 0)
return 29;
else
return 30;
Expand Down

0 comments on commit be4a490

Please sign in to comment.