I have RecyclerView
with custom list item and with CardView
item, in two different Activities
. Now i am getting error when i remove last remained item from list, i did not change any code related to those acitivities
or adapter
or RecyclerView
.
Error is:
java.lang.NullPointerException
at android.support.v7.widget.OrientationHelper$2.getDecoratedStart(OrientationHelper.java:316)
at android.support.v7.widget.LinearLayoutManager.findOneVisibleChild(LinearLayoutManager.java:1633)
at android.support.v7.widget.LinearLayoutManager.findFirstVisibleChildClosestToStart(LinearLayoutManager.java:1453)
at android.support.v7.widget.LinearLayoutManager.computeScrollOffset(LinearLayoutManager.java:997)
at android.support.v7.widget.LinearLayoutManager.computeVerticalScrollOffset(LinearLayoutManager.java:969)
at android.support.v7.widget.RecyclerView.computeVerticalScrollOffset(RecyclerView.java:1175)
at android.view.View.canScrollVertically(View.java:12745)
at android.support.v4.view.ViewCompatICS.canScrollVertically(ViewCompatICS.java:35)
at android.support.v4.view.ViewCompat$ICSViewCompatImpl.canScrollVertically(ViewCompat.java:940)
at android.support.v4.view.ViewCompat.canScrollVertically(ViewCompat.java:1237)
at android.support.v7.widget.RecyclerView$LayoutManager.onInitializeAccessibilityEvent(RecyclerView.java:6594)
at android.support.v7.widget.RecyclerView$LayoutManager.onInitializeAccessibilityEvent(RecyclerView.java:6573)
at android.support.v7.widget.LinearLayoutManager.onInitializeAccessibilityEvent(LinearLayoutManager.java:204)
at android.support.v7.widget.RecyclerViewAccessibilityDelegate.onInitializeAccessibilityEvent(RecyclerViewAccessibilityDelegate.java:66)
at android.support.v4.view.AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl$1.onInitializeAccessibilityEvent(AccessibilityDelegateCompat.java:228)
at android.support.v4.view.AccessibilityDelegateCompatJellyBean$1.onInitializeAccessibilityEvent(AccessibilityDelegateCompatJellyBean.java:56)
at android.view.View.onInitializeAccessibilityEvent(View.java:5292)
at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:5160)
at android.view.View$AccessibilityDelegate.sendAccessibilityEventUnchecked(View.java:20325)
at android.support.v4.view.AccessibilityDelegateCompatIcs.sendAccessibilityEventUnchecked(AccessibilityDelegateCompatIcs.java:117)
at android.support.v4.view.AccessibilityDelegateCompat$AccessibilityDelegateIcsImpl.sendAccessibilityEventUnchecked(AccessibilityDelegateCompat.java:210)
at android.support.v4.view.AccessibilityDelegateCompat.sendAccessibilityEventUnchecked(AccessibilityDelegateCompat.java:358)
at android.support.v4.view.AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl$1.sendAccessibilityEventUnchecked(AccessibilityDelegateCompat.java:255)
at android.support.v4.view.AccessibilityDelegateCompatJellyBean$1.sendAccessibilityEventUnchecked(AccessibilityDelegateCompatJellyBean.java:82)
at android.view.View.sendAccessibilityEventUnchecked(View.java:5143)
at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.run(ViewRootImpl.java:7653)
at android.view.ViewRootImpl$SendWindowContentChangedAccessibilityEvent.runOrPost(ViewRootImpl.java:7679)
at android.view.ViewRootImpl.postSendWindowContentChangedCallback(ViewRootImpl.java:6871)
at android.view.ViewRootImpl.notifySubtreeAccessibilityStateChanged(ViewRootImpl.java:6944)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.ViewGroup.notifySubtreeAccessibilityStateChanged(ViewGroup.java:2746)
at android.view.View.notifySubtreeAccessibi
There is nothing related shown to my code here. I am using dependencies
:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:support-v4:21.0.3'
compile 'se.emilsjolander:StickyScrollViewItems:1.+'
compile 'net.i2p.android.ext:floatingactionbutton:1.8.0'
compile 'com.afollestad:material-dialogs:0.6.4.7'}
Any idea what might be problem?
I made a workaround for this by creating a child class for LinearLayoutManager. It's an unfortunate solution but at least it'll work until the support library fixes this problem...
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
public class LinearLayoutManagerWrapper extends LinearLayoutManager {
private static final String TAG = "LinearLayoutManagerWrapper";
public LinearLayoutManagerWrapper(final Context context) {
super(context);
}
@Override
public void onInitializeAccessibilityEvent(final AccessibilityEvent event) {
try {
super.onInitializeAccessibilityEvent(event);
} catch (final NullPointerException e) {
Log.e(TAG, "NullPointerException in onInitializeAccessibilityEvent(" + event +
')', e);
}
}
@Override
public void onInitializeAccessibilityEvent(final RecyclerView.Recycler recycler,
final RecyclerView.State state, final AccessibilityEvent event) {
try {
super.onInitializeAccessibilityEvent(recycler, state, event);
} catch (final NullPointerException e) {
Log.e(TAG, "NullPointerException in onInitializeAccessibilityEvent(" + recycler +
", " + state + ", " + event + ')', e);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With