Bug? Not sure if its a bug, but...

Discussion in 'Bugs & wishlist' started by Cableguy, May 27, 2015.

  1. Cableguy

    Cableguy Expert Licensed User

    I am getting errors in runtime after compilation in a strange situation...

    I have a few views created by code, and positioned relative to other views.
    I then try to manipulate some props using canvas.
    With screen on, the app works fine, BUT, with screen OFF, it compiles and errors with the canvas complaining about the width and height of the targeted view having to be greater than zero.
    To trouble shoot I placed a simple log statement

    Code:
    Log(Props1Header.Width)
    and to my surprise, screen ON gives positive values, but screen OFF gives NEGATIVE values... Height returns always positive values.

    I am connecting my device by usb cable
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you post your code (or a simple project that demonstrates it)?
     
  3. Cableguy

    Cableguy Expert Licensed User

    I will only be able to in late afternoon, but all i did was create 6 panels in code, initialised them and set their color drawable to get the round corners and borders. I then added 6 labels one for each panel, and did the same with their color drawable. The panels are placed with the same height/width and spaced vertically relative to the previous one. The labels are place inside the panels, one per panel, and have fixed height and take the panels width.
    I then call a sub passing the label as view.
    In this sub I initialise a canvas and set its target to be the passed view. In this sub I only have that, plus two log statements to show the passed views height and width.
    With my phone connected by USB ( haven't tested using bridge), if the screen is ON when deploying, the width value is positive, but if the screen happens to be or to go OFF, the the value is returned as a Negative (ie: 800 vs -800).In which case the app crashes at the canvas, conplaini the view width/height must be larger than zero.
    Placing the same log in the main sub, after all views are set and placed, gives the same values (positive/negative)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The expected behavior is that the activity is paused when the screen turns off so no canvas related code should be executed at that point.
     
  5. Cableguy

    Cableguy Expert Licensed User

    I understand that, but why is the view width negative???

    my main is as follows

    Code:
    Sub Activity_Create(FirstTime As Boolean)
      
    Panel1.Initialize(
    "Props1")
    Header1.Initialize(
    "")
    Private ACD As ColorDrawable
    ACD.Initialize(
    Colors.LightGray, 5dip)
    Activity.Background = ACD
      
        
    Private PCD As ColorDrawable
        PCD.Initialize2(
    Colors.Gray, 3dip2dipColors.DarkGray)
        Panel1.Background = PCD
      
        
    Private PHCD As ColorDrawable
        PHCD.Initialize2(
    Colors.Cyan, 3dip2dipColors.DarkGray)
        Header1.Background = PHCD
      
        
    Activity.AddView(Panel1, 1%y1%y50%x , 10%y)
      
        PropsPanel1.AddView(Props1Header, 
    00, Panel1.Width,10%y)
      
        
    Log(Props1Header.Width)
    End Sub
    EDIT : I also found that the values are different, screen OFF = -807, screen ON = 889...
    even more puzzled
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please create a small example and upload it.
     
  7. Cableguy

    Cableguy Expert Licensed User

    Although I cannot reproduce it in a blank project, it still happens on my current project and I can't understand why.
    So here is my current project, please enlight me why this is happening...
     

    Attached Files:

    • BUG.zip
      File size:
      12.2 KB
      Views:
      17
  8. Erel

    Erel Administrator Staff Member Licensed User

    What is the reason behind this line?
    Code:
    Activity.AddView(Separator, 100%x - 100%y - 2dip1%y4dip98%y)
    Why is the left property set based on the activity height?
     
  9. Cableguy

    Cableguy Expert Licensed User

    That way since my app is to be used in landscape, the separator will be placed in such a way that the right side of the activity will be a square, which will then have a square panel
     
    Last edited: Jun 1, 2015
  10. Erel

    Erel Administrator Staff Member Licensed User

    I see it too. However it will not have any effect on your app as the user cannot start the activity when the screen is off. This will only happen during development.
     
    Cableguy likes this.
  11. Cableguy

    Cableguy Expert Licensed User

    The only annoying thing about this is that when it happens, if I'm in hot swap mode making changes in the code, the debugger closes, and the cursor jumps to the "error" line, and sometimes I end up adding partial keywords out of place...
     
  12. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Sounds like your almost atttempting to multi-task and we all know that men should not multi-task, our brains are wired differently to women who are expected to multi-task :p
    I hope that I haven't just caught the wrath of @lemonisdead with that comment ;)
     
    Cableguy likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice