androidanimationcurlpage-curl

Android Page Curl Animation by Harism shows inconsistency in the reverse index count in the getBitmap() method of CurlActivity()?


I have used Harism's Page Curl animation for my application, but I have been facing a small problem, I am using the index Value in the getBitmap() method of the CurlActivity, I need to show page numbers to the user on every flip of the page(say using a call to Toast.maketext().show), this works fine while going from page 0 to pageCount.length, but when I move page right to left(the pages, i.e. while going the other way from pageCount.lenth to 0) the index values are not consistently reduced.

Can anyone please help me with this.

Thanks in Advance.

P.S.:That would be my first question on stackoverflow

public Bitmap getBitmap(int width, int height, int index) {

        Bitmap b = Bitmap.createBitmap(width, height,Bitmap.Config.ARGB_8888);
        b.eraseColor(0xFFFFFFFF);
        Canvas c = new Canvas(b);

        //this is where index seems to go wrong on reverse counting, I believe
        Log.e("PAGE--", ""+index);
        Toast.makeText(CurlActivity.this, ""+index, Toast.LENGTH_SHORT).show();
        Drawable d = getResources().getDrawable(mBitmapIds[index]);

        int margin = 7;
        int border = 3;

        return b
}

Solution

  • Problem is that you really can't rely on requested page index on purpose you try to implement. Reason for the behavior you're facing is that once you flip through pages forward, only 'next page' is requested, in which case index seems to be what you're expecting. But changing pages backwards works the exact opposite, only 'previous page' is requested, and there's a gap within index between these separate operations.

    There's a method CurlView.getCurrentIndex() though which is constantly set to index of the page being shown on right side. It should give you means for having actual page numbers shown.