etsy/AndroidStaggeredGrid

NullPointerException ListAdapter.getCount();

cesards opened this issue · 8 comments

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

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

Thank you! :)

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

Looking

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)

I know what's cause this problem just now.

You need to setAdapter before return the Fragment'view.

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?

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.