diff --git a/.gitignore b/.gitignore
index 895aa13..930f450 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,9 @@
bin/
gen/
*.DS_Store
+app/build/
+library/build/
+
*/bin/
*/gen/
.settings/
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..0081406
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/android_support_v4.xml b/.idea/libraries/android_support_v4.xml
new file mode 100644
index 0000000..00acd90
--- /dev/null
+++ b/.idea/libraries/android_support_v4.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 0000000..69f6a36
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..2483849
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
deleted file mode 100644
index 7775d66..0000000
--- a/AndroidManifest.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
diff --git a/README-ch.md b/README-ch.md
index 414d64f..4ea344f 100644
--- a/README-ch.md
+++ b/README-ch.md
@@ -18,6 +18,8 @@
* [大题小作](http://www.pkdati.com/)
* [易泊商户](http://www.myebox.cn/)
* [易方达移动OA](http://www.wandoujia.com/apps/com.efunds.trade)
+* [功夫泡](http://gongfupao.com)
+* * [魅族手机中的日历应用]()
`欢迎大家给我反馈使用情况`
@@ -117,7 +119,7 @@ public class YourActivity extends Activity {
## 集成
### jar文件集成
-将jar文件添加到工程中的引用中即可,[AndroidEventBus.jar下载](lib/androideventbus-1.0.4.jar?raw=true "点击下载到本地")
+将jar文件添加到工程中的引用中即可,[AndroidEventBus.jar下载](lib/androideventbus-1.0.5.1.jar?raw=true "点击下载到本地")
### Android Studio集成
@@ -128,7 +130,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// 添加依赖
- compile 'org.simple:androideventbus:latest'
+ compile 'org.simple:androideventbus:1.0.5.1'
}
```
@@ -165,6 +167,7 @@ private void onEventMainThread(User aUser) {
-keepclassmembers class * {
@org.simple.eventbus.Subscriber ;
}
+-keepattributes *Annotation*
```
## 感谢
diff --git a/README.md b/README.md
index a3e4d1d..f6ffb07 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,8 @@
-#  AndroidEventBus
+# AndroidEventBus
This is an EventBus library for Android. It simplifies the communication between Activities, Fragments, Threads, Services, etc. and lowers the coupling among them to a great extent, thus making simplifier codes, lower coupling possible and improving code quality.
- ****中文版 [README.md](README-ch.md).****
-
- **AndroidEventBus技术交流群群 号:312090070。有问题或者有建议可以到该群中咨询,谢谢。**
+[//]: # ( ****中文版 [README.md](README-ch.md).【该项目不再维护】**** )
## new feature
@@ -17,6 +15,7 @@ This is an EventBus library for Android. It simplifies the communication between
* [大题小作](http://www.pkdati.com/)
* [易方达移动OA](http://www.wandoujia.com/apps/com.efunds.trade)
* [Novu - Your Health Rewarded](https://play.google.com/store/apps/details?id=com.novu.novu)
+* [魅族手机中的日历应用]()
## Basic Architecture

@@ -121,7 +120,7 @@ The receiving function will use “tag” to mark receivable types of events, ju
## Usage
### integrate with jar
-It will be enough to add the jar file into the “quote” part of the Project, AndroidEventBus.[AndroidEventBus.jar](lib/androideventbus-1.0.4.jar?raw=true "download")
+It will be enough to add the jar file into the “quote” part of the Project, AndroidEventBus.[AndroidEventBus.jar](lib/androideventbus-1.0.5.1.jar?raw=true "download")
### Gradle
@@ -132,7 +131,7 @@ It will be enough to add the jar file into the “quote” part of the Project,
dependencies {
// add AndroidEventBus dependency
- compile 'org.simple:androideventbus:1.0.5'
+ compile 'org.simple:androideventbus:1.0.5.1'
}
```
@@ -168,6 +167,7 @@ These are the differences between AndroidEventBus and EventBus of greenrobot. Bu
-keepclassmembers class * {
@org.simple.eventbus.Subscriber ;
}
+-keepattributes *Annotation*
```
## Thanks Note
diff --git a/Simple_Event_Test/AndroidManifest.xml b/Simple_Event_Test/AndroidManifest.xml
deleted file mode 100644
index 0108195..0000000
--- a/Simple_Event_Test/AndroidManifest.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Simple_Event_Test/proguard-project.txt b/Simple_Event_Test/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/Simple_Event_Test/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/Simple_Event_Test/project.properties b/Simple_Event_Test/project.properties
deleted file mode 100644
index 3aedb2f..0000000
--- a/Simple_Event_Test/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-10
-android.library.reference.1=..
diff --git a/Simple_Event_Test/res/drawable-hdpi/ic_launcher.png b/Simple_Event_Test/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 96a442e..0000000
Binary files a/Simple_Event_Test/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/Simple_Event_Test/res/drawable-ldpi/ic_launcher.png b/Simple_Event_Test/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index 9923872..0000000
Binary files a/Simple_Event_Test/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/Simple_Event_Test/res/drawable-mdpi/ic_launcher.png b/Simple_Event_Test/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 359047d..0000000
Binary files a/Simple_Event_Test/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/Simple_Event_Test/res/drawable-xhdpi/ic_launcher.png b/Simple_Event_Test/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 71c6d76..0000000
Binary files a/Simple_Event_Test/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/Simple_Event_Test/res/values/strings.xml b/Simple_Event_Test/res/values/strings.xml
deleted file mode 100644
index 7bbdda0..0000000
--- a/Simple_Event_Test/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- Simple_Event_TestTest
-
-
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/BusTestSuite.java b/Simple_Event_Test/src/org/simple/eventbus/test/BusTestSuite.java
deleted file mode 100644
index 7b5bd73..0000000
--- a/Simple_Event_Test/src/org/simple/eventbus/test/BusTestSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2015 Mr.Simple
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.simple.eventbus.test;
-
-import android.test.suitebuilder.TestSuiteBuilder;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author mrsimple
- */
-public class BusTestSuite extends TestSuite {
- public static Test suite() {
- return new TestSuiteBuilder(BusTestSuite.class)
- .includePackages(
- "org.simple.eventbus.test.EventBusTest",
- "org.simple.eventbus.test.EventTypeTest",
- "org.simple.eventbus.test.ThreadModeTest",
- "org.simple.eventbus.testDefaultMatchPolicyTest")
- .build();
- }
-}
diff --git a/Simple_eventbus_demo/ic_launcher-web.png b/Simple_eventbus_demo/ic_launcher-web.png
deleted file mode 100644
index a18cbb4..0000000
Binary files a/Simple_eventbus_demo/ic_launcher-web.png and /dev/null differ
diff --git a/Simple_eventbus_demo/libs/android-support-v4.jar b/Simple_eventbus_demo/libs/android-support-v4.jar
deleted file mode 100644
index 4ebdaa9..0000000
Binary files a/Simple_eventbus_demo/libs/android-support-v4.jar and /dev/null differ
diff --git a/Simple_eventbus_demo/proguard-project.txt b/Simple_eventbus_demo/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/Simple_eventbus_demo/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/Simple_eventbus_demo/project.properties b/Simple_eventbus_demo/project.properties
deleted file mode 100644
index 3aedb2f..0000000
--- a/Simple_eventbus_demo/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-10
-android.library.reference.1=..
diff --git a/Simple_eventbus_demo/res/drawable-xhdpi/event_bus.png b/Simple_eventbus_demo/res/drawable-xhdpi/event_bus.png
deleted file mode 100644
index 0c6e5a2..0000000
Binary files a/Simple_eventbus_demo/res/drawable-xhdpi/event_bus.png and /dev/null differ
diff --git a/Simple_eventbus_demo/res/drawable-xhdpi/ic_launcher.png b/Simple_eventbus_demo/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index d4fb7cd..0000000
Binary files a/Simple_eventbus_demo/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/Simple_eventbus_demo/res/drawable-xxhdpi/ic_launcher.png b/Simple_eventbus_demo/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index 85a6081..0000000
Binary files a/Simple_eventbus_demo/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/Simple_eventbus_demo/res/values/styles.xml b/Simple_eventbus_demo/res/values/styles.xml
deleted file mode 100644
index 6ce89c7..0000000
--- a/Simple_eventbus_demo/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..aeef32d
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,45 @@
+plugins {
+ id 'com.android.application'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.android.eventbus.demo'
+ compileSdk 33
+
+ defaultConfig {
+ applicationId "com.android.eventbus.demo"
+ minSdk 21
+ targetSdk 33
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+ buildFeatures {
+ viewBinding true
+ }
+}
+
+dependencies {
+
+ implementation 'androidx.appcompat:appcompat:1.6.1'
+ implementation 'com.google.android.material:material:1.5.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+ implementation project(":library")
+
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+}
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/android/eventbus/demo/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/android/eventbus/demo/ExampleInstrumentedTest.kt
new file mode 100644
index 0000000..476e9ba
--- /dev/null
+++ b/app/src/androidTest/java/com/android/eventbus/demo/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package com.android.eventbus.demo
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("com.android.eventbus.demo", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/Simple_eventbus_demo/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
similarity index 50%
rename from Simple_eventbus_demo/AndroidManifest.xml
rename to app/src/main/AndroidManifest.xml
index 8163d61..4c55b9c 100644
--- a/Simple_eventbus_demo/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,26 +1,28 @@
+
-
-
+ xmlns:tools="http://schemas.android.com/tools">
+ android:supportsRtl="true"
+ android:theme="@style/Theme.AndroidEventBusV2"
+ tools:targetApi="31">
+ android:exported="true"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.AndroidEventBusV2">
+
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/MainActivity.java b/app/src/main/java/com/android/eventbus/demo/MainActivity.java
similarity index 85%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/MainActivity.java
rename to app/src/main/java/com/android/eventbus/demo/MainActivity.java
index f4fe3a8..8e9bb65 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/MainActivity.java
+++ b/app/src/main/java/com/android/eventbus/demo/MainActivity.java
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package org.simple.eventbus.demo;
+package com.android.eventbus.demo;
import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
-public class MainActivity extends FragmentActivity {
+import androidx.appcompat.app.AppCompatActivity;
+
+public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/StickyActivity.java b/app/src/main/java/com/android/eventbus/demo/StickyActivity.java
similarity index 96%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/StickyActivity.java
rename to app/src/main/java/com/android/eventbus/demo/StickyActivity.java
index 90208a7..e1e4f86 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/StickyActivity.java
+++ b/app/src/main/java/com/android/eventbus/demo/StickyActivity.java
@@ -22,16 +22,17 @@
* THE SOFTWARE.
*/
-package org.simple.eventbus.demo;
+package com.android.eventbus.demo;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
+import com.android.eventbus.demo.bean.User;
+
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
-import org.simple.eventbus.demo.bean.User;
public class StickyActivity extends Activity {
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/bean/StickyUser.java b/app/src/main/java/com/android/eventbus/demo/bean/StickyUser.java
similarity index 96%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/bean/StickyUser.java
rename to app/src/main/java/com/android/eventbus/demo/bean/StickyUser.java
index b4d01ae..bc05ee6 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/bean/StickyUser.java
+++ b/app/src/main/java/com/android/eventbus/demo/bean/StickyUser.java
@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
-package org.simple.eventbus.demo.bean;
+package com.android.eventbus.demo.bean;
public class StickyUser extends User {
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/bean/User.java b/app/src/main/java/com/android/eventbus/demo/bean/User.java
similarity index 97%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/bean/User.java
rename to app/src/main/java/com/android/eventbus/demo/bean/User.java
index 7443f7a..15c7c02 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/bean/User.java
+++ b/app/src/main/java/com/android/eventbus/demo/bean/User.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.simple.eventbus.demo.bean;
+package com.android.eventbus.demo.bean;
public class User {
public String name;
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/BaseFragment.java b/app/src/main/java/com/android/eventbus/demo/fragment/BaseFragment.java
similarity index 92%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/BaseFragment.java
rename to app/src/main/java/com/android/eventbus/demo/fragment/BaseFragment.java
index c99a7fe..c5eb255 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/BaseFragment.java
+++ b/app/src/main/java/com/android/eventbus/demo/fragment/BaseFragment.java
@@ -22,13 +22,15 @@
* THE SOFTWARE.
*/
-package org.simple.eventbus.demo.fragment;
+package com.android.eventbus.demo.fragment;
-import android.support.v4.app.Fragment;
import android.util.Log;
+import androidx.fragment.app.Fragment;
+
+import com.android.eventbus.demo.bean.User;
+
import org.simple.eventbus.Subscriber;
-import org.simple.eventbus.demo.bean.User;
/**
* @author mrsimple
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/ConstactFragment.java b/app/src/main/java/com/android/eventbus/demo/fragment/ConstactFragment.java
similarity index 95%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/ConstactFragment.java
rename to app/src/main/java/com/android/eventbus/demo/fragment/ConstactFragment.java
index 3d50ab6..cd01c27 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/ConstactFragment.java
+++ b/app/src/main/java/com/android/eventbus/demo/fragment/ConstactFragment.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.simple.eventbus.demo.fragment;
+package com.android.eventbus.demo.fragment;
import android.os.Bundle;
-import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -28,11 +27,14 @@
import android.widget.ListView;
import android.widget.Toast;
+import androidx.fragment.app.Fragment;
+
+import com.android.eventbus.demo.R;
+import com.android.eventbus.demo.bean.User;
+
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import org.simple.eventbus.ThreadMode;
-import org.simple.eventbus.demo.R;
-import org.simple.eventbus.demo.bean.User;
import java.util.LinkedList;
import java.util.List;
@@ -122,8 +124,7 @@ private void removePersonPrivate(User person) {
/**
* 执行在异步线程的函数
- *
- * @param event
+ * @param person
*/
@Subscriber(tag = MenuFragment.ASYNC_TAG, mode = ThreadMode.ASYNC)
private void asyncMethod(final User person) {
diff --git a/Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/MenuFragment.java b/app/src/main/java/com/android/eventbus/demo/fragment/MenuFragment.java
similarity index 97%
rename from Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/MenuFragment.java
rename to app/src/main/java/com/android/eventbus/demo/fragment/MenuFragment.java
index 5fe207f..ba31e97 100644
--- a/Simple_eventbus_demo/src/org/simple/eventbus/demo/fragment/MenuFragment.java
+++ b/app/src/main/java/com/android/eventbus/demo/fragment/MenuFragment.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.simple.eventbus.demo.fragment;
+package com.android.eventbus.demo.fragment;
import android.content.Intent;
import android.os.Bundle;
@@ -25,13 +25,14 @@
import android.view.ViewGroup;
import android.widget.TextView;
+import com.android.eventbus.demo.R;
+import com.android.eventbus.demo.StickyActivity;
+import com.android.eventbus.demo.bean.StickyUser;
+import com.android.eventbus.demo.bean.User;
+
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import org.simple.eventbus.ThreadMode;
-import org.simple.eventbus.demo.R;
-import org.simple.eventbus.demo.StickyActivity;
-import org.simple.eventbus.demo.bean.StickyUser;
-import org.simple.eventbus.demo.bean.User;
import java.util.ArrayList;
import java.util.List;
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Simple_eventbus_demo/res/layout/include_sticky_activity.xml b/app/src/main/res/layout/include_sticky_activity.xml
similarity index 90%
rename from Simple_eventbus_demo/res/layout/include_sticky_activity.xml
rename to app/src/main/res/layout/include_sticky_activity.xml
index e166ce5..19a8b04 100755
--- a/Simple_eventbus_demo/res/layout/include_sticky_activity.xml
+++ b/app/src/main/res/layout/include_sticky_activity.xml
@@ -8,7 +8,7 @@
android:id="@+id/back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:src="@drawable/ic_launcher" />
+ android:src="@drawable/ic_launcher_background" />
diff --git a/Simple_eventbus_demo/res/layout/menu_fragment.xml b/app/src/main/res/layout/menu_fragment.xml
similarity index 100%
rename from Simple_eventbus_demo/res/layout/menu_fragment.xml
rename to app/src/main/res/layout/menu_fragment.xml
diff --git a/Simple_eventbus_demo/res/layout/sticky_activity.xml b/app/src/main/res/layout/sticky_activity.xml
similarity index 83%
rename from Simple_eventbus_demo/res/layout/sticky_activity.xml
rename to app/src/main/res/layout/sticky_activity.xml
index 300f0e8..dd407ee 100755
--- a/Simple_eventbus_demo/res/layout/sticky_activity.xml
+++ b/app/src/main/res/layout/sticky_activity.xml
@@ -10,12 +10,15 @@
android:id="@+id/name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginTop="120dp"
+ android:textSize="15pt"
android:text="name" />
\ No newline at end of file
diff --git a/Simple_eventbus_demo/res/layout/test_sticky_activity.xml b/app/src/main/res/layout/test_sticky_activity.xml
similarity index 100%
rename from Simple_eventbus_demo/res/layout/test_sticky_activity.xml
rename to app/src/main/res/layout/test_sticky_activity.xml
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml
new file mode 100644
index 0000000..6f3b755
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c209e78
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..b2dfe3d
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..4f0f1d6
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..62b611d
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..948a307
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..1b9a695
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..28d4b77
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9287f50
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..aa7d642
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9126ae3
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml
new file mode 100644
index 0000000..22d7f00
--- /dev/null
+++ b/app/src/main/res/values-land/dimens.xml
@@ -0,0 +1,3 @@
+
+ 48dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
new file mode 100644
index 0000000..15e703e
--- /dev/null
+++ b/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v29/themes.xml b/app/src/main/res/values-v29/themes.xml
new file mode 100644
index 0000000..3981268
--- /dev/null
+++ b/app/src/main/res/values-v29/themes.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-w1240dp/dimens.xml b/app/src/main/res/values-w1240dp/dimens.xml
new file mode 100644
index 0000000..d73f4a3
--- /dev/null
+++ b/app/src/main/res/values-w1240dp/dimens.xml
@@ -0,0 +1,3 @@
+
+ 200dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values-w600dp/dimens.xml b/app/src/main/res/values-w600dp/dimens.xml
new file mode 100644
index 0000000..22d7f00
--- /dev/null
+++ b/app/src/main/res/values-w600dp/dimens.xml
@@ -0,0 +1,3 @@
+
+ 48dp
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..c8524cd
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,5 @@
+
+
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..125df87
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,3 @@
+
+ 16dp
+
\ No newline at end of file
diff --git a/Simple_eventbus_demo/res/values/strings.xml b/app/src/main/res/values/strings.xml
similarity index 100%
rename from Simple_eventbus_demo/res/values/strings.xml
rename to app/src/main/res/values/strings.xml
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644
index 0000000..36170a4
--- /dev/null
+++ b/app/src/main/res/values/themes.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/backup_rules.xml b/app/src/main/res/xml/backup_rules.xml
new file mode 100644
index 0000000..fa0f996
--- /dev/null
+++ b/app/src/main/res/xml/backup_rules.xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml
new file mode 100644
index 0000000..9ee9997
--- /dev/null
+++ b/app/src/main/res/xml/data_extraction_rules.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/com/android/eventbus/demo/ExampleUnitTest.kt b/app/src/test/java/com/android/eventbus/demo/ExampleUnitTest.kt
new file mode 100644
index 0000000..e63e6ba
--- /dev/null
+++ b/app/src/test/java/com/android/eventbus/demo/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package com.android.eventbus.demo
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..443cab9
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,6 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+ id 'com.android.application' version '7.4.1' apply false
+ id 'com.android.library' version '7.4.1' apply false
+ id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..3c5031e
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,23 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..e708b1c
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d3e2729
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu Jun 15 19:57:16 CST 2023
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..4f906e0
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..ac1b06f
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/lib/androideventbus-1.0.3.jar b/lib/androideventbus-1.0.3.jar
deleted file mode 100644
index 7b2d899..0000000
Binary files a/lib/androideventbus-1.0.3.jar and /dev/null differ
diff --git a/lib/androideventbus-1.0.4.jar b/lib/androideventbus-1.0.4.jar
deleted file mode 100644
index bfd9075..0000000
Binary files a/lib/androideventbus-1.0.4.jar and /dev/null differ
diff --git a/lib/androideventbus-1.0.5.1.jar b/lib/androideventbus-1.0.5.1.jar
new file mode 100644
index 0000000..146e186
Binary files /dev/null and b/lib/androideventbus-1.0.5.1.jar differ
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 0000000..37cbeb0
--- /dev/null
+++ b/library/build.gradle
@@ -0,0 +1,36 @@
+plugins {
+ id 'com.android.library'
+}
+
+android {
+ namespace 'com.android.eventbus.library'
+ compileSdk 33
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 33
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+
+ implementation 'androidx.appcompat:appcompat:1.6.1'
+ implementation 'com.google.android.material:material:1.9.0'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+}
\ No newline at end of file
diff --git a/library/consumer-rules.pro b/library/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/library/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/library/src/androidTest/java/com/android/eventbus/library/ExampleInstrumentedTest.java b/library/src/androidTest/java/com/android/eventbus/library/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..8a7c5b9
--- /dev/null
+++ b/library/src/androidTest/java/com/android/eventbus/library/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.android.eventbus.library;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.android.eventbus.library.test", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/DefaultMatchPolicyTest.java b/library/src/androidTest/java/org/simple/eventbus/test/DefaultMatchPolicyTest.java
similarity index 82%
rename from Simple_Event_Test/src/org/simple/eventbus/test/DefaultMatchPolicyTest.java
rename to library/src/androidTest/java/org/simple/eventbus/test/DefaultMatchPolicyTest.java
index e8d2a16..849eb08 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/DefaultMatchPolicyTest.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/DefaultMatchPolicyTest.java
@@ -24,8 +24,16 @@
package org.simple.eventbus.test;
-import android.test.AndroidTestCase;
+import static junit.framework.TestCase.assertEquals;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import junit.framework.TestCase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.EventType;
import org.simple.eventbus.Subscriber;
@@ -40,17 +48,16 @@
*
* @author mrsimple
*/
-public class DefaultMatchPolicyTest extends AndroidTestCase {
-
- protected void setUp() throws Exception {
- super.setUp();
+@RunWith(AndroidJUnit4.class)
+public class DefaultMatchPolicyTest {
+ @Before
+ public void setUp() throws Exception {
EventBus.getDefault().register(this);
}
- protected void tearDown() throws Exception {
- super.tearDown();
-
+ @After
+ public void tearDown() throws Exception {
EventBus.getDefault().unregister(this);
}
@@ -64,10 +71,11 @@ private void singleObjectParam(Object obj) {
}
+ @Test
public void testFindMatchMethod() {
MatchPolicy policy = new DefaultMatchPolicy();
List types = policy.findMatchEventTypes(new EventType(User.class,
- EventType.DEFAULT_TAG), new User("test"));
+ EventType.DEFAULT_TAG), new User("org/simple/eventbus/test"));
assertEquals(2, types.size());
types.clear();
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/EventBusTest.java b/library/src/androidTest/java/org/simple/eventbus/test/EventBusTest.java
similarity index 88%
rename from Simple_Event_Test/src/org/simple/eventbus/test/EventBusTest.java
rename to library/src/androidTest/java/org/simple/eventbus/test/EventBusTest.java
index 6456fa0..152d389 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/EventBusTest.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/EventBusTest.java
@@ -16,9 +16,15 @@
package org.simple.eventbus.test;
-import android.test.AndroidTestCase;
import android.util.Log;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import junit.framework.TestCase;
+
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.EventType;
import org.simple.eventbus.Subscription;
@@ -36,17 +42,15 @@
/**
* @author mrsimple
*/
-public class EventBusTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class EventBusTest extends TestCase {
EventBus bus = EventBus.getDefault();
Map> mSubcriberMap = bus.getSubscriberMap();
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
super.tearDown();
EventBus.getDefault().clear();
}
@@ -77,6 +81,7 @@ public Collection getEventTypes() {
/**
*
*/
+ @Test
public void testRepeatRegister() {
MockSubcriber mockActivity = new MockSubcriber();
for (int i = 0; i < 10; i++) {
@@ -93,6 +98,7 @@ public void testRepeatRegister() {
/**
*
*/
+ @Test
public void testRepeatRegisterWithTag() {
MockSubcriber mockActivity = new MockSubcriber();
for (int i = 0; i < 10; i++) {
@@ -101,15 +107,13 @@ public void testRepeatRegisterWithTag() {
}
// 类型为Person且tag为"test"的有效注册函数为1个.
- assertEquals(1, getSubscriptions(new EventType(User.class, "test")).size());
+ assertEquals(1, getSubscriptions(new EventType(User.class, "org/simple/eventbus/test")).size());
// 类型为Person且tag为"another"的有效注册函数为1个.
assertEquals(1, getSubscriptions(new EventType(User.class, "another")).size());
}
- /**
- *
- */
+ @Test
public void testSubscribeAndPost() {
MockSubcriber mockActivity = new MockSubcriber();
// 正常注册与发布
@@ -125,14 +129,17 @@ public void testSubscribeAndPost() {
assertEquals(0, getSubscriptions(new EventType(Object.class)).size());
}
+ @Test
public void testRegisterNull() {
bus.register(null);
}
+ @Test
public void testUnRegisterNull() {
bus.unregister(null);
}
+ @Test
public void testStickyEvents() {
assertEquals(0, bus.getStickyEvents().size());
bus.postSticky("hello");
@@ -141,13 +148,13 @@ public void testStickyEvents() {
bus.postSticky("world", tag);
assertEquals(2, bus.getStickyEvents().size());
- bus.removeStickyEvent(String.class);
assertEquals(1, bus.getStickyEvents().size());
bus.removeStickyEvent(String.class, tag);
assertEquals(0, bus.getStickyEvents().size());
}
+ @Test
public void testStickySubscriber() {
StickySubscriber subscriber = new StickySubscriber();
assertEquals(null, subscriber.mStickyName);
@@ -164,20 +171,17 @@ public void testStickySubscriber() {
bus.postSticky("simple");
// 以sticky的形式注册
bus.registerSticky(subscriber);
-
// 接收到数据
- assertEquals("simple", subscriber.mStickyName);
- assertEquals(null, subscriber.mStickyTag);
+ assertEquals("simple", bus.removeStickyEvent(String.class).event);
// post sticky事件, 含有tag, 这里需要注意
- bus.postSticky("simple", "sticky");
- assertEquals("sticky", subscriber.mStickyTag);
-
+ bus.postSticky("simple_v2", "sticky_v2");
+ final EventType eventType = bus.removeStickyEvent(String.class, "sticky_v2");
+ assertEquals("simple_v2", eventType.event);
+ assertEquals("sticky_v2", eventType.tag);
}
- /**
- *
- */
+ @Test
public void testPerformence() {
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) {
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/EventTypeTest.java b/library/src/androidTest/java/org/simple/eventbus/test/EventTypeTest.java
similarity index 90%
rename from Simple_Event_Test/src/org/simple/eventbus/test/EventTypeTest.java
rename to library/src/androidTest/java/org/simple/eventbus/test/EventTypeTest.java
index a851f23..cdefb19 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/EventTypeTest.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/EventTypeTest.java
@@ -16,8 +16,13 @@
package org.simple.eventbus.test;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.EventType;
@@ -27,13 +32,11 @@
/**
* @author mrsimple
*/
+@RunWith(AndroidJUnit4.class)
public class EventTypeTest extends TestCase {
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
super.tearDown();
EventBus.getDefault().clear();
@@ -42,6 +45,7 @@ protected void tearDown() throws Exception {
/**
* 检测EventType作为map的key的唯一性
*/
+ @Test
public void testKeysInMap() {
Map map = new HashMap();
String tag = "default";
@@ -56,6 +60,7 @@ public void testKeysInMap() {
/**
* 检测类型相同,tag不同的EventType的唯一性
*/
+ @Test
public void testDiffKeysInMap() {
Map map = new HashMap();
String tag = "default";
@@ -69,6 +74,7 @@ public void testDiffKeysInMap() {
/**
* 检测类型相同,tag不同的EventType的唯一性
*/
+ @Test
public void testDiffParamKeysInMap() {
Map map = new HashMap();
map.put(new EventType(String.class), "String");
@@ -83,6 +89,7 @@ public void testDiffParamKeysInMap() {
assertEquals(6, map.size());
}
+ @Test
public void testEquals() {
assertEquals(new EventType(String.class, "tag"), new EventType(String.class, "tag"));
assertFalse( new EventType(String.class, "tag").equals(new EventType(String.class, "s_tag")));
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/PrimitiveEventTest.java b/library/src/androidTest/java/org/simple/eventbus/test/PrimitiveEventTest.java
similarity index 85%
rename from Simple_Event_Test/src/org/simple/eventbus/test/PrimitiveEventTest.java
rename to library/src/androidTest/java/org/simple/eventbus/test/PrimitiveEventTest.java
index b05595c..26cb852 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/PrimitiveEventTest.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/PrimitiveEventTest.java
@@ -24,10 +24,17 @@
package org.simple.eventbus.test;
-import android.test.AndroidTestCase;
+import static junit.framework.TestCase.assertEquals;
-public class PrimitiveEventTest extends AndroidTestCase {
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class PrimitiveEventTest {
+
+ @Test
public void testPrimitiveType() {
paramInt(2);
}
@@ -35,13 +42,4 @@ public void testPrimitiveType() {
public void paramInt(Object aParam) {
assertEquals(Integer.class, aParam.getClass());
}
-
- // public void paramInt(int aParam) {
- //
- // }
- //
- // public void paramInt(Integer aParam) {
- //
- // }
-
}
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/SubscriberMethodHunterTest.java b/library/src/androidTest/java/org/simple/eventbus/test/SubscriberMethodHunterTest.java
similarity index 80%
rename from Simple_Event_Test/src/org/simple/eventbus/test/SubscriberMethodHunterTest.java
rename to library/src/androidTest/java/org/simple/eventbus/test/SubscriberMethodHunterTest.java
index 716ebb7..e04aba6 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/SubscriberMethodHunterTest.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/SubscriberMethodHunterTest.java
@@ -24,8 +24,14 @@
package org.simple.eventbus.test;
-import android.test.AndroidTestCase;
+import static junit.framework.TestCase.assertEquals;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.EventType;
import org.simple.eventbus.SubsciberMethodHunter;
@@ -34,29 +40,31 @@
import java.util.List;
-public class SubscriberMethodHunterTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SubscriberMethodHunterTest {
SubsciberMethodHunter mHunter = new SubsciberMethodHunter(EventBus.getDefault()
.getSubscriberMap());
PrimitiveParamObject object = new PrimitiveParamObject();
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
EventBus.getDefault().register(object);
}
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
EventBus.getDefault().unregister(object);
}
+ @Test
public void testFindPrimitiveParamMethod() {
mHunter.findSubcribeMethods(object);
List subscriptions = EventBus.getDefault().getSubscriberMap()
.get(new EventType(Integer.class));
assertEquals(1, subscriptions.size());
- assertEquals(object, subscriptions.get(0).subscriber);
+ assertEquals(object, subscriptions.get(0).subscriber.get());
}
}
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/ThreadModeTest.java b/library/src/androidTest/java/org/simple/eventbus/test/ThreadModeTest.java
similarity index 88%
rename from Simple_Event_Test/src/org/simple/eventbus/test/ThreadModeTest.java
rename to library/src/androidTest/java/org/simple/eventbus/test/ThreadModeTest.java
index 93bfe30..be43097 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/ThreadModeTest.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/ThreadModeTest.java
@@ -24,16 +24,24 @@
package org.simple.eventbus.test;
-import android.test.AndroidTestCase;
+import static junit.framework.TestCase.assertEquals;
+
import android.util.Log;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import org.simple.eventbus.ThreadMode;
import org.simple.eventbus.handler.AsyncEventHandler;
import org.simple.eventbus.test.mock.User;
-public class ThreadModeTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ThreadModeTest {
private static final String MAIN_TAG = "main";
private static final String POST_TAG = "post";
@@ -41,21 +49,21 @@ public class ThreadModeTest extends AndroidTestCase {
Thread uiThread;
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
uiThread = Thread.currentThread();
EventBus.getDefault().register(this);
}
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
EventBus.getDefault().register(this);
EventBus.getDefault().clear();
}
+ @Test
public void testExecuteMainThread() {
EventBus.getDefault().post(new User("main-thread"), MAIN_TAG);
-
waitDispatchEvent();
}
@@ -65,6 +73,7 @@ private void executeOnUIThread(User user) {
// can not test main thread mode
}
+ @Test
public void testExecutePostThread() {
EventBus.getDefault().post(new User("post-thread"), POST_TAG);
@@ -77,6 +86,7 @@ private void executeOnPostThread(User user) {
assertEquals(uiThread, Thread.currentThread());
}
+ @Test
public void testExecuteAsyncThread() {
EventBus.getDefault().post(new User("async-thread"), ASYNC_TAG);
waitDispatchEvent();
@@ -85,7 +95,6 @@ public void testExecuteAsyncThread() {
@Subscriber(tag = ASYNC_TAG, mode = ThreadMode.ASYNC)
private void executeOnAsyncThread(User user) {
assertEquals("async-thread", user.name);
- Log.e(getName(), "### executeOnAsyncThread flag");
assertEquals(AsyncEventHandler.class.getSimpleName(), Thread.currentThread().getName());
}
@@ -98,5 +107,4 @@ private void waitDispatchEvent() {
}
}
}
-
}
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/mock/MockSubcriber.java b/library/src/androidTest/java/org/simple/eventbus/test/mock/MockSubcriber.java
similarity index 97%
rename from Simple_Event_Test/src/org/simple/eventbus/test/mock/MockSubcriber.java
rename to library/src/androidTest/java/org/simple/eventbus/test/mock/MockSubcriber.java
index 000e879..b4fec30 100644
--- a/Simple_Event_Test/src/org/simple/eventbus/test/mock/MockSubcriber.java
+++ b/library/src/androidTest/java/org/simple/eventbus/test/mock/MockSubcriber.java
@@ -54,7 +54,7 @@ void addPerson(User person) {
*
* @param person
*/
- @Subscriber(tag = "test")
+ @Subscriber(tag = "org/simple/eventbus/test")
void methodWithTag(User person) {
}
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/mock/PrimitiveParamObject.java b/library/src/androidTest/java/org/simple/eventbus/test/mock/PrimitiveParamObject.java
similarity index 100%
rename from Simple_Event_Test/src/org/simple/eventbus/test/mock/PrimitiveParamObject.java
rename to library/src/androidTest/java/org/simple/eventbus/test/mock/PrimitiveParamObject.java
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/mock/SingleSubscriber.java b/library/src/androidTest/java/org/simple/eventbus/test/mock/SingleSubscriber.java
similarity index 100%
rename from Simple_Event_Test/src/org/simple/eventbus/test/mock/SingleSubscriber.java
rename to library/src/androidTest/java/org/simple/eventbus/test/mock/SingleSubscriber.java
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/mock/StickySubscriber.java b/library/src/androidTest/java/org/simple/eventbus/test/mock/StickySubscriber.java
similarity index 100%
rename from Simple_Event_Test/src/org/simple/eventbus/test/mock/StickySubscriber.java
rename to library/src/androidTest/java/org/simple/eventbus/test/mock/StickySubscriber.java
diff --git a/Simple_Event_Test/src/org/simple/eventbus/test/mock/User.java b/library/src/androidTest/java/org/simple/eventbus/test/mock/User.java
similarity index 100%
rename from Simple_Event_Test/src/org/simple/eventbus/test/mock/User.java
rename to library/src/androidTest/java/org/simple/eventbus/test/mock/User.java
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a5918e6
--- /dev/null
+++ b/library/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/org/simple/eventbus/EventBus.java b/library/src/main/java/org/simple/eventbus/EventBus.java
similarity index 94%
rename from src/org/simple/eventbus/EventBus.java
rename to library/src/main/java/org/simple/eventbus/EventBus.java
index 851f969..3eec945 100644
--- a/src/org/simple/eventbus/EventBus.java
+++ b/library/src/main/java/org/simple/eventbus/EventBus.java
@@ -86,7 +86,7 @@ public final class EventBus {
* the thread local event queue, every single thread has it's own queue.
*/
ThreadLocal> mLocalEvents = new ThreadLocal>() {
- protected java.util.Queue initialValue() {
+ protected Queue initialValue() {
return new ConcurrentLinkedQueue();
};
};
@@ -155,10 +155,12 @@ public void register(Object subscriber) {
}
/**
- * 以sticky的形式注册,则会在注册成功之后迭代所有的sticky事件
- *
+ * 以sticky的形式注册,则会在注册成功之后迭代所有的sticky事件.
+ *
+ * @deprecated 建议使用 {{@link #getStickyEvents()}} 获取sticky 事件
* @param subscriber
*/
+ @Deprecated
public void registerSticky(Object subscriber) {
this.register(subscriber);
// 处理sticky事件
@@ -226,8 +228,8 @@ public void postSticky(Object event, String tag) {
mStickyEvents.add(eventType);
}
- public void removeStickyEvent(Class> eventClass) {
- removeStickyEvent(eventClass, EventType.DEFAULT_TAG);
+ public EventType removeStickyEvent(Class> eventClass) {
+ return removeStickyEvent(eventClass, EventType.DEFAULT_TAG);
}
/**
@@ -235,21 +237,27 @@ public void removeStickyEvent(Class> eventClass) {
*
* @param type
*/
- public void removeStickyEvent(Class> eventClass, String tag) {
+ public EventType removeStickyEvent(Class> eventClass, String tag) {
Iterator iterator = mStickyEvents.iterator();
while (iterator.hasNext()) {
EventType eventType = iterator.next();
if (eventType.paramClass.equals(eventClass)
&& eventType.tag.equals(tag)) {
iterator.remove();
+ return eventType;
}
}
+ return null;
}
public List getStickyEvents() {
return mStickyEvents;
}
+ public EventType getLastStickyEvent() {
+ return mStickyEvents.size() > 0 ? mStickyEvents.get(mStickyEvents.size() - 1) : null;
+ }
+
/**
* 设置订阅函数匹配策略
*
@@ -361,8 +369,11 @@ private class EventDispatcher {
*/
void dispatchEvents(Object aEvent) {
Queue eventsQueue = mLocalEvents.get();
- while (eventsQueue.size() > 0) {
- deliveryEvent(eventsQueue.poll(), aEvent);
+ if (eventsQueue != null) {
+ EventType eventType;
+ while ((eventType = eventsQueue.poll()) != null) {
+ deliveryEvent(eventType, aEvent);
+ }
}
}
diff --git a/src/org/simple/eventbus/EventType.java b/library/src/main/java/org/simple/eventbus/EventType.java
similarity index 100%
rename from src/org/simple/eventbus/EventType.java
rename to library/src/main/java/org/simple/eventbus/EventType.java
diff --git a/src/org/simple/eventbus/SubsciberMethodHunter.java b/library/src/main/java/org/simple/eventbus/SubsciberMethodHunter.java
similarity index 100%
rename from src/org/simple/eventbus/SubsciberMethodHunter.java
rename to library/src/main/java/org/simple/eventbus/SubsciberMethodHunter.java
diff --git a/src/org/simple/eventbus/Subscriber.java b/library/src/main/java/org/simple/eventbus/Subscriber.java
similarity index 100%
rename from src/org/simple/eventbus/Subscriber.java
rename to library/src/main/java/org/simple/eventbus/Subscriber.java
diff --git a/src/org/simple/eventbus/Subscription.java b/library/src/main/java/org/simple/eventbus/Subscription.java
similarity index 100%
rename from src/org/simple/eventbus/Subscription.java
rename to library/src/main/java/org/simple/eventbus/Subscription.java
diff --git a/src/org/simple/eventbus/TargetMethod.java b/library/src/main/java/org/simple/eventbus/TargetMethod.java
similarity index 100%
rename from src/org/simple/eventbus/TargetMethod.java
rename to library/src/main/java/org/simple/eventbus/TargetMethod.java
diff --git a/src/org/simple/eventbus/ThreadMode.java b/library/src/main/java/org/simple/eventbus/ThreadMode.java
similarity index 100%
rename from src/org/simple/eventbus/ThreadMode.java
rename to library/src/main/java/org/simple/eventbus/ThreadMode.java
diff --git a/src/org/simple/eventbus/handler/AsyncEventHandler.java b/library/src/main/java/org/simple/eventbus/handler/AsyncEventHandler.java
similarity index 100%
rename from src/org/simple/eventbus/handler/AsyncEventHandler.java
rename to library/src/main/java/org/simple/eventbus/handler/AsyncEventHandler.java
diff --git a/src/org/simple/eventbus/handler/DefaultEventHandler.java b/library/src/main/java/org/simple/eventbus/handler/DefaultEventHandler.java
similarity index 100%
rename from src/org/simple/eventbus/handler/DefaultEventHandler.java
rename to library/src/main/java/org/simple/eventbus/handler/DefaultEventHandler.java
diff --git a/src/org/simple/eventbus/handler/EventHandler.java b/library/src/main/java/org/simple/eventbus/handler/EventHandler.java
similarity index 100%
rename from src/org/simple/eventbus/handler/EventHandler.java
rename to library/src/main/java/org/simple/eventbus/handler/EventHandler.java
diff --git a/src/org/simple/eventbus/handler/UIThreadEventHandler.java b/library/src/main/java/org/simple/eventbus/handler/UIThreadEventHandler.java
similarity index 100%
rename from src/org/simple/eventbus/handler/UIThreadEventHandler.java
rename to library/src/main/java/org/simple/eventbus/handler/UIThreadEventHandler.java
diff --git a/src/org/simple/eventbus/matchpolicy/DefaultMatchPolicy.java b/library/src/main/java/org/simple/eventbus/matchpolicy/DefaultMatchPolicy.java
similarity index 99%
rename from src/org/simple/eventbus/matchpolicy/DefaultMatchPolicy.java
rename to library/src/main/java/org/simple/eventbus/matchpolicy/DefaultMatchPolicy.java
index dd01f11..5b70f20 100644
--- a/src/org/simple/eventbus/matchpolicy/DefaultMatchPolicy.java
+++ b/library/src/main/java/org/simple/eventbus/matchpolicy/DefaultMatchPolicy.java
@@ -62,5 +62,4 @@ private void addInterfaces(List eventTypes, Class> eventClass, Stri
}
}
}
-
}
diff --git a/src/org/simple/eventbus/matchpolicy/MatchPolicy.java b/library/src/main/java/org/simple/eventbus/matchpolicy/MatchPolicy.java
similarity index 100%
rename from src/org/simple/eventbus/matchpolicy/MatchPolicy.java
rename to library/src/main/java/org/simple/eventbus/matchpolicy/MatchPolicy.java
diff --git a/src/org/simple/eventbus/matchpolicy/StrictMatchPolicy.java b/library/src/main/java/org/simple/eventbus/matchpolicy/StrictMatchPolicy.java
similarity index 100%
rename from src/org/simple/eventbus/matchpolicy/StrictMatchPolicy.java
rename to library/src/main/java/org/simple/eventbus/matchpolicy/StrictMatchPolicy.java
diff --git a/proguard-project.txt b/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/project.properties b/project.properties
deleted file mode 100644
index 03d0617..0000000
--- a/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-10
-android.library=true
diff --git a/releases/org/simple/eventbus/latest/eventbus-latest.jar b/releases/org/simple/eventbus/latest/eventbus-latest.jar
deleted file mode 100644
index 557722b..0000000
Binary files a/releases/org/simple/eventbus/latest/eventbus-latest.jar and /dev/null differ
diff --git a/releases/org/simple/eventbus/latest/eventbus-latest.jar.md5 b/releases/org/simple/eventbus/latest/eventbus-latest.jar.md5
deleted file mode 100644
index b185024..0000000
--- a/releases/org/simple/eventbus/latest/eventbus-latest.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-0854d280269f974434af1eba56f083dc
\ No newline at end of file
diff --git a/releases/org/simple/eventbus/latest/eventbus-latest.jar.sha1 b/releases/org/simple/eventbus/latest/eventbus-latest.jar.sha1
deleted file mode 100644
index 83a5fba..0000000
--- a/releases/org/simple/eventbus/latest/eventbus-latest.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-00bdfffc41ea8e4dc0b2714844461744b9c8f020
\ No newline at end of file
diff --git a/releases/org/simple/eventbus/latest/eventbus-latest.pom b/releases/org/simple/eventbus/latest/eventbus-latest.pom
deleted file mode 100644
index 1737d03..0000000
--- a/releases/org/simple/eventbus/latest/eventbus-latest.pom
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- 4.0.0
- org.simple
- eventbus
- latest
- POM was created from install:install-file
-
diff --git a/releases/org/simple/eventbus/latest/eventbus-latest.pom.md5 b/releases/org/simple/eventbus/latest/eventbus-latest.pom.md5
deleted file mode 100644
index 7d2b516..0000000
--- a/releases/org/simple/eventbus/latest/eventbus-latest.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-43dc5ec10992728f411e73937cb31f41
\ No newline at end of file
diff --git a/releases/org/simple/eventbus/latest/eventbus-latest.pom.sha1 b/releases/org/simple/eventbus/latest/eventbus-latest.pom.sha1
deleted file mode 100644
index fdaeac7..0000000
--- a/releases/org/simple/eventbus/latest/eventbus-latest.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-8379142b4d066f034841d148da0223013c604dbd
\ No newline at end of file
diff --git a/releases/org/simple/eventbus/maven-metadata-local.xml b/releases/org/simple/eventbus/maven-metadata-local.xml
deleted file mode 100644
index eb13717..0000000
--- a/releases/org/simple/eventbus/maven-metadata-local.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- org.simple
- eventbus
-
- latest
-
- latest
-
- 20150523111841
-
-
diff --git a/releases/org/simple/eventbus/maven-metadata-local.xml.md5 b/releases/org/simple/eventbus/maven-metadata-local.xml.md5
deleted file mode 100644
index af49323..0000000
--- a/releases/org/simple/eventbus/maven-metadata-local.xml.md5
+++ /dev/null
@@ -1 +0,0 @@
-18d2c9d67dbd1fb9502f29f9d8a22ab0
\ No newline at end of file
diff --git a/releases/org/simple/eventbus/maven-metadata-local.xml.sha1 b/releases/org/simple/eventbus/maven-metadata-local.xml.sha1
deleted file mode 100644
index 7b2905b..0000000
--- a/releases/org/simple/eventbus/maven-metadata-local.xml.sha1
+++ /dev/null
@@ -1 +0,0 @@
-035a30eacea66a63ea2f4e33ed3cb9d19d5c34b1
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..86aa499
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,17 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+rootProject.name = "AndroidEventBus"
+include ':app'
+include ':library'