package iSar2007.Study.InfoBox;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
public class ListActivity extends MainActivity {
private static final int INSERTPWD_ID = Menu.FIRST;
private static final int DELETEPWD_ID = Menu.FIRST + 1;
private static final int UPDATEPWD_ID = Menu.FIRST + 2;
private static final int TYPESETUP_ID = Menu.FIRST + 3;
private ListView mInfoList;
private TextView tvType;
private ImageView imgLeft, imgRight;
private Cursor mInfoCursor, mTypeCursor;
private boolean isEmptyDB;
@Override
public void onRestart() {
super.onRestart();
renderView();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.infolist);
mInfoList = (ListView) findViewById(R.id.InfoBody);
tvType = (TextView) findViewById(R.id.Title_tvType);
imgLeft = (ImageView) findViewById(R.id.Title_imgLeft);
imgRight = (ImageView) findViewById(R.id.Title_imgRight);
renderView();
mInfoList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
byte[] PIN = ThreeDES.decryptMode(mInfoCursor.getBlob(3));
Toast("Password/PIN:" + new String(PIN));
}
});
mInfoList.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
mInfoCursor.moveToPosition(position);
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
mInfoList.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (mDetector.onTouchEvent(event)) {
MotionEvent cancelEvent = MotionEvent.obtain(event);
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
v.onTouchEvent(cancelEvent);
return true;
}
return false;
}
});
mInfoList
.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
menu.add(0, UPDATEPWD_ID, Menu.NONE, "更新");
menu.add(0, DELETEPWD_ID, Menu.NONE, "删除");
}
});
imgLeft.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
showPrevious();
}
});
imgRight.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
showNext();
}
});
}
private void renderView() {
// TODO Auto-generated method stub
mTypeCursor = mDb.getAllTypes();
if (mTypeCursor.moveToFirst()) {
isEmptyDB = false;
tvType.setText(mTypeCursor.getString(1));
renderInfoListView();
} else {
isEmptyDB = true;
tvType.setText(R.string.Type_tvCreateType);
}
}
private void renderInfoListView() {
// TODO Auto-generated method stub
mInfoCursor = mDb.getAllInfos(mTypeCursor.getInt(0));
startManagingCursor(mInfoCursor);
String[] from = new String[] { DBAdapter.KEY_DES, DBAdapter.KEY_UID };
int[] to = new int[] { R.id.InfoItem_tvDescription, R.id.InfoItem_tvUID };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.infoitem, mInfoCursor, from, to);
mInfoList.setAdapter(adapter);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case DELETEPWD_ID:
mDb.deleteInfo(mInfoCursor.getLong(0));
renderInfoListView();
break;
case UPDATEPWD_ID:
Intent iInput = new Intent(this, InputActivity.class);
iInput.putExtra(DBAdapter.KEY_ROWID, mInfoCursor.getLong(0));
iInput.putExtra(DBAdapter.KEY_TYPEID, mTypeCursor.getLong(0));
iInput.putExtra(DBAdapter.KEY_DES, mInfoCursor.getString(1));
iInput.putExtra(DBAdapter.KEY_UID, mInfoCursor.getString(2));
byte[] PIN = ThreeDES.decryptMode(mInfoCursor.getBlob(3));
iInput.putExtra(DBAdapter.KEY_UPIN, new String(PIN));
iInput.putExtra(DBAdapter.KEY_REM, mInfoCursor.getString(4));
startActivity(iInput);
break;
}
return super.onContextItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, TYPESETUP_ID, Menu.NONE, "设置");
if (mTypeCursor.getCount() > 0) {
menu.add(0, INSERTPWD_ID, Menu.NONE, "添加");
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case TYPESETUP_ID:
intent = new Intent(this, TypeActivity.class);
startActivity(intent);
break;
case INSERTPWD_ID:
intent = new Intent(this, InputActivity.class);
intent.putExtra(DBAdapter.KEY_ROWID, (long) -1);
intent.putExtra(DBAdapter.KEY_TYPEID, mTypeCursor.getLong(0));
startActivity(intent);
break;
}
return super.onOptionsItemSelected(item);
}
@Override
protected boolean showPrevious() {
// TODO Auto-generated method stub
if (isEmptyDB) {
Toast(R.string.app_EmptyTypeTable);
return false;
} else {
if (!mTypeCursor.isFirst()) {
mTypeCursor.moveToPrevious();
tvType.setText(mTypeCursor.getString(1));
renderInfoListView();
} else
Toast(R.string.app_IsFirstRecord);
return true;
}
}
@Override
protected boolean showNext() {
// TODO Auto-generated method stub
if (isEmptyDB) {
Toast(R.string.app_EmptyTypeTable);
return false;
} else {
if (!mTypeCursor.isLast()) {
mTypeCursor.moveToNext();
tvType.setText(mTypeCursor.getString(1));
renderInfoListView();
} else
Toast(R.string.app_IsLastRecord);
return true;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
InfoBox.zip (92个子文件)
InfoBox
.project 843B
project.properties 360B
proguard.cfg 1KB
src
iSar2007
Study
InfoBox
ListActivity.java 6KB
DBAdapter.java 6KB
TypeActivity.java 5KB
InputActivity.java 4KB
ThreeDES.java 2KB
Type.java 288B
Info.java 1014B
MainActivity.java 3KB
LoginActivity.java 3KB
AndroidManifest.xml 1KB
res
drawable-ldpi
icon.png 26KB
ic_launcher.png 2KB
drawable-hdpi
icon.png 35KB
ic_launcher.png 4KB
drawable
icon.png 17KB
arrow_right_main.png 383B
line.png 196B
arrow_left_main.png 368B
corners.xml 333B
divide.png 3KB
drawable-mdpi
icon.png 28KB
ic_launcher.png 3KB
layout
typeitem.xml 982B
infolist.xml 414B
login.xml 3KB
infoitem.xml 1KB
infobody.xml 278B
title.xml 2KB
inputbody.xml 5KB
inputdialog.xml 1KB
infoinput.xml 373B
typelist.xml 713B
values
color.xml 157B
strings.xml 2KB
.settings
org.eclipse.jdt.core.prefs 173B
assets
gen
iSar2007
Study
InfoBox
R.java 6KB
.classpath 364B
bin
resources.ap_ 48KB
classes
iSar2007
Study
InfoBox
R$layout.class 697B
LoginActivity$2.class 829B
LoginActivity$4.class 891B
R$drawable.class 671B
R$attr.class 352B
ListActivity$5.class 832B
ListActivity.class 6KB
ListActivity$4.class 1KB
InputActivity$4.class 986B
TypeActivity$1.class 1KB
InputActivity.class 4KB
LoginActivity.class 4KB
TypeActivity$5.class 909B
ListActivity$3.class 1KB
ListActivity$1.class 2KB
DBAdapter.class 7KB
TypeActivity$3.class 887B
Type.class 587B
TypeActivity$2.class 1KB
LoginActivity$1.class 2KB
ListActivity$6.class 828B
R$id.class 2KB
TypeActivity$4.class 1KB
MainActivity$2.class 880B
R.class 559B
R$string.class 2KB
MainActivity$1.class 964B
TypeActivity.class 5KB
MainActivity.class 4KB
LoginActivity$3.class 2KB
ListActivity$2.class 2KB
ThreeDES.class 2KB
Info.class 2KB
InputActivity$1.class 838B
InputActivity$3.class 2KB
DBAdapter$DatabaseHelper.class 2KB
InputActivity$2.class 834B
jarlist.cache 119B
res
drawable-ldpi
icon.png 2KB
ic_launcher.png 2KB
drawable-hdpi
icon.png 5KB
ic_launcher.png 4KB
drawable
icon.png 15KB
arrow_right_main.png 383B
line.png 90B
arrow_left_main.png 368B
divide.png 85B
drawable-mdpi
icon.png 3KB
ic_launcher.png 2KB
InfoBox.apk 66KB
classes.dex 33KB
共 92 条
- 1
资源评论
- lujunwei19952015-09-20很不错!谢谢分享!
- kuaisujinru02014-06-14不错,正需要参考
光头谠
- 粉丝: 4
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于STM32F103C8T6单片机蓄电池在线监测系统主板硬件(原理图+PCB)工程文件.zip
- mysql大纲资料.txt
- c++大纲资料.txt
- 效率工具bat脚本实现日志提取
- MyBatis 中动态 SQL 的示例
- STM8L101F3P6单片机+CC1100模块433M遥控器设计硬件(原理图+PCB)工程文件.zip
- 上传下载铁人下载系统 Liuxing 1.0-liuxing1.0.rar
- 南京邮电大学数学实验实力雄厚,凭借其优秀的师资力量、丰富的实践教学资源和卓越的科研成果,成为国内一流的数学实验教学和科研基地
- 【火爆朋友圈的今天吃什么源码 v1.0】随机的为用户带来每一天的用餐选择和推荐.rar
- MPU6050中文版数据手册
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功