Skip to content

Commit

Permalink
合并
Browse files Browse the repository at this point in the history
  • Loading branch information
yannecer committed Mar 26, 2020
2 parents 4046f1e + 179493a commit fee5444
Show file tree
Hide file tree
Showing 19 changed files with 483 additions and 171 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file removed .idea/caches/gradle_models.ser
Binary file not shown.
1 change: 0 additions & 1 deletion .idea/gradle.xml

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

36 changes: 36 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_miui10.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:id="@+id/miui10Calendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:showNumberBackground="true"
>


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_month_adapter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultCalendar="week"
app:isShowNumberBackground="true"
app:showNumberBackground="true"
app:numberBackgroundAlphaColor="100"
app:numberBackgroundTextSize="250sp"
app:numberBackgroundTextColor="#398FE9">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.6.1'

//上传jcenter相关插件
classpath 'com.novoda:bintray-release:0.9'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 28 17:07:44 CST 2018
#Wed Mar 25 14:59:29 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import org.joda.time.LocalDate;

/**
* Created by necer on 2018/9/11.
*
* @author necer
* @date 2018/9/11
* qq群:127278900
*/
public class WeekPagerAdapter extends BasePagerAdapter {
Expand Down
16 changes: 13 additions & 3 deletions ncalendar/src/main/java/com/necer/calendar/BaseCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.necer.R;
import com.necer.adapter.BasePagerAdapter;
import com.necer.enumeration.CalendarBuild;
import com.necer.enumeration.MultipleNumModel;
Expand Down Expand Up @@ -98,10 +106,12 @@ public BaseCalendar(@NonNull Context context, @Nullable AttributeSet attributeSe

mCalendarBgColor = mAttrs.bgCalendarColor;
mFirstDayOfWeek = mAttrs.firstDayOfWeek;
mIsAllMonthSixLine = mAttrs.isAllMonthSixLine;
mIsLastNextMonthClickEnable = mAttrs.isLastNextMonthClickEnable;
mIsAllMonthSixLine = mAttrs.allMonthSixLine;
mIsLastNextMonthClickEnable = mAttrs.lastNextMonthClickEnable;

// setBackgroundColor(Color.YELLOW);


setBackgroundColor(mCalendarBgColor);
addOnPageChangeListener(new SimpleOnPageChangeListener() {
@Override
public void onPageSelected(final int position) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import java.util.List;

/**
* Created by necer on 2019/1/3.
* @author necer
* @date 2019/1/3
*/
public interface CalendarPainter {

Expand Down
27 changes: 15 additions & 12 deletions ncalendar/src/main/java/com/necer/painter/InnerPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import android.graphics.drawable.Drawable;
import android.text.TextUtils;

import androidx.core.content.ContextCompat;

import com.necer.R;
import com.necer.calendar.ICalendar;
import com.necer.entity.CalendarDate;
Expand All @@ -24,7 +26,8 @@
import java.util.Map;

/**
* Created by necer on 2019/1/3.
* @author necer
* @date 2019/1/3
*/
public class InnerPainter implements CalendarPainter {

Expand Down Expand Up @@ -67,13 +70,13 @@ public InnerPainter(Context context, ICalendar calendar) {
mReplaceLunarColorMap = new HashMap<>();
mStretchStrMap = new HashMap<>();

mDefaultCheckedBackground = context.getResources().getDrawable(mAttrs.defaultCheckedBackground);
mTodayCheckedBackground = context.getResources().getDrawable(mAttrs.todayCheckedBackground);
mDefaultCheckedBackground = ContextCompat.getDrawable(context, mAttrs.defaultCheckedBackground);
mTodayCheckedBackground = ContextCompat.getDrawable(context, mAttrs.todayCheckedBackground);

mDefaultCheckedPoint = context.getResources().getDrawable(mAttrs.defaultCheckedPoint);
mDefaultUnCheckedPoint = context.getResources().getDrawable(mAttrs.defaultUnCheckedPoint);
mTodayCheckedPoint = context.getResources().getDrawable(mAttrs.todayCheckedPoint);
mTodayUnCheckedPoint = context.getResources().getDrawable(mAttrs.todayUnCheckedPoint);
mDefaultCheckedPoint = ContextCompat.getDrawable(context, mAttrs.defaultCheckedPoint);
mDefaultUnCheckedPoint = ContextCompat.getDrawable(context, mAttrs.defaultUnCheckedPoint);
mTodayCheckedPoint = ContextCompat.getDrawable(context, mAttrs.todayCheckedPoint);
mTodayUnCheckedPoint = ContextCompat.getDrawable(context, mAttrs.todayUnCheckedPoint);


List<String> holidayList = CalendarUtil.getHolidayList();
Expand All @@ -97,12 +100,12 @@ private Paint getPaint() {

@Override
public void onDrawCalendarBackground(ICalendarView iCalendarView, Canvas canvas, RectF rectF, LocalDate localDate, int totalDistance, int currentDistance) {
if (iCalendarView.getCalendarType() == CalendarType.MONTH && mAttrs.isShowNumberBackground) {
if (iCalendarView.getCalendarType() == CalendarType.MONTH && mAttrs.showNumberBackground) {
mTextPaint.setTextSize(mAttrs.numberBackgroundTextSize);
mTextPaint.setColor(mAttrs.numberBackgroundTextColor);
int alphaColor = mAttrs.numberBackgroundAlphaColor * currentDistance / totalDistance;
mTextPaint.setAlpha(alphaColor);
canvas.drawText(String.valueOf(localDate.getMonthOfYear()), rectF.centerX(), getTextBaseLineY(rectF.centerY()), mTextPaint);
canvas.drawText(localDate.getMonthOfYear()+"", rectF.centerX(), getTextBaseLineY(rectF.centerY()), mTextPaint);
}
}

Expand Down Expand Up @@ -182,12 +185,12 @@ private void drawSolar(Canvas canvas, RectF rectF, LocalDate date, int color, in
mTextPaint.setColor(color);
mTextPaint.setAlpha(alphaColor);
mTextPaint.setTextSize(mAttrs.solarTextSize);
canvas.drawText(date.getDayOfMonth() + "", rectF.centerX(), mAttrs.isShowLunar ? rectF.centerY() : getTextBaseLineY(rectF.centerY()), mTextPaint);
canvas.drawText(date.getDayOfMonth() + "", rectF.centerX(), mAttrs.showLunar ? rectF.centerY() : getTextBaseLineY(rectF.centerY()), mTextPaint);
}

//绘制农历
private void drawLunar(Canvas canvas, RectF rectF, LocalDate localDate, int color, int alphaColor) {
if (mAttrs.isShowLunar) {
if (mAttrs.showLunar) {
CalendarDate calendarDate = CalendarUtil.getCalendarDate(localDate);
//农历部分文字展示优先顺序 替换的文字、农历节日、节气、公历节日、正常农历日期
String lunarString;
Expand Down Expand Up @@ -226,7 +229,7 @@ private void drawPoint(Canvas canvas, RectF rectF, LocalDate date, Drawable draw

//绘制节假日
private void drawHolidayWorkday(Canvas canvas, RectF rectF, LocalDate localDate, Drawable holidayDrawable, Drawable workdayDrawable, int holidayTextColor, int workdayTextColor, int alphaColor) {
if (mAttrs.isShowHoliday) {
if (mAttrs.showHoliday) {
int[] holidayLocation = getHolidayLocation(rectF.centerX(), rectF.centerY());
if (mHolidayList.contains(localDate)) {
if (holidayDrawable == null) {
Expand Down
Loading

0 comments on commit fee5444

Please sign in to comment.