TabLayout/Pizza >> How to guess the delay time?

from the CommonsWare Community archives

At May 13, 2018, 4:55am, Shahood asked:

Hi,

In TabLayout/Pizza sample app, how do we guess how much time it would take for setCurrentItem() to affect ViewPager and MaterialTabs objects? In this case, 100ms has been taken in postDelayed(). Can it be used generically?

Thanks!


At May 13, 2018, 10:39am, mmurphy replied:

how do we guess how much time it would take for setCurrentItem() to affect ViewPager and MaterialTabs objects?

Well, ideally, you don’t do any of that. Using postDelayed() to get past problems like this is a hack. As I noted in the book, this code was a workaround for a bug in the library.

In terms of guessing, play with various values and see what works. Take into account the speed of your test device — if it is fast, then other devices might be slower and might need more time.

FWIW, this sample and all other uses of this library will be removed from the book in the next update.


At May 13, 2018, 2:18pm, Shahood replied:

In terms of guessing, play with various values and see what works. Take into account the speed of your test device — if it is fast, then other devices might be slower and might need more time.

Thanks

FWIW, this sample and all other uses of this library will be removed from the book in the next update.

Would it be replaced by another library or be just removed for good>


At May 13, 2018, 2:39pm, mmurphy replied:

TabLayout is in the Design Support library, with an equivalent in CWAC-CrossPort. The only reason why I kept this sample in here after the release of CWAC-CrossPort was that a bunch of other samples used this particular tab implementation. I am rewriting all of those to use something else, typically the CWAC-CrossPort implementation.