If you have a FooAdapter class containing @ViewType fields the ViewHolder classes are generated for FooAdapter. If you create a second adapter class FooAdapter2 extends FooAdapter then FooAdapter2 will also generate ViewHolders that have already been generated for the base class (in another package).
Hi,
I was wondering if there are any plans to use Android's new Data Binding framework inside of AnnotatedAdapter. Or perhaps there is an easy way for devs to integrate it themselves now?
Often you have to cast the data model (retrieved from a list) to a specific class for each view type.
Even if its not a big deal it would be nice if that cast could be done internally.
Introduce an optional model property in @ViewTyp java @ViewType( layout = R.layout.foo , fields = {...} , model = MyModel.class ) public final int fooRow = 0;
The Binder-Interface should contain a method with the already casted method:
Unlikely AbsListView, RecyclerView does not have a method public Object getItem(int postition). So the AnnotatedAdapter class must provide this method. Ideally this method should only be implemented if at least one @ViewType with model = ... is in the adapter, otherwise this method must not be implemented. So we could put it into the binder interface.
Remove the delegator map. Make it part of the AdapterBinder interface so that everyone Adapater has to return a instance of its delegate by its own, completely without reflections.
Hey,
thanks for the library!
do you have any thought why adapter delegate is not being generated sometimes?
java.lang.RuntimeException: Could not find adapter delegate for com.buneyeu.myapp.fragment.messages.MessagesAdapter@554b2a1 at com.hannesdorfmann.annotatedadapter.AutoSupportDelegators.getDelegator(AutoSupportDelegators.java:22) at com.hannesdorfmann.annotatedadapter.support.recyclerview.SupportAnnotatedAdapter.<init>(SupportAnnotatedAdapter.java:36) at com.buneyeu.myapp.adapters.BaseListAnnotatedAdapter.<init>(BaseListAnnotatedAdapter.java:19) at com.buneyeu.myapp.fragment.messages.MessagesAdapter.<init>(MessagesAdapter.java:71) at com.buneyeu.myapp.fragment.messages.MessagesFragment.onCreate(MessagesFragment.java:65) at com.buneyeu.myapp.fragment.messages.MessagesFragment_.onCreate(MessagesFragment_.java:38) at android.support.v4.app.Fragment.performCreate(Fragment.java:1939) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1029) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Clean rebuild helps things, but it's annoying to unexpectedly see the crash. AutoSupportDelegators contains, let's say, only 2 of 7-8 annotated adapters.
Currently there is no way to manipulate the inflated view directly after the view has been inflated. Some things could be set in the corresponding bind method, but it would be better to do it only once in onCreateViewHolder().
An additional property "initMethod" could be added to @ViewType like this:
Hello,
I am getting the following compilation error:
Error:(30, 37) error: mHousecalls in HistoryListAdapter is not public. Only final integer fields with public visibility can be annotated with @ViewType.
This does not make sense to me. Please elaborate...
Hey Hannes, how would a click listener work with positional clicks, similar to listviews?
I have tried the sample and have gotten to the point where I can differentiate between types of clicks(text, and image).
Hi,
is there a way to set onClickListeners on rows of RecyclerView with your SupportAnnotatedAdapter? The only methods I see I can override are oBindViewHolder and createViewHolder.
Refactoring (at least in intellij) is a little bit painful, because renaming the adapter class will not rename the Delegate, Binder and ViewHolder. Probably this problem could be solved by make them all be a public static inner class of the origin Adapter class.
However refactoring viewtypes will definetly be not as easy because the IDE doesn't know the relation between a field name and the corresponding generated view holder class.
Hello,
is it possible to define a RecyclerView as a @Viewfield? Like this: @ViewField(id = R.id.chargersRecyclerView, type = RecyclerView.class, name = "chargersRecyclerView")
Currently when I do this, it doesn't show up on the screen.
Automatically detect fields from the corresponding xml layout files by checking for views with an id. So you don't have to specify fields for the view holder by hand with@Field
However, that's not an easy task:
How do I access resource folder from the annotation processor? It runs in it's own jvm. How do I get the path of the current execution
Layout xml files in different folders like layout, xlarge-layout etc.
The res folder itself is configureable through gradle configuration
xml layout can include other layouts
However it would be awesome to have such a feature!
Currently AnnotateAdapter uses annotations on a integer field to generate ViewType.
@ViewType(
layout = R.layout.cell_with_icon,
views = {
@ViewField(
type = TextView.class,
name = "text",
id = R.id.textView
),
@ViewField(
type = ImageView.class,
name = "icon",
id = R.id.iconImageView
)
}
)
publicfinalinticonRow = 1;
And using this a class AdapterHolders.IconRowViewHolder is generated. An alternate implementation could be by allowing the users to define an interface and annotate it. The above would then be represented as:
This is closer to @Bind annotation of ButterKnife. And this seems a more intuitive way of defining fields rather than providing options to annotations.
Although if #4 is solved it'd be way more awesome.