-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
290 additions
and
15 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
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/sunchen/netobserver/BaseApplication.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,21 @@ | ||
package com.sunchen.netobserver; | ||
|
||
import android.app.Application; | ||
|
||
import com.sunchen.networkobserver.NetworkManager; | ||
|
||
/** | ||
* Created by 「孙晨」 on 2019/4/2 22:19. | ||
* <p> | ||
* God bless me only | ||
* <p> | ||
* BaseApplication | ||
*/ | ||
|
||
public class BaseApplication extends Application { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
NetworkManager.getInstance().init(this); | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
networkobserver/src/main/java/com/sunchen/networkobserver/MethodManager.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,60 @@ | ||
package com.sunchen.networkobserver; | ||
|
||
/** | ||
* Created by 「孙晨」 on 2019/4/2 22:28. | ||
* <p> | ||
* God bless me only | ||
* <p> | ||
* MethodManager | ||
*/ | ||
|
||
import com.sunchen.networkobserver.type.NetType; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* 保存符合要求的网络监听注解方法 | ||
*/ | ||
public class MethodManager { | ||
|
||
//参数类型 | ||
private Class<?> clazz; | ||
|
||
// 网络类型 | ||
private NetType netType; | ||
|
||
// 需要这执行的方法 | ||
private Method method; | ||
|
||
public MethodManager(Class<?> clazz, NetType netType, Method method) { | ||
this.clazz = clazz; | ||
this.netType = netType; | ||
this.method = method; | ||
} | ||
|
||
|
||
|
||
public Class<?> getClazz() { | ||
return clazz; | ||
} | ||
|
||
public void setClazz(Class<?> clazz) { | ||
this.clazz = clazz; | ||
} | ||
|
||
public NetType getNetType() { | ||
return netType; | ||
} | ||
|
||
public void setNetType(NetType netType) { | ||
this.netType = netType; | ||
} | ||
|
||
public Method getMethod() { | ||
return method; | ||
} | ||
|
||
public void setMethod(Method method) { | ||
this.method = method; | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
networkobserver/src/main/java/com/sunchen/networkobserver/annotation/Network.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,21 @@ | ||
package com.sunchen.networkobserver.annotation; | ||
|
||
import com.sunchen.networkobserver.type.NetType; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Created by 「孙晨」 on 2019/4/2 22:13. | ||
* <p> | ||
* God bless me only | ||
* <p> | ||
* Network | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Network { | ||
NetType netType() default NetType.AUTO; | ||
} |