Skip to content

Commit

Permalink
支持全屏风格、隐藏日历、修复获取周数据、高度等问题
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghaibin-dev committed Mar 7, 2019
1 parent 1f5c8a8 commit b55a31d
Show file tree
Hide file tree
Showing 31 changed files with 818 additions and 85 deletions.
4 changes: 4 additions & 0 deletions QUESTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ public void setOnViewChangeListener(OnViewChangeListener listener);

```

- **CalendarView** 可以设置全屏,只需设置 app:calendar_match_parent="true"即可,全屏**CalendarView**是不需要周视图的,不必嵌套CalendarLayout

<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/full_calendar.png" width="400"/>


- **CalendarView** 也提供了高效便利的年视图,可以快速切换年份、月份,十分便利

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

### Gradle
```
compile 'com.haibin:calendarview:3.5.4'
compile 'com.haibin:calendarview:3.5.5'
```
```
<dependency>
<groupId>com.haibin</groupId>
<artifactId>calendarview</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
<type>pom</type>
</dependency>
```
Expand Down Expand Up @@ -56,8 +56,8 @@ compile 'com.haibin:calendarview:3.5.4'
<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/custom_expand.png" height="650"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/custom_shrink.png" height="650"/>
### 收缩展开的魅族风格效果
<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/meizu_expand.png" height="650"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/meizu_shrink.png" height="650"/>
### 下标和多彩风格
<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/index_expand.png" height="650"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/color_expand.png" height="650"/>
### 全屏和多彩风格
<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/full_calendar.png" height="650"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/color_expand.png" height="650"/>
### 进度条风格
<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/progress_expand.png" height="650"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://github.com/huanghaibin-dev/CalendarView/blob/master/app/src/main/assets/progress_shrink.png" height="650"/>
### 星系图风格
Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This widget has obvious advantages of memory and efficiency, adapt to many scene

### Gradle
```
compile 'com.haibin:calendarview:3.5.4'
compile 'com.haibin:calendarview:3.5.5'
```
```
<dependency>
<groupId>com.haibin</groupId>
<artifactId>calendarview</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
<type>pom</type>
</dependency>
```
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<activity android:name=".progress.ProgressActivity" />
<activity android:name=".custom.CustomActivity" />
<activity android:name=".pager.ViewPagerActivity" />
<activity android:name=".full.FullActivity" />
<activity android:name=".TestActivity" />
</application>

Expand Down
Binary file added app/src/main/assets/full_calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.haibin.calendarviewproject.base.activity.BaseActivity;
import com.haibin.calendarviewproject.colorful.ColorfulActivity;
import com.haibin.calendarviewproject.custom.CustomActivity;
import com.haibin.calendarviewproject.full.FullActivity;
import com.haibin.calendarviewproject.index.IndexActivity;
import com.haibin.calendarviewproject.meizu.MeiZuActivity;
import com.haibin.calendarviewproject.meizu.MeiZuMonthView;
Expand Down Expand Up @@ -266,7 +267,7 @@ protected void initData() {
findViewById(R.id.ll_solar_system).setOnClickListener(this);
findViewById(R.id.ll_progress).setOnClickListener(this);
findViewById(R.id.ll_custom).setOnClickListener(this);

findViewById(R.id.ll_full).setOnClickListener(this);
}

@Override
Expand Down Expand Up @@ -310,14 +311,13 @@ public void onClick(View v) {
switch (v.getId()) {
case R.id.ll_flyme:
MeiZuActivity.show(this);
Log.e("onDateSelected",
" -- " + mCalendarView.getSelectedCalendar().getScheme() +
" -- " + mCalendarView.getSelectedCalendar().toString() +
" -- " + mCalendarView.getSelectedCalendar().hasScheme());
break;
case R.id.ll_custom:
CustomActivity.show(this);
break;
case R.id.ll_full:
FullActivity.show(this);
break;
case R.id.ll_range:
RangeActivity.show(this);
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package com.haibin.calendarviewproject.full;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.haibin.calendarview.Calendar;
import com.haibin.calendarview.CalendarView;
import com.haibin.calendarviewproject.R;
import com.haibin.calendarviewproject.base.activity.BaseActivity;
import com.haibin.calendarviewproject.colorful.ColorfulActivity;
import com.haibin.calendarviewproject.custom.CustomActivity;
import com.haibin.calendarviewproject.index.IndexActivity;
import com.haibin.calendarviewproject.simple.SimpleActivity;

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

/**
* 全屏日历,因为月份大小不同的关系,需要 app:month_view_show_mode="mode_all",
* 一般地,既然使用全屏日历,那也不必要
* Created by huanghaibin on 2019/3/7.
*/

public class FullActivity extends BaseActivity implements
CalendarView.OnCalendarSelectListener,
CalendarView.OnYearChangeListener,
View.OnClickListener {

TextView mTextMonthDay;

TextView mTextYear;

TextView mTextLunar;

TextView mTextCurrentDay;

private int mYear;

CalendarView mCalendarView;

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

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

@SuppressLint("SetTextI18n")
@Override
protected void initView() {
setStatusBarDarkMode();
mTextMonthDay = (TextView) findViewById(R.id.tv_month_day);
mTextYear = (TextView) findViewById(R.id.tv_year);
mTextLunar = (TextView) findViewById(R.id.tv_lunar);
mTextCurrentDay = (TextView) findViewById(R.id.tv_current_day);
mCalendarView = (CalendarView) findViewById(R.id.calendarView);
mTextMonthDay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCalendarView.showYearSelectLayout(mYear);
mTextLunar.setVisibility(View.GONE);
mTextYear.setVisibility(View.GONE);
mTextMonthDay.setText(String.valueOf(mYear));
}
});
findViewById(R.id.fl_current).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCalendarView.scrollToCurrent();
}
});

mCalendarView.setOnCalendarSelectListener(this);
mCalendarView.setOnYearChangeListener(this);
mTextYear.setText(String.valueOf(mCalendarView.getCurYear()));
mYear = mCalendarView.getCurYear();
mTextMonthDay.setText(mCalendarView.getCurMonth() + "月" + mCalendarView.getCurDay() + "日");
mTextLunar.setText("今日");
mTextCurrentDay.setText(String.valueOf(mCalendarView.getCurDay()));
}

@Override
protected void initData() {
int year = mCalendarView.getCurYear();
int month = mCalendarView.getCurMonth();

Map<String, Calendar> map = new HashMap<>();
map.put(getSchemeCalendar(year, month, 3, 0xFF40db25, "假").toString(),
getSchemeCalendar(year, month, 3, 0xFF40db25, "假"));
map.put(getSchemeCalendar(year, month, 6, 0xFFe69138, "事").toString(),
getSchemeCalendar(year, month, 6, 0xFFe69138, "事"));
map.put(getSchemeCalendar(year, month, 9, 0xFFdf1356, "议").toString(),
getSchemeCalendar(year, month, 9, 0xFFdf1356, "议"));
map.put(getSchemeCalendar(year, month, 13, 0xFFedc56d, "记").toString(),
getSchemeCalendar(year, month, 13, 0xFFedc56d, "记"));
map.put(getSchemeCalendar(year, month, 14, 0xFFedc56d, "记").toString(),
getSchemeCalendar(year, month, 14, 0xFFedc56d, "记"));
map.put(getSchemeCalendar(year, month, 15, 0xFFaacc44, "假").toString(),
getSchemeCalendar(year, month, 15, 0xFFaacc44, "假"));
map.put(getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记").toString(),
getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记"));
map.put(getSchemeCalendar(year, month, 22, 0xFFdf1356, "议").toString(),
getSchemeCalendar(year, month, 22, 0xFFdf1356, "议"));
map.put(getSchemeCalendar(year, month, 25, 0xFF13acf0, "假").toString(),
getSchemeCalendar(year, month, 25, 0xFF13acf0, "假"));
map.put(getSchemeCalendar(year, month, 27, 0xFF13acf0, "多").toString(),
getSchemeCalendar(year, month, 27, 0xFF13acf0, "多"));
//此方法在巨大的数据量上不影响遍历性能,推荐使用
mCalendarView.setSchemeDate(map);
}

private Calendar getSchemeCalendar(int year, int month, int day, int color, String text) {
Calendar calendar = new Calendar();
calendar.setYear(year);
calendar.setMonth(month);
calendar.setDay(day);
calendar.setSchemeColor(color);//如果单独标记颜色、则会使用这个颜色
calendar.setScheme(text);
calendar.addScheme(color, "假");
calendar.addScheme(day%2 == 0 ? 0xFF00CD00 : 0xFFD15FEE, "节");
calendar.addScheme(day%2 == 0 ? 0xFF660000 : 0xFF4169E1, "记");
return calendar;
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ll_flyme:
CustomActivity.show(this);
break;
case R.id.ll_simple:
SimpleActivity.show(this);
break;
case R.id.ll_colorful:
ColorfulActivity.show(this);
break;
case R.id.ll_index:
IndexActivity.show(this);
break;
}
}

@Override
public void onCalendarOutOfRange(Calendar calendar) {

}

@SuppressLint("SetTextI18n")
@Override
public void onCalendarSelect(Calendar calendar, boolean isClick) {
mTextLunar.setVisibility(View.VISIBLE);
mTextYear.setVisibility(View.VISIBLE);
mTextMonthDay.setText(calendar.getMonth() + "月" + calendar.getDay() + "日");
mTextYear.setText(String.valueOf(calendar.getYear()));
mTextLunar.setText(calendar.getLunar());
mYear = calendar.getYear();

Log.e("onDateSelected", " -- " + calendar.getYear() +
" -- " + calendar.getMonth() +
" -- " + calendar.getDay() +
" -- " + isClick + " -- " + calendar.getScheme());
}

@Override
public void onYearChange(int year) {
mTextMonthDay.setText(String.valueOf(year));
}
}
Loading

0 comments on commit b55a31d

Please sign in to comment.