Git Product home page Git Product logo

annotatedadapter's People

Contributors

ersin-ertan avatar intrications avatar sockeqwe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

annotatedadapter's Issues

Don't generate duplicated ViewHolders on Adapter inheritance

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).

Enhancement: use Data Binding

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?

AbsListView

Support AbsListView like ListView and GridView.

Model casting

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.

  1. 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:
   public void bindFooRow(FooRowViewHolder vh, int position, MyModel item);

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.

License

Hello. I know it is not an actual issue, but under what is this licensed? Apache License, Version 2.0?

Thank you :)

Support library projects

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.

Could not find adapter delegate

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.

Providing a method to do additional setup after a view has been inflated

Is something like that useful?

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:

@ViewType (
     layout = ... ,
     fields = ... ,
     initMethod = true
)
public final int fooRow = 0;

initMethod = true (default = false) would force to generate a method in the binder interface like this:

public void initFooRow(View inflatedView, FooRowViewHolder vh)

annotated with @ViewType.

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...

Igor

Adapter to take generic types

A useful place to have a generic type. Enhancement?

public class RecyclerAdapter<Type> extends SupportAnnotatedAdapter
        implements RecyclerAdapterBinder{

    @ViewType( ...)

    List<Type> items;
    public RecyclerAdapter(final Context context, List<Type> items){
        super(context);
        this.items = items;
    }
    @Override
    public int getItemCount(){ return items != null ? items.size() : 0;}

    @Override
    public void bindViewHolder(final RecyclerAdapterHolders.RowTxtViewHolder vh, final int position){
        Type item = items.get(position);
    }

RecyclerViews positional click

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).

Clicks on row in RecyclerView

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.

Thanks,
Igor

Better refactoring support

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.

RecyclerView as ViewField

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.

Please advise,
Igor

Automatically detect ViewHolder fields

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:

  1. 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
  2. Layout xml files in different folders like layout, xlarge-layout etc.
  3. The res folder itself is configureable through gradle configuration
  4. xml layout can include other layouts

However it would be awesome to have such a feature!

Use annotated interface instead of annotated int

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
          )
        }
    )
 public final int iconRow = 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:

@ViewType(id = 1, layout = R.layout.cell_with_icon)
public interface IconRowViewHolder {
   @ViewField(R.id.textView) TextView text;
   @ViewField(R.id.iconImageView) ImageView icon;
}

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.