首先,Harism感谢你分享这一美丽的框架!
如今,只是为了补充Harism的反应:
当与杂志、书籍等合作时,我们处理的页数未定。
In the example presented in class CurlActivity, of project Harism-Android-Page-Curl, uses a "Switch" to control the pages. To be able to meet my needs, I had to change the method "updatePage" and then control my magazines more appropriately, regardless of the amount of pages.
我需要根据指数(方法签名本身)和目前的取向装置提出以下概要:
Landscape Orientation ("Side Back" with next page)
索引 Left | Page Right
页: 1
1 D-1, 1 D-1, 1 P-5, 1 P-4, 1 P-3, 1 P-2, 1 GS, 3 NS
页: 1
页: 1
页: 1
<>Portrait Orientation (“Side Back” with same page reflected)
索引
页: 1
页: 1
2 GS
页: 1
4)
......
为了实施这一计划,首先必须改变这一方法:
public int getPageCount() {
//return 5;
int pagesCount = 0;
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int wwidth = displaymetrics.widthPixels;
int hheight = displaymetrics.heightPixels;
if(wwidth > hheight){
if((mBitmapIds.length % 2) > 0)
pagesCount = (mBitmapIds.length / 2) + 1;
else
pagesCount = mBitmapIds.length / 2;
}else{
pagesCount = mBitmapIds.length;
}
return pagesCount;
}
这将使网页柜台能够归还实际页数。
然后改变更新方法 页: 1
public void updatePage(CurlPage page, int width, int height, int index) {
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int wwidth = displaymetrics.widthPixels;
int hheight = displaymetrics.heightPixels;
if(wwidth > hheight){
System.out.println("case landscape orientation...");
Bitmap front = loadBitmap(width, height, (index * 2));
Bitmap back = loadBitmap(width, height, (index * 2) + 1);
Matrix matrix = new Matrix();
matrix.preScale(-1.0f, 1.0f);
Bitmap mirroredBitmap = Bitmap.createBitmap(back, 0, 0, back.getWidth(), back.getHeight(), matrix, false);
page.setTexture(front, CurlPage.SIDE_FRONT);
page.setTexture(mirroredBitmap, CurlPage.SIDE_BACK);
}else{
System.out.println("case portrait orientation...");
Bitmap front = loadBitmap(width, height, index);
Bitmap back = loadBitmap(width, height, index);
page.setTexture(front, CurlPage.SIDE_FRONT);
page.setTexture(back, CurlPage.SIDE_BACK);
}}}
我希望我帮助!
我们再次感谢“Harism”框架!