package com.myCalendar;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import org.xml.sax.ext.LexicalHandler;
import android.app.Activity;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.View;
import android.widget.TextView;
import com.myCalendar.db.DBService;
public class Grid extends CalendarParent implements Serializable{
public static DBService dbService;
private String[] days = new String[42];
// true表示有记录,false表示没有记录
private boolean[] recordDays = new boolean[42];
private String[] monthNames = new String[12];
private TextView tvMsg1;
private TextView tvMsg2;
private TextView tvMsg3;
private int dayColor;
private int innerGridColor;
private int prevNextMonthDayColor;
private int currentDayColor;
private int todayColor;
private int todayBackgroundColor;
private int sundaySaturdayPrevNextMonthDayColor;
private float daySize;
private float dayTopOffset;
private float currentDaySize;
private float cellX = -1, cellY = -1;
// 从0开始
private int currentRow, currentCol;
private boolean redrawForKeyDown = false;
// 当前年和月
public int currentYear, currentMonth;
// 上月或下月选中的天
public int currentDay = -1, currentDay1 = -1, currentDayIndex = -1;
private java.util.Calendar calendar = java.util.Calendar.getInstance();
public Grid(Activity activity, View view) {
super(activity, view);
if(dbService==null)
{
//在Grid类中药通过DBSerivce获得当前月日期是否包含记录,如果包含记录,在日前文字前显示星号
dbService=new DBService(activity);
}
tvMsg1=(TextView)activity.findViewById(R.id.tvMsg1);
tvMsg2=(TextView)activity.findViewById(R.id.tvMsg2);
//日期文本颜色
dayColor=activity.getResources().getColor(R.color.day_color);
//今天日期文本颜色
todayColor=activity.getResources().getColor(R.color.today_color);
//今天的日期文本边框颜色
todayBackgroundColor=activity.getResources().getColor(R.color.today_background_color);
//日历网格线颜色
innerGridColor=activity.getResources().getColor(R.color.inner_grid_color);
//上月和下月日期文本颜色,单击这些日期时,会自动跳到上月或下月
prevNextMonthDayColor=activity.getResources().getColor(R.color.prev_next_month_day_color);
//当前日期文字的颜色
currentDayColor=activity.getResources().getColor(R.color.current_day_color);
//星期六、日文字颜色
sundaySaturdayPrevNextMonthDayColor=activity.getResources().getColor(R.color.sunday_saturday_prev_next_month_day_color);
//日期字体尺寸
daySize=activity.getResources().getDimension(R.dimen.day_size);
//日期文字距当前网格顶端的偏移量,用于微调日期文字的位置
dayTopOffset=activity.getResources().getDimension(R.dimen.day_top_offset);
//当前日期文字尺寸
currentDaySize=activity.getResources().getDimension(R.dimen.current_day_size);
//月份名称
monthNames=activity.getResources().getStringArray(R.array.month_name);
currentYear=calendar.get(calendar.YEAR);
currentMonth=calendar.get(calendar.MONTH);
paint.setColor(activity.getResources().getColor(R.color.border_color));
}
float top, left;
@Override
public void draw(Canvas canvas)
{
left = borderMargin;
top = borderMargin + weekNameSize + weekNameMargin * 2 + 4;
float calendarWidth = view.getMeasuredWidth() - left * 2;
float calendarHeight = view.getMeasuredHeight() - top - borderMargin;
float cellWidth = calendarWidth / 7;
float cellHeight = calendarHeight / 6;
paint.setColor(innerGridColor);
//绘制日历网格顶端的直线
canvas.drawLine(left, top, left + view.getMeasuredWidth()
- borderMargin * 2, top, paint);
// 画横线
for(int i=1;i<6;i++)
{
canvas.drawLine(left, top+(cellHeight)*i, left+calendarWidth, top+(cellHeight)*i, paint);
}
// 画竖线
for (int i = 1; i < 7; i++)
{
canvas.drawLine(left + cellWidth * i, top, left + cellWidth * i,
view.getMeasuredHeight() - borderMargin, paint);
}
// 画日期
//生成当前月需要显示的日前文本,并将结果保存在days变量中
calculateDays();
java.util.Calendar calendar=java.util.Calendar.getInstance();
//获得当前日期的天
int day=calendar.get(calendar.DATE);
//获得当前日期的月和年
int myYear = calendar.get(calendar.YEAR), myMonth = calendar
.get(calendar.MONTH);
calendar.set(calendar.get(calendar.YEAR), calendar.get(calendar.MONTH),
1);
int week = calendar.get(calendar.DAY_OF_WEEK);
//得到今天的索引
int todayIndex = week + day - 2;
boolean today = false;
if (currentDayIndex == -1)
{
currentDayIndex = todayIndex;
}
boolean flag = false;
//获得当前月中所有包含记录信息的日期
getRecordDays();
//开始绘制日期文本
for(int i=0;i<days.length;i++)
{
today=false;
int row=i/7;//行
int col=i%7;//列
String text=String.valueOf(days[i]);
//上月和下月的周六、周日,days数组中所有以星号*开头的日期
if ((i % 7 == 0 || (i - 6) % 7 == 0) && text.startsWith("*"))
{
paint.setColor(sundaySaturdayPrevNextMonthDayColor);
}
//当前月的周六、周日
else if (i % 7 == 0 || (i - 6) % 7 == 0)
{
paint.setColor(sundaySaturdayColor);
}
//上月和下月的普通日期(一到五)以星号开头的
else if (text.startsWith("*"))
{
paint.setColor(prevNextMonthDayColor);
}
//当前月的普通日期
else
{
paint.setColor(dayColor);
}
//将days数组元素中的星号去掉
text=text.startsWith("*")?text.substring(1):text;
Rect dst=new Rect();
dst.left = (int) (left + cellWidth * col);
dst.top = (int) (top + cellHeight * row);
dst.bottom = (int) (dst.top + cellHeight + 1);
dst.right = (int) (dst.left + cellWidth + 1);
String myText = text;
//如果当前日期包含记录信息,在日前文字前加星号
if (recordDays[i])
myText = "*" + myText;
paint.setTextSize(daySize);
float textLeft = left + cellWidth * col
+ (cellWidth - paint.measureText(myText)) / 2;
float textTop = top + cellHeight * row
+ (cellHeight - paint.getTextSize()) / 2 + dayTopOffset;
//当前日期是今天,在日前文字周围绘制边框
if (myYear == currentYear && myMonth == currentMonth
&& i == todayIndex)
{
paint.setTextSize(currentDaySize);
paint.setColor(todayBackgroundColor);
dst.left += 1;
dst.top += 1;
canvas.drawLine(dst.left, dst.top, dst.right, dst.top, paint);
canvas.drawLine(dst.right, dst.top, dst.right, dst.bottom,
paint);
canvas.drawLine(dst.right, dst.bottom, dst.left, dst.bottom,
paint);
canvas.drawLine(dst.left, dst.bottom, dst.left, dst.top, paint);
paint.setColor(todayColor);
today = true;
}
//当单击当前月显示的是上月或下月日前时,自动显示上月或下月的日历
if (isCurrentDay(i, currentDayIndex, dst) && flag == false)
{
if (days[i].startsWith("*"))
{
// 下月
if (i > 20)
{
currentMonth++;
if (currentMonth == 12)
{
currentMonth = 0;
currentYear++;
}
view.invalidate();
}
// 上月
else
{
currentMonth--;
if (currentMonth == -1)
{
currentMonth = 11;
currentYear--;
}
view.invalidate();
}
currentDay = Integer.parseInt(text);
currentDay1 = currentDay;
cellX = -1;
cellY = -1;
break;
}
//如果单击的是当前月,显示一个背景图,并将日期文字设成红色
else
{
paint.setTextSize(currentDaySize);
flag = true;
Bitmap bitmap = BitmapFactory.decodeResource(activity
.getResources(), R.drawable.day);
Rect src = new Rect();
src.left = 0;
src.top = 0;
src.right = bitmap.getWidth();
src.bottom = bitmap.getHeight();
canvas.drawBitmap(bitmap, src, dst, paint);
paint.setColor(currentD
没有合适的资源?快使用搜索试试~ 我知道了~
quartz.rar_java 定时任务_quartz
共473个文件
php:262个
class:41个
jpg:25个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 17 浏览量
2022-07-15
17:09:51
上传
评论
收藏 3.84MB RAR 举报
温馨提示
一个灵活性很好的定时任务调度工具,有兴趣的朋友可以下载
资源推荐
资源详情
资源评论
收起资源包目录
quartz.rar_java 定时任务_quartz (473个子文件)
Sound.aps 21KB
proguard.cfg 1KB
Grid.class 11KB
DBService.class 6KB
AllRecord.class 5KB
myCalendar$OnMyDateMenuItemClick.class 5KB
myCalendar.class 5KB
Record.class 4KB
Record$OnSettingMenuItemClick.class 4KB
Record$OnSaveMenuItemClick.class 3KB
AlarmAlert.class 3KB
Schedule.class 2KB
Week.class 2KB
myCalendar$OnRecordRemindMenuItemClick.class 2KB
CalendarView.class 2KB
AllRecord$OnDeleteRecordMenuItemClick.class 2KB
CallAlarm.class 2KB
R$drawable.class 2KB
myCalendar$OnTodayMenuItemClick.class 1KB
Calendar.class 1KB
R$id.class 1KB
Border.class 1KB
About.class 1KB
CalendarParent.class 1KB
AllRecord$OnAddRecordMenuItemClick.class 1KB
myCalendar$OnAboutMenuItemClick.class 1KB
AlarmAlert$1.class 1KB
AllRecord$OnEditRecordMenuItemClick.class 1KB
R$color.class 949B
RemindSetting.class 798B
R.class 675B
DoJob.class 659B
R$dimen.class 646B
R$layout.class 632B
myCalendar$MenuItemClickParent.class 603B
AllRecord$MenuItemClickParent.class 597B
Record$MenuItemClickParent.class 579B
R$string.class 558B
Remind.class 419B
R$array.class 418B
R$raw.class 373B
R$attr.class 328B
CalendarElement.class 186B
.classpath 627B
.classpath 358B
Sound.clw 947B
org.eclipse.wst.jsdt.ui.superType.container 49B
DirectSound.cpp 10KB
SoundDlg.cpp 7KB
Sound.cpp 1KB
StdAfx.cpp 207B
Thumbs.db 15KB
Sound.dsp 4KB
Sound.dsw 753B
a2009091577014265.gif 8KB
DirectSound.h 4KB
SoundDlg.h 2KB
Sound.h 1KB
resource.h 1KB
StdAfx.h 999B
.htaccess 13B
index.htm 1B
index.htm 1B
index.htm 1B
index.htm 0B
index.htm 0B
index.htm 0B
Sound.ico 1KB
admin.ini 46KB
adminhtml.ini 38KB
admin.ini 23KB
classes.ini 10KB
theme.ini 7KB
install.ini 7KB
default.ini 6KB
theme.ini 5KB
install.ini 4KB
default.ini 3KB
install.ini 1KB
translit.ini 707B
tablecolumns.ini 435B
quartz-all-2.1.5.jar 563KB
log4j-1.2.8.jar 344KB
slf4j-api-1.7.2.jar 25KB
slf4j-log4j12-1.7.2.jar 9KB
Grid.java 16KB
myCalendar.java 7KB
R.java 7KB
DBService.java 6KB
AllRecord.java 5KB
Record.java 5KB
Schedule.java 2KB
AlarmAlert.java 2KB
CalendarView.java 1KB
Week.java 1KB
CalendarParent.java 1KB
CallAlarm.java 868B
Border.java 756B
Calendar.java 716B
About.java 602B
共 473 条
- 1
- 2
- 3
- 4
- 5
资源评论
御道御小黑
- 粉丝: 58
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功