├── .gitignore ├── LICENSE ├── README.md ├── Retrofit ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── lib │ │ └── com │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── lib │ │ │ └── com │ │ │ └── myapplication │ │ │ ├── MainActivity.java │ │ │ ├── bean │ │ │ └── User.java │ │ │ └── netI │ │ │ └── UserI.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── lib │ └── com │ └── myapplication │ └── ExampleUnitTest.java ├── RxAndroid ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── lib │ │ └── com │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── lib │ │ │ └── com │ │ │ └── myapplication │ │ │ ├── MainActivity.java │ │ │ ├── RxBus.java │ │ │ └── RxBusActivity.java │ └── res │ │ ├── layout │ │ ├── activity1.xml │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── lib │ └── com │ └── myapplication │ └── ExampleUnitTest.java ├── RxBinding ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── lib │ │ └── com │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── lib │ │ │ └── com │ │ │ └── myapplication │ │ │ ├── DebounceActivity.java │ │ │ ├── ListActivity.java │ │ │ ├── LoginActivity.java │ │ │ ├── MainActivity.java │ │ │ └── TextViewActivity.java │ └── res │ │ ├── layout │ │ ├── activity_debounce.xml │ │ ├── activity_list.xml │ │ ├── activity_login.xml │ │ ├── activity_main.xml │ │ └── activity_text_view.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── lib │ └── com │ └── myapplication │ └── ExampleUnitTest.java ├── RxLifecycle ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── lib │ │ └── com │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── lib │ │ │ └── com │ │ │ └── myapplication │ │ │ ├── MainActivity.java │ │ │ ├── MyFragment.java │ │ │ ├── OtherActivity.java │ │ │ └── StopActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_other.xml │ │ ├── activity_stop.xml │ │ └── fragment_my.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── lib │ └── com │ └── myapplication │ └── ExampleUnitTest.java ├── RxPreferences ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── app │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── app │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── app │ └── ExampleUnitTest.java ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── app │ │ └── com │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── app │ │ │ └── com │ │ │ └── myapplication │ │ │ ├── Activity1.java │ │ │ ├── Activity10.java │ │ │ ├── Activity2.java │ │ │ ├── Activity3.java │ │ │ ├── Activity4.java │ │ │ ├── Activity5.java │ │ │ ├── Activity6.java │ │ │ ├── Activity7.java │ │ │ ├── Activity8.java │ │ │ ├── BufferActivity.java │ │ │ ├── CombineLatestActivity.java │ │ │ ├── DeferActivity.java │ │ │ ├── DelayActivity.java │ │ │ ├── DoOnNextActivity.java │ │ │ ├── ElementAtActivity.java │ │ │ ├── FilterActivity.java │ │ │ ├── IntervalActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MergeActivity.java │ │ │ ├── RangeActivity.java │ │ │ ├── ScanActivity.java │ │ │ ├── StartWithActivity.java │ │ │ ├── TakeActivity.java │ │ │ └── TimerActivity.java │ └── res │ │ ├── layout │ │ ├── activity_buffer.xml │ │ ├── activity_combine_latest.xml │ │ ├── activity_defer.xml │ │ ├── activity_delay.xml │ │ ├── activity_element_at.xml │ │ ├── activity_filter.xml │ │ ├── activity_finally_do.xml │ │ ├── activity_interval.xml │ │ ├── activity_main.xml │ │ ├── activity_merge.xml │ │ ├── activity_range.xml │ │ ├── activity_scan.xml │ │ ├── activity_start_with.xml │ │ ├── activity_take.xml │ │ ├── activity_timer.xml │ │ └── content_main.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 │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── app │ └── com │ └── myapplication │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Intellij project files 9 | .idea/ 10 | .gradle/ 11 | *.iml 12 | 13 | # Java class files 14 | *.class 15 | 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | build -------------------------------------------------------------------------------- /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, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "{}" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright 2016 君君小朋友 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 我的博客 2 | [RxJava 和 RxAndroid 一 (基础)](http://www.cnblogs.com/zhaoyanjun/p/5175502.html) 3 | 4 | [RxJava 和 RxAndroid 二(操作符的使用)](http://www.cnblogs.com/zhaoyanjun/p/5502804.html) 5 | 6 | [RxJava 和 RxAndroid 三(生命周期控制和内存优化)](http://www.cnblogs.com/zhaoyanjun/p/5523454.html) 7 | 8 | [RxJava 和 RxAndroid 四(RxBinding的使用)](http://www.cnblogs.com/zhaoyanjun/p/5535651.html) 9 | 10 | [RxJava 和 RxAndroid 五(线程调度)](http://www.cnblogs.com/zhaoyanjun/p/5624395.html) 11 | 12 | --- 13 | ### 相关的github地址 14 | [RxJava](https://github.com/ReactiveX/RxJava) 15 | 16 | [RxAndroid]( https://github.com/ReactiveX/RxAndroid) 17 | 18 | [RxLifecycle](https://github.com/trello/RxLifecycle) 19 | 20 | [RxBinding](https://github.com/JakeWharton/RxBinding) 21 | 22 | --- 23 | 24 | 个人微信号:`zhaoyanjun125 ` , 欢迎关注 25 | 26 | ![](http://o7rvuansr.bkt.clouddn.com/weixin200.jpg) -------------------------------------------------------------------------------- /Retrofit/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Retrofit/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "lib.com.myapplication" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile 'com.squareup.retrofit2:retrofit:2.0.2' 27 | compile 'com.squareup.retrofit2:converter-gson:2.0.2' 28 | compile 'com.google.code.gson:gson:2.6.2' 29 | } 30 | -------------------------------------------------------------------------------- /Retrofit/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 D:\soft\SDKandroidStudio/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 | -------------------------------------------------------------------------------- /Retrofit/src/androidTest/java/lib/com/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 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 | } -------------------------------------------------------------------------------- /Retrofit/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Retrofit/src/main/java/lib/com/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.util.Log; 6 | import android.widget.TextView; 7 | import android.widget.Toast; 8 | 9 | import lib.com.myapplication.netI.UserI; 10 | import okhttp3.OkHttpClient; 11 | import retrofit2.Call; 12 | import retrofit2.Callback; 13 | import retrofit2.Response; 14 | import retrofit2.Retrofit; 15 | import retrofit2.converter.gson.GsonConverterFactory; 16 | 17 | public class MainActivity extends AppCompatActivity { 18 | 19 | String Tag = "Retrofit" ; 20 | 21 | private TextView textView ; 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | // HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); 28 | // httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); 29 | // OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(httpLoggingInterceptor).build(); 30 | 31 | OkHttpClient okHttpClient = new OkHttpClient.Builder().build(); 32 | 33 | textView = (TextView) findViewById( R.id.tv ); 34 | 35 | //http://www.app.zhaoaiqiao.com/web2/ 36 | Retrofit retrofit = new Retrofit.Builder() 37 | .baseUrl( "http://www.app.zhaoaiqiao.com/web2" ) 38 | .addConverterFactory( GsonConverterFactory.create()) 39 | .build(); 40 | UserI userBiz = retrofit.create(UserI.class); 41 | final Call call = userBiz.getUsers(); 42 | 43 | call.enqueue(new Callback() { 44 | @Override 45 | public void onResponse(final Call call, final Response response) { 46 | Log.e(Tag, "normalGet:" + response.body().toString() + "" ); 47 | runOnUiThread(new Runnable() { 48 | @Override 49 | public void run() { 50 | Toast.makeText(MainActivity.this, "success:" + response.body() , Toast.LENGTH_SHORT).show(); 51 | Log.e(Tag, "normalGet:" + response.body().toString() + "" ); 52 | textView.setText( response.body().toString() ); 53 | } 54 | }); 55 | } 56 | 57 | @Override 58 | public void onFailure(Call call, Throwable t) { 59 | Toast.makeText(MainActivity.this, "failc" + t.toString() , Toast.LENGTH_SHORT).show(); 60 | textView.setText( t.toString() ); 61 | } 62 | }); 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Retrofit/src/main/java/lib/com/myapplication/bean/User.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication.bean; 2 | 3 | /** 4 | * Created by ${zyj} on 2016/6/1. 5 | */ 6 | public class User { 7 | 8 | String name ; 9 | String id ; 10 | String sex ; 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public void setName(String name) { 17 | this.name = name; 18 | } 19 | 20 | public String getSex() { 21 | return sex; 22 | } 23 | 24 | public void setSex(String sex) { 25 | this.sex = sex; 26 | } 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Retrofit/src/main/java/lib/com/myapplication/netI/UserI.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication.netI; 2 | 3 | import retrofit2.Call; 4 | import retrofit2.http.GET; 5 | 6 | /** 7 | * Created by ${zyj} on 2016/6/1. 8 | */ 9 | public interface UserI { 10 | @GET("/PeopleServlet") 11 | Call getUsers(); 12 | } 13 | -------------------------------------------------------------------------------- /Retrofit/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /Retrofit/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/Retrofit/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Retrofit/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/Retrofit/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Retrofit/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/Retrofit/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Retrofit/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/Retrofit/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Retrofit/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/Retrofit/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Retrofit/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /Retrofit/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /Retrofit/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /Retrofit/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | -------------------------------------------------------------------------------- /Retrofit/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Retrofit/src/test/java/lib/com/myapplication/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /RxAndroid/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /RxAndroid/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "lib.com.myapplication" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.2.1' 26 | compile 'io.reactivex:rxandroid:1.2.0' 27 | } 28 | -------------------------------------------------------------------------------- /RxAndroid/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 D:\soft\SDKandroidStudio/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 | -------------------------------------------------------------------------------- /RxAndroid/src/androidTest/java/lib/com/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 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 | } -------------------------------------------------------------------------------- /RxAndroid/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /RxAndroid/src/main/java/lib/com/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.os.HandlerThread; 5 | import android.os.Looper; 6 | import android.os.Process; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.util.Log; 9 | import android.view.View; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | import rx.Observable; 14 | import rx.Subscriber; 15 | import rx.android.schedulers.AndroidSchedulers; 16 | import rx.exceptions.OnErrorThrowable; 17 | import rx.functions.Func0; 18 | 19 | public class MainActivity extends AppCompatActivity { 20 | 21 | private static final String TAG = "RxAndroidSamples"; 22 | private Looper backgroundLooper; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_main); 28 | 29 | BackgroundThread backgroundThread = new BackgroundThread(); 30 | backgroundThread.start(); 31 | backgroundLooper = backgroundThread.getLooper(); 32 | 33 | findViewById(R.id.button_run_scheduler).setOnClickListener(new View.OnClickListener() { 34 | @Override public void onClick(View v) { 35 | onRunSchedulerExampleButtonClicked(); 36 | } 37 | }); 38 | 39 | } 40 | 41 | void onRunSchedulerExampleButtonClicked() { 42 | sampleObservable() 43 | // Run on a background thread 44 | .subscribeOn( AndroidSchedulers.from(backgroundLooper)) 45 | // Be notified on the main thread 46 | .observeOn(AndroidSchedulers.mainThread()) 47 | .subscribe(new Subscriber() { 48 | @Override public void onCompleted() { 49 | Log.d(TAG, "onCompleted()"); 50 | } 51 | 52 | @Override public void onError(Throwable e) { 53 | Log.e(TAG, "onError()", e); 54 | } 55 | 56 | @Override public void onNext(String string) { 57 | Log.d(TAG, "onNext(" + string + ")"); 58 | } 59 | }); 60 | } 61 | 62 | static rx.Observable sampleObservable() { 63 | return rx.Observable.defer(new Func0>() { 64 | @Override public rx.Observable call() { 65 | try { 66 | // Do some long running operation 67 | Thread.sleep(TimeUnit.SECONDS.toMillis(5)); 68 | } catch (InterruptedException e) { 69 | throw OnErrorThrowable.from(e); 70 | } 71 | return Observable.just("one", "two", "three", "four", "five"); 72 | } 73 | }); 74 | } 75 | 76 | static class BackgroundThread extends HandlerThread { 77 | BackgroundThread() { 78 | super("SchedulerSample-BackgroundThread", Process.THREAD_PRIORITY_BACKGROUND); 79 | } 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /RxAndroid/src/main/java/lib/com/myapplication/RxBus.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | import android.support.annotation.NonNull; 3 | import android.util.Log; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.List; 7 | import java.util.concurrent.ConcurrentHashMap; 8 | import rx.Observable; 9 | import rx.subjects.PublishSubject; 10 | import rx.subjects.Subject; 11 | 12 | /** 13 | * Created by ${zyj} on 2016/5/6. 14 | */ 15 | public class RxBus { 16 | 17 | private static final String TAG = RxBus.class.getSimpleName(); 18 | private static RxBus instance; 19 | public static boolean DEBUG = false; 20 | 21 | public static RxBus get() { 22 | if (instance == null) { 23 | synchronized (RxBus.class) { 24 | if (instance == null) { 25 | instance = new RxBus(); 26 | } 27 | } 28 | } 29 | return instance; 30 | } 31 | 32 | private RxBus() { 33 | } 34 | 35 | private ConcurrentHashMap> subjectMapper = new ConcurrentHashMap<>(); 36 | 37 | @SuppressWarnings("unchecked") 38 | public Observable register(@NonNull Object tag, @NonNull Class clazz) { 39 | List subjectList = subjectMapper.get(tag); 40 | if (null == subjectList) { 41 | subjectList = new ArrayList<>(); 42 | subjectMapper.put(tag, subjectList); 43 | } 44 | 45 | Subject subject; 46 | subjectList.add(subject = PublishSubject.create()); 47 | if (DEBUG) Log.d(TAG, "[register]subjectMapper: " + subjectMapper); 48 | return subject; 49 | } 50 | 51 | public void unregister(@NonNull Object tag, @NonNull Observable observable) { 52 | List subjects = subjectMapper.get(tag); 53 | if (null != subjects) { 54 | if ( observable != null && subjects.contains( observable )){ 55 | subjects.remove((Subject) observable); 56 | } 57 | 58 | if (isEmpty(subjects)) { 59 | subjectMapper.remove(tag); 60 | } 61 | } 62 | 63 | if (DEBUG) Log.d(TAG, "[unregister]subjectMapper: " + subjectMapper); 64 | } 65 | 66 | public void post(@NonNull Object content) { 67 | post( content.getClass().getName(), content); 68 | } 69 | 70 | @SuppressWarnings("unchecked") 71 | public void post(@NonNull Object tag, @NonNull Object content) { 72 | List subjectList = subjectMapper.get(tag); 73 | 74 | if (!isEmpty(subjectList)) { 75 | for (Subject subject : subjectList) { 76 | subject.onNext(content); 77 | } 78 | } 79 | if (DEBUG) Log.d(TAG, "[send]subjectMapper: " + subjectMapper); 80 | } 81 | 82 | private boolean isEmpty(Collection collection) { 83 | return null == collection || collection.isEmpty(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /RxAndroid/src/main/java/lib/com/myapplication/RxBusActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | import android.os.Bundle; 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.widget.TextView; 5 | 6 | import rx.Observable; 7 | import rx.android.schedulers.AndroidSchedulers; 8 | import rx.functions.Action1; 9 | import rx.schedulers.Schedulers; 10 | 11 | public class RxBusActivity extends AppCompatActivity { 12 | 13 | String tag = "tag" ; 14 | Observable ob ; 15 | private TextView tv ; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity1); 21 | 22 | tv = (TextView) findViewById( R.id.tv ); 23 | 24 | //创建被观察者 25 | ob = RxBus.get().register( tag , String.class ) ; 26 | //订阅观察事件 27 | ob.subscribeOn( Schedulers.io()) 28 | .observeOn(AndroidSchedulers.mainThread() ) 29 | .subscribe(new Action1() { 30 | @Override 31 | public void call(String s) { 32 | tv.setText( s ); 33 | } 34 | }) ; 35 | 36 | //发送内容 37 | RxBus.get().post( tag , "我是内容,万能的Rxjava" ); 38 | 39 | } 40 | 41 | @Override 42 | protected void onDestroy() { 43 | super.onDestroy(); 44 | //取消订阅 45 | RxBus.get().unregister( tag , ob ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/layout/activity1.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxAndroid/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxAndroid/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxAndroid/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxAndroid/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxAndroid/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxAndroid/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxAndroid/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxAndroid/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxAndroid/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxAndroid/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | -------------------------------------------------------------------------------- /RxAndroid/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /RxAndroid/src/test/java/lib/com/myapplication/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /RxBinding/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /RxBinding/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "lib.com.myapplication" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile 'com.jakewharton.rxbinding:rxbinding:0.4.0' 27 | } 28 | -------------------------------------------------------------------------------- /RxBinding/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 D:\soft\SDKandroidStudio/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 | -------------------------------------------------------------------------------- /RxBinding/src/androidTest/java/lib/com/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 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 | } -------------------------------------------------------------------------------- /RxBinding/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /RxBinding/src/main/java/lib/com/myapplication/DebounceActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.text.TextUtils; 6 | import android.widget.ArrayAdapter; 7 | import android.widget.EditText; 8 | import android.widget.ListView; 9 | 10 | import com.jakewharton.rxbinding.widget.RxTextView; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import java.util.concurrent.TimeUnit; 15 | 16 | import rx.android.schedulers.AndroidSchedulers; 17 | import rx.functions.Action1; 18 | import rx.functions.Func1; 19 | import rx.schedulers.Schedulers; 20 | 21 | public class DebounceActivity extends AppCompatActivity { 22 | 23 | private EditText editText ; 24 | private ListView listView ; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_debounce); 30 | 31 | editText = (EditText) findViewById( R.id.editText ); 32 | listView = (ListView) findViewById( R.id.listview ); 33 | 34 | final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1 ); 35 | listView.setAdapter( adapter ); 36 | 37 | RxTextView.textChanges( editText ) 38 | .debounce( 600 , TimeUnit.MILLISECONDS ) 39 | .map(new Func1() { 40 | @Override 41 | public String call(CharSequence charSequence) { 42 | //get the keyword 43 | String key = charSequence.toString() ; 44 | return key ; 45 | } 46 | }) 47 | .observeOn( Schedulers.io() ) 48 | .map(new Func1>() { 49 | @Override 50 | public List call(String keyWord ) { 51 | //get list 52 | List dataList = new ArrayList() ; 53 | if ( ! TextUtils.isEmpty( keyWord )){ 54 | for ( String s : getData() ) { 55 | if (s != null) { 56 | if (s.contains(keyWord)) { 57 | dataList.add(s); 58 | } 59 | } 60 | } 61 | } 62 | return dataList ; 63 | } 64 | }) 65 | .observeOn( AndroidSchedulers.mainThread() ) 66 | .subscribe(new Action1>() { 67 | @Override 68 | public void call(List strings) { 69 | adapter.clear(); 70 | adapter.addAll( strings ); 71 | adapter.notifyDataSetChanged(); 72 | } 73 | }) ; 74 | } 75 | 76 | public List getData(){ 77 | List list = new ArrayList<>() ; 78 | list.add( "a" ) ; 79 | list.add( "aab" ) ; 80 | list.add( "aaabc" ) ; 81 | list.add( "aaaaabcd" ) ; 82 | list.add( "aaaaaabcde" ) ; 83 | list.add( "aaaaaaac" ) ; 84 | list.add( "aaaaaaaacd" ) ; 85 | list.add( "aaaaaaaaacdef" ) ; 86 | list.add( "aaaaaaaaaabc" ) ; 87 | list.add( "bcd" ) ; 88 | list.add( "bcdef" ) ; 89 | list.add( "cd" ) ; 90 | list.add( "cde" ) ; 91 | list.add( "cdefg" ) ; 92 | list.add( "dddkkk5662" ) ; 93 | list.add( "bbs" ) ; 94 | list.add( "7b4s" ) ; 95 | list.add( "jjjsssd995556214613" ) ; 96 | list.add( "58350675" ) ; 97 | 98 | return list ; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /RxBinding/src/main/java/lib/com/myapplication/ListActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.ArrayAdapter; 6 | import android.widget.ListView; 7 | import android.widget.Toast; 8 | 9 | import com.jakewharton.rxbinding.widget.RxAdapterView; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | import rx.functions.Action1; 15 | 16 | public class ListActivity extends AppCompatActivity { 17 | 18 | ListView listView ; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_list); 24 | 25 | listView = (ListView) findViewById( R.id.listview ); 26 | 27 | List list = new ArrayList<>() ; 28 | for ( int i = 0 ; i < 40 ; i++ ){ 29 | list.add( "sss" + i ) ; 30 | } 31 | 32 | final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1 ); 33 | adapter.addAll( list ); 34 | 35 | listView.setAdapter( adapter ); 36 | 37 | //item click event 38 | RxAdapterView.itemClicks( listView ) 39 | .subscribe(new Action1() { 40 | @Override 41 | public void call(Integer integer) { 42 | Toast.makeText(ListActivity.this, "item click " + integer , Toast.LENGTH_SHORT).show(); 43 | } 44 | }) ; 45 | 46 | //item long click 47 | RxAdapterView.itemLongClicks( listView) 48 | .subscribe(new Action1() { 49 | @Override 50 | public void call(Integer integer) { 51 | Toast.makeText(ListActivity.this, "item long click " + integer , Toast.LENGTH_SHORT).show(); 52 | } 53 | }) ; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /RxBinding/src/main/java/lib/com/myapplication/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | import android.support.v7.app.AppCompatActivity; 3 | import android.os.Bundle; 4 | import android.widget.Button; 5 | import android.widget.CheckBox; 6 | import com.jakewharton.rxbinding.widget.RxCompoundButton; 7 | import rx.functions.Action1; 8 | 9 | public class LoginActivity extends AppCompatActivity { 10 | 11 | private Button button ; 12 | private CheckBox checkBox ; 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_login); 18 | 19 | button = (Button) findViewById( R.id.login_bt ); 20 | checkBox = (CheckBox) findViewById( R.id.checkbox ); 21 | 22 | RxCompoundButton.checkedChanges( checkBox ) 23 | .subscribe(new Action1() { 24 | @Override 25 | public void call(Boolean aBoolean) { 26 | button.setEnabled( aBoolean ); 27 | button.setBackgroundResource( aBoolean ? R.color.button_yes : R.color.button_no ); 28 | } 29 | }) ; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /RxBinding/src/main/java/lib/com/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.Button; 7 | import android.widget.Toast; 8 | 9 | import com.jakewharton.rxbinding.view.RxView; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | import rx.functions.Action1; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | private Button button ; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_main); 23 | 24 | button = (Button) findViewById( R.id.bt ) ; 25 | 26 | RxView.clicks( button ) 27 | .throttleFirst( 2 , TimeUnit.SECONDS ) //两秒钟之内只取一个点击事件,防抖操作 28 | .subscribe(new Action1() { 29 | @Override 30 | public void call(Void aVoid) { 31 | Toast.makeText(MainActivity.this, "click!!", Toast.LENGTH_SHORT).show(); 32 | } 33 | }) ; 34 | 35 | button = (Button) findViewById( R.id.bt ) ; 36 | 37 | //监听长按时间 38 | RxView.longClicks( button) 39 | .subscribe(new Action1() { 40 | @Override 41 | public void call(Void aVoid) { 42 | Toast.makeText(MainActivity.this, "long click !!", Toast.LENGTH_SHORT).show(); 43 | } 44 | }) ; 45 | 46 | //跳转到listActivity 47 | RxView.clicks( findViewById( R.id.bt2 )) 48 | .subscribe(new Action1() { 49 | @Override 50 | public void call(Void aVoid) { 51 | startActivity( new Intent( MainActivity.this , ListActivity.class )); 52 | } 53 | }) ; 54 | 55 | //跳转到LoginActivity 56 | RxView.clicks( findViewById( R.id.bt3 )) 57 | .subscribe(new Action1() { 58 | @Override 59 | public void call(Void aVoid) { 60 | startActivity( new Intent( MainActivity.this , LoginActivity.class )); 61 | } 62 | }) ; 63 | 64 | //跳转到DebounceActivity 65 | RxView.clicks( findViewById( R.id.debounce )) 66 | .subscribe(new Action1() { 67 | @Override 68 | public void call(Void aVoid) { 69 | startActivity( new Intent( MainActivity.this , DebounceActivity.class )); 70 | } 71 | }) ; 72 | 73 | //跳转到TextViewActivity 74 | RxView.clicks( findViewById( R.id.textView )) 75 | .subscribe(new Action1() { 76 | @Override 77 | public void call(Void aVoid) { 78 | startActivity( new Intent( MainActivity.this , TextViewActivity.class )); 79 | } 80 | }) ; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /RxBinding/src/main/java/lib/com/myapplication/TextViewActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.TextView; 6 | 7 | public class TextViewActivity extends AppCompatActivity { 8 | 9 | private TextView textView ; 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_text_view); 15 | 16 | textView = (TextView) findViewById( R.id.tv ); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/layout/activity_debounce.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/layout/activity_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 39 | 40 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/layout/activity_text_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxBinding/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxBinding/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxBinding/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxBinding/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxBinding/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxBinding/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxBinding/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxBinding/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxBinding/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxBinding/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #dddddd 7 | #3f51b5 8 | 9 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | -------------------------------------------------------------------------------- /RxBinding/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /RxBinding/src/test/java/lib/com/myapplication/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /RxLifecycle/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /RxLifecycle/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "lib.com.myapplication" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile 'com.trello:rxlifecycle-components:0.6.1' 27 | } 28 | -------------------------------------------------------------------------------- /RxLifecycle/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 D:\soft\SDKandroidStudio/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 | -------------------------------------------------------------------------------- /RxLifecycle/src/androidTest/java/lib/com/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 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 | } -------------------------------------------------------------------------------- /RxLifecycle/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/java/lib/com/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | import android.content.Intent; 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity; 7 | import java.util.concurrent.TimeUnit; 8 | import rx.Observable; 9 | import rx.android.schedulers.AndroidSchedulers; 10 | import rx.functions.Action1; 11 | import rx.schedulers.Schedulers; 12 | 13 | public class MainActivity extends RxAppCompatActivity { 14 | TextView textView ; 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | 20 | textView = (TextView) findViewById(R.id.textView); 21 | textView.setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View v) { 24 | startActivity( new Intent( MainActivity.this , StopActivity.class)); 25 | } 26 | }); 27 | 28 | //循环发送数字 29 | Observable.interval(0, 1, TimeUnit.SECONDS) 30 | .subscribeOn( Schedulers.io()) 31 | .compose(this.bindToLifecycle()) //这个订阅关系跟Activity绑定,Observable 和activity生命周期同步 32 | .observeOn( AndroidSchedulers.mainThread()) 33 | .subscribe(new Action1() { 34 | @Override 35 | public void call(Long aLong) { 36 | System.out.println("lifecycle--" + aLong); 37 | textView.setText( "" + aLong ); 38 | } 39 | }); 40 | } 41 | 42 | @Override 43 | protected void onDestroy() { 44 | super.onDestroy(); 45 | System.out.println("life-- Destory"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/java/lib/com/myapplication/MyFragment.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.trello.rxlifecycle.components.RxFragment; 10 | 11 | /** 12 | * Created by ${zyj} on 2016/5/23. 13 | */ 14 | public class MyFragment extends RxFragment { 15 | 16 | @Nullable 17 | @Override 18 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 19 | return super.onCreateView(inflater, container, savedInstanceState); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/java/lib/com/myapplication/OtherActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class OtherActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_other); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/java/lib/com/myapplication/StopActivity.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | 8 | import com.trello.rxlifecycle.ActivityEvent; 9 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity; 10 | 11 | import java.util.concurrent.TimeUnit; 12 | 13 | import rx.Observable; 14 | import rx.android.schedulers.AndroidSchedulers; 15 | import rx.functions.Action1; 16 | import rx.schedulers.Schedulers; 17 | 18 | public class StopActivity extends RxAppCompatActivity { 19 | 20 | TextView textView ; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_stop); 26 | 27 | textView = (TextView) findViewById(R.id.textview); 28 | textView.setOnClickListener(new View.OnClickListener() { 29 | @Override 30 | public void onClick(View v) { 31 | startActivity( new Intent( StopActivity.this , OtherActivity.class)); 32 | } 33 | }); 34 | 35 | //循环发送数字 36 | Observable.interval(0, 1, TimeUnit.SECONDS) 37 | .subscribeOn( Schedulers.io()) 38 | .compose(this.bindUntilEvent(ActivityEvent.STOP )) //当Activity执行Onstop()方法是解除订阅关系 39 | .observeOn( AndroidSchedulers.mainThread()) 40 | .subscribe(new Action1() { 41 | @Override 42 | public void call(Long aLong) { 43 | System.out.println("lifecycle-stop-" + aLong); 44 | textView.setText( "" + aLong ); 45 | } 46 | }); 47 | } 48 | 49 | @Override 50 | protected void onPause() { 51 | super.onPause(); 52 | System.out.println("lifecycle-stop-" + "onPause()方法调用了"); 53 | } 54 | 55 | @Override 56 | protected void onStop() { 57 | super.onStop(); 58 | System.out.println("lifecycle-stop-" + "onStop()方法调用了"); 59 | } 60 | 61 | @Override 62 | protected void onDestroy() { 63 | super.onDestroy(); 64 | System.out.println("lifecycle-stop-" + "onDestroy()方法调用了"); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/layout/activity_other.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/layout/activity_stop.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/layout/fragment_my.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxLifecycle/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxLifecycle/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxLifecycle/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxLifecycle/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyj1609wz/RxJava_RxAndroid/62a2b63ac60813f56e312605a96c46d9992e7ef8/RxLifecycle/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | My Application 3 | 4 | -------------------------------------------------------------------------------- /RxLifecycle/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /RxLifecycle/src/test/java/lib/com/myapplication/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package lib.com.myapplication; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /RxPreferences/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /RxPreferences/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.app" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1' 27 | } 28 | -------------------------------------------------------------------------------- /RxPreferences/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 D:\soft\SDKandroidStudio/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 | -------------------------------------------------------------------------------- /RxPreferences/src/androidTest/java/com/app/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.app; 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 | } -------------------------------------------------------------------------------- /RxPreferences/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /RxPreferences/src/main/java/com/app/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.app; 2 | 3 | import android.content.SharedPreferences; 4 | import android.os.Bundle; 5 | import android.preference.PreferenceManager; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | import android.widget.EditText; 9 | import android.widget.Toast; 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | private EditText editText ; 14 | private SharedPreferences.Editor editor ; 15 | private SharedPreferences preferences ; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | 22 | editText = (EditText) findViewById( R.id.et) ; 23 | preferences = PreferenceManager.getDefaultSharedPreferences( MainActivity.this ) ; 24 | editor = preferences.edit() ; 25 | 26 | preferences.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() { 27 | @Override 28 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { 29 | Toast.makeText( MainActivity.this , "listen--key: " + key + " value: " + sharedPreferences.getString( key , "") , Toast.LENGTH_SHORT ).show(); 30 | } 31 | }); 32 | 33 | //点击 34 | findViewById( R.id.tv).setOnClickListener(new View.OnClickListener() { 35 | @Override 36 | public void onClick(View v) { 37 | String value = editText.getText().toString() ; 38 | editor.putString( "key" , value ) ; 39 | editor.commit() ; 40 | } 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /RxPreferences/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 129 | 130 | 137 | 138 | 145 | 146 | 153 | 154 |