package com.cn.daming;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class AlarmClockView extends View{
private MainActivity activity;
private LinearLayout mLinearLayout;
private Context context;
private DataBaseHelper dbHelper;
private Cursor cursor;
private ListView mAlarmListView;
private List<String> ids;
private List<String> times;
private List<String> repeats;
private List<String> isopens;
private List<String> kinds;
private AlarmClockAdapter alarmAdapter;
Calendar c=Calendar.getInstance();
TextView time1TextView = null;
TextView time2TextView = null;
Button setTimeButton1 = null;
Button setTimeButton2 = null;
TextView repeat1TextView = null;
TextView repeat2TextView = null;
Button repeatButton1 = null;
Button repeatButton2 = null;
CheckBox time1CheckBox = null;
CheckBox time2CheckBox = null;
String tmpS1 = "目前无设置";
String repeatString1 = "目前无设置";
String tmpS2 = "目前无设置";
String repeatString2 = "目前无设置";
boolean isOpenInt1 = false;
boolean isOpenInt2 = false;
String isOpentime1 = null;
String isOpentime2 = null;
boolean isOpenAlarm = false;
CheckBox isOpenCheckBox;
int[] repeatArray1 = {0,0,0,0,0,0,0};
int[] repeatArray2 = {0,0,0,0,0,0,0};
boolean repeat_1_1 = false;
boolean repeat_1_2 = false;
boolean repeat_1_3 = false;
boolean repeat_1_4 = false;
boolean repeat_1_5 = false;
boolean repeat_1_6 = false;
boolean repeat_1_7 = false;
boolean repeat_2_1 = false;
boolean repeat_2_2 = false;
boolean repeat_2_3 = false;
boolean repeat_2_4 = false;
boolean repeat_2_5 = false;
boolean repeat_2_6 = false;
boolean repeat_2_7 = false;
public AlarmClockView(final Context context,MainActivity activity, LinearLayout linearLayout) {
super(context);
this.context = context;
this.activity = activity;
this.mLinearLayout = linearLayout;
View alarmView = View.inflate(context, R.layout.alarm_listview, null);
mLinearLayout.addView(alarmView);
mAlarmListView = (ListView)alarmView.findViewById(R.id.alarm_list);
mAlarmListView.setCacheColorHint(0);
dbHelper = new DataBaseHelper(context);
refreshDBHelper();
mAlarmListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0, View v, int position,
long arg3) {
showAlarmDialog(position); //点击闹钟出现设置页面
}
});
}
public void refreshDBHelper()
{
cursor = dbHelper.selectAlarmColock();
ids = new ArrayList<String>();
times = new ArrayList<String>();
repeats = new ArrayList<String>();
isopens = new ArrayList<String>();
kinds = new ArrayList<String>();
int count = cursor.getCount();
if(count==0){
String[] tempStr = new String[4];
for(int i=1;i<=2;i++){
dbHelper.insertAlarmColock(tempStr);
}
int count2 = cursor.getCount();
if(count2>0){
for(int i=0;i<count2;i++){
cursor.moveToPosition(i);
ids.add(cursor.getString(0));
times.add(cursor.getString(1));
repeats.add(cursor.getString(2));
isopens.add(cursor.getString(3));
kinds.add(cursor.getString(4));
}
}
cursor.close();
dbHelper.close();
refreshDBHelper();
Toast.makeText(context, R.string.not_dbcursor_values, Toast.LENGTH_SHORT).show();
}
else if(count>0){
for(int i=0;i<count;i++){
cursor.moveToPosition(i);
ids.add(cursor.getString(0));
times.add(cursor.getString(1));
repeats.add(cursor.getString(2));
isopens.add(cursor.getString(3));
kinds.add(cursor.getString(4));
}
}
alarmAdapter = new AlarmClockAdapter(context,ids,times,repeats,isopens,kinds);
mAlarmListView.setAdapter(alarmAdapter);
cursor.close();
dbHelper.close();
}
public void showAlarmDialog(int position){
//设置闹钟弹窗
dbHelper = new DataBaseHelper(context);
cursor = dbHelper.selectAlarmColock();
int count = cursor.getCount();
if(position == 0){
LayoutInflater factory = LayoutInflater.from(context);
final View alarm1View = factory.inflate(R.layout.time_repeat_dialog, null);
time1TextView = (TextView)alarm1View.findViewById(R.id.text); //标题设置闹钟
setTimeButton1 = (Button)alarm1View.findViewById(R.id.mButton);//设置时间
repeat1TextView = (TextView)alarm1View.findViewById(R.id.repeattext);
repeatButton1 = (Button)alarm1View.findViewById(R.id.repeatButton); //设置重复
time1CheckBox = (CheckBox)alarm1View.findViewById(R.id.isopen_check);
String isOpen1 = "关";
if(count==2){
for(int i=0;i<count;i++){
if(i == 0){
cursor.moveToPosition(i);
if(cursor.getString(1)==null){
time1TextView.setText(tmpS1);
}else{
time1TextView.setText(cursor.getString(1));
tmpS1 = cursor.getString(1);
}
if((cursor.getString(2))==null){
repeat1TextView.setText(repeatString1);
}else{
repeat1TextView.setText(cursor.getString(2));
repeatString1 = cursor.getString(2);
}
isOpen1 = cursor.getString(3);
if(isOpen1!=null){
if(isOpen1.equals("开")){
time1CheckBox.setChecked(true);
isOpenInt1 = true;
}else{
time1CheckBox.setChecked(false);
isOpenInt1 = false;
}
}
}
}
}
time1CheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){//是否开启闹钟
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
if(arg0.isChecked()){
isOpenInt1 = true;
}else{
isOpenInt1 = false;
}
}
});
setTimeButton1.setOnClickListener(new OnClickListener(){//设置时间
public void onClick(View arg0) {
c.setTimeInMillis(System.currentTimeMillis());//设置当前时间
int mHour=c.get(Calendar.HOUR_OF_DAY);
int mMinute=c.get(Calendar.MINUTE);
int mDay=c.get(Calendar.DAY_OF_WEEK);
new TimePickerDialog(context,
new TimePickerDialog.OnTimeSetListener()
{
public void onTimeSet(TimePicker view,int hourOfDay,
int minute)
{
c.setTimeInMillis(System.currentTimeMillis
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 事务提醒工具源码.zip项目安卓应用源码下载Android 事务提醒工具源码.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android 事务提醒工具源码.zip (67个子文件)
Android 事务提醒工具源码
Android 事务提醒工具源码
1-1210151113340-L.png 450KB
Android 事务提醒工具源码
Alarm
AndroidManifest.xml 848B
res
layout
alarm_listview.xml 1KB
time_repeat_dialog.xml 3KB
alarm_clock.xml 3KB
main.xml 462B
drawable-ldpi
icon.png 2KB
drawable-mdpi
alarm_dialog.png 4KB
clock.png 5KB
icon.png 3KB
alarm_bg.png 242KB
drawable-hdpi
icon.png 4KB
values
color.xml 340B
strings.xml 1KB
arrays.xml 329B
proguard.cfg 1KB
src
com
cn
daming
MainActivity.java 470B
AlarmClockAdapter.java 3KB
CallAlarm.java 748B
AlarmAgainSetting.java 5KB
Contants.java 4KB
DataBaseHelper.java 3KB
AlarmClockView.java 31KB
bin
com
cn
daming
AlarmClockView$5.class 4KB
DataBaseHelper.class 4KB
AlarmAgainSetting.class 5KB
AlarmClockView$9$2.class 3KB
AlarmClockView$4$3.class 853B
AlarmClockAdapter.class 4KB
AlarmClockView$4$2.class 3KB
AlarmClockView$10.class 4KB
AlarmClockView$1.class 1KB
AlarmClockView$8$1.class 2KB
AlarmClockView$9$1.class 1KB
AlarmClockView$9$3.class 853B
AlarmAgainSetting$1.class 894B
AlarmClockView$3$1.class 2KB
R.class 539B
MainActivity.class 826B
AlarmClockView$2.class 958B
AlarmClockView$9.class 2KB
R$layout.class 494B
R$attr.class 325B
Contants.class 4KB
AlarmClockView$4$1.class 1KB
AlarmClockView$11.class 876B
AlarmClockAdapter$ZuJian.class 701B
R$id.class 918B
R$array.class 391B
AlarmAgainSetting$2.class 894B
R$string.class 1KB
AlarmClockView.class 10KB
CallAlarm.class 2KB
AlarmClockView$8.class 2KB
AlarmClockView$6.class 874B
AlarmClockView$4.class 2KB
AlarmClockView$3.class 2KB
R$drawable.class 657B
AlarmClockView$7.class 958B
classes.dex 34KB
Alarm.apk 278KB
resources.ap_ 261KB
.classpath 280B
assets
default.properties 362B
.project 841B
gen
com
cn
daming
R.java 3KB
1_121015111607_1.png 182KB
共 67 条
- 1
资源评论
yxkfw
- 粉丝: 81
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功