B4A Library PaperShredder

It is a wrap for this Github project. Posting the following:
1. B4A library files
2. B4A project
3. The Java code - change it which ever way you want

Note the files in the B4A project's /Object/res/values folder (Property set to READ ONLY)

1.gif


2.gif


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: PaperShredder
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    'https://github.com/ldoublem/PaperShredder

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.

    Private ps1 As PaperShredder
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
   
'    ps1.ShrededType = ps1.SHRED_TYPE_SLIP
'    ps1.ShredderBgColor = Colors.Magenta
'    ps1.PaperColor = Colors.yellow
'    ps1.SherderProgress = True
'    ps1.TextShadow = False
'    ps1.ShredderTextColor = Colors.Black
'    ps1.ShredderTitle = "SHREDDING YOUR DATA...."
   
    ps1.ShrededType = ps1.SHRED_TYPE_PIECE
    ps1.ShredderBgColor = Colors.DarkGray
    ps1.PaperColor = Colors.White
    ps1.SherderProgress = True
    ps1.TextShadow = False
    ps1.ShredderTextColor = Colors.white
    ps1.PaperEnterColor = Colors.Yellow   
    ps1.ShredderTitle = "Deleting unused files...."   

End Sub

Sub Activity_Resume
   
    ps1.startAnim(2000)


End Sub

Sub Activity_Pause (UserClosed As Boolean)
   
    ps1.stopAnim


End Sub

Library:
PaperShredder
Author: Github: ldoublem (https://github.com/ldoublem/PaperShredder), Wrapped by: Johan Schoeman
Version: 1
  • PaperShredder
    Fields:
    • SHRED_TYPE_PIECE As Int
    • SHRED_TYPE_SLIP As Int
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • startAnim (duration As Int)
    • stopAnim
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • PaperColor As Int [write only]
    • PaperEnterColor As Int [write only]
    • Parent As Object [read only]
    • SherderProgress As Boolean [write only]
    • ShredderBgColor As Int [write only]
    • ShredderTextColor As Int [write only]
    • ShredderTitle As String [write only]
    • ShrededType As Int [write only]
    • Tag As Object
    • TextShadow As Boolean [write only]
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • PaperShredderLibFiles.zip
    13.1 KB · Views: 176
  • b4aPaperShredder.zip
    8.3 KB · Views: 172
  • TheJavaCode.zip
    22.6 KB · Views: 165

so27

Active Member
Licensed User
Longtime User
And with a little sleep function, the animation can be stopped wonderful.

B4X:
Sub Sleep(ms As Long)
Dim now As Long
    If ms > 5000 Then ms =5000   'avoid application not responding error
    now=DateTime.now
    Do Until (DateTime.now>now+ms)
      DoEvents
    Loop
End Sub

Sub Button1_Click
        ps1.startAnim(2000)
        Sleep(2000)
        ps1.stopAnim
End Sub
 

so27

Active Member
Licensed User
Longtime User
Okay but works well. Thanks for the note. CallSubPlus was not familiar to me.
 

DonManfred

Expert
Licensed User
Longtime User
CallSubPlus was not familiar to me.
Learn to use it. It is really powerful if you use it right.

No need for workarounds like
avoid application not responding error

Edit also no need for the sleep-sub at all :)
 

so27

Active Member
Licensed User
Longtime User
Thanks for the tip. I will follow him.
 
Top