├── .gitignore ├── LICENSE ├── README.md ├── RxAndroidEventsSample.iml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── sample.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── wangjie │ │ └── rxandroideventssample │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── wangjie │ │ └── rxandroideventssample │ │ ├── annotation │ │ └── accept │ │ │ ├── Accept.java │ │ │ ├── AcceptScheduler.java │ │ │ ├── AcceptType.java │ │ │ └── DefaultAcceptConfiguration.java │ │ ├── application │ │ └── MyApplication.java │ │ ├── base │ │ ├── BaseActivity.java │ │ └── BasePresenter.java │ │ ├── events │ │ ├── ActionEvent.java │ │ ├── AddFeedsEvent.java │ │ ├── DeleteFeedsEvent.java │ │ └── FeedItemClickEvent.java │ │ ├── provider │ │ └── model │ │ │ └── Feed.java │ │ ├── rxbus │ │ ├── ObservableWrapper.java │ │ ├── RxBus.java │ │ ├── RxBusAnnotationManager.java │ │ ├── RxBusBak.java │ │ └── RxBusSample.java │ │ └── ui │ │ ├── main │ │ ├── MainActivity.java │ │ └── adapter │ │ │ ├── FeedAdapter.java │ │ │ └── TabAdapter.java │ │ └── tab │ │ ├── TabContainer.java │ │ ├── chat │ │ └── TabChatContainer.java │ │ ├── feed │ │ ├── TabFeedContainer.java │ │ ├── TabFeedPresenter.java │ │ └── TabFeedViewer.java │ │ └── setting │ │ └── TabSettingContainer.java │ └── res │ ├── layout │ ├── activity_main.xml │ ├── feed_rv_item.xml │ ├── tab_chat.xml │ ├── tab_feed.xml │ └── tab_setting.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RxAndroidEventsSample 2 | BusEvents implementation base RxJava/RxAndroid/AndroidInject. 3 | 4 | 博客《基于RxJava、RxAndroid的EventBus实现》:
5 | 6 | 7 | ## Dependencies:
8 | [AndroidBucket](https://github.com/wangjiegulu/AndroidBucket):My base library
9 | [AndroidInject](https://github.com/wangjiegulu/androidInject):My Inject library
10 | [RxJava](https://github.com/ReactiveX/RxJava)
11 | [RxAndroid](https://github.com/ReactiveX/RxAndroid)
12 | [retrolambda](https://github.com/evant/gradle-retrolambda)
13 | 14 | ## How to use with Annotation(recommended) 15 | `It's realy simple to use with annotation` 16 | ### 1. You must be config presents to support annotations(For example: BaseActivity which extends AIAppCompatActivity in the [AndroidInject](https://github.com/wangjiegulu/androidInject) library) 17 | ```java 18 | private RxBusAnnotationManager rxBusAnnotationManager; 19 | @Override 20 | public void parserMethodAnnotations(Method method) throws Exception { 21 | if (method.isAnnotationPresent(Accept.class)) { 22 | if (null == rxBusAnnotationManager) { 23 | rxBusAnnotationManager = new RxBusAnnotationManager(this); 24 | } 25 | rxBusAnnotationManager.parserObservableEventAnnotations(method); 26 | } 27 | } 28 | 29 | @Override 30 | protected void onDestroy() { 31 | super.onDestroy(); 32 | if (null != rxBusAnnotationManager) { 33 | rxBusAnnotationManager.clear(); 34 | } 35 | } 36 | ``` 37 | ### 2. Write a method in your present(eg. your activity), and use an @Accept annotation 38 | ```java 39 | @Accept 40 | public void onPostAccept(Object tag, AddFeedsEvent event) { 41 | // todo: Accept event and process here (in main thread) 42 | } 43 | ``` 44 | or 45 | ```java 46 | @Accept( 47 | acceptScheduler = AcceptScheduler.NEW_THREAD, 48 | value = { 49 | @AcceptType(tag = ActionEvent.CLOSE, clazz = String.class), 50 | @AcceptType(tag = ActionEvent.BACK, clazz = String.class), 51 | @AcceptType(tag = ActionEvent.EDIT, clazz = String.class), 52 | @AcceptType(tag = ActionEvent.REFRESH, clazz = String.class) 53 | } 54 | ) 55 | public void onPostAccept(Object tag, Object actionEvent) { 56 | Logger.d(TAG, "[ActionEvent]onPostAccept action event name: " + actionEvent); 57 | // todo: Accept event and process here (in new thread) 58 | } 59 | ``` 60 | 61 | @Accept: 62 | ``` 63 | acceptScheduler: Perform this method on a specified scheduler; 64 | value[]: AcceptType annotation array that specify the types this method can be accept. 65 | ``` 66 | @AcceptType: 67 | ``` 68 | tag: The tag of the event. 69 | clazz: The Class of the event. 70 | ``` 71 | 72 | ### 3. Post a event any where: 73 | ```java 74 | AddFeedsEvent addFeedsEvent = new AddFeedsEvent(); 75 | // Construct a AddFeedsEvent Object... 76 | RxBus.get().post(addFeedsEvent); 77 | ``` 78 | 79 | ### 4. Specify an Executor or Handler(Optional) 80 | ```java 81 | public class MyApplication extends Application { 82 | private Executor acceptExecutor = Executors.newCachedThreadPool(); 83 | private Handler handler = new Handler(Looper.getMainLooper()); 84 | 85 | @Override 86 | public void onCreate() { 87 | super.onCreate(); 88 | DefaultAcceptConfiguration.getInstance().registerAcceptConfiguration(new DefaultAcceptConfiguration.OnDefaultAcceptConfiguration() { 89 | @Override 90 | public Executor applyAcceptExecutor() { 91 | return acceptExecutor; 92 | } 93 | 94 | @Override 95 | public Handler applyAcceptHandler() { 96 | return handler; 97 | } 98 | }); 99 | } 100 | } 101 | ``` 102 | 103 |


104 | 105 | ## How to use without Annotation(Not recommended) 106 | ### Register an Observer 107 | ```java 108 | Observable addOb = RxBus.get() 109 | .register("addFeedTag", String.class); 110 | 111 | addOb.observeOn(AndroidSchedulers.mainThread()) 112 | .subscribe(s -> { 113 | // todo: Accept event and process here 114 | }); 115 | ``` 116 | ### Post a event any where 117 | ```java 118 | RxBus.get().post("addFeedTag", "hello RxBus!"); 119 | ``` 120 | ### unregister the Observer 121 | ```java 122 | RxBus.get().unregister("addFeedTag", addOb); 123 | ``` 124 | 125 | License 126 | ======= 127 | 128 | Copyright 2015 Wang Jie 129 | 130 | Licensed under the Apache License, Version 2.0 (the "License"); 131 | you may not use this file except in compliance with the License. 132 | You may obtain a copy of the License at 133 | 134 | http://www.apache.org/licenses/LICENSE-2.0 135 | 136 | Unless required by applicable law or agreed to in writing, software 137 | distributed under the License is distributed on an "AS IS" BASIS, 138 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139 | See the License for the specific language governing permissions and 140 | limitations under the License. 141 | -------------------------------------------------------------------------------- /RxAndroidEventsSample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.1.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangjiegulu/RxAndroidEventsSample/f528a665083065d9f5ab2cdbb4ac798beb2d2e9e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:1.1.1' 7 | classpath 'me.tatarka:gradle-retrolambda:3.1.0' 8 | } 9 | } 10 | apply plugin: 'com.android.application' 11 | apply plugin: 'me.tatarka.retrolambda' 12 | 13 | repositories { 14 | jcenter() 15 | } 16 | 17 | android { 18 | compileSdkVersion 22 19 | buildToolsVersion "22.0.1" 20 | 21 | defaultConfig { 22 | applicationId "com.wangjie.rxandroideventssample" 23 | minSdkVersion 9 24 | targetSdkVersion 22 25 | versionCode 1 26 | versionName "1.0" 27 | } 28 | buildTypes { 29 | release { 30 | minifyEnabled false 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | } 33 | } 34 | 35 | 36 | compileOptions { 37 | sourceCompatibility JavaVersion.VERSION_1_8 38 | targetCompatibility JavaVersion.VERSION_1_8 39 | } 40 | } 41 | 42 | dependencies { 43 | compile fileTree(dir: 'libs', include: ['*.jar']) 44 | compile 'com.android.support:support-v4:22.2.0' 45 | compile 'com.android.support:appcompat-v7:22.2.0' 46 | compile 'com.android.support:recyclerview-v7:22.2.0' 47 | 48 | compile 'com.github.wangjiegulu:AndroidBucket:1.0.4' 49 | compile 'com.github.wangjiegulu:AndroidInject:1.0.5' 50 | 51 | compile 'io.reactivex:rxjava:1.0.12' 52 | compile 'io.reactivex:rxandroid:0.24.0' 53 | 54 | retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.0.2' 55 | 56 | compile 'com.android.support:design:22.2.0' 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/wangjie/work/java/android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/sample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/wangjie/rxandroideventssample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/annotation/accept/Accept.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.annotation.accept; 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 | /** 9 | * Author: wangjie 10 | * Email: tiantian.china.2@gmail.com 11 | * Date: 6/11/15. 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target({ElementType.METHOD}) 15 | public @interface Accept { 16 | AcceptScheduler acceptScheduler() default AcceptScheduler.MAIN_THREAD; 17 | 18 | AcceptType[] value() default {}; 19 | } 20 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/annotation/accept/AcceptScheduler.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.annotation.accept; 2 | 3 | import android.os.Handler; 4 | import rx.Scheduler; 5 | 6 | import java.util.concurrent.Executor; 7 | 8 | /** 9 | * Author: wangjie 10 | * Email: tiantian.china.2@gmail.com 11 | * Date: 6/15/15. 12 | */ 13 | public enum AcceptScheduler { 14 | /** 15 | * {@link Scheduler} which will execute actions on the Android UI thread. 16 | */ 17 | MAIN_THREAD, 18 | 19 | /** 20 | * Creates and returns a {@link Scheduler} that creates a new {@link Thread} for each unit of work. 21 | *

22 | * Unhandled errors will be delivered to the scheduler Thread's {@link java.lang.Thread.UncaughtExceptionHandler}. 23 | */ 24 | NEW_THREAD, 25 | 26 | /** 27 | * Creates and returns a {@link Scheduler} intended for IO-bound work. 28 | *

29 | * The implementation is backed by an {@link Executor} thread-pool that will grow as needed. 30 | *

31 | * This can be used for asynchronously performing blocking IO. 32 | *

33 | * Do not perform computational work on this scheduler. Use computation() instead. 34 | *

35 | * Unhandled errors will be delivered to the scheduler Thread's {@link java.lang.Thread.UncaughtExceptionHandler}. 36 | */ 37 | IO, 38 | 39 | /** 40 | * Creates and returns a {@link Scheduler} intended for computational work. 41 | *

42 | * This can be used for event-loops, processing callbacks and other computational work. 43 | *

44 | * Do not perform IO-bound work on this scheduler. Use io() instead. 45 | *

46 | * Unhandled errors will be delivered to the scheduler Thread's {@link java.lang.Thread.UncaughtExceptionHandler}. 47 | */ 48 | COMPUTATION, 49 | 50 | /** 51 | * Creates and returns a {@link Scheduler} that queues work on the current thread to be executed after the 52 | * current work completes. 53 | */ 54 | TRAMPOLINE, 55 | 56 | /** 57 | * Creates and returns a {@link Scheduler} that executes work immediately on the current thread. 58 | */ 59 | IMMEDIATE, 60 | 61 | /** 62 | * Converts an {@link Executor} into a new Scheduler instance. 63 | */ 64 | EXECUTOR, 65 | 66 | /** 67 | * {@link Scheduler} which uses the provided {@link Handler} to execute actions. 68 | */ 69 | HANDLER 70 | 71 | } 72 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/annotation/accept/AcceptType.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.annotation.accept; 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 | /** 9 | * Author: wangjie 10 | * Email: tiantian.china.2@gmail.com 11 | * Date: 6/11/15. 12 | */ 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Target({ElementType.METHOD}) 15 | public @interface AcceptType { 16 | String tag() default ""; 17 | 18 | Class clazz() default Object.class; 19 | } 20 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/annotation/accept/DefaultAcceptConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.annotation.accept; 2 | 3 | import android.os.Handler; 4 | 5 | import java.util.concurrent.Executor; 6 | 7 | /** 8 | * Author: wangjie 9 | * Email: tiantian.china.2@gmail.com 10 | * Date: 6/15/15. 11 | */ 12 | public class DefaultAcceptConfiguration { 13 | public interface OnDefaultAcceptConfiguration { 14 | /** 15 | * 配置默认的Accept Executor 16 | * 17 | * @return 18 | */ 19 | Executor applyAcceptExecutor(); 20 | 21 | /** 22 | * 配置默认的Handler 23 | * 24 | * @return 25 | */ 26 | Handler applyAcceptHandler(); 27 | } 28 | 29 | private static DefaultAcceptConfiguration configuration; 30 | 31 | public static DefaultAcceptConfiguration getInstance() { 32 | if (null == configuration) { 33 | configuration = new DefaultAcceptConfiguration(); 34 | } 35 | return configuration; 36 | } 37 | 38 | private OnDefaultAcceptConfiguration onDefaultAcceptConfiguration; 39 | 40 | public void registerAcceptConfiguration(OnDefaultAcceptConfiguration onDefaultAcceptConfiguration) { 41 | this.onDefaultAcceptConfiguration = onDefaultAcceptConfiguration; 42 | } 43 | 44 | private DefaultAcceptConfiguration() { 45 | } 46 | 47 | /** 48 | * 配置默认的Accept Executor 49 | * 50 | * @return 51 | */ 52 | public Executor applyAcceptExecutor() { 53 | return null == onDefaultAcceptConfiguration ? null : onDefaultAcceptConfiguration.applyAcceptExecutor(); 54 | } 55 | 56 | /** 57 | * 配置默认的Handler 58 | * 59 | * @return 60 | */ 61 | public Handler applyAcceptHandler() { 62 | return null == onDefaultAcceptConfiguration ? null : onDefaultAcceptConfiguration.applyAcceptHandler(); 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/application/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.application; 2 | 3 | import android.app.Application; 4 | import android.os.Handler; 5 | import android.os.Looper; 6 | import com.wangjie.rxandroideventssample.annotation.accept.DefaultAcceptConfiguration; 7 | import com.wangjie.rxandroideventssample.rxbus.RxBus; 8 | 9 | import java.util.concurrent.Executor; 10 | import java.util.concurrent.Executors; 11 | 12 | /** 13 | * Author: wangjie 14 | * Email: tiantian.china.2@gmail.com 15 | * Date: 6/15/15. 16 | */ 17 | public class MyApplication extends Application { 18 | private Executor acceptExecutor = Executors.newCachedThreadPool(); 19 | private Handler handler = new Handler(Looper.getMainLooper()); 20 | 21 | @Override 22 | public void onCreate() { 23 | super.onCreate(); 24 | RxBus.DEBUG = true; 25 | 26 | DefaultAcceptConfiguration.getInstance().registerAcceptConfiguration(new DefaultAcceptConfiguration.OnDefaultAcceptConfiguration() { 27 | @Override 28 | public Executor applyAcceptExecutor() { 29 | return acceptExecutor; 30 | } 31 | 32 | @Override 33 | public Handler applyAcceptHandler() { 34 | return handler; 35 | } 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.base; 2 | 3 | import com.wangjie.androidinject.annotation.present.AIAppCompatActivity; 4 | import com.wangjie.rxandroideventssample.annotation.accept.Accept; 5 | import com.wangjie.rxandroideventssample.rxbus.RxBusAnnotationManager; 6 | import com.wangjie.rxandroideventssample.rxbus.RxBusSample; 7 | 8 | import java.lang.reflect.Method; 9 | 10 | /** 11 | * Author: wangjie 12 | * Email: tiantian.china.2@gmail.com 13 | * Date: 6/10/15. 14 | */ 15 | public class BaseActivity extends AIAppCompatActivity implements RxBusSample{ 16 | 17 | private RxBusAnnotationManager rxBusAnnotationManager; 18 | 19 | @Override 20 | public void parserMethodAnnotations(Method method) throws Exception { 21 | if (method.isAnnotationPresent(Accept.class)) { 22 | if (null == rxBusAnnotationManager) { 23 | rxBusAnnotationManager = new RxBusAnnotationManager(this); 24 | } 25 | rxBusAnnotationManager.parserObservableEventAnnotations(method); 26 | } 27 | } 28 | 29 | 30 | @Override 31 | protected void onDestroy() { 32 | super.onDestroy(); 33 | if (null != rxBusAnnotationManager) { 34 | rxBusAnnotationManager.clear(); 35 | } 36 | } 37 | 38 | @Override 39 | public void onPostAccept(Object tag, Object event) { 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.base; 2 | 3 | import com.wangjie.androidbucket.log.Logger; 4 | import com.wangjie.androidbucket.mvp.ABActivityViewer; 5 | import com.wangjie.androidbucket.mvp.ABBasePresenter; 6 | import com.wangjie.androidbucket.mvp.ABInteractor; 7 | import rx.Subscription; 8 | 9 | import java.util.HashSet; 10 | import java.util.Iterator; 11 | import java.util.Set; 12 | 13 | /** 14 | * Author: wangjie 15 | * Email: tiantian.china.2@gmail.com 16 | * Date: 6/10/15. 17 | */ 18 | public class BasePresenter extends ABBasePresenter { 19 | private static final String TAG = BasePresenter.class.getSimpleName(); 20 | 21 | private Set subscriptions = new HashSet<>(); 22 | 23 | @Override 24 | public void closeAllTask() { 25 | super.closeAllTask(); 26 | synchronized (this) { 27 | Iterator iter = this.subscriptions.iterator(); 28 | while (iter.hasNext()) { 29 | Subscription subscription = (Subscription) iter.next(); 30 | Logger.i(TAG, "closeAllTask[subscriptions]: " + subscription); 31 | if (null != subscription && !subscription.isUnsubscribed()) { 32 | subscription.unsubscribe(); 33 | } 34 | iter.remove(); 35 | } 36 | } 37 | } 38 | 39 | public void goSubscription(Subscription subscription) { 40 | synchronized (this) { 41 | this.subscriptions.add(subscription); 42 | } 43 | } 44 | 45 | public void removeSubscription(Subscription subscription) { 46 | synchronized (this) { 47 | Logger.i(TAG, "removeSubscription: " + subscription); 48 | this.subscriptions.remove(subscription); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/events/ActionEvent.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.events; 2 | 3 | /** 4 | * Author: wangjie 5 | * Email: tiantian.china.2@gmail.com 6 | * Date: 6/15/15. 7 | */ 8 | public class ActionEvent { 9 | public static final String REFRESH = "REFRESH"; 10 | public static final String BACK = "BACK"; 11 | public static final String CLOSE = "CLOSE"; 12 | public static final String EDIT = "EDIT"; 13 | } 14 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/events/AddFeedsEvent.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.events; 2 | 3 | import com.wangjie.rxandroideventssample.provider.model.Feed; 4 | 5 | import java.io.Serializable; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Author: wangjie 11 | * Email: tiantian.china.2@gmail.com 12 | * Date: 6/15/15. 13 | */ 14 | public class AddFeedsEvent implements Serializable{ 15 | private String name = "addFeeds"; 16 | private List feeds = new ArrayList<>(); 17 | 18 | public List getFeeds() { 19 | return feeds; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/events/DeleteFeedsEvent.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.events; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Author: wangjie 7 | * Email: tiantian.china.2@gmail.com 8 | * Date: 6/15/15. 9 | */ 10 | public class DeleteFeedsEvent implements Serializable { 11 | private String name = "deleteFeeds"; 12 | private int deleteIndex; 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | 18 | public int getDeleteIndex() { 19 | return deleteIndex; 20 | } 21 | 22 | public DeleteFeedsEvent setDeleteIndex(int deleteIndex) { 23 | this.deleteIndex = deleteIndex; 24 | return this; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/events/FeedItemClickEvent.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.events; 2 | 3 | import com.wangjie.rxandroideventssample.provider.model.Feed; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Author: wangjie 9 | * Email: tiantian.china.2@gmail.com 10 | * Date: 6/15/15. 11 | */ 12 | public class FeedItemClickEvent implements Serializable { 13 | private String name = "ItemClickEvent"; 14 | private int position; 15 | private Feed feed; 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public int getPosition() { 22 | return position; 23 | } 24 | 25 | public FeedItemClickEvent setPosition(int position) { 26 | this.position = position; 27 | return this; 28 | } 29 | 30 | public Feed getFeed() { 31 | return feed; 32 | } 33 | 34 | public FeedItemClickEvent setFeed(Feed feed) { 35 | this.feed = feed; 36 | return this; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "FeedItemClickEvent{" + 42 | "name='" + name + '\'' + 43 | ", position=" + position + 44 | ", feed=" + feed + 45 | '}'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/provider/model/Feed.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.provider.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Author: wangjie 7 | * Email: tiantian.china.2@gmail.com 8 | * Date: 6/10/15. 9 | */ 10 | public class Feed implements Serializable{ 11 | private Long feedId; 12 | private String title; 13 | private String content; 14 | private Long created; 15 | 16 | public Long getFeedId() { 17 | return feedId; 18 | } 19 | 20 | public void setFeedId(Long feedId) { 21 | this.feedId = feedId; 22 | } 23 | 24 | public String getTitle() { 25 | return title; 26 | } 27 | 28 | public void setTitle(String title) { 29 | this.title = title; 30 | } 31 | 32 | public String getContent() { 33 | return content; 34 | } 35 | 36 | public void setContent(String content) { 37 | this.content = content; 38 | } 39 | 40 | public Long getCreated() { 41 | return created; 42 | } 43 | 44 | public void setCreated(Long created) { 45 | this.created = created; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/rxbus/ObservableWrapper.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.rxbus; 2 | 3 | import rx.Observable; 4 | 5 | /** 6 | * Author: wangjie 7 | * Email: tiantian.china.2@gmail.com 8 | * Date: 6/11/15. 9 | */ 10 | public class ObservableWrapper { 11 | private Observable observable; 12 | private Object tag; 13 | 14 | public ObservableWrapper(Object tag, Observable observable) { 15 | this.tag = tag; 16 | this.observable = observable; 17 | } 18 | 19 | public Observable getObservable() { 20 | return observable; 21 | } 22 | 23 | public void setObservable(Observable observable) { 24 | this.observable = observable; 25 | } 26 | 27 | public Object getTag() { 28 | return tag; 29 | } 30 | 31 | public void setTag(Object tag) { 32 | this.tag = tag; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/rxbus/RxBus.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.rxbus; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.util.Log; 5 | import com.wangjie.androidbucket.utils.ABTextUtil; 6 | import rx.Observable; 7 | import rx.subjects.PublishSubject; 8 | import rx.subjects.Subject; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.concurrent.ConcurrentHashMap; 13 | 14 | /** 15 | * Author: wangjie 16 | * Email: tiantian.china.2@gmail.com 17 | * Date: 6/11/15. 18 | */ 19 | public class RxBus { 20 | private static final String TAG = RxBus.class.getSimpleName(); 21 | private static RxBus instance; 22 | public static boolean DEBUG = false; 23 | 24 | public static synchronized RxBus get() { 25 | if (null == instance) { 26 | instance = new RxBus(); 27 | } 28 | return instance; 29 | } 30 | 31 | private RxBus() { 32 | } 33 | 34 | private ConcurrentHashMap> subjectMapper = new ConcurrentHashMap<>(); 35 | 36 | @SuppressWarnings("unchecked") 37 | public Observable register(@NonNull Object tag, @NonNull Class clazz) { 38 | List subjectList = subjectMapper.get(tag); 39 | if (null == subjectList) { 40 | subjectList = new ArrayList<>(); 41 | subjectMapper.put(tag, subjectList); 42 | } 43 | 44 | Subject subject; 45 | subjectList.add(subject = PublishSubject.create()); 46 | if (DEBUG) Log.d(TAG, "[register]subjectMapper: " + subjectMapper); 47 | return subject; 48 | } 49 | 50 | public void unregister(@NonNull Object tag, @NonNull Observable observable) { 51 | List subjects = subjectMapper.get(tag); 52 | if (null != subjects) { 53 | subjects.remove((Subject) observable); 54 | if (ABTextUtil.isEmpty(subjects)) { 55 | subjectMapper.remove(tag); 56 | } 57 | } 58 | 59 | if (DEBUG) Log.d(TAG, "[unregister]subjectMapper: " + subjectMapper); 60 | } 61 | 62 | public void post(@NonNull Object content) { 63 | post(content.getClass().getName(), content); 64 | } 65 | 66 | @SuppressWarnings("unchecked") 67 | public void post(@NonNull Object tag, @NonNull Object content) { 68 | List subjectList = subjectMapper.get(tag); 69 | 70 | if (!ABTextUtil.isEmpty(subjectList)) { 71 | for (Subject subject : subjectList) { 72 | subject.onNext(content); 73 | } 74 | } 75 | if (DEBUG) Log.d(TAG, "[send]subjectMapper: " + subjectMapper); 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/rxbus/RxBusAnnotationManager.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.rxbus; 2 | 3 | import android.os.Handler; 4 | import com.wangjie.androidbucket.log.Logger; 5 | import com.wangjie.androidbucket.utils.ABTextUtil; 6 | import com.wangjie.rxandroideventssample.annotation.accept.Accept; 7 | import com.wangjie.rxandroideventssample.annotation.accept.AcceptScheduler; 8 | import com.wangjie.rxandroideventssample.annotation.accept.AcceptType; 9 | import com.wangjie.rxandroideventssample.annotation.accept.DefaultAcceptConfiguration; 10 | import rx.Observable; 11 | import rx.android.schedulers.AndroidSchedulers; 12 | import rx.schedulers.Schedulers; 13 | 14 | import java.lang.reflect.Method; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | import java.util.concurrent.Executor; 18 | 19 | /** 20 | * Author: wangjie 21 | * Email: tiantian.china.2@gmail.com 22 | * Date: 6/11/15. 23 | */ 24 | public class RxBusAnnotationManager { 25 | private static final String TAG = RxBusAnnotationManager.class.getName(); 26 | private Object object; 27 | 28 | public RxBusAnnotationManager(Object object) { 29 | this.object = object; 30 | } 31 | 32 | private List registeredObservable; 33 | 34 | public void parserObservableEventAnnotations(Method method) throws Exception { 35 | if (null == method || !method.isAnnotationPresent(Accept.class)) { 36 | return; 37 | } 38 | Class[] params = method.getParameterTypes(); 39 | // 参数必须是两个,第1个必须是Object类型的tag 40 | if (null == params || 2 != params.length || !Object.class.isAssignableFrom(params[0])) { 41 | throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, T object)"); 42 | } 43 | 44 | Accept accept = method.getAnnotation(Accept.class); 45 | AcceptType[] acceptTypes = accept.value(); 46 | 47 | // 默认clazz参数类型 48 | Class targetClazz = params[1]; 49 | // 默认clazz参数类型的全类名 50 | String targetTag = targetClazz.getName(); 51 | Class specClazz; 52 | String specTag; 53 | int acceptTypeLength = null == acceptTypes ? 0 : acceptTypes.length; 54 | switch (acceptTypeLength) { 55 | case 0: // 如果acceptType是空,则说明具体的类型是params[1],所以params[1]不能为Object类型 56 | if (Object.class.equals(targetClazz)) { 57 | throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, T object)"); 58 | } 59 | registerObservable(method, targetTag, targetClazz, accept.acceptScheduler()); 60 | break; 61 | case 1: // 如果只有一个,如果acceptType中tag不为空,则使用 62 | // 默认clazz参数类型,acceptType中指定clazz优先 63 | specClazz = acceptTypes[0].clazz(); 64 | if (!Object.class.equals(specClazz)) { 65 | targetClazz = specClazz; 66 | } 67 | if (Object.class.equals(targetClazz)) { 68 | throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, T object) OR clazz of @AcceptType"); 69 | } 70 | targetTag = targetClazz.getName(); 71 | // 默认tag参数类型的全类名,acceptType中指定tag优先 72 | specTag = acceptTypes[0].tag(); 73 | if (!ABTextUtil.isEmpty(specTag)) { 74 | targetTag = specTag; 75 | } 76 | registerObservable(method, targetTag, targetClazz, accept.acceptScheduler()); 77 | break; 78 | default: // 如果有多个,则params[1]必须是Object 79 | if (!Object.class.equals(targetClazz)) { 80 | throw new Exception("the method[" + method.getName() + "] must defined xxx(Object tag, Object object)"); 81 | } 82 | for (AcceptType acceptType : acceptTypes) { 83 | specClazz = acceptType.clazz(); 84 | specTag = acceptType.tag(); 85 | // 默认tag参数类型的全名,acceptType中指定tag优先 86 | registerObservable(method, ABTextUtil.isEmpty(specTag) ? specClazz.getName() : specTag, specClazz, accept.acceptScheduler()); 87 | } 88 | break; 89 | } 90 | 91 | 92 | } 93 | 94 | 95 | private void ensureRegisteredObservable() { 96 | if (null == registeredObservable) { 97 | registeredObservable = new ArrayList<>(); 98 | } 99 | } 100 | 101 | private void registerObservable(Method method, String tag, Class clazz, AcceptScheduler acceptScheduler) { 102 | if (null == tag || null == clazz) { 103 | return; 104 | } 105 | ensureRegisteredObservable(); 106 | Observable observable = RxBus.get().register(tag, clazz); 107 | registeredObservable.add(new ObservableWrapper(tag, observable)); 108 | 109 | Observable schedulerObservable; 110 | switch (acceptScheduler) { 111 | case NEW_THREAD: 112 | schedulerObservable = observable.observeOn(Schedulers.newThread()); 113 | break; 114 | case IO: 115 | schedulerObservable = observable.observeOn(Schedulers.io()); 116 | break; 117 | case IMMEDIATE: 118 | schedulerObservable = observable.observeOn(Schedulers.immediate()); 119 | break; 120 | case COMPUTATION: 121 | schedulerObservable = observable.observeOn(Schedulers.computation()); 122 | break; 123 | case TRAMPOLINE: 124 | schedulerObservable = observable.observeOn(Schedulers.trampoline()); 125 | break; 126 | case EXECUTOR: 127 | Executor executor = DefaultAcceptConfiguration.getInstance().applyAcceptExecutor(); 128 | if (null == executor) { 129 | throw new RuntimeException("DefaultAcceptConfiguration applyAcceptExecutor() return null, please register OnDefaultAcceptConfiguration in Application"); 130 | } 131 | schedulerObservable = observable.observeOn(Schedulers.from(executor)); 132 | break; 133 | case HANDLER: 134 | Handler handler = DefaultAcceptConfiguration.getInstance().applyAcceptHandler(); 135 | if (null == handler) { 136 | throw new RuntimeException("DefaultAcceptConfiguration applyAcceptHandler() return null, please register OnDefaultAcceptConfiguration in Application"); 137 | } 138 | schedulerObservable = observable.observeOn(AndroidSchedulers.handlerThread(handler)); 139 | break; 140 | default: // MAIN_THREAD default 141 | schedulerObservable = observable.observeOn(AndroidSchedulers.mainThread()); 142 | break; 143 | } 144 | 145 | schedulerObservable.subscribe(o -> { 146 | try { 147 | method.invoke(object, tag, o); 148 | } catch (Exception e) { 149 | Logger.e(TAG, e); 150 | } 151 | }); 152 | 153 | } 154 | 155 | public void clear() { 156 | if (!ABTextUtil.isEmpty(registeredObservable)) { 157 | for (ObservableWrapper observableWrapper : registeredObservable) { 158 | RxBus.get().unregister(observableWrapper.getTag(), observableWrapper.getObservable()); 159 | } 160 | } 161 | } 162 | 163 | } 164 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/rxbus/RxBusBak.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.rxbus; 2 | 3 | import android.util.Log; 4 | import rx.Observable; 5 | import rx.subjects.PublishSubject; 6 | import rx.subjects.Subject; 7 | 8 | import java.util.HashMap; 9 | 10 | /** 11 | * Author: wangjie 12 | * Email: tiantian.china.2@gmail.com 13 | * Date: 6/11/15. 14 | */ 15 | public class RxBusBak { 16 | private static final String TAG = RxBusBak.class.getSimpleName(); 17 | private static RxBusBak instance; 18 | private static final boolean DEBUG = true; 19 | 20 | public static synchronized RxBusBak getInstance() { 21 | if (null == instance) { 22 | instance = new RxBusBak(); 23 | } 24 | return instance; 25 | } 26 | 27 | private RxBusBak() { 28 | } 29 | 30 | private HashMap subjectMapper = new HashMap<>(); 31 | 32 | @SuppressWarnings("unchecked") 33 | public Observable register(Object tag, Class clazz) { 34 | Subject subject = findSubject(tag); 35 | if (null == subject) { 36 | subject = PublishSubject.create(); 37 | synchronized (this) { 38 | subjectMapper.put(tag, subject); 39 | } 40 | } 41 | if (DEBUG) Log.d(TAG, "[register]subjectMapper: " + subjectMapper); 42 | return subject; 43 | } 44 | 45 | public void unregister(Object tag) { 46 | synchronized (this) { 47 | subjectMapper.remove(tag); 48 | } 49 | if (DEBUG) Log.d(TAG, "[unregister]subjectMapper: " + subjectMapper); 50 | } 51 | 52 | @SuppressWarnings("unchecked") 53 | public void send(Object tag, Object content) { 54 | Subject subject = findSubject(tag); 55 | if (null != subject) { 56 | subject.onNext(content); 57 | } 58 | if (DEBUG) Log.d(TAG, "[send]subjectMapper: " + subjectMapper); 59 | } 60 | 61 | @SuppressWarnings("unchecked") 62 | public Observable toObservable(Object tag, Class clazz) { 63 | return findSubject(tag); 64 | } 65 | 66 | private Subject findSubject(Object tag) { 67 | Subject subject; 68 | synchronized (this) { 69 | subject = subjectMapper.get(tag); 70 | } 71 | return subject; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/rxbus/RxBusSample.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.rxbus; 2 | 3 | /** 4 | * Author: wangjie 5 | * Email: tiantian.china.2@gmail.com 6 | * Date: 6/11/15. 7 | */ 8 | public interface RxBusSample { 9 | void onPostAccept(Object tag, Object event); 10 | } 11 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/main/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.main; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.design.widget.TabLayout; 6 | import android.support.v4.view.ViewPager; 7 | import android.support.v7.widget.Toolbar; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import com.wangjie.androidbucket.log.Logger; 11 | import com.wangjie.androidinject.annotation.annotations.base.AILayout; 12 | import com.wangjie.androidinject.annotation.annotations.base.AIView; 13 | import com.wangjie.rxandroideventssample.R; 14 | import com.wangjie.rxandroideventssample.annotation.accept.Accept; 15 | import com.wangjie.rxandroideventssample.base.BaseActivity; 16 | import com.wangjie.rxandroideventssample.events.ActionEvent; 17 | import com.wangjie.rxandroideventssample.events.AddFeedsEvent; 18 | import com.wangjie.rxandroideventssample.events.DeleteFeedsEvent; 19 | import com.wangjie.rxandroideventssample.events.FeedItemClickEvent; 20 | import com.wangjie.rxandroideventssample.provider.model.Feed; 21 | import com.wangjie.rxandroideventssample.rxbus.RxBus; 22 | import com.wangjie.rxandroideventssample.ui.main.adapter.TabAdapter; 23 | import com.wangjie.rxandroideventssample.ui.tab.TabContainer; 24 | import com.wangjie.rxandroideventssample.ui.tab.chat.TabChatContainer; 25 | import com.wangjie.rxandroideventssample.ui.tab.feed.TabFeedContainer; 26 | import com.wangjie.rxandroideventssample.ui.tab.setting.TabSettingContainer; 27 | 28 | import java.util.List; 29 | import java.util.Random; 30 | 31 | @AILayout(R.layout.activity_main) 32 | public class MainActivity extends BaseActivity { 33 | private static final String TAG = MainActivity.class.getName(); 34 | @AIView(R.id.activity_main_tb) 35 | private Toolbar toolbar; 36 | @AIView(R.id.activity_main_tl) 37 | private TabLayout tabLayout; 38 | @AIView(R.id.activity_main_vp) 39 | private ViewPager viewPager; 40 | 41 | private TabAdapter tabAdapter; 42 | 43 | @Override 44 | protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | 47 | initToolbar(); 48 | 49 | initViews(); 50 | 51 | } 52 | 53 | private void initToolbar() { 54 | toolbar.setTitle("Hello Test"); 55 | setSupportActionBar(toolbar); 56 | } 57 | 58 | private void initViews() { 59 | tabLayout.addTab(tabLayout.newTab().setText("feed")); 60 | tabLayout.addTab(tabLayout.newTab().setText("chat")); 61 | tabLayout.addTab(tabLayout.newTab().setText("setting")); 62 | tabAdapter = new TabAdapter(); 63 | List list = tabAdapter.getList(); 64 | Context context = getContext(); 65 | list.add(new TabFeedContainer(context)); 66 | list.add(new TabChatContainer(context)); 67 | list.add(new TabSettingContainer(context)); 68 | 69 | viewPager.setAdapter(tabAdapter); 70 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 71 | int state = ViewPager.SCROLL_STATE_DRAGGING; 72 | 73 | @Override 74 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 75 | tabLayout.setScrollPosition(position, positionOffset, ViewPager.SCROLL_STATE_DRAGGING == state); 76 | } 77 | 78 | @Override 79 | public void onPageSelected(int position) { 80 | 81 | } 82 | 83 | @Override 84 | public void onPageScrollStateChanged(int state) { 85 | this.state = state; 86 | } 87 | }); 88 | viewPager.setOffscreenPageLimit(2); 89 | tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { 90 | @Override 91 | public void onTabSelected(TabLayout.Tab tab) { 92 | viewPager.setCurrentItem(tab.getPosition()); 93 | } 94 | 95 | @Override 96 | public void onTabUnselected(TabLayout.Tab tab) { 97 | 98 | } 99 | 100 | @Override 101 | public void onTabReselected(TabLayout.Tab tab) { 102 | 103 | } 104 | }); 105 | } 106 | 107 | 108 | @Override 109 | public boolean onCreateOptionsMenu(Menu menu) { 110 | // Inflate the menu; this adds items to the action bar if it is present. 111 | getMenuInflater().inflate(R.menu.menu_main, menu); 112 | return true; 113 | } 114 | 115 | private Random random = new Random(); 116 | private static final int ONE_HOUR = 1000 * 60 * 60; 117 | 118 | @Override 119 | public boolean onOptionsItemSelected(MenuItem item) { 120 | // Handle action bar item clicks here. The action bar will 121 | // automatically handle clicks on the Home/Up button, so long 122 | // as you specify a parent activity in AndroidManifest.xml. 123 | switch (item.getItemId()) { 124 | case R.id.menu_main_add_feed: 125 | AddFeedsEvent addFeedsEvent = new AddFeedsEvent(); 126 | Feed feed = new Feed(); 127 | long currMillis = System.currentTimeMillis(); 128 | feed.setTitle("rxTitle_" + currMillis); 129 | feed.setContent("rxContent_" + currMillis); 130 | feed.setCreated(System.currentTimeMillis() - (random.nextInt(ONE_HOUR + 10) + ONE_HOUR)); 131 | addFeedsEvent.getFeeds().add(feed); 132 | 133 | RxBus.get().post(addFeedsEvent); 134 | // RxBus.getInstance().send(String.class.getName(), "hello aaa"); 135 | break; 136 | case R.id.menu_main_delete_feed: 137 | DeleteFeedsEvent deleteFeedsEvent = new DeleteFeedsEvent(); 138 | deleteFeedsEvent.setDeleteIndex(0); 139 | RxBus.get().post(deleteFeedsEvent); 140 | // RxBus.getInstance().send(String.class.getName(), "hello bbb"); 141 | break; 142 | case R.id.menu_main_action_event_refresh: 143 | RxBus.get().post(ActionEvent.REFRESH, ActionEvent.REFRESH); 144 | break; 145 | case R.id.menu_main_action_event_close: 146 | RxBus.get().post(ActionEvent.CLOSE, ActionEvent.CLOSE); 147 | break; 148 | case R.id.menu_main_action_event_edit: 149 | RxBus.get().post(ActionEvent.EDIT, ActionEvent.EDIT); 150 | break; 151 | 152 | default: 153 | break; 154 | } 155 | return super.onOptionsItemSelected(item); 156 | } 157 | 158 | 159 | @Accept 160 | public void onPostAccept(Object tag, FeedItemClickEvent event) { 161 | Logger.d(TAG, "onPostAccept event: " + event); 162 | Feed feed = event.getFeed(); 163 | showToastMessage("main_" + feed.getTitle() + "_" + event.getPosition()); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/main/adapter/FeedAdapter.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.main.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.TextView; 7 | import com.wangjie.androidbucket.support.recyclerview.adapter.ABRecyclerViewAdapter; 8 | import com.wangjie.androidbucket.support.recyclerview.adapter.ABRecyclerViewHolder; 9 | import com.wangjie.androidbucket.utils.ABTimeUtil; 10 | import com.wangjie.androidbucket.utils.ABViewUtil; 11 | import com.wangjie.androidbucket.utils.imageprocess.ABShape; 12 | import com.wangjie.rxandroideventssample.R; 13 | import com.wangjie.rxandroideventssample.provider.model.Feed; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * Author: wangjie 20 | * Email: tiantian.china.2@gmail.com 21 | * Date: 6/10/15. 22 | */ 23 | public class FeedAdapter extends ABRecyclerViewAdapter { 24 | public interface OnFeedAdapterListener { 25 | void onFeedItemClick(int position, Feed feed); 26 | } 27 | 28 | private OnFeedAdapterListener onFeedAdapterListener; 29 | 30 | public void setOnFeedAdapterListener(OnFeedAdapterListener onFeedAdapterListener) { 31 | this.onFeedAdapterListener = onFeedAdapterListener; 32 | } 33 | 34 | private Context context; 35 | 36 | public FeedAdapter(Context context) { 37 | this.context = context; 38 | } 39 | 40 | private List list = new ArrayList<>(); 41 | 42 | public List getList() { 43 | return list; 44 | } 45 | 46 | public void setList(List list) { 47 | this.list = list; 48 | } 49 | 50 | @Override 51 | public ABRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 52 | View view = View.inflate(context, R.layout.feed_rv_item, null); 53 | ABRecyclerViewHolder holder = new ABRecyclerViewHolder(view); 54 | View rootView = holder.obtainView(R.id.feed_rv_item_root_view); 55 | ABViewUtil.setBackgroundDrawable(rootView, ABShape.selectorClickColorCornerSimple(0xffffffff, 0xffefefef, 0)); 56 | ViewGroup.LayoutParams lp = view.getLayoutParams(); 57 | if(null == lp){ 58 | lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 59 | } 60 | lp.width = ViewGroup.LayoutParams.MATCH_PARENT; 61 | lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; 62 | view.setLayoutParams(lp); 63 | 64 | rootView.setOnClickListener(view1 -> { 65 | if (null != onFeedAdapterListener) { 66 | int position = holder.getAdapterPosition(); 67 | onFeedAdapterListener.onFeedItemClick(position, list.get(position)); 68 | } 69 | }); 70 | return holder; 71 | } 72 | 73 | @Override 74 | public void onBindViewHolder(ABRecyclerViewHolder holder, int position) { 75 | Feed feed = list.get(position); 76 | holder.obtainView(R.id.feed_rv_item_title_tv, TextView.class).setText(feed.getTitle()); 77 | holder.obtainView(R.id.feed_rv_item_content_tv, TextView.class).setText(feed.getContent()); 78 | holder.obtainView(R.id.feed_rv_item_date_tv, TextView.class).setText(ABTimeUtil.millisToLifeString2(feed.getCreated())); 79 | } 80 | 81 | @Override 82 | public int getItemCount() { 83 | return list.size(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/main/adapter/TabAdapter.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.main.adapter; 2 | 3 | import android.support.v4.view.PagerAdapter; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import com.wangjie.rxandroideventssample.ui.tab.TabContainer; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * Author: wangjie 13 | * Email: tiantian.china.2@gmail.com 14 | * Date: 6/10/15. 15 | */ 16 | public class TabAdapter extends PagerAdapter { 17 | private List list = new ArrayList<>(); 18 | 19 | public List getList() { 20 | return list; 21 | } 22 | 23 | @Override 24 | public int getCount() { 25 | return list.size(); 26 | } 27 | 28 | @Override 29 | public boolean isViewFromObject(View view, Object object) { 30 | return object == view; 31 | } 32 | 33 | @Override 34 | public Object instantiateItem(ViewGroup container, int position) { 35 | TabContainer tabContainer = list.get(position); 36 | if (null == tabContainer.getParent()) { 37 | container.addView(tabContainer); 38 | } 39 | return tabContainer; 40 | } 41 | 42 | @Override 43 | public void destroyItem(ViewGroup container, int position, Object object) { 44 | container.removeView((View) object); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/tab/TabContainer.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.tab; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.os.Build; 6 | import android.support.annotation.NonNull; 7 | import android.support.v7.app.AlertDialog; 8 | import android.util.AttributeSet; 9 | import android.util.Log; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.AdapterView; 13 | import android.widget.CompoundButton; 14 | import android.widget.FrameLayout; 15 | import android.widget.Toast; 16 | import com.wangjie.androidbucket.mvp.ABActivityViewer; 17 | import com.wangjie.androidbucket.mvp.ABBasePresenter; 18 | import com.wangjie.androidinject.annotation.core.base.AnnotationManager; 19 | import com.wangjie.androidinject.annotation.present.AIPresent; 20 | import com.wangjie.androidinject.annotation.present.common.CallbackSample; 21 | import com.wangjie.rxandroideventssample.annotation.accept.Accept; 22 | import com.wangjie.rxandroideventssample.rxbus.RxBusAnnotationManager; 23 | import com.wangjie.rxandroideventssample.rxbus.RxBusSample; 24 | 25 | import java.lang.reflect.Field; 26 | import java.lang.reflect.Method; 27 | 28 | /** 29 | * Author: wangjie 30 | * Email: tiantian.china.2@gmail.com 31 | * Date: 6/10/15. 32 | */ 33 | public class TabContainer extends FrameLayout implements AIPresent, CallbackSample, ABActivityViewer, RxBusSample { 34 | private static final String TAG = TabContainer.class.getSimpleName(); 35 | private RxBusAnnotationManager rxBusAnnotationManager; 36 | 37 | private ABBasePresenter presenter; 38 | 39 | public TabContainer(Context context) { 40 | super(context); 41 | init(); 42 | } 43 | 44 | private TabContainer(Context context, AttributeSet attrs) { 45 | super(context, attrs); 46 | init(); 47 | } 48 | 49 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 50 | private TabContainer(Context context, AttributeSet attrs, int defStyleAttr) { 51 | super(context, attrs, defStyleAttr); 52 | init(); 53 | } 54 | 55 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 56 | private TabContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 57 | super(context, attrs, defStyleAttr, defStyleRes); 58 | init(); 59 | } 60 | 61 | private void init() { 62 | 63 | } 64 | 65 | private View rootView; 66 | 67 | @Override 68 | protected void onAttachedToWindow() { 69 | super.onAttachedToWindow(); 70 | Log.d(TAG, "[" + this.getClass().getSimpleName() + "]onAttachedToWindow"); 71 | long start = System.currentTimeMillis(); 72 | new AnnotationManager(this).initAnnotations(); 73 | Log.d(TAG, "[" + this.getClass().getSimpleName() + "]onAttachedToWindow supper(parser annotations) takes: " + (System.currentTimeMillis() - start) + "ms"); 74 | } 75 | 76 | @Override 77 | protected void onDetachedFromWindow() { 78 | super.onDetachedFromWindow(); 79 | Log.d(TAG, "[" + this.getClass().getSimpleName() + "]onDetachedFromWindow"); 80 | closeAllTask(); 81 | 82 | if (null != rxBusAnnotationManager) { 83 | rxBusAnnotationManager.clear(); 84 | } 85 | } 86 | 87 | 88 | protected void setContentView(int resId) { 89 | setContentView(View.inflate(getContext(), resId, null)); 90 | } 91 | 92 | protected void setContentView(@NonNull View view) { 93 | FrameLayout.LayoutParams lp = (LayoutParams) view.getLayoutParams(); 94 | if (null == lp) { 95 | lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 96 | } 97 | lp.width = ViewGroup.LayoutParams.MATCH_PARENT; 98 | lp.height = ViewGroup.LayoutParams.MATCH_PARENT; 99 | view.setLayoutParams(lp); 100 | this.addView(view); 101 | } 102 | 103 | 104 | /** 105 | * ******** annotation support ********* 106 | */ 107 | 108 | @Override 109 | public void setContentView_(int i) { 110 | setContentView(i); 111 | } 112 | 113 | @Override 114 | public View findViewById_(int i) { 115 | return findViewById(i); 116 | } 117 | 118 | @Override 119 | public void parserTypeAnnotations(Class aClass) throws Exception { 120 | 121 | } 122 | 123 | @Override 124 | public void parserMethodAnnotations(Method method) throws Exception { 125 | if (method.isAnnotationPresent(Accept.class)) { 126 | if (null == rxBusAnnotationManager) { 127 | rxBusAnnotationManager = new RxBusAnnotationManager(this); 128 | } 129 | rxBusAnnotationManager.parserObservableEventAnnotations(method); 130 | } 131 | } 132 | 133 | @Override 134 | public void parserFieldAnnotations(Field field) throws Exception { 135 | 136 | } 137 | 138 | @Override 139 | public void registerPresenter(ABBasePresenter abBasePresenter) { 140 | presenter = abBasePresenter; 141 | } 142 | 143 | @Override 144 | public void closeAllTask() { 145 | if (null != presenter) { 146 | presenter.closeAllTask(); 147 | } 148 | } 149 | 150 | @Override 151 | public void onClickCallbackSample(View view) { 152 | 153 | } 154 | 155 | @Override 156 | public void onLongClickCallbackSample(View view) { 157 | 158 | } 159 | 160 | @Override 161 | public void onItemClickCallbackSample(AdapterView adapterView, View view, int i, long l) { 162 | 163 | } 164 | 165 | @Override 166 | public void onItemLongClickCallbackSample(AdapterView adapterView, View view, int i, long l) { 167 | 168 | } 169 | 170 | @Override 171 | public void onCheckedChangedCallbackSample(CompoundButton compoundButton, boolean b) { 172 | 173 | } 174 | 175 | /** 176 | * *************** ABActivityViewer **************** 177 | */ 178 | @Override 179 | public void showToastMessage(String s) { 180 | Toast.makeText(getContext(), s, Toast.LENGTH_SHORT).show(); 181 | } 182 | 183 | @Override 184 | public void showInfoDialog(String s) { 185 | showInfoDialog(null, s, "OK"); 186 | } 187 | 188 | @Override 189 | public void showInfoDialog(String s, String s1) { 190 | showInfoDialog(s, s1, "OK"); 191 | } 192 | 193 | @Override 194 | public void showLoadingDialog(String s) { 195 | 196 | } 197 | 198 | @Override 199 | public void cancelLoadingDialog() { 200 | 201 | } 202 | 203 | @Override 204 | public void showInfoDialog(String s, String s1, String s2) { 205 | new AlertDialog.Builder(getContext()) 206 | .setTitle(s) 207 | .setMessage(s1) 208 | .setPositiveButton(s2, null) 209 | .show(); 210 | } 211 | 212 | 213 | @Override 214 | public void onPostAccept(Object tag, Object event) { 215 | 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/tab/chat/TabChatContainer.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.tab.chat; 2 | 3 | import android.content.Context; 4 | import com.wangjie.androidinject.annotation.annotations.base.AILayout; 5 | import com.wangjie.rxandroideventssample.R; 6 | import com.wangjie.rxandroideventssample.ui.tab.TabContainer; 7 | 8 | /** 9 | * Author: wangjie 10 | * Email: tiantian.china.2@gmail.com 11 | * Date: 6/10/15. 12 | */ 13 | @AILayout(R.layout.tab_chat) 14 | public class TabChatContainer extends TabContainer { 15 | public TabChatContainer(Context context) { 16 | super(context); 17 | } 18 | 19 | @Override 20 | protected void onAttachedToWindow() { 21 | super.onAttachedToWindow(); 22 | } 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/tab/feed/TabFeedContainer.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.tab.feed; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | import com.wangjie.androidbucket.log.Logger; 8 | import com.wangjie.androidbucket.support.recyclerview.layoutmanager.ABaseLinearLayoutManager; 9 | import com.wangjie.androidbucket.utils.ABTextUtil; 10 | import com.wangjie.androidinject.annotation.annotations.base.AIClick; 11 | import com.wangjie.androidinject.annotation.annotations.base.AILayout; 12 | import com.wangjie.androidinject.annotation.annotations.base.AIView; 13 | import com.wangjie.androidinject.annotation.annotations.mvp.AIPresenter; 14 | import com.wangjie.rxandroideventssample.R; 15 | import com.wangjie.rxandroideventssample.annotation.accept.Accept; 16 | import com.wangjie.rxandroideventssample.annotation.accept.AcceptScheduler; 17 | import com.wangjie.rxandroideventssample.annotation.accept.AcceptType; 18 | import com.wangjie.rxandroideventssample.events.ActionEvent; 19 | import com.wangjie.rxandroideventssample.events.AddFeedsEvent; 20 | import com.wangjie.rxandroideventssample.events.DeleteFeedsEvent; 21 | import com.wangjie.rxandroideventssample.events.FeedItemClickEvent; 22 | import com.wangjie.rxandroideventssample.provider.model.Feed; 23 | import com.wangjie.rxandroideventssample.rxbus.RxBus; 24 | import com.wangjie.rxandroideventssample.ui.main.adapter.FeedAdapter; 25 | import com.wangjie.rxandroideventssample.ui.tab.TabContainer; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Author: wangjie 31 | * Email: tiantian.china.2@gmail.com 32 | * Date: 6/10/15. 33 | */ 34 | @AILayout(R.layout.tab_feed) 35 | public class TabFeedContainer extends TabContainer implements TabFeedViewer, FeedAdapter.OnFeedAdapterListener { 36 | private static final String TAG = TabFeedContainer.class.getSimpleName(); 37 | 38 | public TabFeedContainer(Context context) { 39 | super(context); 40 | } 41 | 42 | @AIView(R.id.tab_feed_load_feeds_rv) 43 | private RecyclerView feedRv; 44 | private FeedAdapter adapter; 45 | 46 | private ABaseLinearLayoutManager layoutManager; 47 | 48 | @AIPresenter 49 | private TabFeedPresenter presenter; 50 | 51 | @Override 52 | protected void onAttachedToWindow() { 53 | super.onAttachedToWindow(); 54 | 55 | Context context = getContext(); 56 | layoutManager = new ABaseLinearLayoutManager(context); 57 | layoutManager.setOrientation(LinearLayoutManager.VERTICAL); 58 | feedRv.setLayoutManager(layoutManager); 59 | adapter = new FeedAdapter(context); 60 | adapter.setOnFeedAdapterListener(this); 61 | feedRv.setAdapter(adapter); 62 | loadFeeds(10); 63 | } 64 | 65 | @Override 66 | @AIClick({R.id.tab_feed_load_feeds_btn}) 67 | public void onClickCallbackSample(View view) { 68 | switch (view.getId()) { 69 | case R.id.tab_feed_load_feeds_btn: 70 | loadFeeds(1); 71 | break; 72 | default: 73 | break; 74 | } 75 | } 76 | 77 | @Override 78 | public void loadFeeds(int size) { 79 | presenter.loadFeeds(size); 80 | } 81 | 82 | @Override 83 | public void onLoadReeds(List feedList) { 84 | if (!ABTextUtil.isEmpty(feedList)) { 85 | int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); 86 | int insertPos = firstVisibleItemPosition < 0 ? 0 : firstVisibleItemPosition + 1; 87 | adapter.getList().addAll(insertPos, feedList); 88 | adapter.notifyItemInserted(insertPos); 89 | } 90 | 91 | } 92 | 93 | @Override 94 | public void deleteFeed() { 95 | List list = adapter.getList(); 96 | if (!ABTextUtil.isEmpty(list)) { 97 | list.remove(0); 98 | adapter.notifyItemRemoved(0); 99 | } 100 | } 101 | 102 | @Override 103 | public void onFeedItemClick(int position, Feed feed) { 104 | // showToastMessage(feed.getTitle()); 105 | RxBus.get().post(new FeedItemClickEvent().setPosition(position).setFeed(feed)); 106 | } 107 | 108 | @Override 109 | protected void onDetachedFromWindow() { 110 | super.onDetachedFromWindow(); 111 | } 112 | 113 | /* 114 | @Accept(@AcceptType(clazz = AddFeedsEvent.class)) 115 | public void onPostAcceptX(Object tag, Object event) { 116 | Logger.d(TAG, "[AddFeedsEvent]onPostAccept tag: " + tag + ", object: " + event); 117 | onLoadReeds(((AddFeedsEvent) event).getFeeds()); 118 | } 119 | */ 120 | 121 | @Accept 122 | public void onPostAccept(Object tag, AddFeedsEvent event) { 123 | Logger.d(TAG, "[AddFeedsEvent]onPostAccept tag: " + tag + ", object: " + event); 124 | onLoadReeds(event.getFeeds()); 125 | } 126 | 127 | @Accept(acceptScheduler = AcceptScheduler.MAIN_THREAD) 128 | public void onPostAccept(Object tag, DeleteFeedsEvent event) { 129 | deleteFeed(); 130 | } 131 | 132 | @Accept( 133 | { 134 | @AcceptType(tag = ActionEvent.CLOSE, clazz = String.class), 135 | @AcceptType(tag = ActionEvent.BACK, clazz = String.class), 136 | @AcceptType(tag = ActionEvent.EDIT, clazz = String.class), 137 | @AcceptType(tag = ActionEvent.REFRESH, clazz = String.class) 138 | } 139 | ) 140 | public void onPostAccept(Object tag, Object actionEvent) { 141 | Logger.d(TAG, "[ActionEvent]onPostAccept action event name: " + actionEvent); 142 | showToastMessage(actionEvent.toString()); 143 | } 144 | 145 | 146 | } 147 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/tab/feed/TabFeedPresenter.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.tab.feed; 2 | 3 | import com.wangjie.androidbucket.log.Logger; 4 | import com.wangjie.androidbucket.mvp.ABNoneInteractorImpl; 5 | import com.wangjie.rxandroideventssample.base.BasePresenter; 6 | import com.wangjie.rxandroideventssample.provider.model.Feed; 7 | import rx.Observable; 8 | import rx.android.schedulers.AndroidSchedulers; 9 | import rx.schedulers.Schedulers; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.Random; 14 | 15 | /** 16 | * Author: wangjie 17 | * Email: tiantian.china.2@gmail.com 18 | * Date: 6/10/15. 19 | */ 20 | public class TabFeedPresenter extends BasePresenter { 21 | private static final String TAG = TabFeedPresenter.class.getSimpleName(); 22 | private static int feedCount = 0; 23 | private Random random = new Random(); 24 | private static final int ONE_HOUR = 1000 * 60 * 60; 25 | 26 | void loadFeeds(int size) { 27 | goSubscription( 28 | Observable.from(testLoadFeedsFromNet(size)) 29 | .subscribeOn(Schedulers.newThread()) 30 | .map(feed -> { 31 | feed.setTitle(feed.getTitle() + "_ob"); 32 | return feed; 33 | }) 34 | .toSortedList((feed, feed2) -> (int) (feed.getCreated() - feed2.getCreated())) 35 | .observeOn(AndroidSchedulers.mainThread()) 36 | .subscribe(viewer::onLoadReeds, throwable -> Logger.w(TAG, "error: " + throwable.getMessage())) 37 | ); 38 | } 39 | 40 | /** 41 | * 模拟从网络获取数据 42 | * 43 | * @param size 44 | * @return 45 | */ 46 | private List testLoadFeedsFromNet(int size) { 47 | size = size < 1 ? 1 : size; 48 | List feeds = new ArrayList<>(); 49 | for (int i = 0; i < size; i++) { 50 | Feed feed = new Feed(); 51 | feed.setTitle("title_" + feedCount); 52 | feed.setContent("content_" + feedCount); 53 | feed.setCreated(System.currentTimeMillis() - (random.nextInt(ONE_HOUR + 10) + ONE_HOUR)); 54 | feeds.add(feed); 55 | feedCount++; 56 | } 57 | return feeds; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/tab/feed/TabFeedViewer.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.tab.feed; 2 | 3 | import com.wangjie.androidbucket.mvp.ABActivityViewer; 4 | import com.wangjie.rxandroideventssample.provider.model.Feed; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Author: wangjie 10 | * Email: tiantian.china.2@gmail.com 11 | * Date: 6/10/15. 12 | */ 13 | public interface TabFeedViewer extends ABActivityViewer{ 14 | void loadFeeds(int size); 15 | void onLoadReeds(List feedList); 16 | 17 | void deleteFeed(); 18 | } 19 | -------------------------------------------------------------------------------- /sample/src/main/java/com/wangjie/rxandroideventssample/ui/tab/setting/TabSettingContainer.java: -------------------------------------------------------------------------------- 1 | package com.wangjie.rxandroideventssample.ui.tab.setting; 2 | 3 | import android.content.Context; 4 | import com.wangjie.androidinject.annotation.annotations.base.AILayout; 5 | import com.wangjie.rxandroideventssample.R; 6 | import com.wangjie.rxandroideventssample.ui.tab.TabContainer; 7 | 8 | /** 9 | * Author: wangjie 10 | * Email: tiantian.china.2@gmail.com 11 | * Date: 6/10/15. 12 | */ 13 | @AILayout(R.layout.tab_setting) 14 | public class TabSettingContainer extends TabContainer { 15 | public TabSettingContainer(Context context) { 16 | super(context); 17 | } 18 | 19 | @Override 20 | protected void onAttachedToWindow() { 21 | super.onAttachedToWindow(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/feed_rv_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 29 | 30 | 38 | 39 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/tab_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/tab_feed.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 21 | 22 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/tab_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 |

5 | 6 | 10 | 11 | 15 | 16 | 20 | 21 | 25 | 26 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangjiegulu/RxAndroidEventsSample/f528a665083065d9f5ab2cdbb4ac798beb2d2e9e/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangjiegulu/RxAndroidEventsSample/f528a665083065d9f5ab2cdbb4ac798beb2d2e9e/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangjiegulu/RxAndroidEventsSample/f528a665083065d9f5ab2cdbb4ac798beb2d2e9e/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangjiegulu/RxAndroidEventsSample/f528a665083065d9f5ab2cdbb4ac798beb2d2e9e/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RxAndroidEventsSample 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample' 2 | --------------------------------------------------------------------------------