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

NullPointerException on click on empty table #62

Open
shivamahi opened this issue Feb 26, 2018 · 7 comments
Open

NullPointerException on click on empty table #62

shivamahi opened this issue Feb 26, 2018 · 7 comments

Comments

@shivamahi
Copy link

We are developing new app(not released yet)
While searching found TableView and it is very interesting and matching our usecase.

While testing with TableView
We are getting NPE when we try to tap on empty table for second time.

E/RecyclerView: No adapter attached; skipping layout
I/View: Key up dispatch to android.support.v7.widget.AppCompatEditText{8e559f9 VFED..CL. .F...... 0,0-166,140 #7f0900f4 app:id/registered_farmer_id}, event = KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x68, repeatCount=0, eventTime=475379957, downTime=475379866, deviceId=-1, source=0x101 }
E/CellRecyclerView: mIsVerticalScrollListenerRemoved has been tried to remove itself before add new one
E/CellRecyclerView: mIsVerticalScrollListenerRemoved has been tried to remove itself before add new one
E/InputEventReceiver: Exception dispatching input event.
E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v7.widget.RecyclerView$ViewHolder com.evrencoskun.tableview.adapter.recyclerview.CellRecyclerView.findViewHolderForAdapterPosition(int)' on a null object reference
at com.evrencoskun.tableview.layoutmanager.CellLayoutManager.getVisibleCellViewsByColumnPosition(CellLayoutManager.java:432)
at com.evrencoskun.tableview.handler.SelectionHandler.changeVisibleCellViewsBackgroundForColumn(SelectionHandler.java:320)
at com.evrencoskun.tableview.handler.SelectionHandler.selectedColumnHeader(SelectionHandler.java:221)
at com.evrencoskun.tableview.handler.SelectionHandler.setSelectedColumnPosition(SelectionHandler.java:75)
at com.evrencoskun.tableview.listener.itemclick.ColumnHeaderRecyclerViewItemClickListener.clickAction(ColumnHeaderRecyclerViewItemClickListener.java:54)
at com.evrencoskun.tableview.listener.itemclick.AbstractItemClickListener.onInterceptTouchEvent(AbstractItemClickListener.java:76)
at android.support.v7.widget.RecyclerView.dispatchOnItemTouch(RecyclerView.java:2771)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2899)
at android.view.View.dispatchTouchEvent(View.java:9483)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2665)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2309)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2671)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2323)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2476)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1777)
at android.app.Activity.dispatchTouchEvent(Activity.java:2818)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2437)
at android.view.View.dispatchPointerEvent(View.java:9714)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4861)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4703)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4208)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4261)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4227)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4373)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4235)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4430)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4208)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4261)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4227)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4235)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4208)
at android.view.Vie

@evrencoskun
Copy link
Owner

Hi @shivamahi,

Please, check #26 issue

Thank you for using TableView.

@sivayapps
Copy link

Thank you for quick reply

@sivayapps
Copy link

We started hiding table if we have no data.
We will switch to text view with msg "no data".

@evrencoskun
Copy link
Owner

I know It is an ugly solution. If I have a time at the weekend, I'll implement the requirement that is loading table with empty data.

See you.

@sivayapps
Copy link

Great
That would help many people thank you.

@evrencoskun
Copy link
Owner

evrencoskun commented Mar 10, 2018

Hi @sivayapps,

Actually, you don't need to wait for any implementation to fix this issue. I have just tested the case using empty data, It just looks.

emptydatasets
like below.

You just need to create empty data sets like below

  /**
    * This is a dummy empty model list for a test case.
    */
   private List<List<Cell>> getEmptyCellList() {
       List<List<Cell>> list = new ArrayList<>();
       for (int i = 0; i < ROW_SIZE; i++) {
           List<Cell> cellList = new ArrayList<>();
           list.add(cellList);
           for (int j = 0; j < COLUMN_SIZE; j++) {

               // Create dummy id.
               String id = j + "-" + i;

               Cell cell = new Cell(id, "");
               cellList.add(cell);
           }
       }

       return list;
   }

   /**
    * This is a dummy empty model list for a test case.
    */
   private List<RowHeader> getEmptyRowHeaderList() {
       List<RowHeader> list = new ArrayList<>();
       for (int i = 0; i < ROW_SIZE; i++) {
           RowHeader header = new RowHeader(String.valueOf(i), "");
           list.add(header);
       }
       return list;
   }

and set these list to the adapter.

mTableViewAdapter.setAllItems(getColumnHeaderList(), getEmptyRowHeaderList(), getEmptyCellList());

@sivayapps
Copy link

@evrencoskun Thanks for update
We will try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants