garretyoder / Colorful

Android runtime theme library
Apache License 2.0
2.13k stars 193 forks source link

Sample code for use without kotlin #38

Closed bmbariah closed 6 years ago

bmbariah commented 6 years ago

Is is possible to use this without having to use kotlin? just Java Kindly share some sample code on the README. I tried some Kotlin decompiling but it didn't work

garretyoder commented 6 years ago

This will compile work and function in a java project perfectly fine, infact the API will be the same, you just won't have access to optional arguments is all. If you're having issue with a specific api endpoint in Java, then I'd be happy to help.

bmbariah commented 6 years ago

For starters, I'm using this on my root Application class for initialization Defaults defaults = new Defaults( ThemeColor.BLUE, ThemeColor.YELLOW, true, true, 0); initColorful(this, defaults);

but can't figure out what code to use to actually change color in my Activity color. Kindly assist

garretyoder commented 6 years ago

Read up on the wiki, it goes over how to do this. The api in Java is almost identical. Kotlin is a JVM language. you need to call initColorful.

Setting colors at runtime is also covered in the wiki.

Colorful().edit()
        .setPrimaryColor(ThemeColor.RED)
        .setAccentColor(ThemeColor.BLUE)
        .setDarkTheme(true)
        .setTranslucent(true)
        .apply(context:Context)

The only difference in java will be the ending ;.

bmbariah commented 6 years ago

Thanks. The callback was giving me errors so i set it to null.

Naguchennai commented 4 years ago

how you fixed that callback problem?