[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.
/ fit Public archive

easy storage Object on SharedPreferences

License

Notifications You must be signed in to change notification settings

zongbintu/fit

Repository files navigation

Fit

Release

Fit storage bean for SharedPreferences which uses annotation processing to generate boilerplate code for you.

Installation

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Add the following dependency to your build.gradle file:

dependencies {
    implementation 'com.github.2tu.fit:fit:1.2.3'
    annotationProcessor 'com.github.2tu.fit:fit-compiler:1.2.3'
}

Usage

annotation model class.

@SharedPreferenceAble

save object

User user = new User();
Fit.save(context, user);
Fit.save(context, "user", user);

get

User user = Fit.get(context, User.class);
User user = Fit.get(context, "user", User.class);

clear

Fit.clear(context, User.class);
Fit.clear(context, User.class, "user");

other

Fit.get(context, "name").getBoolean("isFirst", false);
SharedPreferences.Editor editor = Fit.edit(context, "name");
editor.putBoolean("isFirst", true);
editor.apply();
Fit.clearObjectField(cotext, "user", "hobbies");

Q&A

apt or annotationProcessor

License

Copyright 2016 Tu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.