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

Crash while scrolling to second sticky header #2

Closed
ghost opened this issue Jun 26, 2012 · 3 comments
Closed

Crash while scrolling to second sticky header #2

ghost opened this issue Jun 26, 2012 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 26, 2012

Reproduction:

  • ListView with two headers
  • Scroll down till second header will become sticky
  • SetText will cause a crash

LOGCAT

FATAL EXCEPTION: main
java.lang.NullPointerException
at android.widget.TextView.checkForRelayout(TextView.java:6729)
at android.widget.TextView.setText(TextView.java:3306)
at android.widget.TextView.setText(TextView.java:3162)
at android.widget.TextView.setText(TextView.java:3137)
at mobi.inthepocket.madoc.heuvelland.adapters.StickyThematizedAdapter.bindHeaderView(StickyThematizedAdapter.java:41)
at mobi.inthepocket.madoc.heuvelland.stickylistheader.StickyListHeadersCursorAdapter.getHeaderView(StickyListHeadersCursorAdapter.java:89)
at mobi.inthepocket.madoc.heuvelland.stickylistheader.StickyListHeadersListView.onScroll(StickyListHeadersListView.java:274)
at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1276)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4565)
at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:2852)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3106)
at android.view.View.dispatchTouchEvent(View.java:5541)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1951)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1712)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1912)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371)
at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1860)
at android.view.View.dispatchPointerEvent(View.java:5721)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

IMPLEMENTATION

@OverRide
protected View newHeaderView(Context context, Cursor cursor)
{
final TextView textView = (TextView)LayoutInflater.from(context).inflate(R.layout.listview_spotslist_header, null);
return textView;
}

@OverRide
protected void bindHeaderView(View view, Context context, Cursor cursor)
{
final ThematizedSpot t = new ThematizedSpot();
t.constructFromCursor(cursor);

if (view instanceof TextView)
{
    final TextView textView = (TextView)view;
    String text = t.getSpot().isVisited() ? context.getResources().getString(R.string.pathdetail_visited) : context.getResources().getString(R.string.pathdetail_unvisited);
    if (text == null)
        text = "";
    textView.setText(text);
}

}

@OverRide
protected long getHeaderId(Context context, Cursor cursor)
{
final ThematizedSpot t = new ThematizedSpot();
t.constructFromCursor(cursor);
return (t.getSpot().isVisited() ? 1 : 0);
}

@emilsjolander
Copy link
Owner

i really do not see why this would be happening. Could you package a small sample project where you see this bug and send it to me ?

@emilsjolander
Copy link
Owner

Fixed! it was a problem with your header not being a ViewGroup. Should work fine now

@ghost
Copy link
Author

ghost commented Jun 30, 2012

Thanks for the quick response!

mournblade pushed a commit to mournblade/StickyListHeaders that referenced this issue Dec 7, 2020
Gradle wrapper is too old to build on Jitpack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant