CWAC AdapterWrapper: Adding Bits o' Functionality
Android comes with a few "wrapper" classes, like CursorWrapper
, that make it relatively easy for you to add just a bit of functionality to an existing object. The wrapper delegates all behaviors to the wrapped object; you just override the specific behaviors you need. This works well in cases where there are many possible underlying implementations, so you could not robustly accomplish these ends by subclassing.
Android lacks such a wrapper for ListAdapter
, though. There is a WrappedListAdapter
entry in the SDK, but it is an interface, not an implementation.
So, CWAC offers an AdapterWrapper
to fill this void.
By itself, it is not terribly interesting. However, other CWAC projects take advantage of it.
This Android library project is available as a JAR or as an artifact for use with Gradle. To use that, add the following blocks to your build.gradle
file:
repositories {
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
dependencies {
compile 'com.commonsware.cwac:adapter:1.0.5'
}
Or, if you cannot use SSL, use http://repo.commonsware.com
for the repository URL.
NOTE: The JAR name, as of v1.0.2, has a cwac-
prefix, to help distinguish it from other JARs.
Usage
Just extend AdapterWrapper
and override whatever adapter-related methods you wish. By default, all adapter methods delegate to the wrapped adapter. Your code can get at the wrapped adapter by calling getWrappedAdapter()
.
Dependencies
None at present.
Version
This is version v1.0.5 of this module. And there was much rejoicing.
Demo
There is no demo project.
License
The code in this project is licensed under the Apache Software License 2.0, per the terms of the included LICENSE file.
Questions
If you have questions regarding the use of this code, please post a question on Stack Overflow tagged with commonsware-cwac
and android
after searching to see if there already is an answer. Be sure to indicate what CWAC module you are having issues with, and be sure to include source code and stack traces if you are encountering crashes.
If you have encountered what is clearly a bug, please post an issue. Be certain to include complete steps for reproducing the issue. The contribution guidelines provide some suggestions for how to create a bug report that will get the problem fixed the fastest.
You are also welcome to join the CommonsWare Community and post questions and ideas to the CWAC category.
Do not ask for help via Twitter.
Release Notes
- v1.0.5: added sources and JavaDocs JARs to the uploaded artifacts
- v1.0.3: updated for Android Studio 1.0 and new AAR publishing system
- v1.0.2: updated Gradle, fixed manifest for manifest merging, added
cwac-
prefix to JAR - v1.0.1: added Gradle build files and published AAR
- v1.0.0: made this the official 1.0 release
- v0.4.0: converted to Android library project