Android book Reader[Use SimpleOnGestureListener ]



1.Support drug to change page, go to any page by input page number.

2.Support define page font, page content size.

3.Support local drive search.

 

Advantage:

Fast,Only load the content need the show on page.

 

CODE:

extend the listener

		super.onCreate(savedInstanceState);
		mGestureDetector = new GestureDetector(new MyGestureDetector());//use a detector
		context = this;
		setContentView(R.layout.readpage);
.......


class MyGestureDetector extends SimpleOnGestureListener {

		@Override
		public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
				float velocityY) {
			Log.d("ReadPageActivity---", "fling");
			int dx = (int) (e2.getX() - e1.getX());
			// don't accept the fling if it's too short
			// as it may conflict with a button push
			if (Math.abs(dx) > 3 && Math.abs(velocityX) > Math.abs(velocityY)) {
				if (velocityX > 0) {
					Log.d("ReadPageActivity---", "move to the rights");
					if (page != 0) {
						page--;
						gotoNextPage();
					}

				} else {
					Log.d("ReadPageActivity---", "move to the left");
					page++;
					gotoNextPage();
				}
				return true;
			} else {
				return false;
			}
		}

 

Load the text content:

 

			char[] chardata = new char[CONTENT_LENGTH];
			FileInputStream fin = new FileInputStream(textfile);
			InputStreamReader sreader = new InputStreamReader(fin, CODE_SIMPLECHINIESE);
			BufferedReader bufferReader = new BufferedReader(sreader);
			bufferReader.skip(new Long(page * CONTENT_LENGTH).longValue());
			bufferReader.read(chardata);
			tale = new String(chardata);
 

 

 

 



 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值