Android Question Where to put stuff?

Discussion in 'Android Questions' started by Troberg, Apr 28, 2015.

  1. Troberg

    Troberg Well-Known Member Licensed User

    My problem:

    I have a class which is global to the Project (named Glob), with same common framework stuff in it.

    Now, Glob in turn houses some other objects, some of them containing code which handles panels and other GUI components. This means that I can't dim Glob in Globals in the Main activity.

    Where do I put such code for it to work, without having to put everything in Main activity?
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I dont see how it can really be done. The UI has to be decoupled from the process.
    Do you actually get an error if you do it the current way (with Glob in Process_Globals referring to other classes that refer to UI components)?
    If you dont get an error, and you are careful with the references, maybe it is safe?

    For e.g. if you have a large imageview, and the activity is finished, does the imageview reference now point to null (so we can dereference it) or does it still hold a large bitmap?
    lemonisdead, Troberg and NJDude like this.
  3. Troberg

    Troberg Well-Known Member Licensed User

    I get an error at compile time.

    I'm considering, but have not tried it yet, to simply declare it as object, and then, at a later time, put the data in it and cast it to the correct type as needed.

    I think I might be able to rebuild it in this case to solve this issue, but I think it will be harder in other cases down the road.
    thedesolatesoul likes this.
  4. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I am sure there is a solution to it as the ooVoo SDK that I wrapped followed this kind of code pattern. I'm just not sure what its called and how its done.
    It is possible a singleton class at the applicationContext. Then you are able to attach an activity object and detatch it.
    For e.g. timers live in process globals but hold some activity context in order to know if it is active and the event can be raised.
    Troberg likes this.
  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