evrencoskun/TableViewSampleApp

Problem with the CellViewHolder

tuvirus opened this issue · 4 comments

Hello,

I'm developing a software where I show a table from a DB. The issue is that i have 16 colums to show, but somehow it crashes when it tries to render the last (15) column, the log says that the length is 15 and size too, but doing the debug i find out that my array it is 16; plus it happens at the CellViewHolderModel and TableAdapter. When i comment the last ColumHeaderModel, works fine. I have no clue what is going on actually... i was trying to debug to understand, but no conclusion yet. I wanted to know if there's a limit of colums or is it a bug?
I'll try to figure it out.

Also, i tried to add a new column on the TableViewSampleApp2 that works with fragments and Web Service. Same, it crashes when reaching column 16.

02-28 17:44:22.748 19899-19899/com.gigex.fitosoft.analizador E/AndroidRuntime: FATAL EXCEPTION: main Process: com.gigex.fitosoft.analizador, PID: 19899 java.lang.ArrayIndexOutOfBoundsException: length=15; index=15 at com.gigex.fitosoft.analizador.TableView.holder.CellViewHolder.setCellModel(CellViewHolder.java:30) at com.gigex.fitosoft.analizador.TableView.MyTableAdapter.onBindCellViewHolder(MyTableAdapter.java:53) at com.evrencoskun.tableview.adapter.recyclerview.CellRowRecyclerViewAdapter.onBindViewHolder(CellRowRecyclerViewAdapter.java:48) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6508) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6541) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5484) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5750) at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:285) at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:342) at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:358) at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:365) at android.support.v7.widget.GapWorker.run(GapWorker.java:396) at android.os.Handler.handleCallback(Handler.java:746) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5443) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

Hi @tuvirus,

Please check the #30. issue

Oh i see, now it makes more sense. I'm something newbie using github yet haha. Though, it has to be constant? Or i can change it to be, say "refitable" with the size of my array. Shouldn't it return the size of my column array?

Though, it has to be constant?
Of course, it doesn't have to be constant. I just wanted to show that each column could have a different text-align. And this example, the TableView has a constant column size.

You can just remove the COLUMN_TEXT_ALIGNS array on ColumnHeaderViewHolder and the lines that use the array.

For example, below the related line.

public void setColumnHeaderModel(ColumnHeaderModel pColumnHeaderModel, int pColumnPosition) {
       ...
       // Change alignment of textView
       column_header_textview.setGravity(COLUMN_TEXT_ALIGNS[pColumnPosition] | Gravity
               .CENTER_VERTICAL);
      ...
   }

Briefly, your case is not about the usage of TableView. This about the sample.

I hope It would help you to get rid of your confusion.

It did, thanks a lot. Your project helps me greatly at my work. Keep on the great work, have a nice day! :)