declex
declex copied to clipboard
@AdapterMethod annotation
When using AdapterViews or RecyclerView it is used @AdapterClass to specify a custom adapter. But some times there's only some small things which need to be done in the adapter, and declaring whole a class for this is a good proof of writing boilerplate code. Also, the solution cannot be used if there's more than one list referenced in the same @Populate class... An annotation called @AdapterMethod can be used to link a method to the adapter of a view:
@Populate
List<Clock_> clocks;
@AdapterMethod("clock")
public View inflate(LayoutInflater inflater, int viewType) {
if (viewType == 1) {
return inflater.inflate(R.layout.item_tap_for_more, null);
} else {
return inflater.inflate(R.layout.item_user_shift, null);
}
}