50
50
* @author escchao
51
51
*/
52
52
public class PageFlip {
53
- final static String TAG = "PageFlip" ;
53
+ final static String TAG = "PageFlip" ;
54
54
55
55
// default pixels of mesh vertex
56
56
private final static int DEFAULT_MESH_VERTEX_PIXELS = 10 ;
@@ -229,7 +229,7 @@ public class PageFlip {
229
229
*/
230
230
public PageFlip (Context context ) {
231
231
mContext = context ;
232
- mScroller = new Scroller (context , new AccelerateInterpolator (), true );
232
+ mScroller = new Scroller (context );
233
233
mFlipState = PageFlipState .END_FLIP ;
234
234
mIsVertical = false ;
235
235
mViewRect = new GLViewRect ();
@@ -277,9 +277,6 @@ public PageFlip(Context context) {
277
277
FOLD_BASE_SHADOW_START_ALPHA ,
278
278
FOLD_BASE_SHADOW_END_COLOR ,
279
279
FOLD_BASE_SHADOW_END_ALPHA );
280
-
281
- // init default scroller
282
- mScroller = new Scroller (context );
283
280
}
284
281
285
282
/**
@@ -599,7 +596,7 @@ private void createPages() {
599
596
* @param touchX x of finger down point
600
597
* @param touchY y of finger down point
601
598
*/
602
- public void onFingerDown (float touchX , float touchY ) {
599
+ public void onFingerDown (float touchX , float touchY ) {
603
600
// covert to OpenGL coordinate
604
601
touchX = mViewRect .toOpenGLX (touchX );
605
602
touchY = mViewRect .toOpenGLY (touchY );
@@ -628,7 +625,7 @@ else if (mPages[SECOND_PAGE] != null &&
628
625
mTouchP .set (touchX , touchY );
629
626
mFlipState = PageFlipState .BEGIN_FLIP ;
630
627
}
631
- }
628
+ }
632
629
633
630
/**
634
631
* Handle finger moving event
@@ -638,7 +635,7 @@ else if (mPages[SECOND_PAGE] != null &&
638
635
* @return true if moving will trigger to draw a new frame for page flip,
639
636
* False means the movement should be ignored.
640
637
*/
641
- public boolean onFingerMove (float touchX , float touchY ) {
638
+ public boolean onFingerMove (float touchX , float touchY ) {
642
639
touchX = mViewRect .toOpenGLX (touchX );
643
640
touchY = mViewRect .toOpenGLY (touchY );
644
641
@@ -1010,7 +1007,7 @@ else if (mIsVertical) {
1010
1007
computeVertexesWhenSlope ();
1011
1008
}
1012
1009
1013
- return isAnimating ;
1010
+ return isAnimating ;
1014
1011
}
1015
1012
1016
1013
/**
@@ -1026,7 +1023,7 @@ public boolean isAnimating() {
1026
1023
* Abort animating
1027
1024
*/
1028
1025
public void abortAnimating () {
1029
- mScroller .abortAnimation ();
1026
+ mScroller .abortAnimation ();
1030
1027
if (mFlipState == PageFlipState .FORWARD_FLIP ) {
1031
1028
mFlipState = PageFlipState .END_WITH_FORWARD ;
1032
1029
}
@@ -1055,7 +1052,7 @@ public boolean isStartedFlip() {
1055
1052
* @return true if flip is ended
1056
1053
*/
1057
1054
public boolean isEndedFlip () {
1058
- return mFlipState == PageFlipState .END_FLIP ||
1055
+ return mFlipState == PageFlipState .END_FLIP ||
1059
1056
mFlipState == PageFlipState .END_WITH_RESTORE ||
1060
1057
mFlipState == PageFlipState .END_WITH_BACKWARD ||
1061
1058
mFlipState == PageFlipState .END_WITH_FORWARD ;
@@ -1129,7 +1126,7 @@ public void drawFlipFrame() {
1129
1126
/**
1130
1127
* Draw frame with full page
1131
1128
*/
1132
- public void drawPageFrame () {
1129
+ public void drawPageFrame () {
1133
1130
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1134
1131
glUseProgram (mVertexProgram .mProgramRef );
1135
1132
glUniformMatrix4fv (mVertexProgram .mMVPMatrixLoc , 1 , false ,
@@ -1143,7 +1140,7 @@ public void drawPageFrame() {
1143
1140
if (mPages [SECOND_PAGE ] != null ) {
1144
1141
mPages [SECOND_PAGE ].drawFullPage (mVertexProgram , true );
1145
1142
}
1146
- }
1143
+ }
1147
1144
1148
1145
/**
1149
1146
* Compute max mesh count and allocate vertexes buffer
@@ -1291,22 +1288,22 @@ private void computeVertexesWhenVertical() {
1291
1288
/**
1292
1289
* Compute key vertexes when page flip is slope
1293
1290
*/
1294
- private void computeKeyVertexesWhenSlope () {
1291
+ private void computeKeyVertexesWhenSlope () {
1295
1292
final float oX = mPages [FIRST_PAGE ].originP .x ;
1296
1293
final float oY = mPages [FIRST_PAGE ].originP .y ;
1297
1294
1298
- float dX = mMiddleP .x - oX ;
1299
- float dY = mMiddleP .y - oY ;
1300
-
1295
+ float dX = mMiddleP .x - oX ;
1296
+ float dY = mMiddleP .y - oY ;
1297
+
1301
1298
// compute key points on X axis
1302
1299
float r0 = 1 - mSemiPerimeterRatio ;
1303
1300
float r1 = 1 + mSemiPerimeterRatio ;
1304
- mXFoldP .set (mMiddleP .x + dY * dY / dX , oY );
1301
+ mXFoldP .set (mMiddleP .x + dY * dY / dX , oY );
1305
1302
mXFoldP0 .set (oX + (mXFoldP .x - oX ) * r0 , mXFoldP .y );
1306
1303
mXFoldP1 .set (oX + r1 * (mXFoldP .x - oX ), mXFoldP .y );
1307
1304
1308
1305
// compute key points on Y axis
1309
- mYFoldP .set (oX , mMiddleP .y + dX * dX / dY );
1306
+ mYFoldP .set (oX , mMiddleP .y + dX * dX / dY );
1310
1307
mYFoldP0 .set (mYFoldP .x , oY + (mYFoldP .y - oY ) * r0 );
1311
1308
mYFoldP1 .set (mYFoldP .x , oY + r1 * (mYFoldP .y - oY ));
1312
1309
@@ -1322,7 +1319,7 @@ private void computeKeyVertexesWhenSlope() {
1322
1319
1323
1320
// compute mesh count
1324
1321
computeMeshCount ();
1325
- }
1322
+ }
1326
1323
1327
1324
/**
1328
1325
* Compute back vertex and edge shadow vertex of fold page
0 commit comments