mikepenz / Android-Iconics

Android-Iconics - Use any icon font, or vector (.svg) as drawable in your application.
https://mikepenz.dev
Apache License 2.0
5.2k stars 615 forks source link

I can't resolve method .toIconicsColor() #484

Closed geronimo69 closed 4 years ago

geronimo69 commented 4 years ago

i try to assign a color to icon but can't resolve method toIconicsColor. Can guide me to fix the problem please?

 new IconicsDrawable(mContext).icon(GoogleMaterial.Icon.gmd_card_travel).color(Color.WHITE.toIconicsColor()) 

implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar'
implementation 'com.mikepenz:material-design-iconic-typeface:2.2.0.4@aar'
implementation "com.mikepenz:iconics-core:4.0.2@aar"
implementation "com.mikepenz:iconics-views:4.0.2@aar"
mikepenz commented 4 years ago

This method is an extension function. for that you have to use Kotlin

But it is also deprecated, please follow the deprecation message: https://github.com/mikepenz/Android-Iconics/blob/5f0216136bdb55f1feeef0a3861b02703410dd39/library-core/src/main/java/com/mikepenz/iconics/utils/IconicsConverters.kt#L135-L139

geronimo69 commented 4 years ago

I used until now (no kotlin):

implementation 'com.mikepenz:iconics-core:3.1.0@aar'
implementation "com.mikepenz:iconics-views:2.9.5@aar"

Android Studio notify me to update to version 4.02. so I updated to:

 implementation 'com.mikepenz:iconics-core:4.0.2@aar'
 implementation "com.mikepenz:iconics-views:4.0.2@aar"

But now for next code:

holder.mTraveler.setIcon(isFavorite
                ? new IconicsDrawable(mContext).icon(GoogleMaterial.Icon.gmd_card_travel).color(Color.WHITE) :
                new IconicsDrawable(mContext).icon(GoogleMaterial.Icon.gmd_add_location).color(Color.WHITE));

get next error message:

error: no suitable method found for color(int)
method IconicsDrawable.color(Function0<? extends IconicsColor>) is not applicable (argument mismatch; int cannot be converted to Function0<? extends IconicsColor>)
method IconicsDrawable.color(IconicsColor) is not applicable (argument mismatch; int cannot be converted to IconicsColor)

Any suggestion for me please?

mikepenz commented 4 years ago

Android Iconics v4 is meant to be used in kotlin projects. If your project is still in java. please stay with 3.x (also never mix versions)