martino2k6 / storebox Goto Github PK
View Code? Open in Web Editor NEWAndroid library for streamlining SharedPreferences
License: Apache License 2.0
Android library for streamlining SharedPreferences
License: Apache License 2.0
Each time a get method using a @DefaultValue annotation is invoked the resource identifier is resolved to a value. Since this is static, it should only be needed to get it the first time and then store it in a cache private to the InvocationHandler.
The runtime annotations will be stripped, as such it'd be useful to provide some details in the documentation.
I can't remove values. Putting null causes exeption.
Can you please help me how to define a shared preference that returns enum. I have defined my interface as below. please help me to understand what is it that I am not doing right.
public interface Preferences
{
enum OAuthProvider
{
GOOGLE, FACEBOOK
}
@KeyByString("key_login_status")
boolean getLoginStatus(boolean defaultLoginStatus);
@KeyByString("key_login_status")
void setLoginStatus(boolean value);
@KeyByString("oauth_provider")
OAuthProvider getOAuthProvider(OAuthProvider defaultOAuthProvider);
@KeyByString("oauth_provider")
@TypeAdapter(OAuthProvider)
void setOAuthProvider(OAuthProvider value);
}
See #9 (comment).
Haven't had much time trying out your lib yet, but I like the idea. Just gave source a look but haven't noticed support for Set set & get operations.
Bind the type adapters at interface-level to keys, as opposed to requiring each method which uses a custom type to use the TypeAdapter
annotation.
This should result in less duplication for the definitions, and should also pave the way for caching the type adapter instances when the invocation handler is created as opposed to instantiating them on each method invocation (where required) and then just throwing them away.
What if I want to clear all key-value pairs by using one single clear
method?
Caching the KeyByString
, KeyByValue
, RemoveMethod
, RegisterChangeListenerMethod
, UnregisterChangeListenerMethod
should provide a speed-up so the annotations wouldn't be required to be read on each method invocation, but only the first time.
Because you can't access type from adaptFromPreferences(String value). For example, I want my prefenence return null if I renamed enum field. Now it will produce java.lang.IllegalArgumentException: No enum constant for...
or I may want to choose first enum field as default value for all enums etc.
Not wokring harness package.
I wanted to use your class, but the IDE does not see the class CustomClassListTypeAdapter.
I added library through Gradle
Provide a new PreferenceType that allows for using AndroidX Security API for EncryptedSharedPreferences.
https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences
Perhaps provide @ApplyMethod/@CommitMethod annotations for use in interface methods.
Same as #1.
To chain away from having to only support boolean/float/int/long/String due to the native SharedPreferences/Editor, type adapters could be added for serialising and de-serialising user-defined types. Or even build-in type adapters could be provided for some common types (ie Date).
Could we do something like check that methods (whether single or pairs of set/get) annotated with @KeyByXXX have the same value/default/return types? Check invalid, or superfluous, annotations?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.