any help plz if I have many Constantsvalues in a c...
# announcements
a
any help plz if I have many Constantsvalues in a class inside Companion object function and I don't wanna the imports be like this
Copy code
import com.john.movie.util.Constants.Companion.NOW_PLAYING_MOVIES
import com.john.movie.util.Constants.Companion.POPULAR_MOVIES
import com.john.movie.util.Constants.Companion.TOP_RATED_MOVIES
import com.john.movie.util.Constants.Companion.UP_COMING_MOVIES
this not working
import com.john.movie.util.Constants.Companion.*
k
Why did you post that in #android? Pick one (preferably correct) channel and post it there.
πŸ‘ 2
I don't think there's another way to do this though.
πŸ‘ 1
a
@karelpeeters thanks
k
Can I ask why you're worried about the length of the imports?
πŸ‘ 1
a
@karelpeeters yeah, it's around 40 Constant value in that class so then I will call it in many places on my app so this may be boilerplate code or something bad i think 😏
k
Are there are 40 of them, then it starts to make sense. Could you make them an enum? Or maybe the code somehow so it doesn't need to refer to specific values everywhere?
πŸ‘ 1
a
@karelpeeters mmmm I know enums but I never used it before πŸ˜‚ so actually I don't know it will be a proper solution or not I just have around 40 Constant values some of them are an integer like id from 1 to 20 (maybe I can add those values inside enum mmmm) the rest is just string
k
Yeah definitely replace loose integer ids with enums.
πŸ’― 1
πŸ™ 1
πŸ‘Œ 2
a
thanks a lot, @karelpeeters for your help