-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wangdongdong <[email protected]>
- Loading branch information
wangdongdong
committed
Jan 20, 2017
1 parent
139e6e8
commit 5f2f9b1
Showing
91 changed files
with
18,945 additions
and
0 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.
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
104 changes: 104 additions & 0 deletions
104
android-tools/src/main/java/com/mazouri/tools/io/SPTool.java
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,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(); | ||
} | ||
} |
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,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> |
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,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> |
Oops, something went wrong.