-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ShawnLin013/add_object_pref
v1.0.1
- Loading branch information
Showing
12 changed files
with
222 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Preferences Manager | ||
|
||
The android library that is used to manage the preferences. | ||
|
||
[![Platform](http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat)](http://developer.android.com/index.html) [![Language](http://img.shields.io/badge/language-java-orange.svg?style=flat)](http://www.oracle.com/technetwork/java/javase/downloads/index.html) [![License](http://img.shields.io/badge/license-apache2.0-lightgrey.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) | ||
|
||
## Usage | ||
|
||
Initialize the preferences manager | ||
|
||
```java | ||
new PreferencesManager(this) | ||
.setName("prefs") | ||
.init(); | ||
``` | ||
|
||
Example 1: | ||
|
||
```java | ||
// put int to preferences | ||
PreferencesManager.putInt(key, value); | ||
|
||
// get int from preferences | ||
PreferencesManager.getInt(key) | ||
``` | ||
|
||
Example 2: | ||
|
||
```java | ||
// your object | ||
class Person { | ||
|
||
public String name; | ||
|
||
public Person(String name) { | ||
this.name = name; | ||
} | ||
|
||
} | ||
|
||
// put object to preferences | ||
PreferencesManager.putObject(key, new Person(name)); | ||
|
||
// get object from preferences | ||
PreferencesManager.getObject(key, Person.class); | ||
``` | ||
|
||
## Gradle | ||
|
||
Add the dependency in your `build.gradle` | ||
|
||
```groovy | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
dependencies { | ||
compile 'com.shawnlin:PreferencesManager:1.0.1' | ||
} | ||
``` | ||
|
||
## License | ||
|
||
``` | ||
Copyright (C) 2016 ShawnLin013(Shawn Lin) | ||
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. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
# Project-wide Gradle settings. | ||
VERSION_CODE=2 | ||
VERSION_NAME=1.0.1 | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
GROUP=com.shawnlin | ||
ARTIFACT_ID=PreferencesManager | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
# Default value: -Xmx10248m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
POM_DESCRIPTION=The android library that is used to manage the preferences. | ||
POM_URL=https://github.com/ShawnLin013/PreferencesManager | ||
POM_SCM_URL[email protected]:ShawnLin013/PreferencesManager.git | ||
POM_LICENSE_NAME=The Apache Software License, Version 2.0 | ||
POM_LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt | ||
POM_LICENSE_DIST=repo | ||
POM_DEVELOPER_ID=shawnlin013 | ||
POM_DEVELOPER_NAME=shawnlin013 | ||
POM_DEVELOPER_EMAIL[email protected] | ||
ISSUE_URL=https://github.com/ShawnLin013/PreferencesManager/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Oct 21 11:34:03 PDT 2015 | ||
#Thu Apr 14 15:31:39 CST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
tools:context="com.shawnlin.sample.MainActivity" | ||
tools:showIn="@layout/activity_main"> | ||
android:paddingTop="@dimen/activity_vertical_margin"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
<Button | ||
android:id="@+id/int_button" | ||
android:layout_width="200dp" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" /> | ||
</RelativeLayout> | ||
android:text="putInt()" /> | ||
|
||
<Button | ||
android:id="@+id/object_button" | ||
android:layout_width="200dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/activity_vertical_margin" | ||
android:text="putObject()" /> | ||
|
||
</LinearLayout> |