Pablichjenkov
10/13/2019, 4:02 AMobject
.spierce7
10/13/2019, 4:14 AMApplication
object. Otherwise, that’s what I’d do.spierce7
10/13/2019, 4:19 AMinterface
. so that a mock one for testing can be created.
The current approach that I’m taking is that in the constructor of the object, I’m assigning it a Long
id
from an AtomicLong
, and inserting it into an internal object
where it’s held with a WeakReference
.
Then I pass the id of it into the Activity
, and the Activity
pulls it from the internal object that keeps track of any active instance. I’m not very happy with this approach though. It’s VERY hacky. I’m unsure of any alternatives thoughlouiscad
10/13/2019, 11:49 AMspierce7
10/14/2019, 4:32 AMlouiscad
10/14/2019, 6:37 AMBroadcastReceiver
and object
. It can help have the application Context for cases where the activity's one is not needed, but I think that's irrelevant for your need, I'm sorry for the noise.spierce7
10/14/2019, 3:22 PMPablichjenkov
10/14/2019, 4:32 PMCompanyAuth()
to CompanyAuthClient()
or CompanyAuthAccessor()
or CompanyAuthConnection()
. Some name that indicates a user of this class that you don't talk directly to the CompanyAuth()
implementation but to an intermediary class.spierce7
10/14/2019, 5:20 PMCompanyAuth
, with the function CompanyAuth
to get an instance of it, but then I have the instance returned from the function to be an object:
internal object InternalCompanyAuth : CompanyAuth {
// ...
}
fun CompanyAuth(): CompanyAuth = InternalCompanyAuth
Pablichjenkov
10/14/2019, 5:42 PMgetCompanyAuth()
. Using CompanyAuth()
sounds like you are creating a new class instance, and is not the casespierce7
10/14/2019, 5:46 PM