Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Port some features of Butter Knife #975

Description

@WonderCsabo

Butter Knife is a view "injection" library for Android, which also uses code generation, and a little reflection to avoid using new names like MyActivity_. In general, AA can do much-much more than Butter Knife, but some new features can be considered to be ported to AA.

View lists

@InjectViews({ R.id.first_name, R.id.middle_name, R.id.last_name })
List<EditText> nameViews;

Views which can be handled together can be injected to a single List. Also a convenience ButterKnife.apply is provided to avoid foreach, and that can use an Android Property, too.

Single method multiple IDs

@OnClick({ R.id.door1, R.id.door2, R.id.door3 })
public void pickDoor(DoorView door)

I think we could add another parameter to our relevant annotations which accepts an array of ints, and is null by default.
What do you think, guys?

Activity

  1. yDelouis commented on Apr 22, 2014

    @yDelouis
    Contributor

    The view list feature is interesting.

    For @Click, and similar annotations, you already can set an array of ids with AA.

  2. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    MemberAuthor

    For @Click, and similar annotations, you already can set an array of ids with AA.

    Ooops, you are right, how could i forget that. Great! :) Then this issue is just limited to View lists.

  3. DayS commented on Apr 22, 2014

    @DayS
    Contributor

    Interesting indeed. But is that really helpful in common Android development ? Do you see any use case where this feature could help the developer ?

  4. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    MemberAuthor

    You have a main menu, with some buttons. If network is not available, only some of them are clickable. If you do not use View lists you have to collect them yourself and disable them one-by-one. With view lists it can be done by AA/Butter knife.

    Suddenly i cannot tell you a better example, but i am sure Jake could tell us more use cases.

  5. yDelouis commented on Apr 22, 2014

    @yDelouis
    Contributor

    I have the same thing in one of my app where there are three similar views and I want to update them all when an event is triggered.

  6. DayS commented on Apr 22, 2014

    @DayS
    Contributor

    Well, why not. Feel free to implement this one then :)

  7. added this to the 3.1 milestone on Apr 22, 2014
  8. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    MemberAuthor

    I can do it in the future. But i'm ok with @yDelouis doing this if he is faster then me. :)

  9. yDelouis commented on Apr 22, 2014

    @yDelouis
    Contributor

    I'll take this one. You already have some work with the test project and Robolectric. :)

  10. WonderCsabo commented on Apr 22, 2014

    @WonderCsabo
    MemberAuthor

    If i only had that two... Thanks, i am looking forward for your implementation!

  11. DayS commented on Apr 22, 2014

    @DayS
    Contributor

    PRs... PRs everywhere ._.

  12. DayS commented on May 11, 2014

    @DayS
    Contributor

    Merged. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions