MaterialList icon indicating copy to clipboard operation
MaterialList copied to clipboard

Could not dispatch event in removing

Open arashmidos opened this issue 9 years ago • 1 comments

I can not remove items from MaterialListView. Always got the following exceptions. I debug it for couple hours but couldn't understand why this exception happens. When I run the same code in separate Activity for test, it works fine. But in my fragment inside of a viewPager this exception happens.

Here is my code:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        View view = inflater.inflate(R.layout.fragment_page, container, false);

        mListView = (MaterialListView) view.findViewById(R.id.material_listview);

        mListView.addOnItemTouchListener(new RecyclerItemClickListener.OnItemClickListener()
        {
            @Override
            public void onItemClick(CardItemView cardItemView, int i)
            {
            }

            @Override
            public void onItemLongClick(CardItemView cardItemView, int i)
            {
                Log.d(TAG, "Long click" + cardItemView.getTag().toString() + " in position " + i);
                mListView.remove((com.dexafree.materialList.model.Card) cardItemView.getTag());
            }
        });
05-01 21:46:17.442  28856-28856/app.arash.wishlist E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Could not dispatch event: class com.dexafree.materialList.events.DismissEvent to handler [EventHandler public void com.dexafree.materialList.view.MaterialListView.onCardDismiss(com.dexafree.materialList.events.DismissEvent)]: null
            at com.squareup.otto.Bus.throwRuntimeException(Bus.java:456)
            at com.squareup.otto.Bus.dispatch(Bus.java:386)
            at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:367)
            at com.squareup.otto.Bus.post(Bus.java:336)
            at com.dexafree.materialList.events.MainThreadBus.post(MainThreadBus.java:31)
            at com.dexafree.materialList.events.BusProvider.dismiss(BusProvider.java:22)
            at com.dexafree.materialList.view.MaterialListView.remove(MaterialListView.java:118)
            at app.arash.wishlist.activities.PageFragment$1.onItemLongClick(PageFragment.java:108)
            at com.dexafree.materialList.controller.RecyclerItemClickListener$1.onLongPress(RecyclerItemClickListener.java:38)
            at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:624)
            at android.view.GestureDetector.access$200(GestureDetector.java:42)
            at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:269)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:138)
            at android.app.ActivityThread.main(ActivityThread.java:3701)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.dexafree.materialList.view.MaterialListView.onCardDismiss(MaterialListView.java:171)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89)
            at com.squareup.otto.Bus.dispatch(Bus.java:384)
            at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:367)
            at com.squareup.otto.Bus.post(Bus.java:336)
            at com.dexafree.materialList.events.MainThreadBus.post(MainThreadBus.java:31)
            at com.dexafree.materialList.events.BusProvider.dismiss(BusProvider.java:22)
            at com.dexafree.materialList.view.MaterialListView.remove(MaterialListView.java:118)
            at app.arash.wishlist.activities.PageFragment$1.onItemLongClick(PageFragment.java:108)
            at com.dexafree.materialList.controller.RecyclerItemClickListener$1.onLongPress(RecyclerItemClickListener.java:38)
            at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:624)
            at android.view.GestureDetector.access$200(GestureDetector.java:42)
            at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:269)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:138)
            at android.app.ActivityThread.main(ActivityThread.java:3701)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
            at dalvik.system.NativeStart.main(Native Method)

arashmidos avatar May 01 '15 17:05 arashmidos

Is this issue fixed with the version 3.0.0 or greater?

FHellmann avatar Sep 07 '15 16:09 FHellmann