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.

StickyListHeadersListView has build error with AA 4.1.0 #1845

Description

@TomWangTW

Hi AA team,
I found AA 4.1 has build error with lib:StickyListHeaders and it works fine when AA 4.0.
soucrce:https://github.com/emilsjolander/StickyListHeaders

When i have an object which like:
@ViewById
StickyListHeadersListView lvStickyList;

and then i set it ItemClick as below:
@ItemClick(R.id.lvStickyList)
void itemClick(int position) {

It will cause build error as
error: incompatible types: StickyListHeadersListView cannot be converted to AdapterView ((AdapterView ) this.lvStickyList).setOnItemClickListener(new OnItemClickListener() {
...

Maybe it is a side effect by #1785 Cast views to the required type when adding callbacks.
Any solution for this? Thx.

Activity

  1. dodgex commented on Oct 10, 2016

    @dodgex
    Member

    first of all sorry for the late response.

    yeah this is indeed a side effect of #1785. unfortunately I currently have no idea for a good fix.

    one possible way is to allow a class parameter to the annotation to specify the class to be used for the cast.

    e.g.

    @ItemClick(value = R.id.lvStickyList, castTo = StickyListHeadersListView.class)
    void itemClick(int position) {
    }
    

    and then generate the cast like

    ((StickyListHeadersListView) this.lvStickyList).setOnItemClickListener(new OnItemClickListener() {
       //...
    }
    

    but this does not feel clean... @WonderCsabo do you have an idea how to fix this issue?

  2. WonderCsabo commented on Oct 10, 2016

    @WonderCsabo
    Member

    The castTo parameter is horrible. However i am not sure why this error is happening. Why the class cannot be cast to its parent class? 😕

  3. dodgex commented on Oct 10, 2016

    @dodgex
    Member

    StickyListHeadersListView is not a child of AdapterView and I'm pretty sure this is also true for PullToRefreshListView mentioned in #1871

  4. WonderCsabo commented on Oct 10, 2016

    @WonderCsabo
    Member

    I am not sure we want to support these badly designed fake ListView classes.

  5. TomWangTW commented on Oct 11, 2016

    @TomWangTW
    Author

    Well, after i traced the source code of AA, i think it is very hard to support customize view gracefully...
    But so many projects used third-party customize view, so if you make sure AA doesn't support it,
    maybe should be written in 4.1 documents or use instanceof to check these views could cast to AdapterView or not.

  6. WonderCsabo commented on Nov 23, 2016

    @WonderCsabo
    Member

    I am closing this one, as i think we should put effort into supporting some ListView-ish classes, as development moved to the much robust RecyclerView class.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions