I want to write an Android library, which in turn uses another Androd library.
Let's say I want to write libHigh which uses another libLow
There is an interface in libLow:
interface LowLevelInterface{
fun methodA()
}
and I implement this in my higher level library libHigh:
open class OpenClassImpl : LowLevelInterface {
override fun methodA(){//..}
}
It is an 'open' class, because later in app layer I expect to extend from OpenClassImpl.
But I dont want to make the interface 'LowLevelInterface' visible for later upper app level usage.
How can I hide the interface from libLow for the upper app level?
It depends on your existing code whether this will work, or how much effort it will be, but you could have a property implementing the interface instead of doing it directly:
open class OpenClassImpl {
// or protected/private
internal val lowLevelImpl: LowLevelInterface = {
// can access privates of OpenClassImpl here
}
}
and change the relevant calls to pass it.