PietsmietApp / pietsmiet_android

STALE - Android browsing & notification app for the youtube group Pietsmiet
https://play.google.com/store/apps/details?id=de.pscom.pietsmiet
GNU General Public License v3.0
5 stars 1 forks source link

Improve Flash-storage lifespan and performace #55

Closed julian-villing closed 7 years ago

julian-villing commented 7 years ago

Flash-storage has a limited amount of write-cycles until it's dead

SharedPreferenceHelper.java:

Sample

public class SharedPreferencesHelper
{
    private static Boolean initialized;
    private static Boolean changed;

    private static Boolean _prop1:
    private static Int32 _prop2;
    private static TYPE _NAME;

    public void Load(@OnlyIfRequired Context ctxt) { if(initialized) return; [...]; initialized = true; }

    public void Save(@OnlyIfRequired Context ctxt) { if(!changed) return; [...]; }

    public static Boolean prop1() { return prop1; }
    public static void prop1(Boolean value) {if (prop1 == value) return; prop1 = value; propertyChanged();

    [...]

    private static void propertyChanged() { changed = true; }
}

the OnlyIfRequired-Annotation should be taken literally