package com.pwp.activity;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.pwp.borderText.BorderText;
import com.pwp.dao.ScheduleDAO;
import com.pwp.vo.ScheduleVO;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.GestureDetector.OnGestureListener;
import android.view.View.OnTouchListener;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.DatePicker;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import android.widget.AbsListView.LayoutParams;
import android.widget.AdapterView.OnItemClickListener;
/**
* 日历显示activity
* @author jack_peng
*
*/
public class CalendarActivity extends Activity implements OnGestureListener {
private ViewFlipper flipper = null;
private GestureDetector gestureDetector = null;
private CalendarView calV = null;
private GridView gridView = null;
private BorderText topText = null;
private Drawable draw = null;
private static int jumpMonth = 0; //每次滑动,增加或减去一个月,默认为0(即显示当前月)
private static int jumpYear = 0; //滑动跨越一年,则增加或者减去一年,默认为0(即当前年)
private int year_c = 0;
private int month_c = 0;
private int day_c = 0;
private String currentDate = "";
private ScheduleDAO dao = null;
public CalendarActivity() {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
currentDate = sdf.format(date); //当期日期
year_c = Integer.parseInt(currentDate.split("-")[0]);
month_c = Integer.parseInt(currentDate.split("-")[1]);
day_c = Integer.parseInt(currentDate.split("-")[2]);
dao = new ScheduleDAO(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gestureDetector = new GestureDetector(this);
flipper = (ViewFlipper) findViewById(R.id.flipper);
flipper.removeAllViews();
calV = new CalendarView(this, getResources(),jumpMonth,jumpYear,year_c,month_c,day_c);
addGridView();
gridView.setAdapter(calV);
//flipper.addView(gridView);
flipper.addView(gridView,0);
topText = (BorderText) findViewById(R.id.toptext);
addTextToTopTextView(topText);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
int gvFlag = 0; //每次添加gridview到viewflipper中时给的标记
if (e1.getX() - e2.getX() > 120) {
//像左滑动
addGridView(); //添加一个gridView
jumpMonth++; //下一个月
calV = new CalendarView(this, getResources(),jumpMonth,jumpYear,year_c,month_c,day_c);
gridView.setAdapter(calV);
//flipper.addView(gridView);
addTextToTopTextView(topText);
gvFlag++;
flipper.addView(gridView, gvFlag);
this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_in));
this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_out));
this.flipper.showNext();
flipper.removeViewAt(0);
return true;
} else if (e1.getX() - e2.getX() < -120) {
//向右滑动
addGridView(); //添加一个gridView
jumpMonth--; //上一个月
calV = new CalendarView(this, getResources(),jumpMonth,jumpYear,year_c,month_c,day_c);
gridView.setAdapter(calV);
gvFlag++;
addTextToTopTextView(topText);
//flipper.addView(gridView);
flipper.addView(gridView,gvFlag);
this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_in));
this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_out));
this.flipper.showPrevious();
flipper.removeViewAt(0);
return true;
}
return false;
}
/**
* 创建菜单
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, menu.FIRST, menu.FIRST, "今天");
menu.add(0, menu.FIRST+1, menu.FIRST+1, "跳转");
menu.add(0, menu.FIRST+2, menu.FIRST+2, "日程");
menu.add(0, menu.FIRST+3, menu.FIRST+3, "日期转换");
return super.onCreateOptionsMenu(menu);
}
/**
* 选择菜单
*/
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()){
case Menu.FIRST:
//跳转到今天
int xMonth = jumpMonth;
int xYear = jumpYear;
int gvFlag =0;
jumpMonth = 0;
jumpYear = 0;
addGridView(); //添加一个gridView
year_c = Integer.parseInt(currentDate.split("-")[0]);
month_c = Integer.parseInt(currentDate.split("-")[1]);
day_c = Integer.parseInt(currentDate.split("-")[2]);
calV = new CalendarView(this, getResources(),jumpMonth,jumpYear,year_c,month_c,day_c);
gridView.setAdapter(calV);
addTextToTopTextView(topText);
gvFlag++;
flipper.addView(gridView,gvFlag);
if(xMonth == 0 && xYear == 0){
//nothing to do
}else if((xYear == 0 && xMonth >0) || xYear >0){
this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_in));
this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_out));
this.flipper.showNext();
}else{
this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_in));
this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_out));
this.flipper.showPrevious();
}
flipper.removeViewAt(0);
break;
case Menu.FIRST+1:
new DatePickerDialog(this, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
//1901-1-1 ----> 2049-12-31
if(year < 1901 || year > 2049){
//不在查询范围内
new AlertDialog.Builder(CalendarActivity.this).setTitle("错误日期").setMessage("跳转日期范围(1901/1/1-2049/12/31)").setPositiveButton("确认", null).show();
}else{
int gvFlag = 0;
addGridView(); //添加一个gridView
calV = new CalendarView(CalendarActivity.this, CalendarActivity.this.getResources(),year,monthOfYear+1,dayOfMonth);
gridView.setAdapter(calV);
addTextToTopTextView(topText);
gvFlag++;
flipper.addView(gridView,gvFlag);
if(year == year_c && monthOfYear+1 == month_c){
//nothing to do
}
if((year == year_c && monthOfYear+1 > month_c) || year > year_c ){
CalendarActivity.this.flipper.setInAnimation(AnimationUtils.loadAnimation(CalendarActivity.this,R.anim.push_left_in));
CalendarActivity.this.flipper.setOutAnimation(AnimationUtils.loadAnimation(CalendarActivity.this,R.anim.push_left_out));
CalendarActivity.this.flipper.showNext();
}else{
CalendarActivity.this.flipper.setInAnimation(AnimationUtils.loadAnimation(CalendarActivity.this,R.anim.push_right_in));
CalendarActivity.this.flipper.setOutAnimation(AnimationUtils.loadAnimation(CalendarActivity.this,R.anim.push_right_out));
CalendarActivity.t
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之PWP简洁大日历-IT计算机-毕业设计.zip (236个子文件)
resources.ap_ 432KB
Calendar_01.apk 464KB
jarlist.cache 120B
proguard.cfg 1KB
CalendarActivity.class 11KB
LunarCalendar.class 10KB
CalendarView.class 9KB
ScheduleView.class 9KB
ScheduleDAO.class 6KB
ScheduleAll.class 5KB
ScheduleInfoView.class 5KB
ScheduleTypeView.class 4KB
CalendarActivity$1.class 3KB
ScheduleView$3.class 3KB
CalendarActivity$3.class 3KB
CalendarConvert.class 3KB
CalendarConvert$1$1.class 2KB
ScheduleTypeView$1.class 2KB
DBOpenHelper.class 2KB
ScheduleInfoView$1.class 2KB
ScheduleDateTag.class 2KB
CalendarConvert$2.class 2KB
ScheduleInfoView$1$1.class 2KB
ScheduleVO.class 2KB
ScheduleView$1.class 2KB
ScheduleTypeView$2.class 1KB
ScheduleAll$1.class 1KB
CalendarConvert$1.class 1KB
BorderEditText.class 1KB
BorderTextView.class 1KB
ScheduleView$2$1.class 1KB
ScheduleView$2.class 1KB
ScheduleTypeView$3.class 1KB
SpecialCalendar.class 1KB
ScheduleTypeView$1$1.class 1KB
CalendarActivity$2.class 1KB
BorderText.class 933B
R$drawable.class 928B
R$id.class 823B
CalendarConstant.class 792B
R.class 561B
R$layout.class 520B
R$anim.class 502B
R$string.class 421B
BuildConfig.class 341B
R$attr.class 334B
.classpath 475B
classes.dex 70KB
annotations-f8a83684881af84cae48389c17c1dce5.jar 943B
CalendarActivity.java 14KB
ScheduleView.java 11KB
CalendarView.java 10KB
LunarCalendar.java 10KB
ScheduleDAO.java 8KB
ScheduleInfoView.java 6KB
ScheduleTypeView.java 5KB
ScheduleAll.java 4KB
CalendarConvert.java 3KB
R.java 3KB
ScheduleDateTag.java 1KB
ScheduleVO.java 1KB
DBOpenHelper.java 1KB
SpecialCalendar.java 1KB
BorderText.java 1022B
BorderTextView.java 940B
BorderEditText.java 939B
CalendarConstant.java 314B
BuildConfig.java 158B
hs_err_pid41708.log 4KB
hs_err_pid41248.log 4KB
schedule_bk.png 190KB
schedule_bk.png 190KB
schedule_bk.png 190KB
schedule_bk.png 119KB
schedule_bk.png 119KB
schedule_bk.png 119KB
schedule_bk.png 119KB
schedule_bk.png 119KB
schedule_bk.png 119KB
icon.png 4KB
icon.png 4KB
icon.png 4KB
icon.png 3KB
icon.png 2KB
icon.png 2KB
icon.png 2KB
icon.png 2KB
icon.png 2KB
top_day.png 704B
top_day.png 704B
top_day.png 704B
top_day.png 704B
top_day.png 704B
top_day.png 704B
top_day.png 673B
top_day.png 673B
top_day.png 673B
notebook.png 498B
notebook.png 498B
notebook.png 498B
共 236 条
- 1
- 2
- 3
资源评论
芝麻粒儿
- 粉丝: 5w+
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现文档+程序边缘计算任务卸载与资源调度的算法,是论文的源代码,具有价值.rar
- 什么是学生成绩管理系统c++以及学习学生成绩管理系统的意义
- 什么是词向量-以及学习关于了解词向量的意义
- 什么是mybatis动态sql以及学习mybatis动态sql的意义
- 华为数据治理方法论,包括:数据治理框架、数据治理组织架构、数据治理度量评估体系以及华为数据治理案例分享
- 基于matlab实现对表面肌电信号进行归一化处理,并对归一化后的图形显示 .rar
- 基于matlab实现单级倒立摆的 T-S 模型 包括 LMI 程序源码
- 图书管理系统(struts+hibernate+spring+ext).rar
- 基于matlab实现此压缩包包含语音信号处理中的语音变声代码加音频.rar
- STM32使用PWM驱动舵机并通过OLED显示
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功