GithubHelp home page GithubHelp logo

initDefaults broken about esperandro HOT 8 CLOSED

MFlisar avatar MFlisar commented on June 26, 2024
initDefaults broken

from esperandro.

Comments (8)

dkunzler avatar dkunzler commented on June 26, 2024

I will have a look!

from esperandro.

MFlisar avatar MFlisar commented on June 26, 2024

Thanks. Just take your time, I don't need the new features in the project where I need the initDefaults... I can simply continue using v2.2.0 for now

from esperandro.

dkunzler avatar dkunzler commented on June 26, 2024

Hi, I looked into it and guess it is a user error 😁
(And a lack of documentation from my side)

Initidefaults uses (at least in the newer versions, I can't remember the old ones) the getter and setter methods since the getters already contain the complete logic to generate the correct defaults.
If setter or getter is missing no default initialization is generated for this specific preference. I even can't decide how to init them, so it wouldn't make sense to generate them.

Can you check and confirm for your examples that this is the case for the different files you use?

from esperandro.

MFlisar avatar MFlisar commented on June 26, 2024

In this very old app of mine I use it like following:

@SharedPreferences(name = Preferences.PREF_NAME, mode = SharedPreferenceMode.PRIVATE)
public interface Preferences extends SharedPreferenceActions
{
    String PREF_NAME = "APP_PREFERENCES";
    
    public static final String userKnowsNavigationDrawer = "userKnowsNavigationDrawer";
    @Default(ofBoolean = false)
    boolean userKnowsNavigationDrawer();
    boolean userKnowsNavigationDrawer(boolean userKnowsNavigationDrawer);
    
    public static final String language = "language";
    @Default(ofString = "0")
    String language();
    boolean language(String language);
}

Should work, shouldn't it?

from esperandro.

dkunzler avatar dkunzler commented on June 26, 2024

Yeah, that's the bug I found after writing my comment 👍
If you had a commit setter (boolean return type) it also didn't work. This is fixed locally. I will also remove the need for a setter and use the normal SharedPreference object for writing, and then push a new version.

from esperandro.

MFlisar avatar MFlisar commented on June 26, 2024

great, thanks a lot

from esperandro.

dkunzler avatar dkunzler commented on June 26, 2024

I just pushed 2.7.1 to maven central. initDefaults should no show better results.

from esperandro.

MFlisar avatar MFlisar commented on June 26, 2024

Great, works. Thank you

from esperandro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.