Android Question ULV problem!

ilan

Expert
Licensed User
Longtime User
i noticed the the content filter event is raised when you scroll to the top or to the buttom of the ulv.
why is it like this?

this always gives me an error.
when i hide a view in a panel and then it gets out of the visibility and then when it returns i get an error.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Selected date is: 06/2017
01/06/2017
salmas1: 0
salmas2: 154.56
currentMonth 0
Panel size is unknown. Layout may not be loaded correctly.
** Activity (main) Resume **
Error occurred on line: 1246 (Main)
java.lang.ClassCastException: anywheresoftware.b4a.BALayout cannot be cast to android.widget.TextView
at anywheresoftware.b4a.objects.TextViewWrapper.setText(TextViewWrapper.java:38)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at flm.b4a.ultimatelistview.b.getView(SourceFile:631)
at android.widget.AbsListView.obtainView(AbsListView.java:2929)
at android.widget.ListView.makeAndAddView(ListView.java:1945)
at android.widget.ListView.fillDown(ListView.java:719)
at android.widget.ListView.correctTooLow(ListView.java:1509)
at android.widget.ListView.fillGap(ListView.java:693)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:7293)
at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:4391)
at android.widget.AbsListView.onTouchMove(AbsListView.java:5782)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:5610)
at flm.b4a.ultimatelistview.UltimateListView.onTouchEvent(SourceFile:346)
at android.view.View.dispatchTouchEvent(View.java:9993)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2828)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2499)
at android.widget.AbsListView.dispatchTouchEvent(AbsListView.java:5547)
at flm.b4a.ultimatelistview.UltimateListView.dispatchTouchEvent(SourceFile:517)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2839)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2514)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2831)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1863)
at android.app.Activity.dispatchTouchEvent(Activity.java:3046)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2792)
at android.view.View.dispatchPointerEvent(View.java:10228)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5344)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5180)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:46
Message longer than Log limit (4000). Message was truncated.

the thing is that when i dont hide that view with Visible = False i dont get any errors.
also if i have not to much item where all items are visible i also dont get an error.

can i disable the call when i scroll to the top/bottom of the ulv?
 

ilan

Expert
Licensed User
Longtime User
here is the code of both subs:

B4X:
Sub myULV_lc(LayoutName As String, LayoutPanel As Panel)
    Dim w As Float = LayoutPanel.Width/5
    For i = 0 To 3
        Dim lbl As Label
        lbl.Initialize("")
        lbl.color = Colors.Transparent
        lbl.TextColor = Colors.RGB(52,73,94)
        lbl.TextSize = 15*fontajust
        lbl.Gravity = Gravity.CENTER
        lbl.Typeface = Typeface.DEFAULT        
        LayoutPanel.AddView(lbl, i*w, 0, w, LayoutPanel.Height)
    Next
   
    Dim btn4 As Button 'view 4
    btn4.Initialize("CldBtn")
    LayoutPanel.AddView(btn4,(4.095*w),LayoutPanel.Height*0.075, w-(w*0.175), LayoutPanel.Height*0.835)
   
    Dim lbl As Label 'view 5
    lbl.Initialize("")
    lbl.color = Colors.Transparent
    lbl.TextColor = Colors.White
    lbl.TextSize = 9*fontajust
    lbl.Gravity = Gravity.CENTER
    lbl.Typeface = Typeface.DEFAULT_BOLD       
    LayoutPanel.AddView(lbl, 4*w, 0, w, LayoutPanel.Height*0.525)
       
    Dim lbl As Label 'view 6
    lbl.Initialize("")
    lbl.color = Colors.Transparent
    lbl.TextColor = Colors.RGB(52,73,94)
    lbl.TextSize = 15*fontajust
    lbl.Gravity = Gravity.CENTER
    lbl.Typeface = Typeface.DEFAULT        
    LayoutPanel.AddView(lbl, 4*w, LayoutPanel.Height*0.035, w, LayoutPanel.Height)
   
    Dim btn As Button 'view 7
    btn.Initialize("CldBtndown")
    btn.Color = Colors.Transparent
    LayoutPanel.AddView(btn, (4.375*w), LayoutPanel.Height-(LayoutPanel.Height*0.125), w*0.25, LayoutPanel.Height*0.05)
   
    Dim checkPnl As Panel 'view 8
    checkPnl.Initialize("")
    checkPnl.Visible = False       
    LayoutPanel.AddView(checkPnl,(4.175*w),LayoutPanel.Height*0.145, w*0.65, w*0.65)
    Dim desrect As Rect
    desrect.Initialize(checkPnl.Width*0.1,checkPnl.Height*0.1,checkPnl.Width*0.9,checkPnl.Height*0.9)
    Dim cnv As Canvas
    cnv.Initialize(checkPnl)
    cnv.DrawCircle(checkPnl.Width/2,checkPnl.Height/2,checkPnl.Width/2,colorArray(colorInt),True,0)
    cnv.DrawBitmap(LoadBitmap(File.DirAssets,"sel1x.png"),Null,desrect)
    checkPnl.Invalidate
       
    Dim bmp As Bitmap
    bmp.Initialize(File.DirAssets,"note4.png")
   
    Dim noteimg As ImageView 'view 9
    noteimg.Initialize("")
    noteimg.Bitmap = bmp
    noteimg.Gravity = Gravity.FILL
    noteimg.Visible = False
    LayoutPanel.AddView(noteimg,4.075*w,LayoutPanel.Height-(w*0.35), w*0.265, w*0.265)
   
    Dim splbl As Label
    splbl.Initialize("")
    splbl.Visible = False
    splbl.color = Colors.Transparent
    splbl.TextColor = Colors.RGB(52,73,94)
    splbl.TextSize = 15*fontajust
    splbl.Gravity = Gravity.CENTER
    splbl.Typeface = Typeface.DEFAULT        
    LayoutPanel.AddView(splbl,2*w, 0, 2*w, LayoutPanel.Height)
End Sub

Sub myULV_cf(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)   
    LogColor("myulv_cf",Colors.Blue)
   
    LayoutPanel.color = Colors.White
    Dim listshift As shift
   
     Select LayoutName.ToLowerCase
         Case "myulv0"
            listshift = shiftlist.Get(Position)
        Case "myulv1"
            listshift = visshiftlist1.Get(Position)
        Case "myulv2"   
            listshift = visshiftlist3.Get(Position)   
    End Select
   
    Dim lbl1 As Label = LayoutPanel.GetView(0)
    lbl1.Text = listshift.totalwage
       
    Dim lbl2 As Label = LayoutPanel.GetView(1)
    If listshift.totalminutes = 0 Then lbl2.Text = "0:00" Else lbl2.Text = getworkedtime(listshift.totalminutes)
   
    Dim lbl3 As Label = LayoutPanel.GetView(2)
    If listshift.timeout = 0 Then lbl3.Text = "--:--" Else lbl3.Text = DateTime.Time(listshift.timeout)
   
    Dim lbl4 As Label = LayoutPanel.GetView(3)
    lbl4.Text = DateTime.Time(listshift.timein)
   
    Dim btn As Button = LayoutPanel.GetView(4)
'    btn.Tag = ItemID
    Dim vd As VectorDrawable
    vd.Initialize("zzz_calendar_blank")
    vd.ColorFilter = colorArray(colorInt)
    vd.Alpha = 255
    btn.Background = vd.Current
   
    Dim lbl5 As Label = LayoutPanel.GetView(5)
    lbl5.Text = WeekDaysStr(DateTime.GetDayOfWeek(listshift.timein)-1)
    lbl5.TextColor = Colors.White

'    DateTime.DateFormat = "dd/MM/yyyy"
    Dim lbl6 As Label = LayoutPanel.GetView(6)
    lbl6.Text = DateTime.GetDayOfMonth(listshift.timein)
    lbl6.TextColor = Colors.Black
   
    Dim btn2 As Button = LayoutPanel.GetView(7)
    btn2.Color = listshift.btnimg
   
    If listshift.timeout = 0 Then
        lbl1.TextColor = Colors.Red
        lbl2.TextColor = Colors.Red
        lbl3.TextColor = Colors.Red
        lbl4.TextColor = Colors.Red
    Else
        lbl1.TextColor = Colors.Black   
        lbl2.TextColor = Colors.Black
        lbl3.TextColor = Colors.Black
        lbl4.TextColor = Colors.Black
    End If
   
    Dim checkpnl As Panel = LayoutPanel.GetView(8)   
    btn.Tag = checkpnl
           
    Dim noteimg As ImageView = LayoutPanel.GetView(9)
    If listshift.dayinfo <> "" And listshift.dayinfo <> "specialdays" Then
        noteimg.Visible = True
    Else
        noteimg.Visible = False
    End If
   
    Dim splbl As Label = LayoutPanel.GetView(10)
    If listshift.dayinfo = "specialdays" Then
        splbl.Text = listshift.shiftid
        splbl.Visible = True       
        lbl3.Visible = False
        lbl4.Visible = False
    Else
        splbl.Visible = False
        lbl3.Visible = True
        lbl4.Visible = True   
    End If
   
    LayoutPanel.Tag = listshift 'shift type to tag property
End Sub

in runtime i hide or show checkpnl when it was pressed like this:

B4X:
Sub CldBtn_Click
    Dim btn As Button = Sender
    Dim pnl As Panel = btn.Parent
    Dim checkpnl As Panel = btn.Tag
   
    If pnl.Tag Is shift Then
        Dim newshift As shift = pnl.Tag
        Dim str As String = newshift.id
       
        If selectedItems.IndexOf(str) > -1 Then
            pnl.Color = Colors.White
            checkpnl.Visible = False
            Dim vd As VectorDrawable
            vd.Initialize("zzz_calendar_blank")
            vd.ColorFilter = colorArray(colorInt)
            vd.Alpha = 255
            btn.Background = vd.Current           
            selectedItems.RemoveAt(selectedItems.IndexOf(str))   
        Else
            pnl.Color = Colors.ARGB(255,245,245,245)
            checkLW.Initialize
            checkLW.left = checkpnl.Left
            checkLW.width = checkpnl.Width       
            checkpnl.Width = 0
            checkpnl.Left = btn.Left + (btn.Width/2)
            checkpnl.Visible = True
            checkpnl.BringToFront
            checkpnl.SetLayoutAnimated(250,checkLW.left,checkpnl.Top,checkLW.width,checkpnl.Height)
           
            Dim back As ColorDrawable
            back.Initialize(Colors.Transparent,0)
            btn.Background = back
            selectedItems.Add(str)
        End If
    End If

    If selectedItems.Size > 0 And newshiftadd.Tag = "0" Then
        animatNewshiftAdd(LoadBitmap(File.DirAssets,"removebtn2.png"),"1")
    Else if selectedItems.Size = 0 Then
        selectedItems.Clear
        animatNewshiftAdd(LoadBitmap(File.DirAssets,"plusbtn.png"),"0")
    End If
End Sub

please i need help. its really frustrating :(
 
Upvote 0
Top