android / android-ktx

A set of Kotlin extensions for Android app development.
https://android.github.io/android-ktx/core-ktx/
7.48k stars 565 forks source link

Improve View.doOnPreDraw(...) #588

Open andkulikov opened 6 years ago

andkulikov commented 6 years ago

Hi, Recently I found OneShotPreDrawListener class in android framework which looks for me like a solution which covers all the cornercases like removing the view from the hierarchy before the first drawing: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/com/android/internal/view/OneShotPreDrawListener.java Don't you think View.doOnPreDraw(...) should use analog of it internally(with addOnAttachStateChangeListener)?

JakeWharton commented 6 years ago

Makes sense, although it seems like we should try to land this in 'core' and then consume it from 'core-ktx' first.

On Mon, Jun 25, 2018 at 1:25 PM Andrey Kulikov notifications@github.com wrote:

Hi, Recently I found OneShotPreDrawListener class in android framework which looks for me like a solution which covers all the cornercases like removing the view from the hierarchy before the first drawing:

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/com/android/internal/view/OneShotPreDrawListener.java Don't you think View.doOnPreDraw(...) should use analog of it internally(with addOnAttachStateChangeListener)?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/android/android-ktx/issues/588, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEVv8bSfdBNvGhlhCyTtxel-0bChBks5uARz9gaJpZM4U2jF2 .