I would put the adapter in a adapters
package. Even if it is small adapter, mostly its to be used within a activity in a dialog, with operations reflecting back to activity
you will never know how that adapter is going to evolve and in what situation it is going to be used.
Regarding to your concerns:
Too much of context references
- Each instance of your adapter will have a singleContext
to reference. As long as you're not leaking anything from your adapter, then this is not a problem. You may have this adapter extended by other implementations as well and that will apply to those implementation as well.All methods end up public, which fails the OOP's concept of hiding implementation details
. As long as you're calling adapter from your app (which should always be the case) and you're not building an SDK, then I really don't see the problem. If you're worried about OOP best practices, I would rather worry about making the adapter respectSingle Responsibility Principle
: don't let the adapter do more than display the given data.- Considering re-usability, I would rather not have adapter as a private (static or not) class member. To add more, there is a best practice that discourages usage of
private
access when you're dealing with callingprivate
code from inner classes.
So to wrap-up, considering re-usability, Single Responsibility
and the best practice article, I'm in favor or separating adapters
to dedicated classes.