skydoves / PreferenceRoom

:truck: Android processing library for managing SharedPreferences persistence efficiently and structurally.
Apache License 2.0
378 stars 26 forks source link

@PreferenceFunction annotation doesn't work with objects #20

Closed thiagoms83 closed 3 years ago

thiagoms83 commented 4 years ago

Add a clear description about the problem.

@PreferenceFunction annotation doesn't work with target that is an object marked with @TypeConverter. Example:

@TypeConverter(BaseGsonConverter.class)
    protected AccessToken accessToken;

@PreferenceFunction("AccessToken")
    public AccessToken putAccessTokenFunction(AccessToken accessToken) {
        accessToken.update();
        return accessToken;
    }  

The code above generate a error code in the corresponding Preference_ file:

preference.edit().putString("AccessToken", super.putAccessTokenFunction(value.convertObject(accesstoken))).apply();
skydoves commented 4 years ago

Hi, @thiagoms83! Could you let me know the error message or your example project? Thanks!

thiagoms83 commented 4 years ago

After run the task build gradle, in Preferences_Config generate by my example, it is displayed in messages:

    return (AccessToken)super.getAccessTokenFunction(value.convertType(preference.getString("AccessToken", null));
                                                                                                                 ^
1 error

error: ')' expected

skydoves commented 3 years ago

Released a new stable 1.2.2!