Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException ListAdapter.getCount(); #45

Open
cesards opened this issue Feb 3, 2014 · 8 comments
Open

NullPointerException ListAdapter.getCount(); #45

cesards opened this issue Feb 3, 2014 · 8 comments
Assignees
Labels
Milestone

Comments

@cesards
Copy link

cesards commented Feb 3, 2014

I'm getting an error just doing setContentView.

Here is my list layout:

<com.etsy.android.grid.StaggeredGridView
      android:id="@+id/product_grid"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:column_count_landscape="3"
      app:column_count_portrait="2"
      app:grid_paddingBottom="@dimen/padding_medium"
      app:grid_paddingLeft="@dimen/padding_medium"
      app:grid_paddingRight="@dimen/padding_medium"
      app:grid_paddingTop="@dimen/padding_medium"
      app:item_margin="@dimen/padding_medium"/>

Here the staktrace:

java.lang.NullPointerException: Attempt to invoke interface method 'int android.widget.ListAdapter.getCount()' on a null object reference
            at com.etsy.android.grid.ExtendableListView.getLastVisiblePosition(ExtendableListView.java:1828)
            at android.widget.AdapterView.onInitializeAccessibilityEvent(AdapterView.java:957)
            at android.widget.AbsListView.onInitializeAccessibilityEvent(AbsListView.java:1443)
            at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:4946)
            at android.view.View.sendAccessibilityEventUnchecked(View.java:4933)
            at android.view.View$SendViewStateChangedAccessibilityEvent.run(View.java:19472)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5019)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

Thanks!!

@hellovierco
Copy link

Hi,
I have exactly the same error
appreciate any help.

Thank you! :)

@ChristopheVersieux
Copy link

Exactly the same problem here... I will make some more tests, but I cannot reproduce on my own device, only reports from Play Store.

@denizmveli denizmveli added the bug label Feb 22, 2014
@denizmveli denizmveli added this to the 1.0.5 milestone Feb 22, 2014
@denizmveli denizmveli self-assigned this Feb 22, 2014
@denizmveli
Copy link
Contributor

Looking

@gonjay
Copy link

gonjay commented Mar 2, 2014

I meet same problem..

W/dalvikvm﹕ method Lcom/etsy/android/grid/ExtendableListView;.fillGap incorrectly overrides package-private method with same name in Landroid/widget/AbsListView;
W/dalvikvm﹕ method Lcom/etsy/android/grid/ExtendableListView;.getFooterViewsCount incorrectly overrides package-private method with same name in Landroid/widget/AbsListView;
W/dalvikvm﹕ method Lcom/etsy/android/grid/ExtendableListView;.getHeaderViewsCount incorrectly overrides package-private method with same name in Landroid/widget/AbsListView;
W/dalvikvm﹕ method Lcom/etsy/android/grid/ExtendableListView;.invokeOnItemScrollListener incorrectly overrides package-private method with same name in Landroid/widget/AbsListView;
W/dalvikvm﹕ method Lcom/etsy/android/grid/ExtendableListView;.rememberSyncState incorrectly overrides package-private method with same name in Landroid/widget/AdapterView;
W/dalvikvm﹕ method Lcom/etsy/android/grid/ExtendableListView;.reportScrollStateChange incorrectly overrides package-private method with same name in Landroid/widget/AbsListView;
03-02 20:11:26.757  32765-32765/org.rubychina.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: org.rubychina.app, PID: 32765
    java.lang.NullPointerException
            at com.etsy.android.grid.ExtendableListView.getLastVisiblePosition(ExtendableListView.java:1828)
            at android.widget.AdapterView.onInitializeAccessibilityEvent(AdapterView.java:957)
            at android.widget.AbsListView.onInitializeAccessibilityEvent(AbsListView.java:1443)
            at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:4946)
            at android.view.View.sendAccessibilityEventUnchecked(View.java:4933)
            at android.view.View$SendViewStateChangedAccessibilityEvent.run(View.java:19472)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

@gonjay
Copy link

gonjay commented Mar 2, 2014

I know what's cause this problem just now.

You need to setAdapter before return the Fragment'view.

@zeitos
Copy link

zeitos commented Apr 1, 2014

I've got exactly the same error in production with Moto X running android 4.4 and I can't reproduce it,
Gonjay can you elaborate a little bit more?

@denizmveli
Copy link
Contributor

I wasn't able to reproduce with a fragment example added to the sample app. Could you please share the creation code of your fragment.

I did however add a check against the null adapter in the getLastVisiblePosition() so this should now be fixed.

@denizmveli denizmveli modified the milestones: 1.0.6, 1.0.5 May 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants