B4A Library [Class] SlidingSidebar

Hello,

With this class, you can put an hidden sidebar on one of the four sides of the screen and reveal it when needed. It can open with a button, like in the Facebook app, with a handle, as the standard Android slidingdrawer, or with a swipe gesture, like in Prixing. Many options are available to suit all needs.

List of functions:
Initialize(Parent As Panel, SidebarSize As Int, SidebarPosition As Byte, AnimType As Byte, OpenDuration As Int, CloseDuration As Int)
SetOnChangeListeners(Module As Object, SubOnFullyOpen As String, SubOnFullyClosed As String, SubOnMove As String)
Sidebar() As Panel
ContentPanel() As Panel
SetInterpolator(Value As Float)
OpenSidebar()
CloseSidebar()
IsSidebarVisible()
As Boolean
SetOpenCloseButton(Btn As View)
AddOpenCloseHandle(Hdl As View, Position As Int, Width As Int, Height As Int, FinalMovement As Byte)
EnableSwipeGesture(Enabled As Boolean, GestureAreaSize As Int, FinalMovement As Byte)
LoadDrawable(Name As String) As Object

Since September 3rd 2014, the SlidingSidebar class is completely free.

img1.png img2.png img3.png

v1.1: Fixed three bugs and optimized the animation function
 

Attachments

  • SlidingSidebar v1.1 Dw.zip
    38.1 KB · Views: 1,851
Last edited:

susu

Well-Known Member
Licensed User
Longtime User
Thank you.

I just donated (a beer) to you, cheers! :D
 

awama

Active Member
Licensed User
Longtime User
SlidingSidebar and SlidingDrawer Problem

Hi Informatix.

I have "sliding bar v1. 0 ' tested. It looks great. SlidingMenu works well. But SlidingSidebar and SlidingDrawer the phone hangs up after I have clicked on a menu item. I have on a SGS2 v4. 0. 3 tested. Where is the problem?
Thanks for looking.
Walter
 

Informatix

Expert
Licensed User
Longtime User
Hi Informatix.

I have "sliding bar v1. 0 ' tested. It looks great. SlidingMenu works well. But SlidingSidebar and SlidingDrawer the phone hangs up after I have clicked on a menu item. I have on a SGS2 v4. 0. 3 tested. Where is the problem?
Thanks for looking.
Walter

Can you post the content of your log when the problem happens ?

I had no problem with 4.0.3 on the emulator, except one time where a "MotionEvent recycled twice" bug occured.
The current solution that Erel gave to fix this bug is to replace the CallSub by CallSubDelayed. Could you try this fix and tell me ?

EDIT: I see in the changelog of the new beta version (B4A v2.2) that Erel fixed this bug with ListViews.
 
Last edited:

awama

Active Member
Licensed User
Longtime User
I have replaced all CallSub with CallSubDelayed. But the error has not disappeared. Also if I open just the SideBar and do nothing the phone hangs up after a certain time. Below the log.


.....
MOVE IsOpening=true
MOVE IsOpening=true
MOVE IsOpening=true
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=228.0, y[0]=350.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=5193476, downTime=5192983, deviceId=3, source=0x1002 } recycled twice!
at android.view.MotionEvent.recycle(MotionEvent.java:1670)
at android.view.ViewRootImpl.finishMotionEvent(ViewRootImpl.java:3111)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3102)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2614)
at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:978)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2623)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
 

Informatix

Expert
Licensed User
Longtime User
I have replaced all CallSub with CallSubDelayed. But the error has not disappeared. Also if I open just the SideBar and do nothing the phone hangs up after a certain time. Below the log.
As you can read in the log, it's the well-known bug "MotionEvent recycled twice". Only Erel can fix this. The last version of B4A, currently in beta stage, is supposed to fix it. In the meanwhile, remove the ListViews from the demo. My class doesn't need it at all. You can do a menu with many other things (the CheckList class, the CustomListView class, a few buttons, ...)
 
Last edited:

Jost aus Soest

Active Member
Licensed User
Longtime User
5€

Hi Frédéric,

5€ for you! :icon_clap:

I don't need the SlidingSidebar, but as a little thanx for your general work (e. g. tutorials)!
 

Amalkotey

Active Member
Licensed User
Longtime User
Hi Informatix,

thank you for sharing the class.
 

korshkov

Member
Licensed User
Longtime User
Thanks you! Is great Class.
I testing sample and (SlidingMenu) see small problem...
If i many counts tap (and fast) on menu icon, bottom edge of sliding menu is not hidden.

P.S. Try on emulator and HTC with Android 2.3.5
 

Mahares

Expert
Licensed User
Longtime User
@Monsieur Leneuf: Your work in this class and others is superb. You have been an asset since you joined the forum. If I can incorporate it into real world functionality such as SQLite related tables, menu selections, data entry, etc. it will do it for me. I tried to donate, but it is asking for Euros. Can you add an option for USD?
 

Informatix

Expert
Licensed User
Longtime User
@Monsieur Leneuf: Your work in this class and others is superb. You have been an asset since you joined the forum. If I can incorporate it into real world functionality such as SQLite related tables, menu selections, data entry, etc. it will do it for me. I tried to donate, but it is asking for Euros. Can you add an option for USD?

Thank you. :)
Unfortunately, I'm limited to only one currency. But it's not really a problem because the donated euros should be converted on your account into dollars. When I use Paypal to send dollars, they are converted into euros on my account.
Anyway, you have two options if you don't want to take a risk:
- just give one euro and see what happens;
- tell me by PM how many dollars you want to give and I'll send you a link to pay in dollars (I can do this only if I know the amount).
 

bluedude

Well-Known Member
Licensed User
Longtime User
Drawer animation

Small question,

The drawer is cool but would rather have it animate full open on swipe up or fully closed on swipe down. A little like the Android notifications.

That way it would behave kind of "Android guideline" wise. Is this possible?

Cheers,
 

Informatix

Expert
Licensed User
Longtime User
Number 1 does the magic, 2 is not smooth enough.

Did you read the tooltip of the function ? That has nothing to with smoothness (both methods use the same Animate function with the same parameters).

FinalMovement:
0 = the sidebar can stay partially open/closed. There's no final movement.
1 = the sidebar cannot stay partially open/closed. The final movement is an opening if the last movement was an opening movement, otherwise it is a closing.
2 = the sidebar cannot stay partially open/closed. The final movement is an opening if the visible size of the sidebar >= 50% of its total size, otherwise it is a closing.


Some apps, like Prixing, use the method 2.
 

mrossen

Active Member
Licensed User
Longtime User
Change background

Hi,

Thanks for a nice menu class. Nice work,

I have two questions on it.

1. can I change the background and how can I do that.
you use
B4X:
PanelWithSidebar.Sidebar.Background = PanelWithSidebar.LoadDrawable("popup_inline_error")
to load an internal drawing, Correct? I would like to create one that look like the one on my android 4.0 themes.

2. When I make a "Long Press" the app shuts down
This is what the log says:
B4X:
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=149.75476, y[0]=419.92093, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=820900520, downTime=820897820, deviceId=6, source=0x1002 } recycled twice!
   at android.view.MotionEvent.recycle(MotionEvent.java:1746)
   at android.view.ViewRootImpl.finishMotionEvent(ViewRootImpl.java:3184)
   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3175)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2724)
   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:951)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2738)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:156)
   at android.app.ActivityThread.main(ActivityThread.java:5045)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)

Mogens
 
Top