├── .idea ├── .name ├── vcs.xml ├── AndroidProjectSystem.xml ├── migrations.xml ├── deploymentTargetSelector.xml ├── gradle.xml ├── misc.xml ├── jarRepositories.xml ├── runConfigurations.xml ├── compiler.xml └── codeStyles │ └── Project.xml ├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ ├── layout │ │ │ ├── content_main.xml │ │ │ ├── fragment_second.xml │ │ │ ├── fragment_first.xml │ │ │ └── activity_main.xml │ │ ├── navigation │ │ │ └── nav_graph.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── richzjc │ │ └── net │ │ ├── FirstFragment.java │ │ ├── SecondFragment.java │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── network ├── consumer-rules.pro ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── richzjc │ │ │ └── network │ │ │ ├── SubscribeInfoIndex.java │ │ │ ├── ConstKt.java │ │ │ ├── SubscribeInfo.java │ │ │ ├── SubscribeMethod.java │ │ │ ├── NetBroadCastReceiver.java │ │ │ ├── SimpleSubscribeInfo.java │ │ │ ├── NetworkUtils.java │ │ │ └── NetManager.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── netCompiler ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── richzjc │ │ └── netcompiler │ │ ├── Const.java │ │ ├── util │ │ └── EmptyUtils.java │ │ └── NetCompiler.java └── build.gradle ├── netannotation ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── richzjc │ │ └── netannotation │ │ ├── nettype │ │ └── NetType.java │ │ ├── NetLose.java │ │ ├── NetAvailable.java │ │ └── NetChange.java └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | net -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /network/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /netCompiler/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /network/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /netannotation/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='net' 2 | include ':app' 3 | include ':netannotation' 4 | include ':netCompiler' 5 | include ':network' 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/richzjc/NetworkListener/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /netannotation/src/main/java/com/richzjc/netannotation/nettype/NetType.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.netannotation.nettype; 2 | 3 | public enum NetType { 4 | AUTO, WIFI, MOBILE, NONE; 5 | } 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /network/src/main/java/com/richzjc/network/SubscribeInfoIndex.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.network; 2 | 3 | import java.util.Map; 4 | 5 | public interface SubscribeInfoIndex { 6 | Map getSubscriberInfo(); 7 | } 8 | -------------------------------------------------------------------------------- /.idea/AndroidProjectSystem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /network/src/main/java/com/richzjc/network/ConstKt.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.network; 2 | 3 | public class ConstKt { 4 | public static final String ANDROID_NET_CHANGE_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; 5 | public static final String LOG_TAG = "net >>>"; 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jan 02 15:23:37 CST 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /.idea/migrations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /network/src/main/java/com/richzjc/network/SubscribeInfo.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.network; 2 | 3 | import java.util.List; 4 | 5 | public interface SubscribeInfo { 6 | List availabeMethods(); 7 | List loseMethods(); 8 | List changeMethods(); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/deploymentTargetSelector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /netannotation/src/main/java/com/richzjc/netannotation/NetLose.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.netannotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.CLASS) 9 | @Target(ElementType.METHOD) 10 | public @interface NetLose { 11 | } 12 | -------------------------------------------------------------------------------- /netannotation/src/main/java/com/richzjc/netannotation/NetAvailable.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.netannotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.CLASS) 9 | @Target(ElementType.METHOD) 10 | public @interface NetAvailable { 11 | } 12 | -------------------------------------------------------------------------------- /network/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /network/src/main/java/com/richzjc/network/SubscribeMethod.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.network; 2 | 3 | import com.richzjc.netannotation.nettype.NetType; 4 | 5 | public class SubscribeMethod { 6 | public String getMethodName() { 7 | return methodName; 8 | } 9 | 10 | public NetType getNetType() { 11 | return netType; 12 | } 13 | 14 | private String methodName; 15 | private NetType netType; 16 | 17 | public SubscribeMethod(String methodName, NetType type){ 18 | this.methodName = methodName; 19 | this.netType = type; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /netCompiler/src/main/java/com/richzjc/netcompiler/Const.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.netcompiler; 2 | 3 | public class Const { 4 | public static final String SUBSCRIBE_INFO_INDEX = "com.richzjc.network.SubscribeInfoIndex"; 5 | public static final String OVERRIDE_ANNOTATION = "java.lang.Override"; 6 | public static final String NETTYPE_PATH = "com.richzjc.netannotation.nettype.NetType"; 7 | public static final String SIMPLE_SUBSCRIBE_INFO = "com.richzjc.network.SimpleSubscribeInfo"; 8 | public static final String SUBSCRIBE_METHOD_PATH = "com.richzjc.network.SubscribeMethod"; 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | net 3 | Settings 4 | 5 | First Fragment 6 | Second Fragment 7 | Next 8 | Previous 9 | 10 | Hello first fragment 11 | Hello second fragment. Arg: %1$s 12 | 13 | -------------------------------------------------------------------------------- /netCompiler/src/main/java/com/richzjc/netcompiler/util/EmptyUtils.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.netcompiler.util; 2 | 3 | import java.util.Collection; 4 | import java.util.Map; 5 | 6 | /** 7 | * 字符串、集合判空工具 8 | */ 9 | public final class EmptyUtils { 10 | 11 | 12 | public static boolean isEmpty(CharSequence cs) { 13 | return cs == null || cs.length() == 0; 14 | } 15 | 16 | public static boolean isEmpty(Collection coll) { 17 | return coll == null || coll.isEmpty(); 18 | } 19 | 20 | public static boolean isEmpty(final Map map) { 21 | return map == null || map.isEmpty(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /netannotation/src/main/java/com/richzjc/netannotation/NetChange.java: -------------------------------------------------------------------------------- 1 | package com.richzjc.netannotation; 2 | 3 | import com.richzjc.netannotation.nettype.NetType; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | 12 | 13 | @Retention(RetentionPolicy.CLASS) 14 | @Target(ElementType.METHOD) 15 | public @interface NetChange { 16 | /** 17 | * 描述 netType 属性的作用 18 | * 19 | * @return 返回网络类型枚举值(如 4G/5G/WiFi) 20 | */ 21 | NetType netType(); 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |