Android Question Where to put stuff?

Troberg

Well-Known Member
Licensed User
Longtime 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?
 

thedesolatesoul

Expert
Licensed User
Longtime 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?
 
Upvote 0

Troberg

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime 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.
 
Upvote 0
Top