package com.bn.rcgl;
import java.util.ArrayList;
import java.util.Calendar;
import com.bn.rcgl.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import static com.bn.rcgl.Constant.*;
import static com.bn.rcgl.DBUtil.*;
public class RcActivity extends Activity
{
String[] defultType=new String[]{"会议","备忘","待办"};//软件的三个不能删除的默认类型
Dialog dialogSetRange;//日程查找时设置日期起始范围的对话框
Dialog dialogSetDatetime;//新建或修改日程时设置日期和时间的对话框
Dialog dialogSchDelConfirm;//删除日程时的确认对话框
Dialog dialogCheck;//主界面中查看日程详细内容的对话框
Dialog dialogAllDelConfirm;//删除全部过期日程时的确认对话框
Dialog dialogAbout;//关于对话框
static ArrayList<String> alType=new ArrayList<String>();//存储所有日程类型的arraylist
static ArrayList<Schedule> alSch=new ArrayList<Schedule>();//存储所有schedule对象的ArrayList
Schedule schTemp;//临时的schedule
ArrayList<Boolean> alSelectedType=new ArrayList<Boolean>();//记录查找界面中类型前面checkbox状态的
String rangeFrom=getNowDateString();//查找日程时设置的起始日期,默认当前日期
String rangeTo=rangeFrom;//查找日程时设置的终止日期,默认当前日期
Layout curr=null;//记录当前界面的枚举类型
WhoCall wcSetTimeOrAlarm;//用来判断调用时间日期对话框的按钮是设置时间还是设置闹钟,以便更改对话框中的一些控件该设置为visible还是gone
WhoCall wcNewOrEdit;//用来判断调用日程编辑界面的是新建日程按钮还是在修改日程按钮,以便设置对应的界面标题
int sel=0;
/*临时记录新建日程界面里的类型spinner的position,因为设置时间的对话框cancel后
回到新建日程界面时会刷新所有控件,spinner中以选中的项目也会回到默认*/
Handler hd=new Handler()
{
@Override
public void handleMessage(Message msg)
{
switch(msg.what)
{
case 0:
gotoMain();
break;
}
}
};
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);//无标题
goToWelcomeView();
}
//欢迎界面
public void goToWelcomeView()
{
MySurfaceView mview=new MySurfaceView(this);
getWindow().setFlags//全屏
(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
setContentView(mview);
curr=Layout.WELCOME_VIEW;
}
//===================================主界面start===========================================
public void gotoMain()//初始化主界面
{
getWindow().setFlags
(//非全屏
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
);
setContentView(R.layout.main);
curr=Layout.MAIN;
sel=0;
final ArrayList<Boolean> alIsSelected=new ArrayList<Boolean>();//记录ListView中哪项选中了的标志位
final ImageButton bEdit=(ImageButton)findViewById(R.id.ibmainEdit);//修改日程按钮
final ImageButton bCheck=(ImageButton)findViewById(R.id.ibmainCheck);//查看日程详细内容的按钮
final ImageButton bDel=(ImageButton)findViewById(R.id.ibmainDel);//删除当前选中日程的按钮
ImageButton bNew=(ImageButton)findViewById(R.id.ibmainNew);//新建日程按钮
ImageButton bDelAll=(ImageButton)findViewById(R.id.ibmainDelAll);//删除所有过期日程按钮
ImageButton bSearch=(ImageButton)findViewById(R.id.ibmainSearch);//查找日程按钮
final ListView lv=(ListView)findViewById(R.id.lvmainSchedule);//日程列表
bCheck.setEnabled(false);//这三个按钮分别为主界面的日程查看、日程修改、日程删除,
bEdit.setEnabled(false);//默认设为不可用状态
bDel.setEnabled(false);
alSch.clear();//从数据库读取之前清空存储日程的arraylist
loadSchedule(this);//从数据库中读取日程
loadType(this);//从数据库中读取类型
if(alSch.size()==0)//如果没有任何日程,则删除全部过期日程按钮设为禁用
{
bDelAll.setEnabled(false);
}
else
{
bDelAll.setEnabled(true);
}
alIsSelected.clear();
for(int i=0;i<alSch.size();i++)//全部设置为false,即没有一项选中
{
alIsSelected.add(false);
}
//以下是ListView设置
lv.setAdapter
(
new BaseAdapter()
{
@Override
public int getCount()
{
return alSch.size();
}
@Override
public Object getItem(int position)
{
return alSch.get(position);
}
@Override
public long getItemId(int position)
{
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
LinearLayout ll=new LinearLayout(RcActivity.this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setPadding(5, 5, 5, 5);
LinearLayout llUp=new LinearLayout(RcActivity.this);
llUp.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout llDown=new LinearLayout(RcActivity.this);
llDown.setOrientation(LinearLayout.HORIZONTAL);
//ListView中日期TextView
TextView tvDate=new TextView(RcActivity.this);
tvDate.setText(alSch.get(position).getDate1()+" ");
tvDate.setTextSize(17);
tvDate.setTextColor(Color.parseColor("#129666"));
llUp.addView(tvDate);
//ListView时间TextView
TextView tvTime=new TextView(RcActivity.this);
tvTime.setText(alSch.get(position).timeForListView());
tvTime.setTextSize(17);
tvTime.setTextColor(Color.parseColor("#925301"));
llUp.addView(tvTime);
//若日程已过期,则日期和时间颜色、背景色设置为过期的颜色
if(alSch.get(position).isPassed())
{
tvDate.setTextColor(getResources().getColor(R.color.passedschtext));
tvTime.setTextColor(getResources().getColor(R.color.passedschtext));
ll.setBackgroundColor(getResources().getColor(R.color.passedschbg));
}
//如果该项被选中了,背景色设置为选中的背景色
if(alIsSelected.get(position))
{
ll.setBackgroundColor(getResources().getColor(R.color.selectedsch));
}
//如果有闹钟,则加上闹钟的图标
if(alSch.get(position).getAlarmSet())
{
ImageView iv=new ImageView(RcActivity.this);
iv.setImageDrawable(getResources().getDrawable(R.drawable.alarm));
iv.setLayoutParams(new LayoutParams(20, 20));
llUp.addView(iv);
}
//日程类型TextView
TextView tvType=new TextView(RcActivity.this);
tvType.setText(alSch.get(position).typeForListView());
tvType.setTextSize(17);
tvType.setTextColor(Color.parseColor("#b20000"));
llDown.addView(tvType);
//日程标题TextView
TextView tvTitle=new TextView(RcActivity.this);
tvTitle.setText(alSch.get(position).getTitle());
tvTitle.setTextSize(17);
tvTitle.setTextColor(Color.parseColor("#000000"));
llDown.addView(tvTitle);
ll.addView(llUp);
ll.addView(llDown);
return ll;
}
}
);
数据库客户端应用-日程管理专家
5星 · 超过95%的资源 需积分: 3 105 浏览量
2012-05-01
17:14:29
上传
评论 2
收藏 1.27MB ZIP 举报
yhjm880718
- 粉丝: 3
- 资源: 11
最新资源
- 基于SSM的电影购票系统 框架:Spring+SpringMVC+MyBatis+JSP
- UE5插件 后台WebApi的Restful接口请求交互
- 易语言简单绘制Demo
- 数值积分-复化梯形求积公式 - 北太天元
- DUmeter-8050exe
- 毕业设计:Java项目之jsp医院药品采购管理系统(源码 + 数据库 + 说明文档)
- JavaScript DOM视频教程包含源码作业及项目实战
- 简历-求职简历-word-文件-简历模版免费分享-应届生-高颜值简历模版-个人简历模版-简约大气-大学生在校生-求职-实习
- UMG图表控件+UE5插件+曲线图、饼图、环状图、柱状图
- 简历-求职简历-word-文件-简历模版免费分享-应届生-高颜值简历模版-个人简历模版-简约大气-大学生在校生-求职-实习
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页