Android Question Turning the book to the right

PoleStar

Member
Licensed User
Longtime User
Hi my friends
I using PageTurnView for turning the book
I need to turning book from left to right for arabic and persian books.

This source was turning book to the left
Please help me


I using this code:

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: Book Application - Lyndon Bermoy
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim PageNumber As Int
   
    Dim paragraph As String
    paragraph = "I’ve came across this mediocre status quo of my life. I’m almost on the primal point of conformity in this world. I’ve come out on peak where rivalries are extremely vied. I have passed those vendettas and feuds of life and came to groove with the rhythm of dynamism in living. I let slithered those failures and slipped a bit at the grip of living, but I always had my flag held up high for those laurels and feats I have experienced. I still remember clearly. It was a few months ago. It was the mystical month of January when flowers then were in bloom and the breeze felt like fresh hay. When my fate led me to this woman and still admired till today."
    Dim paracount As Int : paracount = 8
    Dim LeftMargin As Int : LeftMargin = 10dip
    Dim TopMargin As Int : TopMargin = 10dip
    Dim LineSpacing As Int : LineSpacing = 1
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim PageTurner As PageTurnView
    Dim Pager As TextPaginator
    Dim Font As Typeface
End Sub

Sub Activity_Create(FirstTime As Boolean)
    PageTurner.Initialize("PageTurner", 20)
    Activity.AddView(PageTurner, 10dip, 10dip, Activity.Width - 20dip, Activity.Height - 20dip)

    If Activity.Width > Activity.Height Then
        PageTurner.TwoPages = True ' the default is False
        PageTurner.RenderLeftPage = True ' the default is True
        Pager.SetPageParameters(Pager.ALIGN_NORMAL, PageTurner.Width/2 - 12dip, LeftMargin, PageTurner.Height - 12dip, TopMargin, LineSpacing)
        PageTurner.SetMarginPixels(6dip, 6dip, 6dip, 6dip)
    Else   
        PageTurner.TwoPages = False
        PageTurner.RenderLeftPage = False
        Pager.SetPageParameters(Pager.ALIGN_CENTER, PageTurner.Width - 20dip, LeftMargin, PageTurner.Height - 20dip, TopMargin, LineSpacing)
        PageTurner.SetMarginPixels(10dip, 10dip, 10dip, 10dip)
    End If
    PageTurner.AllowLastPageCurl = False ' the default is true   
   
    Font = Font.CreateNew(Typeface.SERIF, Typeface.STYLE_NORMAL)
    Dim text As String
    For i = 0 To paracount - 1
        text = text & paragraph & CRLF & CRLF
    Next
    Pager.SetPaintParameters(Font, 16, Colors.Black, True)
    Pager.Paginate(text)
   
End Sub

Sub Activity_Resume
    PageTurner.CurrentPage = PageNumber
    PageTurner.Color = Colors.LightGray ' otherwise it gets lost on Pause and Resume without a Create
    PageTurner.OnResume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    PageNumber = PageTurner.CurrentPage
    PageTurner.OnPause
End Sub

Sub ShowPTError(title As String, msg As String)
    Msgbox(msg, title)
End Sub


Sub PageTurner_GetBitmap(Width As Int, Height As Int, Page As Int) As Bitmap
    Dim bmp As Bitmap
    Dim cnv As Canvas
    bmp.InitializeMutable(Width, Height)
    Try   
       
        If Page = 0 Then   
            cnv.Initialize2(bmp)
            cnv.DrawColor(Colors.ARGB(255,129,23,56))
            cnv.DrawText( "(To the Seraph of Angels..) ", Width/2, 100dip, Typeface.DEFAULT, 24, Colors.White, "CENTER")
            Return bmp
        Else If Page = Pager.PageCount + 1 Then   
            cnv.Initialize2(bmp)
            cnv.DrawColor(Colors.DarkGray)
            cnv.DrawText( "The End", Width/2, 100dip, Typeface.DEFAULT, 24, Colors.White, "CENTER")
            Return bmp
        Else
            Return Pager.GetPageBitmap(Page - 1, Colors.Cyan)
        End If   
    Catch
       
        PTException
    End Try   
    Return bmp
End Sub

Sub PageTurner_GetPages() As Int
    Try
        Return Pager.PageCount + 2
    Catch
        Return 0
    End Try
End Sub

Sub PTException()
    Dim Ex As ExceptionEx
    Dim where As String
    Ex = LastException
    Dim args(2) As Object
    args(0) = LastException.Message
    where = Ex.StackTraceElement(2)
    args(1) = where   
    PageTurner.RunOnGuiThread("ShowPTError", args)
End Sub
 
Top