1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4A Library PageTurnView library providing a page turn animation

Discussion in 'Additional libraries, classes and official updates' started by agraham, Aug 12, 2011.

  1. agraham

    agraham Expert Licensed User

    Android compresses files into DirAssets but is unable to unpack compressed files larger than 1mb. A workaround for this issue is to change the file extension to jpg. Then the Android packager doesn't compress the file and it can be larger than 1mb but as text compresses very efficiently this might make the file very large. Alternatively split the text file into two or more files and concatenate them when you read them.
     
  2. keklikhasan

    keklikhasan New Member

    Thanks:sign0098:
     
  3. malc

    malc New Member Licensed User

    I have just installed B4A and run the Hello World example. I thought Id give the Page Turner a try out and downloaded the .jar and .xml files to the Library but when I run the demo it will not comple ...

    [​IMG]

    I realise I'm just a beginner and probably trying something too advanced but can anyone tell me why the demo code will not compile?

    Many thanks!
     
  4. nfordbscndrd

    nfordbscndrd Well-Known Member Licensed User

  5. malc

    malc New Member Licensed User

    Thanks for the quick reply.

    I have read the documentation as indicated, and the correct library is installed, but still no joy.

    Maybe I should stick to simpler examples! :confused:
     
  6. klaus

    klaus Expert Licensed User

    In the lower right corner of the IDE you find the Lib Tab. You should see the PageTurnView library in the list and you must check it.

    Best regards.
     
  7. malc

    malc New Member Licensed User

    Many thanks nfordbscndrd and Klaus.

    I've sussed it now. I had 'PageTurnView' selected in Libs but I hadn't downloaded and installed the 'Threading' library, which is where ExceptionEx is defined.

    Sorted now and installed on my device. Works like a charm, I'm impressed!
     
  8. ChrShe

    ChrShe Member Licensed User

    I think I'm totally missing something.
    PageTurnView seems to work only with a string passed in. But, I would like to use it to show pages similar to the attached, with a text, a photo and some buttons.

    What would be the best way to do this?

    DogView.png

    I'd also like to have some formatting control over the passed in text. Is that possible?

    Thanks much!!!
    Chris
     
    Last edited: Sep 4, 2012
  9. agraham

    agraham Expert Licensed User

    What makes you think that :confused: Work through the demo code and you will see that it works entirely with bitmaps so what you display is up to you.
     
  10. ChrShe

    ChrShe Member Licensed User

    I think me being a n00b is what make me think that. LOL

    I'm looking at the demo and can't see for forest through the trees. :-(

    What would be the best way to do what I need? Currently, I'm creating panels and adding them to a scrollview. Could I add them to a PageTurnerView instead? If so...how?

    Thanks again!!!!!!
     
  11. agraham

    agraham Expert Licensed User

    No, it needs a bitmap for each page which you return from the GetBitmap event.
     
  12. ChrShe

    ChrShe Member Licensed User

    Okay, thanks for the info!!!
    I'll fiddle and see what I can come up with. :D
     
  13. ChrShe

    ChrShe Member Licensed User

    I got the "A BOOK" and "THE END" pages looking the way I want. WOOHOO!!! :sign0060:

    Now on to the dynamically generated pages that go in between those two...this ought to be fun. :D

    Thanks so much for the help!
     
  14. sanjibnanda

    sanjibnanda Active Member Licensed User

  15. kershawj42

    kershawj42 New Member Licensed User

    Bitmap resize or scale

    Hi,
    Very new to Basic4PPC and finding out what a fantastic product this is, and this being a great example of so many very useful libaries.

    Having a problem which I can't seem to get around and would be greatful for any available help or suggestions, Using the example found in the libary as an activity called when a menu item is selected and all working fine.
    Instead of having the libary create a bitmap from text I wanted a picture on the first page so changed:

    Code:
    If Page = 0 Then
             cnv.Initialize2(bmp)
             cnv.DrawColor(
    Colors.Blue)
             cnv.DrawText( 
    "A Book", Width/2100dipTypeface.DEFAULT, 24Colors.White, "CENTER")
             
    Return bmp
    To be:

    Code:
    If Page = 0 Then
             bmp.Initialize(
    File.DirAssets, "filename.png")
             
    Return bmp
    The picture shows up, but is not scaled correctly. I did think it was half the size but it's more like 3/4 of the original size, the rest is clipped.
    I tried resizing the png but same thing always happens.
    Also tried:

    Code:
    bmp.InitializeSample(File.DirAssets, "filename.png", Width/2, Height/2)
    But same result.
    Had a good look around the forum but can't seem to see any method around it. Guess it works fine for others?
    I have tried on my own phone (HTC Desire HD) and the emulator (Nexus-ARM, Android 4.0.3) and same result seen.
     
  16. agraham

    agraham Expert Licensed User

    From the library help
    It tells you what size of Bitmap it needs - it's up to you to provide it.
     
  17. kershawj42

    kershawj42 New Member Licensed User

    Finally got the point

    Well, nearly sent a reply saying how I'm missing the obvious or just do not understand which turns out would have been pretty close.

    As shown in my previous code I was just replacing all the good stuff you had of initializing a canvas, drawing upon this then returning as the bmp with just loading the bitmap and sending it back.
    So after a while and a few false starts now realise I needed to still have the canvas, initialize a rectangle on this then draw the image onto this then return the whole thing.

    Code:
    Dim bmp As Bitmap
       
    Dim cover As Bitmap
       
    Dim cnv As Canvas
       bmp.InitializeMutable(Width, Height) 
    ' do this here so we have a valid return in case of an exception
       Try   
          
    'File.OpenInput("bad", "filename") ' this would cause an exception to be reported on the main thread
          If Page = 0 Then
             cover.Initialize(
    File.DirAssets, "filename.bmp")
             cnv.Initialize2(bmp)
             
    Dim DestRect As Rect
             DestRect.Initialize(
    0dip0dip,Width, Height) 
             cnv.DrawBitmap (cover, 
    Null, DestRect)
             
    Return bmp
    Put the code I used in here in case someone else at the same basic (no pun intended) level finds useful.
    Thanks for the nudge in the right direction, like the libary, and unlike my code, expertly done!
    :)
     
  18. fanfalveto

    fanfalveto Active Member Licensed User

    Thank you for your job is very good.Is possible to get as string the text of the current page?
     
  19. fanfalveto

    fanfalveto Active Member Licensed User

    Well I found a way. thanks
    Code:
    Pager.Paginate(ipsum)
    Log("PAGINAS: "&Pager.PageCount)
    Log("LONGITUD TEXTO: "&ipsum.Length)
    pag
    PageNumber =pagina
    PageTurner.CurrentPage = PageNumber
    If PageNumber>0 Then
    start=(ipsum.Length/Pager.PageCount)
    Log("Empieza en: "&(start*pagina))
    lectura=ipsum.SubString(start*(pagina-
    1))
    Else
    lectura=ipsum
    End If
     
  20. zeuspower

    zeuspower Member Licensed User

    Agraham, :sign0188:

    beautiful job...

    I already loaded from an external text file,and my book is ready :icon_clap:

    well...not exactly for publish,but for my eyes is ready !

    1. Any first ideas,of how can i insert some graphic images between the images with the text ?

    It's easy to change the first an last images because they are static somehow,but the between main images-text seem a little complicated to insert a new(extra) image with a painting or photo for example ,because of the serial generation by pager object ..

    thanks

    ...and something else !

    2. I try to use the library inside of my greek mythology app
    It takes the text data from my sql database

    in the first load it works ok,but the next time it contains the previous text data + the new text data ,how i clear and refresh the text(images) contained in the pager ?

    check my code :

    Code:
    Sub create_Mini_book(perigrafiData As String)  
      
          
    If  PageTurner.IsInitialized=False Then   <<----- first run and load OK
       
           PageTurner.Initialize(
    "PageTurner"20)
             pnlPage3.AddView(PageTurner, 
    10dip10dip, tbhPages.Width - 25dip, tbhPages.Height - 70dip)
           PageTurner.TwoPages = 
    False 
          PageTurner.RenderLeftPage = 
    False
          Pager.SetPageParameters(Pager.ALIGN_CENTER, PageTurner.Width - 
    20dip, LeftMargin, PageTurner.Height - 20dip, TopMargin, LineSpacing)
          PageTurner.SetMarginPixels(
    10dip10dip10dip10dip)
       
       PageTurner.AllowLastPageCurl = 
    False ' the default is true   
       
       
    Font = Font.CreateNew(Typeface.SERIF, Typeface.STYLE_NORMAL)
       
    Dim text As String
       
          text = perigrafiData & 
    CRLF & CRLF
       
       Pager.SetPaintParameters(
    Font16Colors.Black, True)
       Pager.Paginate(text)
        
      
    Else
                                            <<--
    next load of fresh text from database    
                                                        it adds 
    to the previous text
        
       PageTurner.RemoveView 
          PageTurner.Initialize(
    "PageTurner"20)
             pnlPage3.AddView(PageTurner, 
    10dip10dip, tbhPages.Width - 25dip, tbhPages.Height - 70dip)
           PageTurner.TwoPages = 
    False 
          PageTurner.RenderLeftPage = 
    False
          Pager.SetPageParameters(Pager.ALIGN_CENTER, PageTurner.Width - 
    20dip, LeftMargin, PageTurner.Height - 20dip, TopMargin, LineSpacing)
          PageTurner.SetMarginPixels(
    10dip10dip10dip10dip)
       
       PageTurner.AllowLastPageCurl = 
    False ' the default is true   
       
       
    Font = Font.CreateNew(Typeface.SERIF, Typeface.STYLE_NORMAL)
       
    Dim text As String
       text=
    ""                                 << I try here to clear possible previous text data but no use...
       
          text =perigrafiData & 
    CRLF & CRLF
       
       Pager.SetPaintParameters(
    Font16Colors.Black, True)
       Pager.Paginate(text)
       
        
    End If
        
          
          
       
       
    End Sub
     
    Last edited: Jan 28, 2013
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice