Skip to content

Commit

Permalink
add sp tool and docs
Browse files Browse the repository at this point in the history
Signed-off-by: wangdongdong <[email protected]>
  • Loading branch information
wangdongdong committed Jan 20, 2017
1 parent 139e6e8 commit 5f2f9b1
Show file tree
Hide file tree
Showing 91 changed files with 18,945 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.mazouri.tools.device.NetworkTool;
import com.mazouri.tools.image.BitmapTool;
import com.mazouri.tools.io.ExternalStorageTool;
import com.mazouri.tools.io.SPTool;
import com.mazouri.tools.log.LogTool;
import com.mazouri.tools.regex.RegexTool;
import com.mazouri.tools.secure.SecureAESTool;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class AndroidTools {
private static InputMethodTool mInputMethodTool;
private static ToastTool mToast;
private static NetworkTool mNetwork;
private static SPTool mSP;

public AndroidTools() {
}
Expand Down Expand Up @@ -202,4 +204,11 @@ public static NetworkTool network() {
}
return mNetwork;
}

public static SPTool sp() {
if (mSP == null) {
mSP = SPTool.instance();
}
return mSP;
}
}
104 changes: 104 additions & 0 deletions android-tools/src/main/java/com/mazouri/tools/io/SPTool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.mazouri.tools.io;

import android.content.Context;
import android.content.SharedPreferences;

import com.mazouri.tools.AndroidTools;

/**
* SharedPreferences工具类
*
* Created by wangdongdong on 17-1-20.
*/

public final class SPTool {

private String SP = AndroidTools.class.getSimpleName();
private static final Object lock = new Object();
private static volatile SPTool instance;

public static SPTool instance() {
if (instance == null) {
synchronized (lock) {
if (instance == null) {
instance = new SPTool();
}
}
}
return instance;
}

/**
* default SharedPreferences file name is the class name of {@link AndroidTools}, if you want to
* define your own file name, please use this method at your Application class.
*
* <pre>
* AndroidTools.sp().name("ur_sp_name");
* </pre>
*
* @param name
* @return
*/
public SPTool name(String name) {
SP = name;
return this;
}

public boolean getShareBoolean(String name) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
return share.getBoolean(name, false);
}

public void saveShareBoolean(String name, boolean flag) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = share.edit();
editor.putBoolean(name, flag);
editor.commit();
}

public int getShareInt(String name) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
return share.getInt(name, 0);
}

/**
* @param name
* @param value 默认值
* @return
*/
public int getShareInt(String name, int value) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
return share.getInt(name, value);
}

public void saveShareInt(String name, int value) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = share.edit();
editor.putInt(name, value);
editor.commit();
}

public String getShareString(String name) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
return share.getString(name, "");
}

public void saveShareString(String name, String value) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = share.edit();
editor.putString(name, value);
editor.commit();
}

private long getShareLong(String name) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
return share.getLong(name, 0L);
}

private void saveShareLong(String name, Long value) {
SharedPreferences share = AndroidTools.app().getSharedPreferences(SP, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = share.edit();
editor.putLong(name, value);
editor.commit();
}
}
41 changes: 41 additions & 0 deletions docs/allclasses-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="zh">
<head>
<!-- Generated by javadoc (1.8.0_76-release) on Fri Jan 20 17:41:55 CST 2017 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>所有类</title>
<meta name="date" content="2017-01-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h1 class="bar">所有类</h1>
<div class="indexContainer">
<ul>
<li><a href="com/mazouri/tools/AndroidTools.html" title="com.mazouri.tools中的类" target="classFrame">AndroidTools</a></li>
<li><a href="com/mazouri/tools/apk/ApkTool.html" title="com.mazouri.tools.apk中的类" target="classFrame">ApkTool</a></li>
<li><a href="com/mazouri/tools/app/AppTool.html" title="com.mazouri.tools.app中的类" target="classFrame">AppTool</a></li>
<li><a href="com/mazouri/tools/image/BitmapTool.html" title="com.mazouri.tools.image中的类" target="classFrame">BitmapTool</a></li>
<li><a href="com/mazouri/tools/device/DeviceTool.html" title="com.mazouri.tools.device中的类" target="classFrame">DeviceTool</a></li>
<li><a href="com/mazouri/tools/io/ExternalStorageTool.html" title="com.mazouri.tools.io中的类" target="classFrame">ExternalStorageTool</a></li>
<li><a href="com/mazouri/tools/app/InputMethodTool.html" title="com.mazouri.tools.app中的类" target="classFrame">InputMethodTool</a></li>
<li><a href="com/mazouri/tools/log/LogTool.html" title="com.mazouri.tools.log中的类" target="classFrame">LogTool</a></li>
<li><a href="com/mazouri/tools/device/NetworkTool.html" title="com.mazouri.tools.device中的类" target="classFrame">NetworkTool</a></li>
<li><a href="com/mazouri/tools/regex/RegexTool.html" title="com.mazouri.tools.regex中的类" target="classFrame">RegexTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureAESTool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureAESTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureBase64Tool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureBase64Tool</a></li>
<li><a href="com/mazouri/tools/secure/SecureDES3Tool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureDES3Tool</a></li>
<li><a href="com/mazouri/tools/secure/SecureDESTool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureDESTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureHexTool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureHexTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureMD5Tool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureMD5Tool</a></li>
<li><a href="com/mazouri/tools/secure/SecureRSATool.html" title="com.mazouri.tools.secure中的类" target="classFrame">SecureRSATool</a></li>
<li><a href="com/mazouri/tools/secure/SecureRSATool.PADDING.html" title="com.mazouri.tools.secure中的枚举" target="classFrame">SecureRSATool.PADDING</a></li>
<li><a href="com/mazouri/tools/io/SPTool.html" title="com.mazouri.tools.io中的类" target="classFrame">SPTool</a></li>
<li><a href="com/mazouri/tools/string/StringTool.html" title="com.mazouri.tools.string中的类" target="classFrame">StringTool</a></li>
<li><a href="com/mazouri/tools/app/ToastTool.html" title="com.mazouri.tools.app中的类" target="classFrame">ToastTool</a></li>
<li><a href="com/mazouri/tools/unit/UnitTool.html" title="com.mazouri.tools.unit中的类" target="classFrame">UnitTool</a></li>
</ul>
</div>
</body>
</html>
41 changes: 41 additions & 0 deletions docs/allclasses-noframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="zh">
<head>
<!-- Generated by javadoc (1.8.0_76-release) on Fri Jan 20 17:41:55 CST 2017 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>所有类</title>
<meta name="date" content="2017-01-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h1 class="bar">所有类</h1>
<div class="indexContainer">
<ul>
<li><a href="com/mazouri/tools/AndroidTools.html" title="com.mazouri.tools中的类">AndroidTools</a></li>
<li><a href="com/mazouri/tools/apk/ApkTool.html" title="com.mazouri.tools.apk中的类">ApkTool</a></li>
<li><a href="com/mazouri/tools/app/AppTool.html" title="com.mazouri.tools.app中的类">AppTool</a></li>
<li><a href="com/mazouri/tools/image/BitmapTool.html" title="com.mazouri.tools.image中的类">BitmapTool</a></li>
<li><a href="com/mazouri/tools/device/DeviceTool.html" title="com.mazouri.tools.device中的类">DeviceTool</a></li>
<li><a href="com/mazouri/tools/io/ExternalStorageTool.html" title="com.mazouri.tools.io中的类">ExternalStorageTool</a></li>
<li><a href="com/mazouri/tools/app/InputMethodTool.html" title="com.mazouri.tools.app中的类">InputMethodTool</a></li>
<li><a href="com/mazouri/tools/log/LogTool.html" title="com.mazouri.tools.log中的类">LogTool</a></li>
<li><a href="com/mazouri/tools/device/NetworkTool.html" title="com.mazouri.tools.device中的类">NetworkTool</a></li>
<li><a href="com/mazouri/tools/regex/RegexTool.html" title="com.mazouri.tools.regex中的类">RegexTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureAESTool.html" title="com.mazouri.tools.secure中的类">SecureAESTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureBase64Tool.html" title="com.mazouri.tools.secure中的类">SecureBase64Tool</a></li>
<li><a href="com/mazouri/tools/secure/SecureDES3Tool.html" title="com.mazouri.tools.secure中的类">SecureDES3Tool</a></li>
<li><a href="com/mazouri/tools/secure/SecureDESTool.html" title="com.mazouri.tools.secure中的类">SecureDESTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureHexTool.html" title="com.mazouri.tools.secure中的类">SecureHexTool</a></li>
<li><a href="com/mazouri/tools/secure/SecureMD5Tool.html" title="com.mazouri.tools.secure中的类">SecureMD5Tool</a></li>
<li><a href="com/mazouri/tools/secure/SecureRSATool.html" title="com.mazouri.tools.secure中的类">SecureRSATool</a></li>
<li><a href="com/mazouri/tools/secure/SecureRSATool.PADDING.html" title="com.mazouri.tools.secure中的枚举">SecureRSATool.PADDING</a></li>
<li><a href="com/mazouri/tools/io/SPTool.html" title="com.mazouri.tools.io中的类">SPTool</a></li>
<li><a href="com/mazouri/tools/string/StringTool.html" title="com.mazouri.tools.string中的类">StringTool</a></li>
<li><a href="com/mazouri/tools/app/ToastTool.html" title="com.mazouri.tools.app中的类">ToastTool</a></li>
<li><a href="com/mazouri/tools/unit/UnitTool.html" title="com.mazouri.tools.unit中的类">UnitTool</a></li>
</ul>
</div>
</body>
</html>
Loading

0 comments on commit 5f2f9b1

Please sign in to comment.