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

TableView cell items are garbled #41

Closed
jeremy-ingenuity opened this issue Feb 4, 2018 · 3 comments
Closed

TableView cell items are garbled #41

jeremy-ingenuity opened this issue Feb 4, 2018 · 3 comments

Comments

@jeremy-ingenuity
Copy link
Contributor

jeremy-ingenuity commented Feb 4, 2018

Hi again, this issue is completely unrelated to any extended feature (row/column hiding/showing, scrollingTo row/column, sorting, filtering or pagination) of the TableView. This happens when the TableView is scrolled too fast to the right. The data of cells can all be strings or in my case, there are cells that displays a drawable.

Notes:

  • scrolling to the right causes the issue described here and in the preview below
  • scrolling down and going back up will restore/fix the views and displays the data correctly

One thing I can suggest is to use setItemViewCacheSize(int size) method of the RecyclerView for the data cells to preserve the layout and data of "offscreen views". The size to be set should be the number of items in the adapter.
Once again, no pressure, take your time man. I just want to help in improving your library.

evrencoskun added a commit that referenced this issue Feb 4, 2018
@evrencoskun
Copy link
Owner

evrencoskun commented Feb 4, 2018

Hi @jeremy-ingenuity,

You shouldn't give a drawable object as a data to the cell model. It can be primitive data type like "int" or whatever you want. In this case, I would like to set data 1 or 0 value respectively for "happy" and "sad". Beside this, as you know that each cell model store the data. In your case it stores drawable, This may cause memory problems for a large-scale TableView.

So how do you set icon using primitive data type ?
The solution is creating an unique view type for mood column and gender column. That means; you should create an MoodCellViewHolder and GenderViewHolder which has got imageView instead of TextView.

When they are binding, control the value whether is 0 or 1. and set the right drawable at that time. There is also sample usage of this approach on TableViewSample App

Edit: I have also fixed the this issue. Please test the case again. And let me know the result.

I just want to help in improving your library.

I sincerely appreciate you taking the time to improve the library.

See you.

@jeremy-ingenuity
Copy link
Contributor Author

Oh yeah, sorry, my bad there for passing the Drawable object directly to the VHs instead of just basic data type. Also sorry for not implementing properly in the examples. Thank you very much for correcting the issue.

@evrencoskun
Copy link
Owner

No problem @jeremy-ingenuity :)

Have a nice week

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

2 participants