TonicArtos / StickyGridHeaders

This project has been superseded by SuperSLiM, a layout manager for RecyclerView. I strongly recommend using SuperSLiM and not StickyGridHeaders.
http://tonicartos.com
Apache License 2.0
1.47k stars 441 forks source link

Error supporting platform 19 #99

Closed SylvainRousson closed 6 years ago

SylvainRousson commented 10 years ago

When I use columns on tablets, I am facing this issue randomly on Nexus 7 :

com.tonicartos.widget.stickygridheaders.StickyGridHeadersGridView$RuntimePlatformSupportException: Error supporting platform 19. at com.tonicartos.widget.stickygridheaders.StickyGridHeadersGridView.attachHeader(StickyGridHeadersGridView.java:1049) at com.tonicartos.widget.stickygridheaders.StickyGridHeadersBaseAdapterWrapper.getView(StickyGridHeadersBaseAdapterWrapper.java:183) at android.widget.AbsListView.obtainView(AbsListView.java:2255) at android.widget.GridView.makeAndAddView(GridView.java:1345) at android.widget.GridView.makeRow(GridView.java:345) at android.widget.GridView.fillUp(GridView.java:386) at android.widget.GridView.fillGap(GridView.java:262) at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5143) at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4254) 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:5001) 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:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.tonicartos.widget.stickygridheaders.StickyGridHeadersGridView.attachHeader(StickyGridHeadersGridView.java:1039) ... 17 more Caused by: java.lang.NullPointerException at android.view.View.dispatchAttachedToWindow(View.java:12600) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2458) ... 20 more

Any idea about this problem ?

TonicArtos commented 10 years ago

This is due to a dirty hack that should never have been done and I am very sorry I did it. If you are not using widgets other than a text view then I suggest grabbing an earlier version of SGH. I am working on a new version of SGH but that work is dependent on RecyclerView in the Android L preview of the v7 compatibility library.

This is the last commit before all the bad things started 8c14279e04ff94c51d5e385f5ad3954035f38685.

SylvainRousson commented 10 years ago

thank you for your fast answer.

Could you please recommand me the best version to use ? I integrated it in my application which is an update of a famous sport application. I really need to fix it as fast as I can !

SylvainRousson commented 10 years ago

Or maybe just removing the complex view I put in the Header, and replace it with TextView without images ?

This is my header view (non sticky header view in this case) : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:customfonts="http://schemas.android.com/apk/res-auto" android:id="@+id/header_stories" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_weight="@integer/header_button_weight" android:paddingBottom="@dimen/padding_default" android:paddingRight="@dimen/padding_default" android:paddingTop="@dimen/padding_huge" >

<LinearLayout
    android:id="@+id/buttons_bar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/header_button_item_height"
    android:layout_alignParentTop="true"
    android:layout_gravity="center_horizontal"
    android:layout_marginBottom="@dimen/margin_default"
    android:minWidth="@dimen/header_buttons_container"
    android:orientation="horizontal"
    android:weightSum="@integer/header_button_weight" >

    <com.kreactive.feedget.customfont.CustomFontButton
        android:id="@+id/btn_video_list"
        style="@style/live_header_button"
        android:layout_width="0dp"
        android:layout_height="@dimen/header_button_item_height"
        android:layout_marginLeft="@dimen/margin_small"
        android:layout_weight="1"
        android:drawableLeft="@drawable/picto_popular"
        android:paddingLeft="@dimen/padding_default"
        android:paddingRight="@dimen/padding_default"
        android:text="@string/stories_tab_videos"
        customfonts:font="@string/roboto" />

    <com.kreactive.feedget.customfont.CustomFontButton
        android:id="@+id/btn_story_popular"
        style="@style/live_header_button"
        android:layout_width="0dp"
        android:layout_height="@dimen/header_button_item_height"
        android:layout_marginLeft="@dimen/margin_small"
        android:layout_weight="1"
        android:drawableLeft="@drawable/picto_popular"
        android:paddingLeft="@dimen/padding_default"
        android:paddingRight="@dimen/padding_default"
        android:text="@string/stories_tab_popular"
        customfonts:font="@string/roboto" />
</LinearLayout>

<com.kreactive.feedget.customfont.CustomFontTextView
    android:id="@+id/tv_header_title"
    style="@style/header_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/buttons_bar"
    android:paddingBottom="@dimen/padding_default"
    android:paddingTop="@dimen/padding_default"
    android:text="@string/stories_tab_headlines"
    customfonts:font="@string/roboto_light" />

TonicArtos commented 10 years ago

Just using TextViews in the header should fix the issue.

TonicArtos commented 10 years ago

I use SGH myself in my apps without any problems, and I only ever use TextViews for my headers.

SylvainRousson commented 10 years ago

I removed the drawable left I put, and get the error again (once only). I should have mentionned that my headers textview are customed (for fontt changing) and are clickable).

Do you think it is the way I use it that can cause crash ?

TonicArtos commented 10 years ago

Actually I just looked closer at the issue. From what I can tell, for some reason there is a null value getting substituted for your header at some point. For various reasons this is hidden behind the platform support exception you are seeing.

This will also explain why the problem is intermittent.