Android 翻页卷曲 电子书源代码

我的真机测试结果:

测试卷曲DEMO环境:三星T959 手机一部 系统 Android 2.3

测试txt文件位置:请自行将z8806c.txt放置SDcard 根目录,进行测试

测试txt文件大小:98.5 MB(103,387,040 字节)电子书文件一个(为了复制出这么大的文本文件,电脑足足卡了20多分钟,实际中应该没有这么大的电子书,我想说明什么,你懂的.....不解释)

读取此文本时间:低于0.5毫秒(貌似夸张了一点)

Android 翻页卷曲 电子书源代码下载:

免费下载地址在

用户名与密码都是

具体下载目录在 /pub/Android源码集锦/2011年/11月/Android 翻页卷曲 电子书源代码/

package sf.hmg.turntest;

import java.io.IOException;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class turntest extends Activity {
 /** Called when the activity is first created. */
 private PageWidget mPageWidget;
 Bitmap mCurPageBitmap, mNextPageBitmap;
 Canvas mCurPageCanvas, mNextPageCanvas;
 BookPageFactory pagefactory;

@Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
  mPageWidget = new PageWidget(this);
  setContentView(mPageWidget);

mCurPageBitmap = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
  mNextPageBitmap = Bitmap
    .createBitmap(480, 800, Bitmap.Config.ARGB_8888);

mCurPageCanvas = new Canvas(mCurPageBitmap);
  mNextPageCanvas = new Canvas(mNextPageBitmap);
  pagefactory = new BookPageFactory(480, 800);

pagefactory.setBgBitmap(BitmapFactory.decodeResource(
    this.getResources(), R.drawable.shelf_bkg));

try {
   pagefactory.openbook("/sdcard/z8806c.txt");
   pagefactory.onDraw(mCurPageCanvas);
  } catch (IOException e1) {
   Toast.makeText(this, "电子书不存在,请将《z8806c.txt》放在SD卡根目录下,可以超过100M容量",
     Toast.LENGTH_LONG).show();
  }

mPageWidget.setBitmaps(mCurPageBitmap, mCurPageBitmap);

mPageWidget.setOnTouchListener(new OnTouchListener() {
   @Override
   public boolean onTouch(View v, MotionEvent e) {
    // TODO Auto-generated method stub

boolean ret = false;
    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) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
       }
       if (pagefactory.isfirstPage())
        return false;
       pagefactory.onDraw(mNextPageCanvas);
      } else {
       try {
        pagefactory.nextPage();
       } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
       }
       if (pagefactory.islastPage()) {
        return false;
       }
       pagefactory.onDraw(mNextPageCanvas);
      }
      mPageWidget.setBitmaps(mCurPageBitmap, mNextPageBitmap);
     }

ret = mPageWidget.doTouchEvent(e);
     return ret;
    }

return false;
   }

});

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyspsd.html