B4A Library PageTurnView library providing a page turn animation

Smee

Well-Known Member
Licensed User
B4X:
Sub PageTurner_GetBitmap(Width As Int, Height As Int, Page As Int) As Bitmap 'Called when the Bitmap for the given page number is required. Return the Bitmap
   Dim bmp As Bitmap
   Dim cnv As Canvas
   
   bmp.InitializeMutable(Width, Height)
   cnv.Initialize2(bmp)
   
   FilenameOnly=PicFileName(Page)
   Filenamex= "/cats/" & DirName & PicFileName(Page)

   Log(Page & "/" & MaxRecs & " " & Filenamex)

   Try
      b.Initialize(File.DirInternal,Filenamex)
   Catch
      b.Initialize(File.DirInternal,"/cats/blank.jpg")
   End Try
   
   brect.Initialize(0,0,b.Width, b.Height)
   cnv.DrawBitmap(b, Null, brect)
   PageNumber=page
           Return bmp

End Sub
As far as i can tell i am feeding the next page in the sequence each time the user makes a turn. But as i say if the screen is touched the page is advanced by one but the screen is showing the previous page becuse the user has not completed the entire turn. Therefore my PageNumber=page becomes incorrect because in that instance PageNumber=page-1.
In other words my links will point to Page 1 but the screen shows page 0.

A synchronisation error
 

agraham

Expert
Licensed User
You are making the erroneous assumption that the page requested is the page displayed. Surely you don't need to track the page number, just give it the page it requests. If the user subsequently makes a decision to react to something he sees on the page just fetch CurrentPage in whatever event he causes to be raised and carry on from there.
 

Smee

Well-Known Member
Licensed User
You are making the erroneous assumption that the page requested is the page displayed. Surely you don't need to track the page number, just give it the page it requests.
Yes I do

If the user subsequently makes a decision to react to something he sees on the page just fetch CurrentPage in whatever event he causes to be raised and carry on from there.
Sometimes i dont see the forest for the trees

I will modify my code but i think that will do the trick. I am using the pagename to track but i will modify

Thanks Andrew.

Hopefully that will work
 

Smee

Well-Known Member
Licensed User
:sign0060::sign0060:

Yep that did it. Now on to the next hurdle

Thanks Andrew
 

karmba_a

Member
Licensed User
But I mean The direction of the book from right to left :confused:

Browse its pages starting from the left how to make him start from the right.

Please help me and thank you
 

Smee

Well-Known Member
Licensed User
But I mean The direction of the book from right to left :confused:

Browse its pages starting from the left how to make him start from the right.

Just start the pages from the last page. i.e if you have 11 pages then start at page 10

PageTurner.CurrentPage=10 then you will move back 1 page at a time

Hope this helps
 

karmba_a

Member
Licensed User
Click when the right or left of the page it changes the page number with me and I do not want to change only if the turned the page.
 

Smee

Well-Known Member
Licensed User
Read through this whole thread again. ifr i understand you properly you are making the same mistake i was making

Quote:Originally Posted by agraham
You are making the erroneous assumption that the page requested is the page displayed. Surely you don't need to track the page number, just give it the page it requests.

Yes I do

Quote:If the user subsequently makes a decision to react to something he sees on the page just fetch CurrentPage in whatever event he causes to be raised and carry on from there.
 

Rusty

Well-Known Member
Licensed User
Page Turn View

This is wonderful.
Is there a way to do this with views on the pages?
Thanks,
 

hackhack

Active Member
Licensed User
Small request, couldn't you write the version changes in the first post? (or if not, then link to the messages?)
 

susu

Well-Known Member
Licensed User
Agraham, I tried to read a text file into text string

text = File.GetText(File.DirAssets, "content.txt")
but I got "java.io.IOException" error.

>>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
CheckJNI is ON


--- registering native functions ---
Scanning package: /data/app/vmdl20860.tmp
Removing non-system package:anywheresoftware.b4a.agraham.pageturnviewdemo
Removing package anywheresoftware.b4a.agraham.pageturnviewdemo
Activities: anywheresoftware.b4a.agraham.pageturnviewdemo.main
Scanning package anywheresoftware.b4a.agraham.pageturnviewdemo
/data/app/vmdl20860.tmp changed; unpacking
DexInv: --- BEGIN '/data/app/vmdl20860.tmp' ---
DexOpt: load 170ms, verify 566ms, opt 16ms
DexInv: --- END '/data/app/vmdl20860.tmp' (success) ---
Activities: anywheresoftware.b4a.agraham.pageturnviewdemo.main
Uninstalling process anywheresoftware.b4a.agraham.pageturnviewdemo
move /data/dalvik-cache/data@app@vmdl20860.tmp@classes.dex -> /data/dalvik-cache/data@app@anywheresoftware.b4a.agraham.pageturnviewdemo.apk@classes.dex
New package installed in /data/app/anywheresoftware.b4a.agraham.pageturnviewdemo.apk
Shutting down VM
DestroyJavaVM waiting for non-daemon threads to exit
DestroyJavaVM shutting VM down
HeapWorker thread shutting down
HeapWorker thread has shut down
JDWP shutting down net...
adbd disconnected
VM cleaning up
ERROR: thread attach failed
Uninstalling process anywheresoftware.b4a.agraham.pageturnviewdemo
LinearAlloc 0x0 used 621708 of 5242880 (11%)
Resources don't contain package for resource number 0x7f0700e5
Resources don't contain package for resource number 0x7f020031
Resources don't contain package for resource number 0x7f020030
Resources don't contain package for resource number 0x7f050000
Resources don't contain package for resource number 0x7f060000
Resources don't contain package for resource number 0x7f060001
GC freed 2517 objects / 148336 bytes in 318ms
Resources don't contain package for resource number 0x7f0700e5
Resources don't contain package for resource number 0x7f020031
Resources don't contain package for resource number 0x7f020030
Resources don't contain package for resource number 0x7f050000
Resources don't contain package for resource number 0x7f060000
Resources don't contain package for resource number 0x7f060001
GC freed 7682 objects / 560872 bytes in 314ms
GC freed 1589 objects / 74152 bytes in 209ms

>>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
CheckJNI is ON
--- registering native functions ---
Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=anywheresoftware.b4a.agraham.pageturnviewdemo/.main }
Start proc anywheresoftware.b4a.agraham.pageturnviewdemo for activity anywheresoftware.b4a.agraham.pageturnviewdemo/.main: pid=280 uid=10029 gids={}
Shutting down VM
DestroyJavaVM waiting for non-daemon threads to exit
DestroyJavaVM shutting VM down
HeapWorker thread shutting down
HeapWorker thread has shut down
JDWP shutting down net...
adbd disconnected
VM cleaning up
LinearAlloc 0x0 used 637292 of 5242880 (12%)
** Activity (main) Create, isFirst = true **


Data exceeds UNCOMPRESS_DATA_MAX (1826483 vs 1048576)


main_activity_create (java line: 217)



java.io.IOException
at android.content.res.AssetManager.readAsset(Native Method)
at android.content.res.AssetManager.access$700(AssetManager.java:35)
at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:543)
at java.io.InputStreamReader.read(InputStreamReader.java:270)
at java.io.BufferedReader.fillbuf(BufferedReader.java:126)
at java.io.BufferedReader.read(BufferedReader.java:309)
at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.Read(File.java:545)
at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.ReadAll(File.java:560)
at anywheresoftware.b4a.objects.streams.File.GetText(File.java:205)
at anywheresoftware.b4a.agraham.pageturnviewdemo.main._activity_create(main.java:217)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.agraham.pageturnviewdemo.main.afterFirstLayout(main.java:84)
at anywheresoftware.b4a.agraham.pageturnviewdemo.main.access$100(main.java:16)
at anywheresoftware.b4a.agraham.pageturnviewdemo.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
java.io.IOException


Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@43d6c2f0 (uid=10029 pid=280)


Client not active, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43cbe3c8


Displayed activity anywheresoftware.b4a.agraham.pageturnviewdemo/.main: 1795 ms (total 1795 ms)
How can I fix it?
Thank you so much.
 

susu

Well-Known Member
Licensed User
I found out that "Data exceeds" error. Maybe I need to "trim" the text file first?
 
Top