AnderWeb / discreteSeekBar

Apache License 2.0
2.11k stars 400 forks source link

Moved initialization of metrics for PopupIndicator in onSizeChanged method. #64

Closed mrfix1t closed 8 years ago

mrfix1t commented 8 years ago

Fix for issue https://github.com/AnderWeb/discreteSeekBar/issues/53. In some cases, (ex. when activity containing seekBar don't recreate on rotations), PopupIndicator don't know about new display metrics, that causes indicator cut behavior when rotate from vertical layout to horizontal. To fix that, now PopupIndicator metrics initialized during onSizeChange state of SeekBar.

AnderWeb commented 8 years ago

I think I've done a simpler (and maybe better?) fix in commit ae1b758387c3ff3c0ea695fb9054cce6fedae352

Thanks!

mrfix1t commented 8 years ago

Well it also fixes the issue. But from my point of view it's little overhead and overkill to reinit display metrics every time Popup indicator is showing.

AnderWeb commented 8 years ago

We're not "reinit-ing" anything. getResources is a simple getter (return mResources) and getDisplayMetrics is a nother simple getter (return mMetrics) so I don't see the overhead you're referring to.

mrfix1t commented 8 years ago

Well, yes, it's simple getter. But we don't need to do this each time before show indicator. We need to set new display metrics in only one case, when parent view onSizeChanged method is calling (because of redrawing). In other cases length of seekbar is remains unchanged, so older display metrics is ok. So, I think my solution is bit cleaner.

AnderWeb commented 8 years ago

As I said, we're not creating new DisplayMetrics or new "anything", we're just reading the screen size when we need it.