Mikes_IDEA_extensions icon indicating copy to clipboard operation
Mikes_IDEA_extensions copied to clipboard

Request: for Kotlin, offer to replace View.setVisibility to View.isVisible and similar cases

Open AndroidDeveloperLB opened this issue 2 years ago • 6 comments

Meaning:

view.setVisibility = View.VISIBLE -> view.isVisible = true view.setVisibility = View.GONE -> view.isVisible = false view.setVisibility = View.INVISIBLE -> view.isInvisible = true

And also the getter:

if(view.visibility==View.VISIBLE) -> if(view.isVisible) if(view.visibility==View.GONE) -> if(view.isGone) if(view.visibility==View.INVISIBLE) -> if(view.isInvisible )

And the negated forms.

This is only to make code shorter and cleaner, of course. If you check its code, it does about the same...

AndroidDeveloperLB avatar Dec 30 '21 14:12 AndroidDeveloperLB

Where these properties come from? ktx?

Miha-x64 avatar Dec 30 '21 17:12 Miha-x64

@Miha-x64 When you create a new project, don't you see them?

I can see this line when using it, if that helps:

import androidx.core.view.isVisible

AndroidDeveloperLB avatar Dec 30 '21 17:12 AndroidDeveloperLB

Doesn't this inspection satisfy your needs? Android | Lint | Productivity | KTX Extension Available

Unfortunately, it doesn't work on the fly. And I keep it disabled because I prefer not to use ktx.

Miha-x64 avatar Dec 30 '21 20:12 Miha-x64

@Miha-x64 It doesn't offer this. I don't know what it covers.

AndroidDeveloperLB avatar Dec 30 '21 20:12 AndroidDeveloperLB

@AndroidDeveloperLB, don't you mind building a list of methods and replacements you want to be suggested?

Miha-x64 avatar Jan 07 '22 16:01 Miha-x64

I don't know of any other examples. I just noticed them, so I thought I should use them instead, as it looks nicer :)

AndroidDeveloperLB avatar Jan 07 '22 20:01 AndroidDeveloperLB