B4A Library FoldingCell

This is a wrap for this Github-Project.

FoldingCell
Author:
DonManfred (wrapper)
Version: 1
FoldingCellView
Fields:

  • ba As anywheresoftware.b4a.BA
Methods:
  • DesignerCreateView (base As anywheresoftware.b4a.objects.PanelWrapper, lw As anywheresoftware.b4a.objects.LabelWrapper, props As anywheresoftware.b4a.objects.collections.Map) As void
  • withFrontView (frontView As android.view.View) As de.donmanfred.FoldingCellViewWrapper
  • animateFrontView (animation As android.view.animation.Animation) As void
  • IsInitialized As boolean
  • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String, frontView As android.view.View, backView As android.view.View) As void
  • BringToFront As void
  • SetLayout (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
  • SendToBack As void
  • SetVisibleAnimated (arg0 As int, arg1 As boolean) As void
  • RemoveView As void
  • Invalidate3 (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
  • Invalidate2 (arg0 As android.graphics.Rect) As void
  • withBackView (backView As android.view.View) As de.donmanfred.FoldingCellViewWrapper
  • SetColorAnimated (arg0 As int, arg1 As int, arg2 As int) As void
  • SetBackgroundImage (arg0 As android.graphics.Bitmap) As void
  • Invalidate As void
  • SetLayoutAnimated (arg0 As int, arg1 As int, arg2 As int, arg3 As int, arg4 As int) As void
  • RequestFocus As boolean
Properties:
  • Left As int
  • Background As android.graphics.drawable.Drawable
  • Parent As java.lang.Object [read only]
  • Color As int [write only]
  • Enabled As boolean
  • BackView As android.view.View [read only]
  • Top As int
  • Visible As boolean
  • Padding As int[]
  • Height As int
  • Tag As java.lang.Object
  • Width As int
  • FrontView As android.view.View [read only]

FoldingCell
Fields:

  • ba As anywheresoftware.b4a.BA
Methods:
  • DesignerCreateView (base As anywheresoftware.b4a.objects.PanelWrapper, lw As anywheresoftware.b4a.objects.LabelWrapper, props As anywheresoftware.b4a.objects.collections.Map) As void
  • IsInitialized As boolean
  • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String, frontView As android.view.View, backView As android.view.View) As void
  • BringToFront As void
  • SetLayout (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
  • SendToBack As void
  • SetVisibleAnimated (arg0 As int, arg1 As boolean) As void
  • init (animationDuration As int, backSideColor As int, additionalFlipsCount As int) As void
    Initializes folding cell programmatically with custom settings
    animationDuration: animation duration, default is 1000
    backSideColor: color of back side, default is android.graphics.Color.GREY (0xFF888888)
    additionalFlipsCount: count of additional flips (after first one), set 0 for auto
  • RemoveView As void
  • Invalidate3 (arg0 As int, arg1 As int, arg2 As int, arg3 As int) As void
  • isUnfolded As boolean
  • Invalidate2 (arg0 As android.graphics.Rect) As void
  • toggle (skipAnimation As boolean) As void
    Toggle current state of FoldingCellLayout
  • SetColorAnimated (arg0 As int, arg1 As int, arg2 As int) As void
  • addView (child As android.view.View, width As int, height As int) As void
  • SetBackgroundImage (arg0 As android.graphics.Bitmap) As void
  • fold (skipAnimation As boolean) As void
    Fold cell with (or without) animation
    skipAnimation: if true - change state of cell instantly without animation
  • Invalidate As void
  • SetLayoutAnimated (arg0 As int, arg1 As int, arg2 As int, arg3 As int, arg4 As int) As void
  • RequestFocus As boolean
  • unfold (skipAnimation As boolean) As void
    Unfold cell with (or without) animation
    skipAnimation: if true - change state of cell instantly without animation
Properties:
  • Left As int
  • Background As android.graphics.drawable.Drawable
  • Parent As java.lang.Object [read only]
  • Color As int [write only]
  • Enabled As boolean
  • Top As int
  • Visible As boolean
  • Padding As int[]
  • Height As int
  • Tag As java.lang.Object
  • Width As int


Installation:
Copy content of res.Foldingell.zip to additional libs folder!
Copy content of FoldingCellV1.0.zip to additional libs folder!
Use the code in FoldingCellEx.zip as Example on how it works.

thanks to (for "Motivating me" :) ):
@Douglas Farias
@rboeck
@Ohanian
@BillMeyer
 

Attachments

  • FoldingCellV1.0.zip
    18.3 KB · Views: 412
  • res.FoldingCell.zip
    913 bytes · Views: 503
  • FoldingCellV1.1.zip
    18.3 KB · Views: 389
  • FoldingCellEx.zip
    59.4 KB · Views: 460
  • FoldingCellV1.11.zip
    18.8 KB · Views: 474
Last edited:

itgirl

Active Member
Licensed User
Longtime User
Amazing Lib really nice animation can be really useful in listviews
thaaaaaaaanks:rolleyes:donmanfred:rolleyes: im trying to keep up with ur warps [wrappers] :)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User

MarcoRome

Expert
Licensed User
Longtime User
Hi Don. Exist Event type
onClickListener

as in libray

4. Final step! Add onClickListener to your Folding Cell in MainActivity.java to toggle animation:

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get our folding cell
final FoldingCell fc = (FoldingCell) findViewById(R.id.folding_cell);
// attach click listener to folding cell
fc.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
fc.toggle(false);
}
});
}

Thank you
Marco
 

Douglas Farias

Expert
Licensed User
Longtime User
Hi man.

i tryed your example, but i dont understand the panels, idk if is a bug.

how can i show only one layout when it is closed?
for example here

proxy.php


is a closed panel, when user click it opens.

in your example, at first time i can see the 2 panels, the closed and the opned too.

i uploaded here 3 images to show what happens.

1.png = first time i run your example (note i can see the 2 layouts, 2 panels)
2.png = if i click at first time at FoldingCell, it close and show only layout 1
3.png = the FoldingCell is closed, if i click at the FoldingCell it opens


how can i make like the image above?
i need start with 2.png and if i click go to 3.png, if i click back, it back to 2.png.
how can i avoid the bug of 1.png?

thx and sorry for the bad english.

1.png 2.png 3.png
 

DonManfred

Expert
Licensed User
Longtime User
how can i make like the image above?
sorry for the late answer. I´m stressed these days (work, a old website must be updated (still)).

I tried to get rid of it a few hours the day you posted here...

I come a bit closer but it still showing kind of both layouts at the beginning.
I can´t figure it out. Maybe a but in the github project.
 

Wolli013

Well-Known Member
Licensed User
Longtime User
Hi man.

i tryed your example, but i dont understand the panels, idk if is a bug.

how can i show only one layout when it is closed?
for example here

proxy.php


is a closed panel, when user click it opens.

in your example, at first time i can see the 2 panels, the closed and the opned too.

i uploaded here 3 images to show what happens.

1.png = first time i run your example (note i can see the 2 layouts, 2 panels)
2.png = if i click at first time at FoldingCell, it close and show only layout 1
3.png = the FoldingCell is closed, if i click at the FoldingCell it opens


how can i make like the image above?
i need start with 2.png and if i click go to 3.png, if i click back, it back to 2.png.
how can i avoid the bug of 1.png?

thx and sorry for the bad english.

View attachment 51831 View attachment 51832 View attachment 51833

Wie kann ich so eine Präsentation erstellen?
 

DonManfred

Expert
Licensed User
Longtime User
This is the english part of the forum.
Please write english here.

Feel free to create a thread in the german forum.

About your question which is the same as Douglas is requesting.

The problem is that the lib as yet seem to have a bug. Not sure it the github project is the problem or my code or the way we are using it.
Still investigating.
 

Douglas Farias

Expert
Licensed User
Longtime User
about clv.
This is what I tried to do.


B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #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

#AdditionalRes: ..\res.FoldingCell
#Extends: android.support.v7.app.AppCompatActivity

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
    Private Button1 As Button
    Private Button2 As Button
    Private Button3 As Button
    Private fcell As FoldingCell
    Private flood As FoldingCellView
    Private CustomListView1 As CustomListView
   
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")
   
    Dim pfront As Panel
    pfront.Initialize("Panel")
    pfront.LoadLayout("front")
    Dim pback As Panel
    pback.Initialize("Panel")
    pback.Visible = False
    pback.LoadLayout("back")


'    fcell.addView(pback,100%x,350dip)
'    fcell.addView(pfront,100%x,100dip)
'    fcell.init(1500,Colors.Transparent,5)
'    fcell.fold(True)
   
   
    flood.Initialize("flood",pfront,pback)

   
    For i = 0 To 10
        Private p1 As Panel
        p1.Initialize("p1")
        p1.Color = Colors.Black
        p1.AddView(flood,0,0,100%x,100%y)
        CustomListView1.Add(p1,20%y,i)
        p1.Color = Colors.Transparent
    Next
   
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    fcell.fold(True)
End Sub

Sub Button2_Click
    fcell.unfold(True)   
End Sub

Sub Button3_Click
    fcell.toggle(True)
End Sub

this example crash in this line, when i try add the FoldingCellView to a panel, the same crash when i try use FoldingCell (fcell in this case)
B4X:
p1.AddView(flood,0,0,100%x,100%y)

if i try add this direct to a clv give crash too
B4X:
CustomListView1.Add(flood%y,i)
or
B4X:
CustomListView1.Add(fcell%y,i)

the error is the same, here is the log
** Activity (main) Pause, UserClosed = false **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Panel size is unknown. Layout may not be loaded correctly.
Panel size is unknown. Layout may not be loaded correctly.
Error occurred on line: 168 (CustomListView)
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:4277)
at android.view.ViewGroup.addView(ViewGroup.java:4127)
at android.view.ViewGroup.addView(ViewGroup.java:4099)
at anywheresoftware.b4a.objects.PanelWrapper.AddView(PanelWrapper.java:65)
at b4a.example.customlistview._insertatimpl(customlistview.java:485)
at b4a.example.customlistview._insertat(customlistview.java:72)
at b4a.example.customlistview._add(customlistview.java:58)
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:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at b4a.example.main.afterFirstLayout(main.java:102)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:80)
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:6946)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
** Activity (main) Resume **
** Activity (main) Resume **

this crash is when i try add the FoldingCell or FoldingCellView to a panel, any panel it crash.

can you fix this pls? i really need use this lib on a clv like the example gif>

thx again for the support.
 

DonManfred

Expert
Licensed User
Longtime User
this crash is when
The problem is that you are doing it wrong. That´s the crash.
I tried to build it on my own.. It was working but not as expected. I asked for help and now it is working better. But still not perfect...

Time for you to adapt it to your needs.

In my example it is working fine to UNFOLD the cell... But folding the same way does not look good. So i decided to do the folding not animated.

I can´t investigate more on this as i dont have the time

B4X:
Sub Globals

	Private clv1 As CustomListView
	Private Label1 As Label
	Private Button1 As Button
	Private CheckBox1 As CheckBox
	Private fcell As FoldingCell
End Sub


Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")

    For i = 0 To 10
        Private p1 As Panel
        p1.Initialize("p1")
        p1.Tag = i
        p1.Color = Colors.Black
        clv1.Add(p1,100dip,i)
        p1.LoadLayout("LayoutFolding")
       
        Dim pfront As Panel
        pfront.Initialize("Panel")
        pfront.LoadLayout("front")
        Dim pback As Panel
        pback.Initialize("Panel")
        pback.Visible = False
        pback.LoadLayout("back")

        fcell.addView(pback,100%x,350dip)
        fcell.addView(pfront,100%x,100dip)
        fcell.init(1500,Colors.Transparent,5)
        fcell.fold(True)
       
       
       
   
        'p1.Color = Colors.Transparent



    Next
    clv1.AddTextItem("Aaaa", "a")
    clv1.AddTextItem("Aaaa" & CRLF & "Bbbb", "b")
    clv1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc", "c")
    clv1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" , "d")
    clv1.AddTextItem("Aaaa" & CRLF & "Bbbb" & CRLF & "Cccc" & CRLF & "Dddd" & CRLF & "Eeee", "e")
End Sub
Sub FoldingCell_click()
    Log($"FoldingCell_click()"$)
    Dim cell As FoldingCell = Sender
    If cell.isUnfolded Then
        ' Fold
        Dim parent As Panel
        parent = cell.Parent
        Log($"Parent: ${parent.Left}:${parent.Top}   ${parent.Width} x ${parent.Height}   (Tag: ${parent.Tag})"$)
        'parent.SetLayout(0,0,100%x,100dip)
        Starter.csu.CallSubPlus2(Me, "Replace_Parent", 100, Array(parent,100dip,cell,True))
    Else
        ' Unfold
        Dim parent As Panel
        parent = cell.Parent
        Log($"Parent: ${parent.Left}:${parent.Top}   ${parent.Width} x ${parent.Height}   (Tag: ${parent.Tag})"$)
        'parent.SetLayoutanimated(1600,0,0,100%x,300dip)
        Starter.csu.CallSubPlus2(Me, "Replace_Parent", 100, Array(parent,300dip,cell,False))
    End If
End Sub
Sub Replace_Parent(args() As Object)
    Log($"Replace_Parent: $Time{DateTime.Now}"$)
    Dim p As Panel = args(0)
    p.SetLayout(0,0,100%x,args(1))
    p.RemoveView
    clv1.ReplaceAt(p.Tag,p,args(1),p.Tag)
    Starter.csu.CallSubPlus2(Me, "Parent_Layout", 1000, args)
    Dim cell As FoldingCell = args(2)
    cell.toggle(args(3))
End Sub
Sub Parent_Layout(args() As Object)
    Log($"Parent_Layout()"$)
    Dim p As Panel = args(0)
    p.SetLayoutAnimated(100,0,0,100%x,args(1))
End Sub
 

Attachments

  • clvex.zip
    69.6 KB · Views: 390

Mashiane

Expert
Licensed User
Longtime User

Smee

Well-Known Member
Licensed User
Longtime User
This looks fantastic, cant wait until I have time to put it to good use. Thanks @DonManfred for what looks to be a great library
 
Top