B4A Library SlidingPuzzleView

It is a bare minimum wrap for this Github project. Extract and copy the B4A lib files from attached b4aLibFiles.zip to your additional library folder.

Attached the B4A project and the source code. Can you solve the sliding puzzle?

1.png



dog.jpg


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aSlidingPuzzleView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #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.

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 bm As Bitmap
    Dim bmd As BitmapDrawable

    Private spv1 As SlidingPuzzleView
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")
    bm.Initialize(File.DirAssets, "dog.jpg")
    bmd.Initialize(bm)
    spv1.ImageDrawable = bmd

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • JavaCode.zip
    8.1 KB · Views: 316
  • b4aSlidingPuzzleView.zip
    49.2 KB · Views: 361
  • b4aLibFiles.zip
    10.4 KB · Views: 351
Last edited:

udg

Expert
Licensed User
Longtime User
Hi,
out of curiosity, what that Github project does more or better than the DraggableView in a pure-B4A solution?
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi,
out of curiosity, what that Github project does more or better than the DraggableView in a pure-B4A solution?
Have never looked at DraggableView in B4A. This is like 4 lines of code....?
 

udg

Expert
Licensed User
Longtime User
Like a tennis match: 6-4. First set to Github..eheh
 

BarryW

Active Member
Licensed User
Longtime User
is there event for success also can you remove the numbers on top of the picture?
 

semar

Active Member
Licensed User
Longtime User
Hello, I get the following errors when I run the example.
I've put the b4aLibFiles in the Additional-Libraries folder, and the java "widget" folder in the Android one.
What went wrong and why ?
Thanks for your attention,
Sergio
B4X:
PackageAdded: package:JHS.SlidingPuzzleView
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 34 (Main)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at JHS.SlidingPuzzleView.main._activity_create(main.java:392)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at JHS.SlidingPuzzleView.main.afterFirstLayout(main.java:105)
    at JHS.SlidingPuzzleView.main.access$000(main.java:17)
    at JHS.SlidingPuzzleView.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6117)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 21 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/GestureDetectorCompat;
    at com.luxiliu.android.widget.SlidingPuzzleView.init(SlidingPuzzleView.java:170)
    at com.luxiliu.android.widget.SlidingPuzzleView.<init>(SlidingPuzzleView.java:61)
    at com.luxiliu.android.widget.SlidingPuzzleView.<init>(SlidingPuzzleView.java:55)
    at slidingpuzzleviewwrapper.slidingpuzzleviewWrapper._initialize(slidingpuzzleviewWrapper.java:82)
    ... 25 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.GestureDetectorCompat" on path: DexPathList[[zip file "/data/app/JHS.SlidingPuzzleView-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 29 more
    Suppressed: java.lang.ClassNotFoundException: android.support.v4.view.GestureDetectorCompat
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 30 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
** Activity (main) Resume **
 
Top