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

when the cell width greater than the column width #10

Closed
spd-heshuip opened this issue Dec 27, 2017 · 16 comments
Closed

when the cell width greater than the column width #10

spd-heshuip opened this issue Dec 27, 2017 · 16 comments
Labels

Comments

@spd-heshuip
Copy link

when the tableview load the data first time,if the cell width greater than the column width,the tableview show like that :
2017-12-27 3 13 13
when I call the code:
2017-12-27 3 20 48

the tableview will show correct:
2017-12-27 3 18 25

@evrencoskun
Copy link
Owner

evrencoskun commented Dec 27, 2017

Do you have the below lines on your TableViewAdapter ? If you don't have. Please check the sample TableViewAdapter

     // It is necessary to remeasure itself.
     viewHolder.cell_container.getLayoutParams().width = LinearLayout.LayoutParams.WRAP_CONTENT;
     viewHolder.cell_textview.requestLayout();

It shouldn't be necessary to call notifyDataSetChanged

And Which version are you using ?

@spd-heshuip
Copy link
Author

Yeah,I check the code,it include that lines;
the version is 0.8.3;

@spd-heshuip
Copy link
Author

I check the source code,In the ColumnLayoutManager.java,method measureChild(),when the column width not equal to cell width at the first time,it did not call the line:
fb1f0eca-552e-4d94-9d0f-0cf08b75a18e

@evrencoskun
Copy link
Owner

m_nLastDx value will be '0' for first population process. So

if shouldFitColumns control returns true, then the below line will be called.

m_iCellLayoutManager.fitWidthSize(nPosition, false);

when the column width not equal to cell width at the first time,it did not call the line:

You can check shouldFitColumns control. If it is necessary to fit column width values, it calls at end of visible row index.

Anyway, Can you try the below codes instead using Observable.timer

tableView.getCellLayoutManager.fitWidthSize(false);

After that if you still got the same problem. Please try that;

// Force remeasure each cell header views
tableView.getColumnHeaderLayoutManager.customRequestLayout();
// Recalculate all of column width values.
`tableView.getCellLayoutManager.fitWidthSize(false);`

I will check your case on my leisure time.

See you

@spd-heshuip
Copy link
Author

Hi,Thank you for your reply!
I use the below codes instead using Observer.timer
2017-12-28 9 11 57
and the tableview will show normal,but it will shake like that:
ezgif com-video-to-gif

@evrencoskun
Copy link
Owner

Hi,
It's shaking that's because of your post runnable
Because, It goes into the main thread queue and gets executed after the other pending tasks are finished.

Let's try the below codes without using any thread process.

// Force remeasure each cell header views
tableView.getColumnHeaderLayoutManager.customRequestLayout();
// Recalculate all of column width values.
`tableView.getCellLayoutManager.fitWidthSize(false);

And let me know the result.

@spd-heshuip
Copy link
Author

I have try he below codes without using any thread process:
2017-12-28 2 43 01
but it will cause NullPointerException:
2017-12-28 2 45 12

@evrencoskun
Copy link
Owner

Can you share your TableView model with me ? I want to test your case with your model.

Actually I don't have time for this now. But, I will do that at least 8 hours later.

@spd-heshuip
Copy link
Author

I upload the project to the dropbox,you can download the project and check that,Thanks!!
https://www.dropbox.com/s/zrjtgcxsdoytnwn/TableView-master.zip?dl=0
and I think I found the reason why the tableview show abnormality at the first time,because it did not got focus in the beginning;

@spd-heshuip
Copy link
Author

Hi,did you try the sample code?

@evrencoskun
Copy link
Owner

evrencoskun commented Jan 2, 2018

Hello,

Unfortunately, I haven't tried your code yet because of the celebration of new year. However, You can be sure that, in my first leisure time, I'll check it on.

Have a nice day.

@spd-heshuip
Copy link
Author

OK,Thank you very much and wish you Happy new year!!

@evrencoskun
Copy link
Owner

Happy new year to you, too! :)

@evrencoskun
Copy link
Owner

Hi,
The link seems broken. Could you fix it ?

Thanks.

@spd-heshuip
Copy link
Author

@evrencoskun
Copy link
Owner

evrencoskun commented Jan 3, 2018

I have tested your codes.

My first observation on your code, when I change

m_iTableView.postDelayed(new Runnable() {
            @Override
            public void run() {
                mStatusLayout.showContent();
            }
        }, 3000);

with

mStatusLayout.showContent();

It works perfectly.

However, let's assume you need to above lines and don't want to change it. At that time, I realised that you modified the TableView codes.

When I use the 0.8.5.1 version instead of yours, It works perfectly, even though using the above lines.

If you don't want to horizontal lines of the TableView

you can use app:show_horizontal_separator="false" like this:

 <com.evrencoskun.tableview.TableView
        android:id="@+id/tableView"
        android:layout_width="match_parent"
        app:show_horizontal_separator="false"
   ....
  >

After that, you can insert a line view both your column header layout and corner layout like I do on the sample app.

Well, why does your modified TableView have got this bug ?

Because, on CellLayoutManager

    // This below lines is for populating for the first time like fetching all data to display.
            // It shouldn't be worked when it is scrolling horizontally ."getLastDx() == 0"
            // control for it.
        } else if (m_iCellRecyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE &&
                childLayoutManager.getLastDx() == 0) {

            if (childLayoutManager.isNeedFit()) {
                m_bNeedFit = true;

                // all columns have been fitted.
                childLayoutManager.clearNeedFit();
            }

            if (m_bNeedFit) {
                // for the first time to populate adapter
                if (m_jRowHeaderLayoutManager.findLastVisibleItemPosition() == nPosition) {

                    // The below line helps to change left & right value of the each column
                    // header views
                    // without using requestLayout().
                    m_iColumnHeaderLayoutManager.customRequestLayout();

                    fitWidthSize(false);
                    Log.e(LOG_TAG, nPosition + " fitWidthSize populating data for the first time");

                    m_bNeedFit = false;
                }
            }
        }

Something you did causes on this control, m_jRowHeaderLayoutManager.findLastVisibleItemPosition()
returns -1 .

I strongly recommend to you use the latest version without doing any modify.

simoneraffaelli pushed a commit to simoneraffaelli/TableView that referenced this issue Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants