android-ktx icon indicating copy to clipboard operation
android-ktx copied to clipboard

Use generics to get rid of casting

Open bina1204 opened this issue 7 years ago • 4 comments

It is better to use generics instead of casting like below.

imageView.doOnPreDraw {
    (it as ImageView).doSomething()
}

bina1204 avatar Feb 06 '18 06:02 bina1204

Please retain an overload with the old signature and a deprecated annotation with a visibility of hidden to maintain binary compatibility as well.

JakeWharton avatar Feb 06 '18 16:02 JakeWharton

Does it make sense to upgrade the signature for doOnLayout and doOnNextLayout to use generics as well?

davethomas11 avatar Feb 06 '18 16:02 davethomas11

Sure!

On Tue, Feb 6, 2018 at 11:48 AM Dave Thomas [email protected] wrote:

Does it make sense to upgrade signature for doOnLayout and doOnNextLayout to use generics as well?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/android/android-ktx/pull/177#issuecomment-363486825, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEERDlv_dmnXKjdWNCy05WWhBba1Elks5tSIJagaJpZM4R6jyt .

JakeWharton avatar Feb 06 '18 17:02 JakeWharton

@romainguy Thank you for your review! I updated current.txt and added some tests.

bina1204 avatar Feb 07 '18 16:02 bina1204