基于Android平台的手机电子书阅读器代码
- 格式:doc
- 大小:146.50 KB
- 文档页数:28
期末作品报告课程名称: Android应用程序开发学号:姓名:班别:1引言在这个快节奏的时代,人们的空余时间越来越零碎,而且人们对智能手机的依赖越来越重,所以,一个拥有丰富功能且能随时进行电子书阅读的在线小说阅读器的出现,则是我们刻不容缓的事情。
此软件是在Android平台上进行设计开发,此软件的开发是通过了客户需求分析阶段以及技术可行性分析阶段,然后进行总体设计阶段和详细设计编码等阶段。
此软件不仅具有基本的电子书阅读功能,而且还拥有丰富的实用功能设计。
经过不断的测试与完善,电子书阅读器功能稳定,并且在真机上对其进行了测试与验证,基本上达到了用户的需求标准。
1、功能分析1.1项目来源此次开发的项目是在线小说阅读器,属于自选项目。
随着社会的发展,人们的生活节奏也越来越快空闲时间也越来越零碎,人们没有了大段的时间来进行书籍的阅读,所以一款能利用零碎时间进行随时阅读的软件成为了我们的需求。
而一款能在人们随身携带的手机上运行的阅读软件成为了大家的选择。
以前我们看看杂志,小说都要去图书馆借阅,而且时间有限,很不方便;而在电脑上看杂志,看小说,文档也是很不方便的。
以此看来,一个好的手机阅读器软件的开发是相当有必要的。
1.2开发目标在线小说阅读器的开发目标就是让用户可以把零碎的空余时间有效的利用到书籍的阅读上,而且用户在没有网路的情况下也可以正常的进行书籍的阅读,让用户摆脱书籍的笨重携带不方便等确定,给予阅读者更大的便利性更好的舒适性。
此软件是在Android平台上进行设计开发,它的界面丰富简洁但是却不简单,它包含了书架界面、2文件查看界面、软件设置界面、书籍阅读界面等界面,它的功能全面。
其优越性表现在:自动扫描手机里的所有书籍、手动从文件夹中选择添加书籍、自动为书籍生成章节目录、添加查看书签、全文关键词搜索、阅读主题选择、阅读字体大小设置等功能。
此外,给用户更清晰方便的界面,也是本软件的出发点之一。
2、功能设计2.1系统功能设计根据需要,在线图书阅读器主要实现即时的在线阅读,主要包含以下功能:(1)在线即时搜索图书:可以按照书名、作者进行搜索所要阅读的书籍。
安卓电子书程序源代码/Android源码(自己制作Android电子书)作者:我的江南2012标签:安卓电子书源Android源码自己动手制作Android电子2012-04-04 23:06 星期三晴•本Android源代码实现了电子书功能。
您就可以通过替换本代码中的.txt文件,使用Eclipse自己动手编译生成.apk文件,然后上传到Android市场、Hiapk、安智市场、木蚂蚁市场等,通过用户下载、点击书中嵌入的广告(有米、多盟等)获得盈利。
请速到淘宝网获取源代码吧!点击超链接:安卓电子书程序源代码网址:/item.htm?id=14643499851•该Android电子书源代码实现了电子书功能,生成.apk文件。
具体功能如下:1.有封面,有目录,读取内容为txt文字,分章节阅读;2.背景和文字搭配好,阅读舒畅;3.无重力感应翻转,有翻页功能,且翻页方便;4.书签功能及下次进入程序回到正在观看的文字位置功能;5.能够改变字体大小和背景颜色、亮度;7.支持常规的手机屏幕都可以正常阅读;8.界面美观,操作简单;9.拍下后交付android源代码,源代码规范工整,注释清晰易于维护和再开发。
10.用户可通过该代码自己制作Android电子书,只需更换txt文件,实现Android 电子书DIY。
备注:1. 我旺旺不在线时,亲也可放心拍下(留下邮箱地址),我会在24小时内将源代码发到用户指定的邮箱里。
2.亲,需要时可以直接打我手机:133****3705,也可QQ361372840 ,加我时注明:Android源码。
3.如果亲有需要帮助,比如android环境配置、如何更换.txt文件生成电子书、如何添加有米、多盟广告等问题,我也可协助用户。
虚拟机运行截图•真机运行截图。
android之文本阅读器显示和阅读sd卡上的所有文本文件截图如下:目录结构ListAllFileActivity.java package com.example.txtreader;import java.io.File;import java.util.ArrayList;import java.util.List;import android.os.Bundle;import android.os.Environment;import android.app.Activity;import android.content.Intent;import android.view.Menu;import android.view.View;import android.widget.ArrayAdapter;import android.widget.ListView;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;public class ListAllFileActivity extends Activity {/*文件列表*/private List<File> fileNameList;private Bundle bundle;//展示SD卡中的所有文件@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.activity_list_all_file);initializeFile();}private void initializeFile(){File path = Environment.getExternalStorageDirectory();File[] f = path.listFiles();putFile(f);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.activity_list_all_file, menu);return true;}//读取SD卡中的所有的文件列表,并放到list中private void putFile(File[] f){fileNameList = new ArrayList();for(int i = 0; i < f.length; i++){if(isValid(f[i])){fileNameList.add(f[i]);}}ListView lv = (ListView) this.findViewById(R.id.fileList);ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, yout.simple_list_item_1, fileToStrArr(fileNameList));lv.setAdapter(adapter);OnItemClickListener listener = new OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view,int position, long id) {Intent intent = new Intent(ListAllFileActivity.this,ViewFile.class);bundle = new Bundle();File file = fileNameList.get(position);if (file.isDirectory()) {File[] f = file.listFiles();putFile(f);} else {bundle.putString("fileName",file.getAbsolutePath());intent.putExtras(bundle);startActivityForResult(intent, 0);}}};lv.setOnItemClickListener(listener);}//检查时文件名或者目录private boolean isValid(File f){if(f.isDirectory()){return true;}if(f.getName().endsWith(".txt")){return true;}else{return false;}}private String[] fileToStrArr(List<File> fl){ArrayList<String> fnList = new ArrayList<String>();for (int i = 0; i < fl.size(); i++) {String nameString = fl.get(i).getName();fnList.add(nameString);}return fnList.toArray(new String[0]);}}MainActivity.javapackage com.example.txtreader;import android.os.Bundle;import android.app.Activity;import android.content.Intent;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.activity_main);Button openFile = (Button) this.findViewById(R.id.openFile);openFile.setOnClickListener(new OpenFileListener());}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.activity_main, menu);return true;}class OpenFileListener implements OnClickListener{@Overridepublic void onClick(View arg0) {Intent intent = new Intent(MainActivity.this, ListAllFileActivity.class);startActivityForResult(intent, 1);}}}ViewFile.javapackage com.example.txtreader;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import java.io.UnsupportedEncodingException;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.widget.TextView;public class ViewFile extends Activity {private String filename;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.activity_view_file);Bundle bundle = this.getIntent().getExtras();filename = bundle.getString("fileName");TextView lv = (TextView) this.findViewById(R.id.view_contents);String fileContent = getStringFromFile("UTF-8");lv.setText(fileContent);}private String getStringFromFile(String code){StringBuffer sb = new StringBuffer();try {FileInputStream in = new FileInputStream(filename);InputStreamReader is = new InputStreamReader(in, code);BufferedReader br = new BufferedReader(is);if(!new File(filename).exists()){return null;}else{while(br.ready()){sb.append(br.readLine()).append("\n");}br.close();return sb.toString();}} catch (FileNotFoundException e) {e.printStackTrace();}catch (UnsupportedEncodingException e) {e.printStackTrace();}catch (IOException e) {e.printStackTrace();}return null;}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.activity_view_file, menu);return true;}}activity_list_all_file.xml<LinearLayoutxmlns:android="/apk/res/android"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".ListAllFileActivity"><ListViewandroid:id="@+id/fileList"android:layout_width="fill_parent"android:layout_height="fill_parent"></ListView></LinearLayout>activity_main.xml<LinearLayoutxmlns:android="/apk/res/android"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity"><Buttonandroid:id="@+id/openFile"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="点击浏览SD卡上的所有文件"/></LinearLayout>activity_view_file.xml<?xml version="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><ScrollView android:layout_width="fill_parent"android:layout_height="fill_parent"><TextView android:id="@+id/view_contents"android:layout_width="fill_parent"android:layout_height="fill_parent"android:textSize="18sp"></TextView></ScrollView></LinearLayout>当然不要忘了在AndroidManifest.xml配置activity。
保密类别______ 编号________本科毕业论文基于Android平台的电子书阅读器设计院(系)别传媒技术学院专业数字媒体技术班级08数媒技术〔影视〕姓名王哲学号201010014指导教师王莉莉中国传媒大学南广学院2012年4 月12 日摘要在科技日益发达的今天,社会竞争越来越激烈,这要求人们不断的摄取信息来充实自己。
要求人们能随时随地的了解并获取所需的信息。
在这种情况下,电子书阅读器刚好满足了人们便捷地获取信息的需求。
本文设计的电子书阅读器是基于Android平台设计的,Android平台是目前发展最快、最具市场前景的智能操作系统。
本系统是根据Google Android 平台用户的喜好和其平台的特性而设计的,在Google Android平台自带的SDK1.5环境下,运用Eclipse,Photoshop等相关工具进行开发的。
本文介绍了Google Android 开发的流程,讨论了基于Android平台应用程序开发的关键技术,对电子书阅读器做了详细的需求分析,并重点介绍了基于Android 平台的电子书阅读器的总体设计,主要包括电子书阅读器的架构设计、各功能模块的设计与实现。
本文设计的电子书阅读器通过了功能和性能方面的测试,证明了本文设计方案的可行性。
通过对基于Android平台电子书阅读器的设计与实现的介绍,希望能为今后开发出功能更强大的阅读器提供有益的借鉴。
关键词:Android平台;电子书阅读器;JavaABSTRACTToday,it’s a more advanced in technology, increasingly competitive society, which requires people to the intake of information to enrich themselves. Requires people to always be in the know and get the required information. In this case, the news reader just to meet the needs of people know of external objects. In this paper the ebook reader is mobile phone design based on the Android platform of the design, Android platform is the fastest developing, the most market prospect of smartphone operating system.In this system, Google Android platform is based on the user's preferences and characteristics of its platform designed, in Google Android platform, comes with SDK1.5 environment, the use of the Eclipse, PhotoShop and other tools for development. This article introduces the development process of the Google Android, discusses the application development based on the Android platform of the key technology, to do a detailed analysis of the demand for Mobile phone ebook and introduces the focus on Mobile phone ebook reader overall’s design. includes the ebook reader mobile phone design mainly, architecture design and the function of the system.In this paper the ebook reader through mobile phone design of the function and performance test, proved the feasibility of this design. Through to the Android platform based on mobile phone ebook reader design and implementation of the introduction, the hope for the development in the future more powerful offer beneficial reference for the reader.Keywords :Android; E-book reader; Java目录摘要 (I)ABSTRACT (II)绪论 (1)(一)课题研究背景及意义 (1)(二)国内外研究现状 (1)(三)论文组织结构及安排 (3)一、相关理论及关键技术 (3)(一)Andriod特征 (3)(二)Andriod架构 (4)(三)Andriod应用的构成和工作机制 (6)(四) Andriod 平台控件研究 (8)二、电子阅读器需求分析 (9)(一)概述 (9)(二) 阅读器功能需求 (9)(三) 性能需求 (13)三、电子书阅读器总体设计 (13)(一)软件架构设计 (13)(二)软件结构设计 (14)(三)功能模块设计 (15)(四)系统数据流设计 (15)四、电子书阅读器的设计与实现 (15)(一)数据库设计 (15)(二)关键代码实现 (17)五、系统测试 (26)(一)Android 系统测试之打断事件 (26)(二)测试中发现的问题及修复 (27)(三)本程序的扩展功能 (27)(四)测试结果 (28)结语 (31)参考文献 (32)后记 (33)绪论已经成为了生活中不可缺少的通讯设备,没有有时会让人觉得寸步难行。
android 电子书源码,翻页效果2014/02/21 0这两天模仿着做了一个apk 电子书的应用,有翻页效果,本来是想学一下自己写的,无奈,最后偷懒使用了别人写的翻页类PageWidget.java下面是工程文件的结构这个是写的类的包结构,PageView.java 类本类是打算自己写的,然后学习安卓动画效果,但是由于时间加上懒,再加上看晕了,就使用了别人写的PageWidger.java类。
来源我忘了,当时搜索到的,本来是打算学习的。
好了下面,插入代码:HomeActivity.javapackage com.horse;import com.horse.R;import com.horse.bean.Book;import com.horse.dialog.AboutDialog;import android.app.Activity;import android.app.Dialog;import android.content.Intent;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.AdapterView;import android.widget.ListView;import android.widget.TextView;importandroid.widget.AdapterView.OnItemClickListener;public class HomeActivity extends Activity {private ListView booklistLv;private TextView booknameTv;private Book book;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.home_activity);booklistLv = (ListView) findViewById(R.id.booklist_lv);booknameTv = (TextView) findViewById(R.id.bookname_tv);book = Book.getInstance();booklistLv.setOnItemClickListener(itemListener);init();}private void init() {booknameTv.setText(book.getBookname());fillBooklistLv();}private void fillBooklistLv(){BooklistAdapter bAdapter = new BooklistAdapter(book.getChapterList(),this);booklistLv.setAdapter(bAdapter);}private。
毕业设计基于Android平台的手机电子书阅读器的设计与实现附外文文献及中文翻译摘要在这个信息化的时代,计算机越来越精致,手机也越来越智能化,所以,一个较好的应用软件在很大程度上能提升一个手机的品牌。
而在智能手机上安装一个拥有丰富功能支持的电子书阅读器,更是我们刻不容缓的事情。
本设计采用Android平台,根据对手机电子书阅读器的客户需求分析和技术可行性分析,经过总体设计和详细设计编码测试等阶段,完成了电子书阅读器软件的设计。
不仅实现了电子书阅读器最基本的阅读功能,而且还为用户提供了丰富的功能支持,包括找书,书签,自动翻页以及阅读界面设置的操作。
而本次设计最大的特点则是通过屏幕触控实现了移动时的翻页特效。
经过不断的测试与完善,电子书阅读器功能稳定,并且在真机上对其进行了测试与验证,基本上达到了用户的需求标准。
关键词:Android;电子书阅读器;屏幕触控;翻页;AbstractIn the time of information technology, with the increasingly sophisticated of computers and more and more intelligent of mobile phones, a better application software can enhance a brand of the phone to large extent. It is our urgent for us that installed on the smart-phone has a rich functionality to support the e-book reader.Based on the needs analysis of customers and technical feasibility analysis, I use the Android platform to achieve the design of mobile phone’s e-book reader. After completing the overall design and detailed design coding testing stage, I achieved the design of the e-book reader software. Not only can the soft achieve the basic function of E-book reader, but also offer many other functions for users, including books and bookmarks, flipping pages automatically and designing the reader. The significant character of the design achieve the flipping page of mobile by touching screen Through continuous testing and improvement, E-book reader is stable. The testing and verification in real device has carried out to meet the customers’ requirements which have reached the standards of the customers’ requirements. Key words: Android; e-book Reader; Touch Screen; Flip目录第1章前言 (1)1.1课题提出的背景目的及意义 (1)1.1.1 课题提出的背景 (1)1.1.2 课题提出的目的 (1)1.1.3 课题提出的意义 (1)1.2设计思路及研究方法 (2)1.2.1 设计思路 (2)1.2.2 研究方法 (2)第2章需求分析 (1)2.1软件的基本功能要求 (1)2.2系统架构 (2)2.3开发环境 (2)第3章软件设计 (3)3.1总体软件结构设计 (3)3.2接口设计 (4)3.2.1 外部接口 (4)3.2.2 内部接口 (5)3.3数据库设计 (5)3.3.1 数据模式设计 (5)3.3.2 数据表格设计 (5)3.3.3 表的具体设计 (6)3.3.4 数据字典 (6)3.4软件设计模型 (7)3.5代码设计 (8)3.6软件维护设计 (8)第4 章系统功能模块的设计与实现 (9)4.1关键技术 (9)4.1.1 android平台及java语言 (9)4.1.2 中介软件 (9)4.1.3 四大组件 (10)4.1.4 sqlite3 数据库 (10)4.1.5 Tomcat服务器 (10)4.2欢迎界面的实现 (11)4.3主控制类的实现 (11)4.4工具类的设计 (12)4.5阅读界面的实现 (12)4.6找书功能的实现 (13)4.7书签功能的实现 (14)4.8设置字体大小功能的实现 (15)4.9更换背景图片以及设置字体颜色功能的实现 (16)4.10音乐播放功能的实现 (16)第5章系统测试 (1)5.1欢迎界面 (1)5.2用户阅读界面 (1)毕业设计总结 (1)参考文献 (1)附录一核心代码 (1)附录二毕业设计外文翻译(英文) (1)附录三毕业设计外文翻译(中文) (8)致谢 (1)第1章前言1.1 课题提出的背景目的及意义1.1.1 课题提出的背景在这个信息化的时代,IT业已经成为世界发展的主流,我们对信息技术的依赖远远超过了对我们自己的依赖,计算机和手机已经成为我们日常生活中不可缺少的获得信息的渠道。
摘要基于Android平台的电子书管理及阅读系统,是采用JA V A语言开发的一个小型应用系统。
在科技日益发展的今天,社会竞争越来越激烈,3G时代已经慢慢融入了我们的日常生活。
手机已经成为人们日常生活中不可缺少的一部分,尤其是在电子产品日新月异的今天,我们在平时随处可见的电子产品中,手机无疑是一个最大的用户集,而各大厂商智能手机则依旧是电子商场的一个耀眼明星。
其中代表作有微软的WP7系统,苹果的IOS系统,但是其中Google的Android系统以其开放的源代码和方便简洁的操作成为手机领域的领头羊。
所以我选择了这个题目作为毕业设计的题目,并希望再进一步完善系统后将系统发布到Google android market上供用户下载使用。
据了解,越来越多的年轻人喜欢阅读小说,本系统则根据用户需求及平台的特性而设计的,在Google Android SDK2.1环境下,运用Eclipse,PhotoShop等相关工具进行开发。
同时解决了大型书籍载入、动态分页等众多技术难题。
该系统在Android手机上运行,由于手机性能及内存的瓶颈,在设计方面,本系统进行了相应的优化处理,以减少不必要的内存损耗,尽可能的使其在手机上能够流畅运行,增强友好度,方便用户使用。
关键词:电子书,安卓,JAVA。
AbstractBased on the E-book management and reading system of Android platform is a small application system which adopt to a development language of JAVA . Increasing development in technology today , more and more competitive , 3G era has been slowly integrated into our daily lives . Mobile phones have become an indispensable daily part of life , especially in the rapidly changing electronic products today , we usually ubiquitous in electronic products , mobile phone users is undoubtedly one of the largest sets , the major smartphone manufacturers of electronic markets is still a bright star . Representative has the promise of which Microsoft’s WP7 system , Apple’s IOS system , but is still sudden emergence of Google's Android open source system for its simplicity and ease of operation has become the leader in the field of smart phones . so i chose this topic as the subject of graduation and hopes to further improve the system will be posted to the Google android market system for refence by users download .It is understood that more and more young people like to read novels , the system is based on user needs and characteristics of platform design , in Google Android SDK2.1 environment , the use of the Eclipse , PhotoShop and other tools for development . While addressing a large load of books , dynamic pages , and many other technical problems .The system runs on Android phones , because mobile performance and memory bottlenecks , in terms of design , the system was optimized accordingly , to reduce unnecessary memory loss , as much as possible so that it can run smoothly on thephone , and enhance Friendliness , user-friendly .Key words: E-book, Android, JAVA.目录1 前言 (1)2 可行性分析 (2)2.1 开发前景 (2)2.2 市场可行性 (2)2.3 技术可行性 (3)2.3.1 Android基本框架 (3)2.3.2 Android系统的四大组件 (5)3 系统分析 (7)3.1 功能需求(用例图分析) (7)3.1.1 书库管理需求 (7)3.1.2 阅读的基本功能需求 (8)3.1.3 SD卡内电子书清单管理需求 (9)3.2 系统流程图和结构图 (10)3.3 系统界面需求 (12)3.4 系统性能需求 (12)3.5 运行环境需求 (12)4 数据库设计 (13)4.1 Android SQLite概述 (13)4.2 Android SQLite特征及内部结构 (13)4.3 数据库概念模型 (16)4.4 数据库字段设计 (17)4.4.1 电子书信息表 (17)4.4.2 书签信息表 (18)5 系统功能详细设计 (19)5.1 系统主界面功能实现 (19)5.1.1 系统主界面 (19)5.1.2 工具栏 (21)5.1.3 OptionsMenu (22)5.2 手机扩展卡访问 (22)5.2.1本地书目的显示 (22)5.2.2 刷新本地书目 (24)5.2.3 本地书目的导入 (25)5.3 文章载入及翻页实现 (27)5.3.1 文章载入 (28)5.3.2 手势识别 (30)5.4 阅读设置功能实现 (31)5.4.1 字体设置 (32)5.4.2 亮度设置 (33)5.4.3 书签 (34)5.4.4 跳转 (36)5.4.5 横、竖屏翻页切换 (37)5.5 其它功能点实现 (38)5.5.1 回退键的重写 (38)5.5.2 快捷方式及书目删除 (39)5.5.3 SharedPreferences (40)6 系统测试 (42)6.1 测试环境 (42)6.2 超大文件载入 (42)6.3 书目损坏或为空 (42)6.4 关于 (43)7 总结 (44)致谢.................................................................................................... 错误!未定义书签。
基于Android的电子书阅读器的设计与实现作者:马鸣钱鸽来源:《电脑知识与技术》2012年第27期摘要:Android系统是一个层次的软件集,所以先从层次方面对Android进行系统研究;其次,通过对Android平台上应用的开发,更进一步了解Android这个系统。
此次基于Android平台的电子书阅读器的设计与实现主要通过Eclipse开发工具, Java语言与Sqlite数据库来完成的。
本阅读器实现了本地阅读,手动翻页,书签的添加、查看、删除,自动翻页,书架,快速定位,及在线下载。
本文主要介绍程序的设计思路、逻辑、架构、及数据库的设计与整体的实现流程。
最后进一步阐述Android电子阅读器对文化发展的影响及其市场价值。
关键词:Android;电子阅读器; java; sqlite;书签中图分类号:TP311文献标识码:A文章编号:1009-3044(2012)27-6533-05Design and Realization of the Ebook Reader Based on AndroidMA Ming, QIAN Ge(Nanyang Institute of Technology, Nanyang 473004, China)Abstract:The Android system is a hierarchical software set, so doing system research on the levels of Android come to first; Sec? ondly, leaning more about the development of applications on the Android platform, a better understanding of the Android Sys? tem. The completed of the design and realization of e-book reader based on the Android platform mainly by using the Eclipse development tools, Java language and Sqlite database. The e-book reader has realized the locality reading, manual page, add bookmark, quiry, delete, auto flip, bookshelf, rapid positioning, and online download. This article mainly introduces the thinking and logic, architecture of the program design, the design of the database and the whole realization process. Finally, further elabo? rates the influence of Android e-reader on the cultural development and their marketable value.Key words: Android; Ebook reader; java; Sqlite; bookmark1概述电子书和电子书阅读器早在上世纪90年代就已经出现,它以其环保、容量大、携带方便等特点迅速吸引广大阅读爱好者的青睐,经过多年的发展,各种不同版本的电子书相继出现,使得电子书阅读器的风格、界面更加完善接近真实,并给用户带来了非凡的体验[1]。
基于Android平台的手机电子书阅读器代码package com.lrc.view;/*** 书籍阅读*/import java.io.IOException;import ng.reflect.Array;import java.math.BigDecimal;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Vector;import java.util.regex.Matcher;import java.util.regex.Pattern;import com.lrc.R;import com.lrc.bll.BookPageFactory;import com.lrc.bll.DbDataOperation;import com.lrc.bll.DbTags;import com.lrc.bll.PageWidget;import com.lrc.util.ArrayUtil;import com.lrc.util.BgUtil;import com.lrc.util.MathUtil;import com.lrc.util.TimeUtil;import android.app.Activity;import android.app.AlertDialog;import android.content.ContentResolver;import android.content.ContentValues;import android.content.DialogInterface;import android.content.Intent;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Color;import .Uri;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.provider.Settings;import android.util.DisplayMetrics;import android.util.Log;import android.view.Gravity;import android.view.KeyEvent;import android.view.Menu;import android.view.MotionEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnTouchListener;import youtParams;import android.view.Window;import android.view.WindowManager;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener; import android.widget.EditText;import android.widget.GridView;import android.widget.ImageButton;import android.widget.LinearLayout;import android.widget.PopupWindow;import android.widget.ProgressBar;import android.widget.SeekBar;import android.widget.SimpleAdapter;import android.widget.TextView;import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.Toast;public class BookReadActivity extends Activity{private PageWidget mPageWidget;Bitmap mCurPageBitmap, mNextPageBitmap;Canvas mCurPageCanvas, mNextPageCanvas;public static BookPageFactory pagefactory;int screenWidth ,screenHeight;int bookId;String bookPath,bookName,bookProgress;private int bookBeginPosition;//dbprivate ContentResolver resolver;//tabMenupublic final static int TITLE_USING_OFTEN = 0;public final static int TITLE_TOOLS = 1;public final static int MENU_FONT_SIZE = 0;public final static int MENU_READ_THEME = 1;public final static int MENU_BRIGHTNESS_CONTROL = 2;public final static int MENU_FLIP_OVER = 3;public final static int MENU_JUMP = 4;public final static int MENU_SEARCH = 5;public final static int MENU_PRE_CHAPTER = 6;public final static int MENU_NEXT_CHAPTER= 7;public final static int MENU_CUSTOM_THEME = 0;public final static int MENU_AUDIO_BOOK = 1;public final static int MENU_BOOK_CHAPTER = 2;public final static int MENU_BOOK_CODE = 3;public final static int MENU_BOOK_MARK = 4;public final static int MENU_SETTING = 5;public final static int MENU_SHARE = 6;public final static int MENU_BACK = 7;TabMenu.MenuBodyAdapter []bodyAdapter=new TabMenu.MenuBodyAdapter[2];TabMenu.MenuTitleAdapter titleAdapter;TabMenu tabMenu;int selTitle=0;PopupWindow popupWindow;//定义每项分页栏的内容String[] title1BodyName , title2BodyName;int[] title1BodyIcon , title2BodyIcon;private SeekBar sbFontSize,sbBrightnessControl,sbJump;//menu jumpprivate TextView tvCurrentProgress ;private ImageButton ibtnJumpUp,ibtnJumpDown;//flip overprivate Handler readHandler = new Handler();private FlipOverRunnable flipOverRunnable = new FlipOverRunnable();private boolean isRead = true;//menu custom themeprivate SeekBar redForegroundSeekBar,greenForegroundSeekBar,blueForegroundSeekBar, redBackgroundSeekBar,greenBackgroundSeekBar,blueBackgroundSeekBar;int currentProgress;private TextView fontColorTxt,backgroundColorTxt,themeStyleTxt ;private int redForegoundProgress,greenForegroundProgress,blueForegroundProgress, redBackgoundProgress,greenBackgroundProgress,blueBackgroundProgress;private String foreColor,foreR="00",foreG="00",foreB="00",backColor,backR="00",backG="00",backB="00";private int currentForeColorId,currentBackColorId;//chapterPattern pattern = pile("第{1}.+章{1}.+");Matcher matcher;List<String> chapterName = new ArrayList<String>();List<Integer> chapterBeginPositions = new ArrayList<Integer>();Vector<String> lines;int chapterNum = 0;private AlertDialog chapterDialog;private String currentChapterName = "wu";private int currentBeginPosition = 0;Handler chapterHandler = new Handler(){@Overridepublic void handleMessage(Message msg){super.handleMessage(msg);if(msg.what == 0){// updateView();showChapterDialog();}else if(msg.what == 1){chapterDialog.setMessage("正在提取章节,请稍后...\n已发现章节:["+chapterNum+"] "+currentChapterName);}else if(msg.what == 2){mPageWidget.invalidate();}}};//pre and next chapterprivate String currentChapter;private int currentChapterIndex;private boolean preOrNext = true;Handler preHandler = new Handler(){@Overridepublic void handleMessage(Message msg){super.handleMessage(msg);for(int i=0;i<chapterName.size();i++){if(chapterName.get(i).equals(currentChapter)){currentChapterIndex = i;Log.i("chapter"+i+"-->",currentChapterIndex+"");break;}}if(currentChapterIndex==0){new AlertDialog.Builder(BookReadActivity.this).setTitle("提示").setMessage("已是第一章!").setPositiveButton("确定", null).show();}else{pagefactory.setM_mbBufBegin(chapterBeginPositions.get(currentChapterIndex-1));updateView();}}};Handler nextHandler = new Handler(){@Overridepublic void handleMessage(Message msg){super.handleMessage(msg);for(int i=0;i<chapterName.size();i++){Log.i("name"+i,chapterName.get(i));if(chapterName.get(i).equals(currentChapter)){currentChapterIndex = i;Log.i("chapter"+i+"-->",currentChapterIndex+"");break;}}if(currentChapterIndex==(chapterName.size()-1)){new AlertDialog.Builder(BookReadActivity.this).setTitle("提示").setMessage("已是最后一章!").setPositiveButton("确定", null).show();}else{pagefactory.setM_mbBufBegin(chapterBeginPositions.get(currentChapterIndex+1));updateView();}}};@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);resolver = getContentResolver();requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(youtParams.FLAG_FULLSCREEN,WindowMan youtParams.FLAG_FULLSCREEN);mPageWidget = new PageWidget(this);setContentView(mPageWidget);DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);screenWidth = dm.widthPixels;screenHeight = dm.heightPixels;mCurPageBitmap = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888);mNextPageBitmap = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888);mCurPageCanvas = new Canvas(mCurPageBitmap);mNextPageCanvas = new Canvas(mNextPageBitmap);pagefactory = new BookPageFactory(screenWidth, screenHeight);pagefactory.setBgBitmap(BgUtil.getSuitableBg(this,screenWidth,screenHeight,R.drawable.re ad_bg_3));try{bookPath = getIntent().getExtras().getString(DbTags.FIELD_BOOK_PATH);bookName = getIntent().getExtras().getString(DbTags.FIELD_BOOK_NAME);bookId = getIntent().getExtras().getInt(DbTags.FIELD_BOOK_ID);bookProgress = getIntent().getExtras().getString(DbTags.FIELD_BOOK_PROGRESS);bookBeginPosition = getIntent().getExtras().getInt(DbTags.FIELD_BOOK_BEGIN_POSITION);pagefactory.openbook(bookPath);if(bookProgress==null||bookProgress.equals("onlyRead")){pagefactory.onDraw(mCurPageCanvas);System.out.println("1");}else if(bookProgress.equals("begin")){pagefactory.setM_mbBufBegin(getIntent().getIntExtra("begin", 0));updateView();System.out.println("2");}else{pagefactory.setM_mbBufBegin(bookBeginPosition);System.out.println("3");updateView();}}catch (IOException e1){e1.printStackTrace();Toast.makeText(this, "电子书不存在",Toast.LENGTH_SHORT).show();}mPageWidget.setBitmaps(mCurPageBitmap, mCurPageBitmap);mPageWidget.setOnTouchListener(new OnTouchListener(){public boolean onTouch(View v, MotionEvent e){boolean ret=false;if(popupWindow==null||!popupWindow.isShowing()){if (v == mPageWidget){if (e.getAction() == MotionEvent.ACTION_DOWN) {mPageWidget.abortAnimation();mPageWidget.calcCornerXY(e.getX(), e.getY());pagefactory.onDraw(mCurPageCanvas);if (mPageWidget.DragToRight()){try{pagefactory.prePage();}catch (IOException e1){e1.printStackTrace();}if(pagefactory.isfirstPage()){// Toast.makeText(BookReadActivity.this, "已到第一页!", 200).show();return false;}pagefactory.onDraw(mNextPageCanvas);} else{try{pagefactory.nextPage();}catch (IOException e1){e1.printStackTrace();}if(pagefactory.islastPage()){// Toast.makeText(BookReadActivity.this, "已到最后一页!", 200).show();return false;}pagefactory.onDraw(mNextPageCanvas);}mPageWidget.setBitmaps(mCurPageBitmap, mNextPageBitmap);}ret = mPageWidget.doTouchEvent(e);return ret;}}return false;});//设置分页栏的标题titleAdapter = new TabMenu.MenuTitleAdapter(this, new String[] { "常用","工具",}, 16, 0xFF222222,Color.LTGRAY,Color.BLACK);//定义每项分页栏的内容title1BodyName = new String[] { "字体大小", "阅读主题", "亮度调节","开始翻页","跳转","搜索","上一章","下一章"};title1BodyIcon = new int[] { R.drawable.menu_fontsize,R.drawable.menu_theme,R.drawable.menu_light,R.drawable.menu_ play,R.drawable.menu_jump,R.drawable.menu_search,R.drawable.menu_pre,R.drawable.menu_next};title2BodyName = new String[] { "自定主题", "开始朗诵","章节目录", "文章编码", "书签", "设置", "分享", "退出"};title2BodyIcon = new int[] { R.drawable.menu_theme,R.drawable.menu_play, R.drawable.menu_extract, R.drawable.menu_charset, R.drawable.menu_bookmark, R.drawable.menu_setting, R.drawable.menu_share, R.drawable.menu_exit};bodyAdapter[0]=newTabMenu.MenuBodyAdapter(this,title1BodyName,title1BodyIcon,12, 0xFF000000);bodyAdapter[1]=newTabMenu.MenuBodyAdapter(this,title2BodyName,title2BodyIcon,12, 0xFF000000);tabMenu=new TabMenu(this,new TitleClickEvent(),new BodyClickEvent(),titleAdapter,0xFFFFFFFF,//TabMenu的背景颜色R.style.PopupAnimation);//出现与消失的动画tabMenu.update();tabMenu.setTitleSelect(0);tabMenu.SetBodyAdapter(bodyAdapter[0]);}class TitleClickEvent implements OnItemClickListener{public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3){selTitle=arg2;tabMenu.setTitleSelect(arg2);tabMenu.SetBodyAdapter(bodyAdapter[arg2]);}class BodyClickEvent implements OnItemClickListener ,View.OnClickListener{MySeekBarChangedListener seekBarChangedListener = new MySeekBarChangedListener();//Bg Drawableint[] bgs = new int[]{R.drawable.read_bg_1,R.drawable.read_bg_2,R.drawable.read_bg_3,R.drawable.read_bg_6, R.drawable.read_bg_7};int[] styles = new int[]{R.drawable.style01,R.drawable.style02,R.drawable.style03,R.drawable.style06,R.drawable.s tyle07};String[] styleName = new String[]{"羊皮纸","粉红回忆","蓝色幻想","咖啡时光","水墨江南"};GridView gvReadTheme;//searchEditText etSearchContent;ImageButton ibtnSearch,ibtnSearchBack,ibtnSearchForward,ibtnSearchClear;public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3){tabMenu.setBodyClick(position,Color.GRAY);if(selTitle==TITLE_USING_OFTEN){if(position==MENU_FONT_SIZE){LinearLayout fontSizeView = null;if(fontSizeView==null)fontSizeView = (LinearLayout)getLayoutInflater().inflate(yout.fontsize_view, null);showPopupWindowAtBottom(fontSizeView,LayoutParams.FILL_PARENT,100,Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,0);popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_listview ));sbFontSize = (SeekBar) fontSizeView.findViewById(R.id.fontSizeProgress);sbFontSize.setProgress(pagefactory.getM_fontSize());sbFontSize.setOnSeekBarChangeListener(seekBarChangedListener);}else if(position==MENU_READ_THEME){LinearLayout readThemeView = null;if(readThemeView==null)readThemeView = (LinearLayout)getLayoutInflater().inflate(yout.read_theme_view, null);gvReadTheme = (GridView) readThemeView.findViewById(R.id.gvReadTheme);List<Map<String,Integer>> themeList = new ArrayList<Map<String,Integer>>();for(int i=0;i<styles.length;i++){Map<String,Integer> themeMap = new HashMap<String,Integer> ();themeMap.put("themeStyle", styles[i]);themeList.add(themeMap);}SimpleAdapter simpleAdapter = new SimpleAdapter(BookReadActivity.this,themeList,yout.theme_imageview,new String[]{"themeStyle"},new int[]{R.id.themeStyle});gvReadTheme.setAdapter(simpleAdapter);gvReadTheme.setOnItemClickListener(new OnItemClickListener(){public void onItemClick(AdapterView<?> parent,View view, int position, long id){Toast.makeText(BookReadActivity.this, styleName[position], 50).show();pagefactory.setM_backColor(0x000000);pagefactory.setBgBitmap(BgUtil.getSuitableBg(BookReadActivity.this,screenWidth,screenH eight,bgs[position]));updateView();}});showPopupWindowAtBottom(readThemeView,LayoutParams.FILL_PARENT,110,Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,0);popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_listview ));popupWindow.setFocusable(true);}else if(position==MENU_BRIGHTNESS_CONTROL){LinearLayout brightnessControlView = null;if(brightnessControlView==null)brightnessControlView = (LinearLayout)getLayoutInflater().inflate(yout.brightness_control_view, null);showPopupWindowAtBottom(brightnessControlView,LayoutParams.FILL_PARENT,100,Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,0);popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_listview ));sbBrightnessControl = (SeekBar) brightnessControlView.findViewById(R.id.brightnessControlProgress);sbBrightnessControl.setProgress((int)(android.provider.Settings.System.getInt(getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, 255) ));sbBrightnessControl.setOnSeekBarChangeListener(seekBarChangedListener);}else if(position==MENU_FLIP_OVER){if(isRead){readHandler.postDelayed(flipOverRunnable, 1000);isRead = false;title1BodyName[MENU_FLIP_OVER] = "停止阅读";title1BodyIcon[MENU_FLIP_OVER] = R.drawable.menu_stop;Toast.makeText(BookReadActivity.this, "开始阅读", 500).show();}else{readHandler.removeCallbacks(flipOverRunnable);isRead = true;title1BodyName[MENU_FLIP_OVER] = "开始阅读";title1BodyIcon[MENU_FLIP_OVER] = R.drawable.menu_play;Toast.makeText(BookReadActivity.this, "停止阅读", 500).show();}bodyAdapter[0]=newTabMenu.MenuBodyAdapter(BookReadActivity.this,title1BodyName,title1BodyIcon,12,0xFF000000);tabMenu.SetBodyAdapter(bodyAdapter[0]);}else if(position==MENU_JUMP){LinearLayout bookJumpView = null;if(bookJumpView==null)bookJumpView = (LinearLayout)getLayoutInflater().inflate(yout.bookskip_byprogress_view, null);showPopupWindowAtBottom(bookJumpView,LayoutParams.FILL_PARENT,130,Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,0);popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_listview ));tvCurrentProgress = (TextView)bookJumpView.findViewById(CurrentProgress);ibtnJumpUp = (ImageButton)bookJumpView.findViewById(R.id.ibtnJumpUp);ibtnJumpDown = (ImageButton)bookJumpView.findViewById(R.id.ibtnJumpDown);sbJump = (SeekBar) bookJumpView.findViewById(R.id.sbJump);String currentProgress = pagefactory.getStrPercent();String temp = currentProgress.split("%")[0];//去除掉%sbJump.setProgress((int)(Float.parseFloat(temp)*1000)/100);sbJump.setOnSeekBarChangeListener(seekBarChangedListener);tvCurrentProgress.setText(currentProgress);ibtnJumpUp.setOnClickListener(new OnClickListener(){public void onClick(View v){sbJump.setProgress(sbJump.getProgress()+1);}});ibtnJumpDown.setOnClickListener(new OnClickListener(){public void onClick(View v){sbJump.setProgress(sbJump.getProgress()-1);}});}else if(position==MENU_SEARCH){//方式1Intent intent = new Intent(BookReadActivity.this,SearchActivity.class);intent.putExtra(DbTags.FIELD_BOOK_PATH, bookPath);startActivity(intent);//方式2// LinearLayout bookSearchView = null;// if(bookSearchView==null)// bookSearchView = (LinearLayout)getLayoutInflater().inflate(yout.search_view, null);// etSearchContent = (EditText)bookSearchView.findViewById(R.id.etSearchContent);// ibtnSearch = (ImageButton)bookSearchView.findViewById(R.id.ibtnSearch);// ibtnSearch.setOnClickListener(this);//showPopupWindowAtBottom(bookSearchView,LayoutParams.FILL_PARENT,// 70,Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,pagefactory.getmWidth());}else if(position==MENU_PRE_CHAPTER){preOrNext = true;if(chapterName.size()<=0){new AlertDialog.Builder(BookReadActivity.this).setTitle("提示").setMessage("章节还未提取,请先提取章节").setPositiveButton("确定", new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialog, int which){}}).show();}else{getCureentChapter();}}else if(position==MENU_NEXT_CHAPTER){preOrNext = false;if(chapterName.size()<=0){new AlertDialog.Builder(BookReadActivity.this).setTitle("提示").setMessage("章节还未提取,请先提取章节").setPositiveButton("确定", new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialog, int which){}}).show();}else{getCureentChapter();}}}else if(selTitle==TITLE_TOOLS){if(position==MENU_CUSTOM_THEME){LinearLayout customThemeLayout = (LinearLayout)getLayoutInflater().inflate(yout.customtheme_view, null);redForegroundSeekBar = (SeekBar)customThemeLayout.findViewById(R.id.redForegroundSeekBar);greenForegroundSeekBar = (SeekBar)customThemeLayout.findViewById(R.id.greenForegroundSeekBar);blueForegroundSeekBar = (SeekBar)customThemeLayout.findViewById(R.id.blueForegroundSeekBar);redBackgroundSeekBar = (SeekBar)customThemeLayout.findViewById(R.id.redBackgroundSeekBar);greenBackgroundSeekBar = (SeekBar)customThemeLayout.findViewById(R.id.greenBackgroundSeekBar);blueBackgroundSeekBar = (SeekBar)customThemeLayout.findViewById(R.id.blueBackgroundSeekBar);fontColorTxt = (TextView)customThemeLayout.findViewById(R.id.fontColorTxt);backgroundColorTxt = (TextView)customThemeLayout.findViewById(R.id.backgroundColorTxt);themeStyleTxt = (TextView)customThemeLayout.findViewById(R.id.themeStyleTxt);redForegroundSeekBar.setOnSeekBarChangeListener(seekBarChangedListener);greenForegroundSeekBar.setOnSeekBarChangeListener(seekBarChangedListener);;blueForegroundSeekBar.setOnSeekBarChangeListener(seekBarChangedListener);;redBackgroundSeekBar.setOnSeekBarChangeListener(seekBarChangedListener);;greenBackgroundSeekBar.setOnSeekBarChangeListener(seekBarChangedListener);;blueBackgroundSeekBar.setOnSeekBarChangeListener(seekBarChangedListener);;AlertDialog ad = new AlertDialog.Builder(BookReadActivity.this).create();ad.setView(customThemeLayout);ad.setButton("确定", new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialog, int which){pagefactory.getmPaint().setColor(currentForeColorId);pagefactory.setM_book_bg(null);pagefactory.setM_backColor(currentBackColorId);updateView();}});ad.setButton2("取消", new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialog, int which){}});ad.show();}else if(position==MENU_AUDIO_BOOK){}else if(position==MENU_BOOK_CHAPTER){if(chapterName.size()<=0){chapterDialog = new AlertDialog.Builder(BookReadActivity.this).create();chapterDialog.setMessage("正在提取章节,请稍后...");chapterDialog.show();new Thread(new Runnable(){public void run(){pagefactory.setM_mbBufBegin(0);Vector<String> upLines = pagefactory.pageUp();for(int j=0;j<upLines.size();j++){currentBeginPosition+=upLines.get(j).length();}while(!pagefactory.isM_islastPage()){lines= pagefactory.pageDown();// chapterHandler.sendEmptyMessage(2);if(lines.size()>0){for(int i=0;i<lines.size();i++){matcher = pattern.matcher(lines.get(i));if(i==0)currentBeginPosition+=lines.get(i).length();elsecurrentBeginPosition+=lines.get(i-1).length()+lines.get(i).length();if(matcher.find()){currentChapterName = matcher.group();chapterName.add(currentChapterName);chapterBeginPositions.add(currentBeginPosition);chapterNum++;chapterHandler.sendEmptyMessage(1);}}}else{pagefactory.setM_islastPage(true);chapterDialog.dismiss();chapterHandler.sendEmptyMessage(0);break;}}}}).start();}else{showChapterDialog();}}else if(position==MENU_BOOK_CODE){}else if(position==MENU_BOOK_MARK){if(bookProgress.equals("onlyRead")){new AlertDialog.Builder(BookReadActivity.this).setTitle("提示").setMessage("电子书书未添加到书架,无法添加书签").setPositiveButton("确定", null).show();}else{ContentValues values = new ContentValues();values.put(DbTags.FIELD_BOOK_ID, bookId);values.put(DbTags.FIELD_BOOK_NAME, bookName);System.out.println("name -->"+bookName);values.put(DbTags.FIELD_BOOK_PA TH, bookPath);values.put(DbTags.FIELD_BOOK_MARK_ADD_TIME, TimeUtil.getCurrentTime());values.put(DbTags.FIELD_BOOK_MARK_PROGRESS, pagefactory.getStrPercent());values.put(DbTags.FIELD_BOOK_MARK_BEGIN_POSITION, pagefactory.getM_mbBufBegin());try{pagefactory.nextPage();} catch (IOException e){e.printStackTrace();}Vector<String> details = pagefactory.pageUp();values.put(DbTags.FIELD_BOOK_MARK_DETAIL,details.get(0));resolver.insert(Uri.parse(DbTags.URI_TABLE_BOOK_MARK), values);Toast.makeText(BookReadActivity.this, "添加书签成功", 200).show();}}else if(position==MENU_SETTING){}else if(position==MENU_SHARE){}else if(position==MENU_BACK){if(!bookProgress.equals("onlyRead")){ContentValues values = new ContentValues();values.put(DbTags.FIELD_BOOK_PROGRESS,pagefactory.getStrPercent());int bookId = getIntent().getExtras().getInt(DbTags.FIELD_BOOK_ID);DbDataOperation.updateV aluesToTable(resolver,(Uri.parse(DbTags.URI_TABLE_BOOK_I NFO)),values, DbTags.FIELD_BOOK_ID+"=?", new String[]{bookId+""});}BookReadActivity.this.finish();}}}@Overridepublic void onClick(View v){if(v==ibtnSearch){popupWindow.dismiss();popupWindow = null;String searchContent = etSearchContent.getText().toString();pagefactory.pageDown();Vector<String> currentPageLines = pagefactory.pageUp();for(int i=0;i<currentPageLines.size();i++){if(currentPageLines.get(i).contains(searchContent)){}}LinearLayout searchControlView = null;if(searchControlView==null)searchControlView = (LinearLayout)getLayoutInflater().inflate(yout.search_control, null);ibtnSearchBack = (ImageButton)searchControlView.findViewById(R.id.ibtnSearchBack);ibtnSearchForward = (ImageButton)searchControlView.findViewById(R.id.ibtnSearchForward);ibtnSearchClear = (ImageButton)searchControlView.findViewById(R.id.ibtnSearchClear);ibtnSearchBack.setOnClickListener(this);ibtnSearchForward.setOnClickListener(this);ibtnSearchClear.setOnClickListener(this);showPopupWindowAtBottom(searchControlView,LayoutParams.FILL_PARENT,100, Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,0);}else if(v==ibtnSearchBack){}else if(v==ibtnSearchForward){}else if(v==ibtnSearchClear){}}}public boolean onCreateOptionsMenu(Menu menu){menu.add("menu");// 必须创建一项return super.onCreateOptionsMenu(menu);}@Override/*** 拦截MENU*/public boolean onMenuOpened(int featureId, Menu menu){if (tabMenu != null){if (tabMenu.isShowing()){tabMenu.dismiss();tabMenu = null;}else{tabMenu.showAtLocation(mPageWidget, Gravity.BOTTOM, 0, 0);}}return false;// 返回为true 则显示系统menu}@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event){if(keyCode==KeyEvent.KEYCODE_BACK){if(popupWindow!=null&&popupWindow.isShowing()){popupWindow.dismiss();popupWindow = null;return true;}if(!bookProgress.equals("onlyRead")){ContentV alues values = new ContentValues();values.put(DbTags.FIELD_BOOK_PROGRESS, pagefactory.getStrPercent());values.put(DbTags.FIELD_BOOK_BEGIN_POSITION,pagefactory.getM_mbBufBegin());DbDataOperation.updateV aluesToTable(resolver,(Uri.parse(DbTags.URI_TABLE_BOOK_I NFO)),values, DbTags.FIELD_BOOK_ID+"=?", new String[]{bookId+""});}}else if(keyCode==KeyEvent.KEYCODE_MENU){if(tabMenu!=null&&tabMenu.isShowing()){tabMenu.dismiss();tabMenu = null;return true;}if(popupWindow!=null&&popupWindow.isShowing()){popupWindow.dismiss();popupWindow = null;return true;}}return super.onKeyDown(keyCode, event);}@Overridepublic boolean onTouchEvent(MotionEvent event){if(popupWindow!=null&&popupWindow.isShowing()){popupWindow.dismiss();popupWindow = null;}return super.onTouchEvent(event);}//SeekBar事件监听器class MySeekBarChangedListener implements OnSeekBarChangeListener{public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser){currentProgress = seekBar.getProgress();if(seekBar==sbFontSize){pagefactory.setM_fontSize(currentProgress);pagefactory.getmPaint().setTextSize(currentProgress);pagefactory.setmLineCount((int)pagefactory.getmVisibleHeight()/pagefactory.getM_fontSize ());Toast.makeText(BookReadActivity.this, currentProgress+" 号", 50).show();updateView();}else if(seekBar==sbBrightnessControl){Toast.makeText(BookReadActivity.this, "亮度:"+currentProgress, 100).show();android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, currentProgress);currentProgress = Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS,-1);youtParams lp = getWindow().getAttributes();if(0<=currentProgress&¤tProgress<=255)。