PageTurnView with images

sanjibnanda

Active Member
Licensed User
Longtime User
PageTurnView with images project not working

Hello Erel,

I am attaching my turnPage project that crashes when i add images to pages..

the error caught is "android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views."

I have tried many combinations, but all in vain.. so i am stuck. Please help me to continue with my project..

Also, how is it possible to display images on both sides of the page on wide screen.

regards,
sanjib nanda
 

Attachments

  • pageTurn.zip
    46.9 KB · Views: 425
Upvote 0

agraham

Expert
Licensed User
Longtime User
The error you are getting is self explanatory when you read the comments from the demo that you have left in your program at lines 69 and 70.
' The PageTurnerView events run on a separate thread to the main thread.
' They therefore must not try to manipulate GUI elements
.
The error is occurring at line 94 in your program "cnv.Initialize(Activity)". the exception is being trapped in Sub PTException at line 184 and is displayed on the GUI thread in Sub ShowPTError at line 65. Sub PageTurner_GetBitmap is not running on the GUI thread but is referencing Activity (which is a GUI element) in the Initialize argument. I don't see why you need to use a Canvas in PageTurner_GetBitmap, apparently trying to draw on the Activity background.

Also, how is it possible to display images on both sides of the page on wide screen.
You can't.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Andrew,
The demo was fantastic and it is just the same as those eBooks we read from Amazon..
Now may I ask for a little push with another demo with mixed contents.. just two pages, one text
and the other image.. then I can build on it.

Thank you in advance.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
In the example there is only text.. no mention as to how to to add images or how to
put image on bitmap.. I don't know how to do that.
I searched the tutorials and didn't find any reference either.. May be I am missing something.
Thanks anyways. The View is great but the example presumes a level of knowledge on the subject.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Andrew,
Alright, I believe I spotted the place where I can put image..
B4X:
cnv.DrawText( "The End", Width/2, 100dip, Typeface.DEFAULT, 24, Colors.White, "CENTER")
This is the line I should replace, right?
But now I didn't know the syntax of adding a bitmap.. is it DrawBMP() or DrawBitmap() and what are the parameters
of the bitmap..
If you see this is too obvious and a waste of time to discuss it then please pardon me.
 
Upvote 0
Top