This repository has been archived by the owner on Dec 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.IntentTool
- Loading branch information
Showing
50 changed files
with
6,083 additions
and
6,493 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
...asydeveloper/ExampleInstrumentedTest.java → .../easyandroid/ExampleInstrumentedTest.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
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,3 +1,3 @@ | ||
<resources> | ||
<string name="app_name">AndroidEasyDeveloper</string> | ||
<string name="app_name">EasyAndroid</string> | ||
</resources> |
2 changes: 1 addition & 1 deletion
2
...ayvytr/easydeveloper/ExampleUnitTest.java → ...m/ayvytr/easyandroid/ExampleUnitTest.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.ayvytr.easydeveloper; | ||
package com.ayvytr.easyandroid; | ||
|
||
import org.junit.Test; | ||
|
||
|
File renamed without changes.
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...asydeveloper/ExampleInstrumentedTest.java → ...droidlibrary/ExampleInstrumentedTest.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
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,14 @@ | ||
<manifest package="com.ayvytr.easyandroidlibrary" | ||
|
||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
> | ||
|
||
</application> | ||
|
||
</manifest> |
197 changes: 99 additions & 98 deletions
197
...n/java/com/ayvytr/easydeveloper/Easy.java → ...a/com/ayvytr/easyandroidlibrary/Easy.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 |
---|---|---|
@@ -1,98 +1,99 @@ | ||
package com.ayvytr.easydeveloper; | ||
|
||
import android.app.KeyguardManager; | ||
import android.content.ClipboardManager; | ||
import android.content.Context; | ||
import android.view.WindowManager; | ||
|
||
import com.ayvytr.easydeveloper.exception.UnInitLibraryException; | ||
|
||
import java.lang.ref.SoftReference; | ||
|
||
/** | ||
* Created by davidwang on 2017/3/15. | ||
* Easy:入口类,单例模式。Tools包中或者其他需要用到Context的类在使用之前, | ||
* 需要初始化这个类 | ||
* | ||
* 提供了获取Context,常用SystemService等方法 | ||
*/ | ||
|
||
public class Easy | ||
{ | ||
private static Easy easy = new Easy(); | ||
private static SoftReference<Context> contextRef; | ||
|
||
public static Context getContext() | ||
{ | ||
checkInitState(); | ||
return contextRef.get(); | ||
} | ||
|
||
/** | ||
* 检测初始化状态。Easy类暂时定为静态初始化,所以直接检测contextRef是否已初始化, | ||
* 未初始化,直接抛出自定义异常 | ||
*/ | ||
private static void checkInitState() | ||
{ | ||
if(contextRef == null) | ||
{ | ||
throw new UnInitLibraryException(); | ||
} | ||
} | ||
|
||
private Easy() | ||
{ | ||
} | ||
|
||
public static Easy getDefault() | ||
{ | ||
return easy; | ||
} | ||
|
||
/** | ||
* 初始化Context | ||
* @param context context | ||
*/ | ||
public void init(Context context) | ||
{ | ||
if(context == null) | ||
{ | ||
throw new NullPointerException("Context is null on 'init'."); | ||
} | ||
|
||
this.contextRef = new SoftReference<>(context); | ||
} | ||
|
||
/** | ||
* 释放资源(可能用不到,但还是提供吧) | ||
*/ | ||
public void release() | ||
{ | ||
contextRef = null; | ||
easy = null; | ||
} | ||
|
||
/** | ||
* 获取 ClipboardManager | ||
*/ | ||
public ClipboardManager getClipboardManager() | ||
{ | ||
return (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); | ||
} | ||
|
||
/** | ||
* 获取WindowManager | ||
*/ | ||
public WindowManager getWindowManager() | ||
{ | ||
return (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); | ||
} | ||
|
||
/** | ||
* 获取KeyguardManager | ||
*/ | ||
public KeyguardManager getKeyguardManager() | ||
{ | ||
return (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE); | ||
} | ||
} | ||
package com.ayvytr.easyandroidlibrary; | ||
|
||
import android.app.KeyguardManager; | ||
import android.content.ClipboardManager; | ||
import android.content.Context; | ||
import android.view.WindowManager; | ||
|
||
import com.ayvytr.easyandroidlibrary.exception.UnInitLibraryException; | ||
|
||
import java.lang.ref.SoftReference; | ||
|
||
/** | ||
* Created by davidwang on 2017/3/15. | ||
* Easy:入口类,单例模式。Tools包中或者其他需要用到Context的类在使用之前, | ||
* 需要初始化这个类 | ||
* <p> | ||
* 提供了获取Context,常用SystemService等方法 | ||
*/ | ||
|
||
public class Easy | ||
{ | ||
private static Easy easy = new Easy(); | ||
private static SoftReference<Context> contextRef; | ||
|
||
public static Context getContext() | ||
{ | ||
checkInitState(); | ||
return contextRef.get(); | ||
} | ||
|
||
/** | ||
* 检测初始化状态。Easy类暂时定为静态初始化,所以直接检测contextRef是否已初始化, | ||
* 未初始化,直接抛出自定义异常 | ||
*/ | ||
private static void checkInitState() | ||
{ | ||
if(contextRef == null) | ||
{ | ||
throw new UnInitLibraryException(); | ||
} | ||
} | ||
|
||
private Easy() | ||
{ | ||
} | ||
|
||
public static Easy getDefault() | ||
{ | ||
return easy; | ||
} | ||
|
||
/** | ||
* 初始化Context | ||
* | ||
* @param context context | ||
*/ | ||
public void init(Context context) | ||
{ | ||
if(context == null) | ||
{ | ||
throw new NullPointerException("Context is null on 'init'."); | ||
} | ||
|
||
this.contextRef = new SoftReference<>(context); | ||
} | ||
|
||
/** | ||
* 释放资源(可能用不到,但还是提供吧) | ||
*/ | ||
public void release() | ||
{ | ||
contextRef = null; | ||
easy = null; | ||
} | ||
|
||
/** | ||
* 获取 ClipboardManager | ||
*/ | ||
public ClipboardManager getClipboardManager() | ||
{ | ||
return (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); | ||
} | ||
|
||
/** | ||
* 获取WindowManager | ||
*/ | ||
public WindowManager getWindowManager() | ||
{ | ||
return (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); | ||
} | ||
|
||
/** | ||
* 获取KeyguardManager | ||
*/ | ||
public KeyguardManager getKeyguardManager() | ||
{ | ||
return (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE); | ||
} | ||
} |
Oops, something went wrong.