package com.note;
import java.util.Calendar;
import com.note.R;
import com.note.dao.SqliteDBConnect;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.app.AlertDialog.Builder;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class DisPlay extends Activity {
private static final String TAG = "XU";
private Button btnCommit, btnCancel;
private EditText txtName, txtContent;
private TextView txtTime;
private String noteId;
private SQLiteDatabase sdb;
private ActivityManager am;
private Calendar c;
private int year, month, day, hours, minute, second;
private PendingIntent pi;
private AlarmManager alm;
String getName,getContent,getTime;
int getCategory;
MediaPlayer player;
String category = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
am = ActivityManager.getInstance();
am.addActivity(this);
player = new MediaPlayer();//用来播放录音的音频文件
Intent intent = getIntent();
noteId = intent.getStringExtra("noteId");
category = intent.getStringExtra("category");
btnCommit = (Button) findViewById(R.id.btnCommit);
btnCancel = (Button) findViewById(R.id.btnCancel);
txtName = (EditText) findViewById(R.id.noteName);
txtContent = (EditText) findViewById(R.id.noteMain);
txtTime = (TextView) findViewById(R.id.noteTime);
txtContent.setEnabled(true);
c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
hours = c.get(Calendar.HOUR);
minute = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
SqliteDBConnect sd = new SqliteDBConnect(DisPlay.this);
sdb = sd.getReadableDatabase();
Cursor c = sdb.query("note", new String[] { "noteId", "noteName",
"noteContent", "noteTime" ,"category"}, "noteId=?",
new String[] { noteId }, null, null, null);
while (c.moveToNext()) {
getName = c.getString(c.getColumnIndex("noteName"));
getContent = c.getString(c.getColumnIndex("noteContent"));
getTime = c.getString(c.getColumnIndex("noteTime"));
getCategory = c.getInt(c.getColumnIndex("category"));
txtName.setText(getName);
txtContent.setText(getContent);
txtTime.setText(getTime);
}
c.close();
try{
//如果从数据库读取的类别号是2则调用播放函数处理
if(getCategory == 2)
{
txtContent.setEnabled(false);
play();
}
}catch(Exception e){e.printStackTrace();}
txtTime.setTextColor(Color.RED);
btnCommit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
int n = testTime();
if (n == 0) {
return;
}
AlertDialog.Builder adb = new Builder(DisPlay.this);
adb.setTitle("保存");
adb.setMessage("Are you sure to Save?");
adb.setPositiveButton("保存",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
baocunNote();
}
});
adb.setNegativeButton("取消",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
Toast.makeText(DisPlay.this, "Don't Save",
Toast.LENGTH_SHORT).show();
}
});
adb.show();
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
System.exit(0);
}
});
txtTime.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
DatePickerDialog dpd = new DatePickerDialog(DisPlay.this,
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int y,
int monthOfYear, int dayOfMonth) {
String[] time = { "",
hours + ":" + minute + ":" + second };
try {
String[] time2 = txtTime.getText().toString().trim()
.split(" ");
if(time2.length==2){
time[1]=time2[1];
}
} catch (Exception e) {
e.printStackTrace();
}
String mo = "", da = "";
if (monthOfYear < 10) {
mo = "0" + (monthOfYear + 1);
} else {
mo = monthOfYear + "";
}
if (dayOfMonth < 10) {
da = "0" + dayOfMonth;
} else {
da = dayOfMonth + "";
}
txtTime.setText(y + "-" + mo + "-" + da + " "
+ time[1]);
}
}, year, month, day);
dpd.setTitle("设置日期");
dpd.show();
}
});
txtTime.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
TimePickerDialog tpd = new TimePickerDialog(DisPlay.this,
new OnTimeSetListener() {
public void onTimeSet(TimePicker view,
int hourOfDay, int minute) {
String[] time = {year + "-" + month + "-" + day, "" };
try {
time = txtTime.getText().toString().trim()
.split(" ");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String ho = "", mi = "";
if (hourOfDay < 10) {
ho = "0" + hourOfDay;
} else {
ho = hourOfDay + "";
}
if (minute < 10) {
mi = "0" + minute;
} else {
mi = minute + "";
}
txtTime.setText(time[0] + " " + ho + ":" + mi);
}
}, hours, minute, true);
tpd.setTitle("设置时间");
tpd.show();
return true;
}
});
}
//这个方法用来判断并播放录音文件
public void play()
{
player.reset();
try{
player.setDataSource(getContent);
player.prepare();
player.start();
}catch (Exception e) {e.printStackTrace();}
}
public int testTime() {
int flag = 0;
try {
String[] t = txtTime.getText().toString().trim().split(" ");
String[] t1 = t[0].split("-");
String[] t2 = t[1].split(":");
if (t1.length != 3)
flag = 1;
if (t2.length != 2 && t2.length != 3)
flag = 1;
int m = Integer.parseInt(t1[1]) - 1;
int d = Integer.parseInt(t1[2]);
int h = Integer.parseInt(t2[0]);
int mi = Integer.parseInt(t2[1]);
if (m < 0 || m > 11)
flag = 1;
if (d < 1 || d > 31)
flag = 1;
if (h < 0 || h > 24)
flag = 1;
if (mi < 0 || mi > 60)
flag = 1;
if (t2.length == 3) {
int s = Integer.parseInt(t2[2]);
if (s < 0 || s > 60)
flag = 1;
}
if (flag == 1) {
Toast.makeText(DisPlay.this, "时间格式不正确,请单击或长按时间框设置",
Toast.LENGTH_SHORT).show();
return 0;
}
Calendar c2 = Calendar.getInstance();
c2.set(Integer.parseInt(t1[0]), Integer.parseInt(t1[1]) - 1,
Integer.parseInt(t1[2]), Integer.parseInt(t2[0]),
Integer.parseInt(t2[1]));
} catch (Exception e) {
Toast.makeText(DisPlay.this, "日期时间不正确,请单击�
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android开发的多媒体备忘录(含代码) (337个子文件)
all-wcprops 514B
resources.ap_ 5.14MB
resources.ap_ 596KB
MyNote.apk 5.17MB
Android应用_颖秘书.apk 5.11MB
MyNote.apk 620KB
bgimg2.bmp 76KB
bgimg2.bmp 76KB
bgimg.bmp 39KB
bgimg.bmp 39KB
jarlist.cache 120B
proguard.cfg 1KB
proguard.cfg 1KB
DisPlay.class 11KB
DisPlay.class 11KB
ActivityMain.class 9KB
ActivityMain.class 9KB
MainActivity.class 8KB
MainActivity.class 8KB
ShowVoiceList.class 7KB
ShowTextList.class 7KB
AddNewText.class 6KB
AddNewText.class 6KB
AddNewVideo.class 5KB
AddNewVoice.class 5KB
AddNewVoice.class 5KB
ShowVoiceList$ButtonClick.class 4KB
MainUIActivity.class 4KB
ShowTextList$ButtonClick.class 4KB
ActivityManager.class 4KB
MainActivity$ButtonClick.class 4KB
MainActivity$ButtonClick.class 4KB
ActivityManager.class 3KB
SQLManage.class 3KB
SQLManage.class 3KB
SetAlarm$1.class 3KB
SetAlarm$1.class 3KB
SetAlarm.class 3KB
Alarm.class 2KB
Alarm.class 2KB
ShowVoiceList$2$1.class 2KB
ShowTextList$2$1.class 2KB
R$id.class 2KB
SetAlarm.class 2KB
ShowVoiceList$2.class 2KB
ShowTextList$2.class 2KB
MainActivity$2.class 2KB
MainActivity$2.class 2KB
MainActivity$2$1.class 2KB
MainActivity$2$1.class 2KB
ActivityMain$1$1.class 2KB
ActivityMain$1$1.class 2KB
ActivityMain$2$1.class 2KB
ActivityMain$2$1.class 2KB
SharePreferences.class 2KB
DisPlay$3$1.class 2KB
DisPlay$3$1.class 2KB
DisPlay$4$1.class 2KB
DisPlay$4$1.class 2KB
ActivityMain$1.class 2KB
ActivityMain$1.class 2KB
ShowVoiceList$1.class 2KB
ShowTextList$1.class 2KB
ActivityMain$2.class 2KB
ActivityMain$2.class 2KB
R$color.class 2KB
MainActivity$1.class 2KB
MainActivity$1.class 2KB
ActivityMain$3.class 2KB
ActivityMain$3.class 2KB
DisPlay$1.class 2KB
DisPlay$1.class 2KB
three.class 2KB
one.class 2KB
SetAlarm$1$1.class 2KB
SetAlarm$1$1.class 2KB
ActivityMain$4.class 2KB
ActivityMain$4.class 2KB
AddNewText$5.class 2KB
LinedEditText.class 1KB
two.class 1KB
two$1.class 1KB
DisPlay$3.class 1KB
DisPlay$3.class 1KB
R$id.class 1KB
DisPlay$4.class 1KB
DisPlay$4.class 1KB
SqliteDBConnect.class 1KB
DisPlay$8.class 1KB
AddNewText$5.class 1KB
three$1.class 1KB
ActivityMain$4$1.class 1KB
ActivityMain$4$1.class 1KB
SqliteDBConnect.class 1KB
R$string.class 1KB
one$1.class 1KB
AlarmNote.class 1KB
AlarmNote.class 1KB
AddNewVoice$1.class 1KB
AddNewVoice$1.class 1KB
共 337 条
- 1
- 2
- 3
- 4
xsy341341
- 粉丝: 14
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- user+name.csv
- 安卓学习教材经验Android进阶学习资料安卓面试资料等文档资料合集(22个).zip
- 王小晨申论高分课.zip
- 基于matlab实现说话人语音识别源码+项目说明+PPT+报告(高分项目).zip
- VSc++编程助手1.0 - 1
- 基于matlab的说话人语音识别源码+PPT+报告(优质项目).zip
- 语音识别基于matlab说话人识别系统源码+报告PPT(高分优质项目).zip
- 毕业设计: 校园失物招领小程序的设计与实现论文(源码 + 数据库 + 说明文档)
- 美易ME-DUI自绘模块3.3-易语言模块
- 毕业设计:小程序消防知识每天学(源码 + 数据库 + 说明文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页