├── .gitignore ├── LICENSE.txt ├── README.md ├── app ├── .gitignore ├── art │ ├── 1.png │ ├── 2.png │ └── 3.png ├── build.gradle ├── libs │ └── commons-codec-1.6.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jiang │ │ └── android │ │ └── rxjavaapp │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── jiang │ │ │ └── android │ │ │ └── rxjavaapp │ │ │ ├── App.java │ │ │ ├── activity │ │ │ ├── LauncherActivity.java │ │ │ ├── MainActivity.java │ │ │ └── PhotoPagerActivity.java │ │ │ ├── adapter │ │ │ ├── BaseAdapter.java │ │ │ ├── fragmentadapter │ │ │ │ ├── FragmentPagerAdapter.java │ │ │ │ ├── PagerAdapter.java │ │ │ │ └── ViewPager.java │ │ │ ├── holder │ │ │ │ └── BaseViewHolder.java │ │ │ └── inter │ │ │ │ └── OnItemClickListener.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ ├── BaseAppManager.java │ │ │ └── BaseWebActivity.java │ │ │ ├── common │ │ │ ├── CommonString.java │ │ │ ├── OperatorsUrl.java │ │ │ └── SPKey.java │ │ │ ├── database │ │ │ ├── DaoMaster.java │ │ │ ├── DaoSession.java │ │ │ ├── alloperators.java │ │ │ ├── alloperatorsDao.java │ │ │ ├── helper │ │ │ │ ├── AllOperatorsService.java │ │ │ │ ├── BaseService.java │ │ │ │ ├── DbCore.java │ │ │ │ ├── DbUtil.java │ │ │ │ └── OperatorsService.java │ │ │ ├── operators.java │ │ │ └── operatorsDao.java │ │ │ ├── utils │ │ │ ├── DataUtils.java │ │ │ ├── L.java │ │ │ ├── SharePrefUtil.java │ │ │ └── Utils.java │ │ │ └── widget │ │ │ ├── BrowserLayout.java │ │ │ └── HackyViewPager.java │ └── res │ │ ├── drawable-v21 │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ └── ic_menu_slideshow.xml │ │ ├── drawable-xhdpi │ │ ├── btn_back_normal.png │ │ ├── btn_back_pressed.png │ │ ├── btn_export_normal.png │ │ ├── btn_forward_normal.png │ │ ├── btn_forward_pressed.png │ │ ├── btn_refresh_normal.png │ │ └── btn_refresh_pressed.png │ │ ├── drawable │ │ ├── delector.xml │ │ ├── dialog_topbar_bg.xml │ │ ├── progress_bar_horizontal.xml │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── activity_common_web.xml │ │ ├── activity_main.xml │ │ ├── activity_photoview.xml │ │ ├── activity_splash.xml │ │ ├── app_bar_main.xml │ │ ├── browser_controller.xml │ │ ├── common_toolbar.xml │ │ ├── content_main.xml │ │ ├── item_index_content.xml │ │ ├── item_nav_head.xml │ │ ├── nav_header_main.xml │ │ └── progress_horizontal.xml │ │ ├── menu │ │ ├── activity_main_drawer.xml │ │ └── main.xml │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── jiang │ └── android │ └── rxjavaapp │ └── ExampleUnitTest.java ├── build.gradle ├── qrcode └── a └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | rxjavaapp.jks 10 | grad* -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ### 学习RxJava操作符的APP 3 | 全新升级,更漂亮,更耐看,已加入RxJava2.x介绍 自行编译 4 | 5 | ### 展示: 6 | 7 | 8 | 9 | 10 | ### 下载地址 11 | >* 自行编译 12 | ### 说明: 13 | >* Logo来源于网络 14 | >* app中用到的数据来自: https://github.com/mcxiaoke/RxDocs 15 | >* 介绍的操作符并不是全部操作符,大都是我们常用的,想要看全部操作符,请移步:http://reactivex.io/RxJava/javadoc/overview-summary.html 16 | >* 线程调度的一些说明可能不准确,如发现错误,欢迎提issue,我会及时更正过来 17 | 18 | ### 捐赠 19 | 如果您觉得对您有帮助,欢迎请作者一杯咖啡

20 | ![](https://raw.githubusercontent.com/jiang111/RxJavaApp/master/qrcode/wechat_alipay.png) 21 | 22 | 23 | ### License 24 | 25 | Copyright 2016 NewTab 26 | 27 | Licensed under the Apache License, Version 2.0 (the "License"); 28 | you may not use this file except in compliance with the License. 29 | You may obtain a copy of the License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software 34 | distributed under the License is distributed on an "AS IS" BASIS, 35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 | See the License for the specific language governing permissions and 37 | limitations under the License. 38 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/art/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/art/1.png -------------------------------------------------------------------------------- /app/art/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/art/2.png -------------------------------------------------------------------------------- /app/art/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/art/3.png -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.jiang.android.rxjavaapp" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 9 12 | versionName "2.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 'com.android.support:design:23.2.1' 27 | compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' 28 | compile 'com.android.support:recyclerview-v7:23.2.1' 29 | compile 'com.commit451:PhotoView:1.2.4' 30 | compile 'de.greenrobot:greendao:2.1.0' 31 | compile 'de.greenrobot:greendao-generator:2.1.0' 32 | compile 'com.android.support:support-v4:23.2.1' 33 | compile files('libs/commons-codec-1.6.jar') 34 | compile 'io.reactivex:rxjava:1.1.1' 35 | compile 'io.reactivex:rxandroid:1.1.0' 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/libs/commons-codec-1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/libs/commons-codec-1.6.jar -------------------------------------------------------------------------------- /app/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/jiang/androidsdk/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/jiang/android/rxjavaapp/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp; 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 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/App.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp; 30 | 31 | import android.app.Application; 32 | import android.content.Context; 33 | import android.graphics.Bitmap; 34 | 35 | import com.jiang.android.rxjavaapp.database.helper.DbCore; 36 | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; 37 | import com.nostra13.universalimageloader.core.DisplayImageOptions; 38 | import com.nostra13.universalimageloader.core.ImageLoader; 39 | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; 40 | import com.nostra13.universalimageloader.core.assist.ImageScaleType; 41 | import com.nostra13.universalimageloader.core.assist.QueueProcessingType; 42 | import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; 43 | 44 | /** 45 | * Created by jiang on 16/3/13. 46 | */ 47 | public class App extends Application { 48 | @Override 49 | public void onCreate() { 50 | super.onCreate(); 51 | DbCore.init(this); 52 | initImageLoader(getApplicationContext()); 53 | } 54 | 55 | private void initImageLoader(Context context) { 56 | 57 | DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() 58 | //.showImageForEmptyUri(R.drawable.ic_empty) 59 | //.showImageOnFail(R.drawable.ic_error) 60 | .resetViewBeforeLoading(true) 61 | .cacheInMemory(true) 62 | .cacheOnDisk(true) 63 | .imageScaleType(ImageScaleType.EXACTLY) 64 | .bitmapConfig(Bitmap.Config.RGB_565) 65 | .considerExifParams(true) 66 | .displayer(new FadeInBitmapDisplayer(300)) 67 | .build(); 68 | 69 | // This configuration tuning is custom. You can tune every option, you may tune some of them, 70 | // or you can create default configuration by 71 | // ImageLoaderConfiguration.createDefault(this); 72 | // method. 73 | ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context); 74 | config.threadPriority(Thread.NORM_PRIORITY - 2); 75 | config.denyCacheImageMultipleSizesInMemory(); 76 | config.diskCacheFileNameGenerator(new Md5FileNameGenerator()); 77 | config.diskCacheSize(50 * 1024 * 1024); // 50 MiB 78 | config.tasksProcessingOrder(QueueProcessingType.LIFO); 79 | config.defaultDisplayImageOptions(defaultOptions); 80 | 81 | // Initialize ImageLoader with configuration. 82 | ImageLoader.getInstance().init(config.build()); 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/activity/LauncherActivity.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.widget.ImageView; 8 | 9 | import com.jiang.android.rxjavaapp.R; 10 | import com.jiang.android.rxjavaapp.common.CommonString; 11 | import com.jiang.android.rxjavaapp.database.helper.DbUtil; 12 | import com.jiang.android.rxjavaapp.utils.DataUtils; 13 | import com.nostra13.universalimageloader.core.ImageLoader; 14 | 15 | public class LauncherActivity extends AppCompatActivity { 16 | 17 | 18 | ImageView mSplash; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_splash); 24 | mSplash = (ImageView) findViewById(R.id.splash_index); 25 | ImageLoader.getInstance().displayImage(CommonString.SPLASH_INDEX_URL, mSplash); 26 | startAct(); 27 | 28 | } 29 | 30 | private void startAct() { 31 | 32 | 33 | long count = DbUtil.getOperatorsService().count(); 34 | if (count == 0) { 35 | DataUtils.fillData(new DataUtils.callBack() { 36 | @Override 37 | public void onSuccess() { 38 | startActivity(new Intent(LauncherActivity.this, MainActivity.class)); 39 | LauncherActivity.this.finish(); 40 | 41 | } 42 | 43 | @Override 44 | public void onFail(Throwable e) { 45 | Snackbar.make(mSplash, e.getMessage(), Snackbar.LENGTH_LONG).show(); 46 | 47 | } 48 | }); 49 | 50 | } else { 51 | startActivity(new Intent(LauncherActivity.this, MainActivity.class)); 52 | LauncherActivity.this.finish(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.activity; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.design.widget.NavigationView; 7 | import android.support.v4.view.GravityCompat; 8 | import android.support.v4.widget.DrawerLayout; 9 | import android.support.v7.app.ActionBarDrawerToggle; 10 | import android.support.v7.widget.LinearLayoutManager; 11 | import android.support.v7.widget.RecyclerView; 12 | import android.support.v7.widget.Toolbar; 13 | import android.text.TextUtils; 14 | import android.view.Menu; 15 | import android.view.MenuItem; 16 | import android.view.View; 17 | import android.widget.ImageView; 18 | import android.widget.LinearLayout; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import com.jiang.android.rxjavaapp.R; 23 | import com.jiang.android.rxjavaapp.adapter.BaseAdapter; 24 | import com.jiang.android.rxjavaapp.adapter.holder.BaseViewHolder; 25 | import com.jiang.android.rxjavaapp.adapter.inter.OnItemClickListener; 26 | import com.jiang.android.rxjavaapp.base.BaseActivity; 27 | import com.jiang.android.rxjavaapp.base.BaseWebActivity; 28 | import com.jiang.android.rxjavaapp.common.CommonString; 29 | import com.jiang.android.rxjavaapp.database.alloperators; 30 | import com.jiang.android.rxjavaapp.database.helper.DbUtil; 31 | import com.jiang.android.rxjavaapp.database.operators; 32 | import com.nostra13.universalimageloader.core.ImageLoader; 33 | 34 | import java.util.ArrayList; 35 | import java.util.List; 36 | 37 | import rx.Observable; 38 | import rx.Subscriber; 39 | import rx.android.schedulers.AndroidSchedulers; 40 | import rx.functions.Action1; 41 | import rx.schedulers.Schedulers; 42 | 43 | public class MainActivity extends BaseActivity implements View.OnClickListener { 44 | 45 | private static final int REQUEST_STORAGE = 1010; 46 | private Toolbar toolbar; 47 | private LinearLayout mHeadView; 48 | 49 | RecyclerView mNavRecyclerView; 50 | BaseAdapter mAdapter; 51 | BaseAdapter mContentAdapter; 52 | private int checkedPosition = 0; 53 | 54 | private List mList = new ArrayList<>(); 55 | private List mContentLists = new ArrayList<>(); 56 | private RecyclerView mContentRecyclerView; 57 | private ArrayList photos; 58 | private DrawerLayout drawer; 59 | private NavigationView navigationView; 60 | private ActionBarDrawerToggle toggle; 61 | 62 | 63 | @Override 64 | protected void initViewsAndEvents() { 65 | initToolBar(); 66 | initNavigationView(); 67 | initNavRecycerView(); 68 | mContentRecyclerView = (RecyclerView) findViewById(R.id.id_content); 69 | 70 | 71 | } 72 | 73 | private void getAllOperatorById(final long parent_id) { 74 | Observable.create(new Observable.OnSubscribe>() { 75 | @Override 76 | public void call(Subscriber> subscriber) { 77 | try { 78 | subscriber.onNext(DbUtil.getAllOperatorsService() 79 | .query("where operators_id=?", new String[]{String.valueOf(parent_id)})); 80 | subscriber.onCompleted(); 81 | } catch (Exception e) { 82 | subscriber.onError(e); 83 | } 84 | 85 | } 86 | }).subscribeOn(Schedulers.io()) 87 | .observeOn(AndroidSchedulers.mainThread()) 88 | .subscribe(new Action1>() { 89 | @Override 90 | public void call(List operatorses) { 91 | mContentLists.clear(); 92 | mContentLists.addAll(operatorses); 93 | initContentAdapter(); 94 | } 95 | }); 96 | 97 | } 98 | 99 | private void initContentRecyclerView() { 100 | LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); 101 | mContentRecyclerView.setLayoutManager(manager); 102 | mContentRecyclerView.setHasFixedSize(true); 103 | if (mList != null && mList.size() > 0) { 104 | getAllOperatorById(mList.get(0).getOuter_id()); 105 | } 106 | 107 | } 108 | 109 | private void initContentAdapter() { 110 | if (mContentAdapter == null) { 111 | mContentAdapter = new BaseAdapter() { 112 | @Override 113 | protected void onBindView(BaseViewHolder holder, final int position) { 114 | 115 | ImageView iv = holder.getView(R.id.item_content_iv); 116 | TextView title = holder.getView(R.id.item_content_title); 117 | TextView desc = holder.getView(R.id.item_content_desc); 118 | TextView thread = holder.getView(R.id.item_content_thread); 119 | if (TextUtils.isEmpty(mContentLists.get(position).getThread())) { 120 | thread.setText("默认线程"); 121 | } else { 122 | thread.setText(mContentLists.get(position).getThread()); 123 | } 124 | title.setText(mContentLists.get(position).getName()); 125 | desc.setText(mContentLists.get(position).getDesc()); 126 | ImageLoader.getInstance().displayImage(mContentLists.get(position).getImg(), iv); 127 | iv.setClickable(true); 128 | iv.setOnClickListener(new View.OnClickListener() { 129 | @Override 130 | public void onClick(View v) { 131 | showImgFullScreen(position); 132 | } 133 | }); 134 | } 135 | 136 | @Override 137 | protected int getLayoutID(int position) { 138 | return R.layout.item_index_content; 139 | } 140 | 141 | @Override 142 | public int getItemCount() { 143 | return mContentLists.size(); 144 | } 145 | }; 146 | mContentAdapter.setOnItemClickListener(new OnItemClickListener() { 147 | @Override 148 | public void onItemClick(int position) { 149 | Bundle bundle = new Bundle(); 150 | bundle.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mContentLists.get(position).getName()); 151 | bundle.putString(BaseWebActivity.BUNDLE_KEY_URL, mContentLists.get(position).getUrl()); 152 | bundle.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true); 153 | readyGo(BaseWebActivity.class, bundle); 154 | 155 | } 156 | }); 157 | mContentRecyclerView.setAdapter(mContentAdapter); 158 | } else { 159 | mContentRecyclerView.getLayoutManager().scrollToPosition(0); 160 | mContentAdapter.notifyDataSetChanged(); 161 | } 162 | } 163 | 164 | private void initNavRecycerView() { 165 | 166 | LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); 167 | mNavRecyclerView.setLayoutManager(manager); 168 | mNavRecyclerView.setHasFixedSize(true); 169 | 170 | Observable.create(new Observable.OnSubscribe>() { 171 | @Override 172 | public void call(Subscriber> subscriber) { 173 | try { 174 | subscriber.onNext(DbUtil.getOperatorsService().queryAll()); 175 | subscriber.onCompleted(); 176 | } catch (Exception e) { 177 | subscriber.onError(e); 178 | } 179 | 180 | } 181 | }).subscribeOn(Schedulers.io()) 182 | .observeOn(AndroidSchedulers.mainThread()) 183 | .subscribe(new Action1>() { 184 | @Override 185 | public void call(List operatorses) { 186 | mList.clear(); 187 | mList.addAll(operatorses); 188 | initAdapter(); 189 | initContentRecyclerView(); 190 | } 191 | }); 192 | 193 | 194 | } 195 | 196 | private void initAdapter() { 197 | 198 | mAdapter = new BaseAdapter() { 199 | @Override 200 | public int getItemCount() { 201 | return mList.size(); 202 | } 203 | 204 | @Override 205 | protected void onBindView(BaseViewHolder holder, int position) { 206 | TextView tv = holder.getView(R.id.item_nav_head_v); 207 | tv.setText(mList.get(position).getName()); 208 | if (position == checkedPosition) { 209 | tv.setBackgroundColor(getResources().getColor(R.color._eeeeee)); 210 | } else { 211 | tv.setBackgroundColor(getResources().getColor(R.color.white)); 212 | } 213 | } 214 | 215 | @Override 216 | protected int getLayoutID(int position) { 217 | return R.layout.item_nav_head; 218 | } 219 | }; 220 | mAdapter.setOnItemClickListener(new OnItemClickListener() { 221 | @Override 222 | public void onItemClick(int position) { 223 | checkedPosition = position; 224 | mAdapter.notifyDataSetChanged(); 225 | getAllOperatorById(mList.get(position).getOuter_id()); 226 | if (drawer.isDrawerOpen(GravityCompat.START)) { 227 | drawer.closeDrawer(GravityCompat.START); 228 | } 229 | } 230 | }); 231 | mNavRecyclerView.setAdapter(mAdapter); 232 | } 233 | 234 | 235 | @Override 236 | protected int getContentViewLayoutID() { 237 | return R.layout.activity_main; 238 | } 239 | 240 | private void initNavigationView() { 241 | drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 242 | toggle = new ActionBarDrawerToggle( 243 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 244 | drawer.setDrawerListener(toggle); 245 | toggle.syncState(); 246 | 247 | navigationView = (NavigationView) findViewById(R.id.nav_view); 248 | 249 | mHeadView = (LinearLayout) navigationView.getHeaderView(0); 250 | mNavRecyclerView = (RecyclerView) navigationView.getHeaderView(0).findViewById(R.id.index_nav_recycler); 251 | mHeadView.setClickable(true); 252 | mHeadView.setOnClickListener(this); 253 | 254 | } 255 | 256 | private void initToolBar() { 257 | toolbar = (Toolbar) findViewById(R.id.common_toolbar); 258 | setSupportActionBar(toolbar); 259 | } 260 | 261 | @Override 262 | public void onBackPressed() { 263 | if (drawer.isDrawerOpen(GravityCompat.START)) { 264 | drawer.closeDrawer(GravityCompat.START); 265 | } else { 266 | super.onBackPressed(); 267 | } 268 | } 269 | 270 | @Override 271 | protected void onDestroy() { 272 | super.onDestroy(); 273 | } 274 | 275 | @Override 276 | public boolean onCreateOptionsMenu(Menu menu) { 277 | getMenuInflater().inflate(R.menu.main, menu); 278 | return true; 279 | } 280 | 281 | @Override 282 | public boolean onOptionsItemSelected(MenuItem item) { 283 | switch (item.getItemId()) { 284 | case R.id.about: 285 | Bundle bundle = new Bundle(); 286 | bundle.putString(BaseWebActivity.BUNDLE_KEY_URL, "https://github.com/jiang111?tab=repositories"); 287 | bundle.putString(BaseWebActivity.BUNDLE_KEY_TITLE, "关于"); 288 | bundle.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true); 289 | readyGo(BaseWebActivity.class, bundle); 290 | break; 291 | case R.id.share: 292 | shareText(item.getActionView()); 293 | break; 294 | case R.id.mark: 295 | try { 296 | Intent viewIntent = new Intent("android.intent.action.VIEW", 297 | Uri.parse("market://details?id=" + getPackageName())); 298 | startActivity(viewIntent); 299 | } catch (Exception e) { 300 | e.printStackTrace(); 301 | toast("手机未安装应用市场"); 302 | } 303 | } 304 | 305 | 306 | return super.onOptionsItemSelected(item); 307 | } 308 | 309 | private void toast(String str) { 310 | Toast.makeText(this, str, Toast.LENGTH_SHORT).show(); 311 | } 312 | 313 | public void shareText(View view) { 314 | Intent shareIntent = new Intent(); 315 | shareIntent.setAction(Intent.ACTION_SEND); 316 | shareIntent.putExtra(Intent.EXTRA_TEXT, "Hi,我正在学习RxJava,推荐你下载这个app一起学习吧 到应用商店或者https://github.com/jiang111/RxJavaApp/releases即可下载"); 317 | shareIntent.setType("text/plain"); 318 | startActivity(Intent.createChooser(shareIntent, "分享到")); 319 | } 320 | 321 | @Override 322 | public void onClick(View v) { 323 | switch (v.getId()) { 324 | case R.id.index_head: 325 | Bundle bundle = new Bundle(); 326 | bundle.putString(BaseWebActivity.BUNDLE_KEY_URL, CommonString.GITHUB_URL); 327 | bundle.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true); 328 | bundle.putString(BaseWebActivity.BUNDLE_KEY_TITLE, getString(R.string.github)); 329 | readyGo(BaseWebActivity.class, bundle); 330 | break; 331 | } 332 | } 333 | 334 | 335 | public void showImgFullScreen(int pos) { 336 | if (photos == null) { 337 | photos = new ArrayList<>(); 338 | } 339 | if (photos.size() != mContentLists.size()) { 340 | photos.clear(); 341 | for (int i = 0; i < mContentLists.size(); i++) { 342 | photos.add(mContentLists.get(i).getImg()); 343 | } 344 | } 345 | Bundle bundle = new Bundle(); 346 | bundle.putStringArrayList("files", photos); 347 | bundle.putInt("position", pos); 348 | readyGo(PhotoPagerActivity.class, bundle); 349 | 350 | } 351 | 352 | 353 | } 354 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/activity/PhotoPagerActivity.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.activity; 2 | 3 | import android.support.v4.view.PagerAdapter; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import com.jiang.android.rxjavaapp.R; 8 | import com.jiang.android.rxjavaapp.base.BaseActivity; 9 | import com.jiang.android.rxjavaapp.widget.HackyViewPager; 10 | import com.nostra13.universalimageloader.core.ImageLoader; 11 | 12 | import java.util.ArrayList; 13 | 14 | import uk.co.senab.photoview.PhotoView; 15 | 16 | 17 | public class PhotoPagerActivity extends BaseActivity { 18 | 19 | HackyViewPager viewPager; 20 | 21 | private ArrayList photos; 22 | private int position; 23 | 24 | void initViews() { 25 | photos = getIntent().getStringArrayListExtra("files"); 26 | position = getIntent().getIntExtra("position", 0); 27 | viewPager.setAdapter(new SamplePagerAdapter()); 28 | viewPager.setCurrentItem(position); 29 | } 30 | @Override 31 | protected void initViewsAndEvents() { 32 | viewPager = (HackyViewPager) findViewById(R.id.photo_view_pager); 33 | initViews(); 34 | 35 | } 36 | 37 | @Override 38 | protected int getContentViewLayoutID() { 39 | return R.layout.activity_photoview; 40 | } 41 | 42 | class SamplePagerAdapter extends PagerAdapter { 43 | @Override 44 | public int getCount() { 45 | return photos.size(); 46 | } 47 | 48 | @Override 49 | public Object instantiateItem(ViewGroup container, int position) { 50 | PhotoView photoView = new PhotoView(container.getContext()); 51 | ImageLoader.getInstance().displayImage(photos.get(position), photoView); 52 | container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 53 | return photoView; 54 | } 55 | 56 | @Override 57 | public void destroyItem(ViewGroup container, int position, Object object) { 58 | container.removeView((View) object); 59 | } 60 | 61 | @Override 62 | public boolean isViewFromObject(View view, Object object) { 63 | return view == object; 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/adapter/BaseAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 12/3/15 3 | * Copyright (c) 2015, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.adapter; 30 | 31 | import android.support.v7.widget.RecyclerView; 32 | import android.view.LayoutInflater; 33 | import android.view.View; 34 | import android.view.ViewGroup; 35 | 36 | import com.jiang.android.rxjavaapp.adapter.holder.BaseViewHolder; 37 | import com.jiang.android.rxjavaapp.adapter.inter.OnItemClickListener; 38 | 39 | 40 | /** 41 | * Created by jiang on 2/19/16. 42 | */ 43 | public abstract class BaseAdapter extends RecyclerView.Adapter { 44 | 45 | 46 | private OnItemClickListener onItemClickListener; 47 | 48 | @Override 49 | public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 50 | return new BaseViewHolder(LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false)); 51 | } 52 | 53 | @Override 54 | public void onBindViewHolder(final BaseViewHolder holder, final int position) { 55 | 56 | 57 | if (onItemClickListener != null) { 58 | holder.getmConvertView().setClickable(true); 59 | holder.getmConvertView().setOnClickListener(new View.OnClickListener() { 60 | @Override 61 | public void onClick(View v) { 62 | onItemClickListener.onItemClick(holder.getAdapterPosition()); 63 | } 64 | }); 65 | } 66 | onBindView(holder, holder.getAdapterPosition()); 67 | 68 | } 69 | 70 | protected abstract void onBindView(BaseViewHolder holder, int position); 71 | 72 | @Override 73 | public int getItemViewType(int position) { 74 | return getLayoutID(position); 75 | } 76 | 77 | 78 | protected abstract int getLayoutID(int position); 79 | 80 | 81 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) { 82 | this.onItemClickListener = onItemClickListener; 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/adapter/fragmentadapter/FragmentPagerAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/2/28 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.adapter.fragmentadapter; 30 | 31 | import android.annotation.TargetApi; 32 | import android.app.Fragment; 33 | import android.app.FragmentManager; 34 | import android.app.FragmentTransaction; 35 | import android.os.Build; 36 | import android.os.Parcelable; 37 | import android.util.Log; 38 | import android.view.View; 39 | import android.view.ViewGroup; 40 | 41 | /** 42 | * Created by jiang on 16/2/28. 43 | */ 44 | public abstract class FragmentPagerAdapter extends PagerAdapter { 45 | 46 | private static final String TAG = "FragmentPagerAdapter"; 47 | private static final boolean DEBUG = false; 48 | 49 | private final FragmentManager mFragmentManager; 50 | private FragmentTransaction mCurTransaction = null; 51 | private Fragment mCurrentPrimaryItem = null; 52 | 53 | public FragmentPagerAdapter(FragmentManager fm) { 54 | mFragmentManager = fm; 55 | } 56 | 57 | /** 58 | * Return the Fragment associated with a specified position. 59 | */ 60 | public abstract Fragment getItem(int position); 61 | 62 | @Override 63 | public void startUpdate(ViewGroup container) { 64 | } 65 | 66 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) 67 | @Override 68 | public Object instantiateItem(ViewGroup container, int position) { 69 | if (mCurTransaction == null) { 70 | mCurTransaction = mFragmentManager.beginTransaction(); 71 | } 72 | 73 | final long itemId = getItemId(position); 74 | 75 | // Do we already have this fragment? 76 | String name = makeFragmentName(container.getId(), itemId); 77 | Fragment fragment = mFragmentManager.findFragmentByTag(name); 78 | if (fragment != null) { 79 | if (DEBUG) Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment); 80 | mCurTransaction.attach(fragment); 81 | } else { 82 | fragment = getItem(position); 83 | if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment); 84 | mCurTransaction.add(container.getId(), fragment, 85 | makeFragmentName(container.getId(), itemId)); 86 | } 87 | if (fragment != mCurrentPrimaryItem) { 88 | fragment.setMenuVisibility(false); 89 | fragment.setUserVisibleHint(false); 90 | } 91 | 92 | return fragment; 93 | } 94 | 95 | @Override 96 | public void destroyItem(ViewGroup container, int position, Object object) { 97 | if (mCurTransaction == null) { 98 | mCurTransaction = mFragmentManager.beginTransaction(); 99 | } 100 | if (DEBUG) Log.v(TAG, "Detaching item #" + getItemId(position) + ": f=" + object 101 | + " v=" + ((Fragment) object).getView()); 102 | mCurTransaction.detach((Fragment) object); 103 | } 104 | 105 | @Override 106 | public void setPrimaryItem(ViewGroup container, int position, Object object) { 107 | Fragment fragment = (Fragment) object; 108 | if (fragment != mCurrentPrimaryItem) { 109 | if (mCurrentPrimaryItem != null) { 110 | mCurrentPrimaryItem.setMenuVisibility(false); 111 | mCurrentPrimaryItem.setUserVisibleHint(false); 112 | } 113 | if (fragment != null) { 114 | fragment.setMenuVisibility(true); 115 | fragment.setUserVisibleHint(true); 116 | } 117 | mCurrentPrimaryItem = fragment; 118 | } 119 | } 120 | 121 | @Override 122 | public void finishUpdate(ViewGroup container) { 123 | if (mCurTransaction != null) { 124 | mCurTransaction.commitAllowingStateLoss(); 125 | mCurTransaction = null; 126 | mFragmentManager.executePendingTransactions(); 127 | } 128 | } 129 | 130 | @Override 131 | public boolean isViewFromObject(View view, Object object) { 132 | return ((Fragment) object).getView() == view; 133 | } 134 | 135 | @Override 136 | public Parcelable saveState() { 137 | return null; 138 | } 139 | 140 | @Override 141 | public void restoreState(Parcelable state, ClassLoader loader) { 142 | } 143 | 144 | /** 145 | * Return a unique identifier for the item at the given position. 146 | *

147 | *

The default implementation returns the given position. 148 | * Subclasses should override this method if the positions of items can change.

149 | * 150 | * @param position Position within this adapter 151 | * @return Unique identifier for the item at position 152 | */ 153 | public long getItemId(int position) { 154 | return position; 155 | } 156 | 157 | private static String makeFragmentName(int viewId, long id) { 158 | return "android:switcher:" + viewId + ":" + id; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/adapter/fragmentadapter/PagerAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/2/28 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.adapter.fragmentadapter; 30 | 31 | import android.database.DataSetObservable; 32 | import android.database.DataSetObserver; 33 | import android.os.Parcelable; 34 | import android.view.View; 35 | import android.view.ViewGroup; 36 | 37 | /** 38 | * Created by jiang on 16/2/28. 39 | */ 40 | public abstract class PagerAdapter { 41 | 42 | 43 | private DataSetObservable mObservable = new DataSetObservable(); 44 | 45 | public static final int POSITION_UNCHANGED = -1; 46 | public static final int POSITION_NONE = -2; 47 | 48 | /** 49 | * Return the number of views available. 50 | */ 51 | public abstract int getCount(); 52 | 53 | /** 54 | * Called when a change in the shown pages is going to start being made. 55 | * 56 | * @param container The containing View which is displaying this adapter's 57 | * page views. 58 | */ 59 | public void startUpdate(ViewGroup container) { 60 | startUpdate((View) container); 61 | } 62 | 63 | /** 64 | * Create the page for the given position. The adapter is responsible 65 | * for adding the view to the container given here, although it only 66 | * must ensure this is done by the time it returns from 67 | * {@link #finishUpdate(ViewGroup)}. 68 | * 69 | * @param container The containing View in which the page will be shown. 70 | * @param position The page position to be instantiated. 71 | * @return Returns an Object representing the new page. This does not 72 | * need to be a View, but can be some other container of the page. 73 | */ 74 | public Object instantiateItem(ViewGroup container, int position) { 75 | return instantiateItem((View) container, position); 76 | } 77 | 78 | /** 79 | * Remove a page for the given position. The adapter is responsible 80 | * for removing the view from its container, although it only must ensure 81 | * this is done by the time it returns from {@link #finishUpdate(ViewGroup)}. 82 | * 83 | * @param container The containing View from which the page will be removed. 84 | * @param position The page position to be removed. 85 | * @param object The same object that was returned by 86 | * {@link #instantiateItem(View, int)}. 87 | */ 88 | public void destroyItem(ViewGroup container, int position, Object object) { 89 | destroyItem((View) container, position, object); 90 | } 91 | 92 | /** 93 | * Called to inform the adapter of which item is currently considered to 94 | * be the "primary", that is the one show to the user as the current page. 95 | * 96 | * @param container The containing View from which the page will be removed. 97 | * @param position The page position that is now the primary. 98 | * @param object The same object that was returned by 99 | * {@link #instantiateItem(View, int)}. 100 | */ 101 | public void setPrimaryItem(ViewGroup container, int position, Object object) { 102 | setPrimaryItem((View) container, position, object); 103 | } 104 | 105 | /** 106 | * Called when the a change in the shown pages has been completed. At this 107 | * point you must ensure that all of the pages have actually been added or 108 | * removed from the container as appropriate. 109 | * 110 | * @param container The containing View which is displaying this adapter's 111 | * page views. 112 | */ 113 | public void finishUpdate(ViewGroup container) { 114 | finishUpdate((View) container); 115 | } 116 | 117 | /** 118 | * Called when a change in the shown pages is going to start being made. 119 | * 120 | * @param container The containing View which is displaying this adapter's 121 | * page views. 122 | * @deprecated Use {@link #startUpdate(ViewGroup)} 123 | */ 124 | public void startUpdate(View container) { 125 | } 126 | 127 | /** 128 | * Create the page for the given position. The adapter is responsible 129 | * for adding the view to the container given here, although it only 130 | * must ensure this is done by the time it returns from 131 | * {@link #finishUpdate(ViewGroup)}. 132 | * 133 | * @param container The containing View in which the page will be shown. 134 | * @param position The page position to be instantiated. 135 | * @return Returns an Object representing the new page. This does not 136 | * need to be a View, but can be some other container of the page. 137 | * @deprecated Use {@link #instantiateItem(ViewGroup, int)} 138 | */ 139 | public Object instantiateItem(View container, int position) { 140 | throw new UnsupportedOperationException( 141 | "Required method instantiateItem was not overridden"); 142 | } 143 | 144 | /** 145 | * Remove a page for the given position. The adapter is responsible 146 | * for removing the view from its container, although it only must ensure 147 | * this is done by the time it returns from {@link #finishUpdate(View)}. 148 | * 149 | * @param container The containing View from which the page will be removed. 150 | * @param position The page position to be removed. 151 | * @param object The same object that was returned by 152 | * {@link #instantiateItem(View, int)}. 153 | * @deprecated Use {@link #destroyItem(ViewGroup, int, Object)} 154 | */ 155 | public void destroyItem(View container, int position, Object object) { 156 | throw new UnsupportedOperationException("Required method destroyItem was not overridden"); 157 | } 158 | 159 | /** 160 | * Called to inform the adapter of which item is currently considered to 161 | * be the "primary", that is the one show to the user as the current page. 162 | * 163 | * @param container The containing View from which the page will be removed. 164 | * @param position The page position that is now the primary. 165 | * @param object The same object that was returned by 166 | * {@link #instantiateItem(View, int)}. 167 | * @deprecated Use {@link #setPrimaryItem(ViewGroup, int, Object)} 168 | */ 169 | public void setPrimaryItem(View container, int position, Object object) { 170 | } 171 | 172 | /** 173 | * Called when the a change in the shown pages has been completed. At this 174 | * point you must ensure that all of the pages have actually been added or 175 | * removed from the container as appropriate. 176 | * 177 | * @param container The containing View which is displaying this adapter's 178 | * page views. 179 | * @deprecated Use {@link #finishUpdate(ViewGroup)} 180 | */ 181 | public void finishUpdate(View container) { 182 | } 183 | 184 | /** 185 | * Determines whether a page View is associated with a specific key object 186 | * as returned by {@link #instantiateItem(ViewGroup, int)}. This method is 187 | * required for a PagerAdapter to function properly. 188 | * 189 | * @param view Page View to check for association with object 190 | * @param object Object to check for association with view 191 | * @return true if view is associated with the key object object 192 | */ 193 | public abstract boolean isViewFromObject(View view, Object object); 194 | 195 | /** 196 | * Save any instance state associated with this adapter and its pages that should be 197 | * restored if the current UI state needs to be reconstructed. 198 | * 199 | * @return Saved state for this adapter 200 | */ 201 | public Parcelable saveState() { 202 | return null; 203 | } 204 | 205 | /** 206 | * Restore any instance state associated with this adapter and its pages 207 | * that was previously saved by {@link #saveState()}. 208 | * 209 | * @param state State previously saved by a call to {@link #saveState()} 210 | * @param loader A ClassLoader that should be used to instantiate any restored objects 211 | */ 212 | public void restoreState(Parcelable state, ClassLoader loader) { 213 | } 214 | 215 | /** 216 | * Called when the host view is attempting to determine if an item's position 217 | * has changed. Returns {@link #POSITION_UNCHANGED} if the position of the given 218 | * item has not changed or {@link #POSITION_NONE} if the item is no longer present 219 | * in the adapter. 220 | *

221 | *

The default implementation assumes that items will never 222 | * change position and always returns {@link #POSITION_UNCHANGED}. 223 | * 224 | * @param object Object representing an item, previously returned by a call to 225 | * {@link #instantiateItem(View, int)}. 226 | * @return object's new position index from [0, {@link #getCount()}), 227 | * {@link #POSITION_UNCHANGED} if the object's position has not changed, 228 | * or {@link #POSITION_NONE} if the item is no longer present. 229 | */ 230 | public int getItemPosition(Object object) { 231 | return POSITION_UNCHANGED; 232 | } 233 | 234 | /** 235 | * This method should be called by the application if the data backing this adapter has changed 236 | * and associated views should update. 237 | */ 238 | public void notifyDataSetChanged() { 239 | mObservable.notifyChanged(); 240 | } 241 | 242 | /** 243 | * Register an observer to receive callbacks related to the adapter's data changing. 244 | * 245 | * @param observer The {@link DataSetObserver} which will receive callbacks. 246 | */ 247 | public void registerDataSetObserver(DataSetObserver observer) { 248 | mObservable.registerObserver(observer); 249 | } 250 | 251 | /** 252 | * Unregister an observer from callbacks related to the adapter's data changing. 253 | * 254 | * @param observer The {@link DataSetObserver} which will be unregistered. 255 | */ 256 | public void unregisterDataSetObserver(DataSetObserver observer) { 257 | mObservable.unregisterObserver(observer); 258 | } 259 | 260 | /** 261 | * This method may be called by the ViewPager to obtain a title string 262 | * to describe the specified page. This method may return null 263 | * indicating no title for this page. The default implementation returns 264 | * null. 265 | * 266 | * @param position The position of the title requested 267 | * @return A title for the requested page 268 | */ 269 | public CharSequence getPageTitle(int position) { 270 | return null; 271 | } 272 | 273 | /** 274 | * Returns the proportional width of a given page as a percentage of the 275 | * ViewPager's measured width from (0.f-1.f] 276 | * 277 | * @param position The position of the page requested 278 | * @return Proportional width for the given page position 279 | */ 280 | public float getPageWidth(int position) { 281 | return 1.f; 282 | } 283 | } 284 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/adapter/holder/BaseViewHolder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 12/3/15 3 | * Copyright (c) 2015, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.adapter.holder; 30 | 31 | import android.support.annotation.IdRes; 32 | import android.support.v7.widget.RecyclerView; 33 | import android.util.SparseArray; 34 | import android.view.View; 35 | 36 | /** 37 | * Created by jiang on 12/3/15. 38 | */ 39 | public class BaseViewHolder extends RecyclerView.ViewHolder { 40 | 41 | protected final SparseArray mViews; 42 | protected View mConvertView; 43 | 44 | 45 | public BaseViewHolder(View itemView) { 46 | super(itemView); 47 | mViews = new SparseArray<>(); 48 | mConvertView = itemView; 49 | } 50 | 51 | 52 | /** 53 | * 通过控件的Id获取对应的控件,如果没有则加入mViews,则从item根控件中查找并保存到mViews中 54 | * 55 | * @param viewId 56 | * @return 57 | */ 58 | public T getView(@IdRes int viewId) { 59 | View view = mViews.get(viewId); 60 | if (view == null) { 61 | view = mConvertView.findViewById(viewId); 62 | mViews.put(viewId, view); 63 | } 64 | return (T) view; 65 | } 66 | 67 | public View getmConvertView() { 68 | return mConvertView; 69 | } 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/adapter/inter/OnItemClickListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 12/3/15 3 | * Copyright (c) 2015, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | package com.jiang.android.rxjavaapp.adapter.inter; 29 | 30 | /** 31 | * Created by jiang on 12/3/15. 32 | */ 33 | public interface OnItemClickListener { 34 | 35 | void onItemClick(int position); 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.base; 30 | 31 | import android.content.Intent; 32 | import android.os.Bundle; 33 | import android.support.annotation.Nullable; 34 | import android.support.design.widget.Snackbar; 35 | import android.support.v7.app.AppCompatActivity; 36 | import android.text.TextUtils; 37 | import android.view.View; 38 | 39 | /** 40 | * Created by jiang on 16/3/13. 41 | */ 42 | public abstract class BaseActivity extends AppCompatActivity { 43 | 44 | @Override 45 | protected void onCreate(@Nullable Bundle savedInstanceState) { 46 | super.onCreate(savedInstanceState); 47 | BaseAppManager.getInstance().addActivity(this); 48 | 49 | Bundle extras = getIntent().getExtras(); 50 | if (null != extras) { 51 | getBundleExtras(extras); 52 | } 53 | if (getContentViewLayoutID() != 0) { 54 | setContentView(getContentViewLayoutID()); 55 | } else { 56 | throw new IllegalArgumentException("You must return a right contentView layout resource Id"); 57 | } 58 | initViewsAndEvents(); 59 | 60 | } 61 | 62 | protected void getBundleExtras(Bundle extras) { 63 | } 64 | 65 | @Override 66 | public void setContentView(int layoutResID) { 67 | super.setContentView(layoutResID); 68 | 69 | 70 | } 71 | 72 | 73 | 74 | @Override 75 | public void finish() { 76 | super.finish(); 77 | BaseAppManager.getInstance().removeActivity(this); 78 | } 79 | 80 | 81 | /** 82 | * startActivity 83 | * 84 | * @param clazz 85 | */ 86 | protected void readyGo(Class clazz) { 87 | Intent intent = new Intent(this, clazz); 88 | startActivity(intent); 89 | } 90 | 91 | /** 92 | * startActivity with bundle 93 | * 94 | * @param clazz 95 | * @param bundle 96 | */ 97 | protected void readyGo(Class clazz, Bundle bundle) { 98 | Intent intent = new Intent(this, clazz); 99 | if (null != bundle) { 100 | intent.putExtras(bundle); 101 | } 102 | startActivity(intent); 103 | } 104 | 105 | /** 106 | * startActivity then finish 107 | * 108 | * @param clazz 109 | */ 110 | protected void readyGoThenKill(Class clazz) { 111 | Intent intent = new Intent(this, clazz); 112 | startActivity(intent); 113 | finish(); 114 | } 115 | 116 | /** 117 | * startActivity with bundle then finish 118 | * 119 | * @param clazz 120 | * @param bundle 121 | */ 122 | protected void readyGoThenKill(Class clazz, Bundle bundle) { 123 | Intent intent = new Intent(this, clazz); 124 | if (null != bundle) { 125 | intent.putExtras(bundle); 126 | } 127 | startActivity(intent); 128 | finish(); 129 | } 130 | 131 | /** 132 | * startActivityForResult 133 | * 134 | * @param clazz 135 | * @param requestCode 136 | */ 137 | protected void readyGoForResult(Class clazz, int requestCode) { 138 | Intent intent = new Intent(this, clazz); 139 | startActivityForResult(intent, requestCode); 140 | } 141 | 142 | /** 143 | * startActivityForResult with bundle 144 | * 145 | * @param clazz 146 | * @param requestCode 147 | * @param bundle 148 | */ 149 | protected void readyGoForResult(Class clazz, int requestCode, Bundle bundle) { 150 | Intent intent = new Intent(this, clazz); 151 | if (null != bundle) { 152 | intent.putExtras(bundle); 153 | } 154 | startActivityForResult(intent, requestCode); 155 | } 156 | 157 | /** 158 | * show toast 159 | * 160 | * @param msg 161 | */ 162 | protected void showToast(View v, String msg) { 163 | //防止遮盖虚拟按键 164 | if (null != msg && !TextUtils.isEmpty(msg)) { 165 | Snackbar.make(v, msg, Snackbar.LENGTH_SHORT).show(); 166 | } 167 | } 168 | 169 | 170 | protected abstract void initViewsAndEvents(); 171 | 172 | protected abstract int getContentViewLayoutID(); 173 | 174 | } 175 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/base/BaseAppManager.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jiang.android.rxjavaapp.base; 3 | 4 | import android.app.Activity; 5 | 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | 9 | 10 | public class BaseAppManager { 11 | 12 | private static final String TAG = BaseAppManager.class.getSimpleName(); 13 | 14 | private static BaseAppManager instance = null; 15 | private static List mActivities = new LinkedList(); 16 | 17 | private BaseAppManager() { 18 | 19 | } 20 | 21 | public static BaseAppManager getInstance() { 22 | if (null == instance) { 23 | synchronized (BaseAppManager.class) { 24 | if (null == instance) { 25 | instance = new BaseAppManager(); 26 | } 27 | } 28 | } 29 | return instance; 30 | } 31 | 32 | public int size() { 33 | return mActivities.size(); 34 | } 35 | 36 | public synchronized Activity getForwardActivity() { 37 | return size() > 0 ? mActivities.get(size() - 1) : null; 38 | } 39 | 40 | public synchronized void addActivity(Activity activity) { 41 | mActivities.add(activity); 42 | } 43 | 44 | public synchronized void removeActivity(Activity activity) { 45 | if (mActivities.contains(activity)) { 46 | mActivities.remove(activity); 47 | } 48 | } 49 | 50 | public synchronized void clear() { 51 | for (int i = mActivities.size() - 1; i > -1; i--) { 52 | Activity activity = mActivities.get(i); 53 | removeActivity(activity); 54 | activity.finish(); 55 | i = mActivities.size(); 56 | } 57 | } 58 | 59 | public synchronized void clearToTop() { 60 | for (int i = mActivities.size() - 2; i > -1; i--) { 61 | Activity activity = mActivities.get(i); 62 | removeActivity(activity); 63 | activity.finish(); 64 | i = mActivities.size() - 1; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/base/BaseWebActivity.java: -------------------------------------------------------------------------------- 1 | 2 | package com.jiang.android.rxjavaapp.base; 3 | 4 | import android.os.Bundle; 5 | import android.support.v7.widget.Toolbar; 6 | import android.text.TextUtils; 7 | import android.view.View; 8 | 9 | import com.jiang.android.rxjavaapp.R; 10 | import com.jiang.android.rxjavaapp.widget.BrowserLayout; 11 | 12 | 13 | public class BaseWebActivity extends BaseActivity { 14 | 15 | public static final String BUNDLE_KEY_URL = "BUNDLE_KEY_URL"; 16 | public static final String BUNDLE_KEY_TITLE = "BUNDLE_KEY_TITLE"; 17 | public static final String BUNDLE_KEY_SHOW_BOTTOM_BAR = "BUNDLE_KEY_SHOW_BOTTOM_BAR"; 18 | 19 | private String mWebUrl = null; 20 | private String mWebTitle = null; 21 | private boolean isShowBottomBar = true; 22 | 23 | private Toolbar mToolBar = null; 24 | private BrowserLayout mBrowserLayout = null; 25 | 26 | 27 | protected void getBundleExtras(Bundle extras) { 28 | mWebTitle = extras.getString(BUNDLE_KEY_TITLE); 29 | mWebUrl = extras.getString(BUNDLE_KEY_URL); 30 | isShowBottomBar = extras.getBoolean(BUNDLE_KEY_SHOW_BOTTOM_BAR); 31 | } 32 | 33 | @Override 34 | protected int getContentViewLayoutID() { 35 | return R.layout.activity_common_web; 36 | } 37 | 38 | 39 | @Override 40 | protected void initViewsAndEvents() { 41 | mToolBar = (Toolbar) findViewById(R.id.common_toolbar); 42 | mBrowserLayout = (BrowserLayout) findViewById(R.id.common_web_browser_layout); 43 | 44 | if (null != mToolBar) { 45 | setSupportActionBar(mToolBar); 46 | getSupportActionBar().setHomeButtonEnabled(true); 47 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 48 | mToolBar.setNavigationOnClickListener(new View.OnClickListener() { 49 | @Override 50 | public void onClick(View v) { 51 | BaseWebActivity.this.finish(); 52 | } 53 | }); 54 | } 55 | 56 | if (!TextUtils.isEmpty(mWebTitle)) { 57 | setTitle(mWebTitle); 58 | } else { 59 | setTitle("网页"); 60 | } 61 | 62 | if (!TextUtils.isEmpty(mWebUrl)) { 63 | mBrowserLayout.loadUrl(mWebUrl); 64 | } else { 65 | showToast(mBrowserLayout, "获取URL地址失败"); 66 | } 67 | 68 | if (!isShowBottomBar) { 69 | mBrowserLayout.hideBrowserController(); 70 | } else { 71 | mBrowserLayout.showBrowserController(); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/common/CommonString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.common; 30 | 31 | /** 32 | * Created by jiang on 16/3/13. 33 | */ 34 | public class CommonString { 35 | public static final String SPLASH_INDEX_URL = "https://raw.githubusercontent.com/jiang111/jiang111.github.io/master/images/rxjava_app_launcher.png"; 36 | public static final String GITHUB_URL = "https://github.com/jiang111/RxJavaApp"; 37 | public static final String OBSERVABLES = "https://github.com/jiang111/RxDocs/raw/master/images/legend.png"; 38 | public static final String SUBJECT = "https://github.com/jiang111/RxDocs/raw/master/images/S.AsyncSubject.png"; 39 | public static final String JUST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/just.png"; 40 | public static final String FROM = "https://github.com/jiang111/RxDocs/raw/master/images/operators/from.png"; 41 | public static final String REPEAT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/repeat.c.png"; 42 | public static final String REPEAT_WHEN = "https://github.com/jiang111/RxDocs/raw/master/images/operators/repeatWhen.f.png"; 43 | public static final String CREATE = "https://github.com/jiang111/RxDocs/raw/master/images/operators/create.c.png"; 44 | public static final String DEFER = "https://github.com/jiang111/RxDocs/raw/master/images/operators/defer.c.png"; 45 | public static final String RANGE = "https://github.com/jiang111/RxDocs/raw/master/images/operators/range.png"; 46 | public static final String INTERVAL = "https://github.com/jiang111/RxDocs/raw/master/images/operators/interval.c.png"; 47 | public static final String TIMER = "https://github.com/jiang111/RxDocs/raw/master/images/operators/timer.p.png"; 48 | public static final String EMPTY = SPLASH_INDEX_URL; 49 | // transd form 50 | public static final String MAP = "https://github.com/jiang111/RxDocs/raw/master/images/operators/map.png"; 51 | public static final String FLATMAP = "https://github.com/jiang111/RxDocs/raw/master/images/operators/flatMap.png"; 52 | public static final String CONTACTMAP = "https://github.com/jiang111/RxDocs/raw/master/images/operators/concatMap.png"; 53 | public static final String SWITCHMAP = "https://github.com/jiang111/RxDocs/raw/master/images/operators/switchMap.png"; 54 | public static final String SCAN = "https://github.com/jiang111/RxDocs/raw/master/images/operators/scan.c.png"; 55 | public static final String GROUPBY = "https://github.com/jiang111/RxDocs/raw/master/images/operators/groupBy.c.png"; 56 | public static final String BUFFER = "https://github.com/jiang111/RxDocs/raw/master/images/operators/buffer.png"; 57 | public static final String WINDOW = "https://github.com/jiang111/RxDocs/raw/master/images/operators/window.C.png"; 58 | public static final String CAST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/cast.png"; 59 | //filter 60 | public static final String FILTER = "https://github.com/jiang111/RxDocs/raw/master/images/operators/filter.c.png"; 61 | public static final String TAKE_LAST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/takeLast.c.png"; 62 | public static final String LAST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/last.c.png"; 63 | public static final String LAST_OR_DEFAULT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/lastOrDefault.p.png"; 64 | public static final String TAKE_LAST_BUFFER = "https://github.com/jiang111/RxDocs/raw/master/images/operators/takeLastBuffer.png"; 65 | public static final String SKIP = "https://github.com/jiang111/RxDocs/raw/master/images/operators/skip.png"; 66 | public static final String SKIP_LAST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/skipLast.c.png"; 67 | public static final String TAKE = "https://github.com/jiang111/RxDocs/raw/master/images/operators/take.c.png"; 68 | public static final String FIRST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/first.c.png"; 69 | public static final String FIRST_DEFAULT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/firstOrDefault.png"; 70 | public static final String ELEMENT_AT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/elementAt.c.png"; 71 | public static final String ELEMENT_DEFAULT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/elementAtOrDefault.png"; 72 | public static final String SAMPLE = "https://github.com/jiang111/RxDocs/raw/master/images/operators/sample.png"; 73 | public static final String THROLFIRST = "https://github.com/jiang111/RxDocs/raw/master/images/operators/throttleFirst.png"; 74 | public static final String DEBOUND = "https://github.com/jiang111/RxDocs/raw/master/images/operators/debounce.png"; 75 | public static final String TIMEOUT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/timeout.c.png"; 76 | public static final String DISTINCT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/distinct.png"; 77 | public static final String UNTILCHANGED = "https://github.com/jiang111/RxDocs/raw/master/images/operators/distinctUntilChanged.png"; 78 | public static final String OF_TYPE = "https://github.com/jiang111/RxDocs/raw/master/images/operators/filter.png"; 79 | public static final String IGNORE_ELEMENT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/ignoreElements.c.png"; 80 | 81 | 82 | //combin 83 | public static final String STARTWITH = "https://github.com/jiang111/RxDocs/raw/master/images/operators/startWith.png"; 84 | public static final String MERGE = "https://github.com/jiang111/RxDocs/raw/master/images/operators/merge.c.png"; 85 | public static final String MERGEDELAY = "https://github.com/jiang111/RxDocs/raw/master/images/operators/mergeDelayError.C.png"; 86 | public static final String ZIP = "https://github.com/jiang111/RxDocs/raw/master/images/operators/zip.c.png"; 87 | public static final String AND = "https://github.com/jiang111/RxDocs/raw/master/images/operators/and_then_when.C.png"; 88 | public static final String COMBINLASTED = "https://github.com/jiang111/RxDocs/raw/master/images/operators/combineLatest.c.png"; 89 | public static final String JOIN = "https://github.com/jiang111/RxDocs/raw/master/images/operators/join.c.png"; 90 | public static final String SWITHONNEXT = "https://github.com/jiang111/RxDocs/raw/master/images/operators/switch.c.png"; 91 | 92 | 93 | //error 94 | public static final String RETRY = "https://github.com/jiang111/RxDocs/raw/master/images/operators/retry.C.png"; 95 | public static final String RETRYWHEN = "https://github.com/jiang111/RxDocs/raw/master/images/operators/retryWhen.f.png"; 96 | 97 | 98 | //utility 99 | public static final String Materialize = "https://github.com/jiang111/RxDocs/raw/master/images/operators/materialize.c.png"; 100 | public static final String Dematerialize = "https://github.com/jiang111/RxDocs/raw/master/images/operators/dematerialize.c.png"; 101 | public static final String Timestamp = "https://github.com/jiang111/RxDocs/raw/master/images/operators/timestamp.c.png"; 102 | public static final String Serialize = "https://github.com/jiang111/RxDocs/raw/master/images/operators/serialize.c.png"; 103 | public static final String ObserveOn = "https://github.com/jiang111/RxDocs/raw/master/images/operators/observeOn.c.png"; 104 | public static final String SubscribeOn = "https://github.com/jiang111/RxDocs/raw/master/images/operators/subscribeOn.c.png"; 105 | public static final String doOnEach = "https://github.com/jiang111/RxDocs/raw/master/images/operators/doOnEach.png"; 106 | public static final String doOnSubscribe = "https://github.com/jiang111/RxDocs/raw/master/images/operators/doOnSubscribe.png"; 107 | public static final String doOnUnsubscribe = "https://github.com/jiang111/RxDocs/raw/master/images/operators/doOnUnsubscribe.png"; 108 | public static final String doOnCompleted = "https://github.com/jiang111/RxDocs/raw/master/images/operators/doOnCompleted.png"; 109 | public static final String doOnError = "https://github.com/jiang111/RxDocs/raw/master/images/operators/doOnError.png"; 110 | public static final String doOnTerminate = "https://github.com/jiang111/RxDocs/raw/master/images/operators/doOnTerminate.png"; 111 | 112 | public static final String finallyDo = "https://github.com/jiang111/RxDocs/raw/master/images/operators/finallyDo.png"; 113 | public static final String Delay = "https://github.com/jiang111/RxDocs/raw/master/images/operators/delay.c.png"; 114 | public static final String delaySubscription = "https://github.com/jiang111/RxDocs/raw/master/images/operators/delaySubscription.o.png"; 115 | public static final String TimeInterval = "https://github.com/jiang111/RxDocs/raw/master/images/operators/timeInterval.c.png"; 116 | public static final String Using = "https://github.com/jiang111/RxDocs/raw/master/images/operators/using.c.png"; 117 | public static final String First = "https://github.com/jiang111/RxDocs/raw/master/images/operators/first.c.png"; 118 | public static final String To = "https://github.com/jiang111/RxDocs/raw/master/images/operators/to.c.png"; 119 | 120 | 121 | //string 122 | public static final String byLine = "https://github.com/jiang111/RxDocs/raw/master/images/operators/St.byLine.png"; 123 | public static final String decode = "https://github.com/jiang111/RxDocs/raw/master/images/operators/St.decode.png"; 124 | public static final String encode = "https://github.com/jiang111/RxDocs/raw/master/images/operators/St.encode.png"; 125 | public static final String from_String = "https://github.com/jiang111/RxDocs/raw/master/images/operators/St.from.png"; 126 | public static final String join = "https://github.com/jiang111/RxDocs/raw/master/images/operators/St.join.png"; 127 | public static final String split = "https://github.com/jiang111/RxDocs/raw/master/images/operators/St.split.png"; 128 | public static final String stringConcat = "https://github.com/jiang111/RxDocs/raw/master/images/operators/sum.f.png"; 129 | 130 | 131 | //conditional 132 | public static final String amb = "https://github.com/jiang111/RxDocs/raw/master/images/operators/amb.c.png"; 133 | public static final String defaultIfEmpty = "https://github.com/jiang111/RxDocs/raw/master/images/operators/defaultIfEmpty.c.png"; 134 | public static final String doWhile = amb; 135 | public static final String ifThen = amb; 136 | public static final String skipUntil = "https://github.com/jiang111/RxDocs/raw/master/images/operators/skipUntil.c.png"; 137 | public static final String skipWhile = "https://github.com/jiang111/RxDocs/raw/master/images/operators/skipWhile.c.png"; 138 | public static final String switchCase = amb; 139 | public static final String takeUntil = "https://github.com/jiang111/RxDocs/raw/master/images/operators/takeUntil.png"; 140 | public static final String takeWhile = "https://github.com/jiang111/RxDocs/raw/master/images/operators/takeWhile.c.png"; 141 | public static final String whileDo = amb; 142 | 143 | //bool 144 | public static final String all = "https://github.com/jiang111/RxDocs/raw/master/images/operators/all.png"; 145 | public static final String contains = "https://github.com/jiang111/RxDocs/raw/master/images/operators/contains.png"; 146 | public static final String exists = "https://github.com/jiang111/RxDocs/raw/master/images/operators/exists.png"; 147 | public static final String sequenceEqual = "https://github.com/jiang111/RxDocs/raw/master/images/operators/sequenceEqual.png"; 148 | 149 | public static final String MATH = "https://github.com/jiang111/RxDocs/raw/master/images/operators/collect.png"; 150 | 151 | 152 | // math other 153 | public static final String concat = "https://github.com/jiang111/RxDocs/raw/master/images/operators/concat.c.png"; 154 | public static final String count = "https://github.com/jiang111/RxDocs/raw/master/images/operators/count.c.png"; 155 | public static final String reduce = "https://github.com/jiang111/RxDocs/raw/master/images/operators/reduce.c.png"; 156 | public static final String collect = "https://github.com/jiang111/RxDocs/raw/master/images/operators/collect.png"; 157 | public static final String toList = "https://github.com/jiang111/RxDocs/raw/master/images/operators/toList.png"; 158 | public static final String toSortedList = "https://github.com/jiang111/RxDocs/raw/master/images/operators/toSortedList.png"; 159 | public static final String toMap = "https://github.com/jiang111/RxDocs/raw/master/images/operators/toMap.png"; 160 | public static final String toMultiMap = "https://github.com/jiang111/RxDocs/raw/master/images/operators/toMultiMap.png"; 161 | 162 | public static String start = "https://github.com/jiang111/RxDocs/raw/master/images/operators/start.png"; 163 | public static String toAsync = "https://github.com/jiang111/RxDocs/raw/master/images/operators/toAsync.png"; 164 | public static String startFuture = "https://github.com/jiang111/RxDocs/raw/master/images/operators/startFuture.png"; 165 | public static String deferFuture = "https://github.com/jiang111/RxDocs/raw/master/images/operators/deferFuture.png"; 166 | public static String forEachFuture = "https://github.com/jiang111/RxDocs/raw/master/images/operators/forEachFuture.png"; 167 | public static String fromAction = start; 168 | public static String runAsync = start; 169 | public static String fromRunnable = "https://github.com/jiang111/RxDocs/raw/master/images/operators/fromRunnable.png"; 170 | public static String fromCallable = "https://github.com/jiang111/RxDocs/raw/master/images/operators/fromCallable.png"; 171 | 172 | //connect 173 | public static String connect = "https://github.com/jiang111/RxDocs/raw/master/images/operators/publishConnect.c.png"; 174 | public static String publish = "https://github.com/jiang111/RxDocs/raw/master/images/operators/publishConnect.c.png"; 175 | public static String replay = "https://github.com/jiang111/RxDocs/raw/master/images/operators/replay.c.png"; 176 | public static String refCount = replay; 177 | 178 | //block 179 | public static String forEach=EMPTY; 180 | public static String first="https://github.com/jiang111/RxDocs/raw/master/images/operators/first.c.png"; 181 | public static String firstOrDefault="https://github.com/jiang111/RxDocs/raw/master/images/operators/firstOrDefault.png"; 182 | public static String last="https://github.com/jiang111/RxDocs/raw/master/images/operators/last.png"; 183 | public static String lastOrDefault="https://github.com/jiang111/RxDocs/raw/master/images/operators/lastOrDefault.png"; 184 | public static String mostRecent="https://github.com/jiang111/RxDocs/raw/master/images/operators/first.png"; 185 | public static String next="https://github.com/jiang111/RxDocs/raw/master/images/operators/takeLast.c.png"; 186 | public static String single="https://github.com/jiang111/RxDocs/raw/master/images/operators/single.p.png"; 187 | public static String singleOrDefault="https://github.com/jiang111/RxDocs/raw/master/images/operators/singleOrDefault.p.png"; 188 | public static String toFuture="https://github.com/jiang111/RxDocs/raw/master/images/operators/B.toFuture.png"; 189 | public static String toIterable="https://github.com/jiang111/RxDocs/raw/master/images/operators/B.getIterator.png"; 190 | public static String getIterator="https://github.com/jiang111/RxDocs/raw/master/images/operators/B.getIterator.png"; 191 | } 192 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/common/OperatorsUrl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.common; 30 | 31 | /** 32 | * Created by jiang on 16/3/13. 33 | */ 34 | public class OperatorsUrl { 35 | 36 | public static final String INTRODUCE = "https://github.com/mcxiaoke/RxDocs/blob/master/Intro.md"; 37 | 38 | 39 | public static final String OBSERVABLES = "https://github.com/mcxiaoke/RxDocs/blob/master/Observables.md"; 40 | public static final String SINGLE = "https://github.com/mcxiaoke/RxDocs/blob/master/Single.md"; 41 | public static final String SUBJECT = "https://github.com/mcxiaoke/RxDocs/blob/master/Subject.md"; 42 | public static final String SCHEDULE = "https://github.com/mcxiaoke/RxDocs/blob/master/Scheduler.md"; 43 | public static final String JUST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Just.md"; 44 | public static final String FROM = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/From.md"; 45 | public static final String REPEAT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Repeat.md"; 46 | public static final String CREATE = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Create.md"; 47 | public static final String DEFER = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Defer.md"; 48 | public static final String RANGE = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Range.md"; 49 | public static final String INTERVAL = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Interval.md"; 50 | public static final String TIMER = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Timer.md"; 51 | public static final String EMPTY = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Empty.md"; 52 | 53 | // transform 54 | public static final String MAP = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Map.md"; 55 | public static final String FLATMAP = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/FlatMap.md"; 56 | public static final String CONTACTMAP = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/FlatMap.md"; 57 | public static final String SWITCHMAP = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/FlatMap.md"; 58 | public static final String SCAN = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Scan.md"; 59 | public static final String GROUPBY = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/GroupBy.md"; 60 | public static final String BUFFER = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Buffer.md"; 61 | public static final String WINDOW = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Window.md"; 62 | public static final String CAST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Map.md"; 63 | 64 | 65 | //filter 66 | 67 | 68 | //filter 69 | public static final String FILTER = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Filter.md"; 70 | public static final String TAKE_LAST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/TakeLast.md"; 71 | public static final String LAST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Last.md"; 72 | public static final String LAST_OR_DEFAULT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Last.md"; 73 | public static final String TAKE_LAST_BUFFER = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/TakeLast.md"; 74 | public static final String SKIP = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Skip.md"; 75 | public static final String SKIP_LAST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/SkipLast.md"; 76 | public static final String TAKE = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Take.md"; 77 | public static final String FIRST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 78 | public static final String FIRST_DEFAULT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 79 | public static final String ELEMENT_AT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/ElementAt.md"; 80 | public static final String ELEMENT_DEFAULT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/ElementAt.md"; 81 | public static final String SAMPLE = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Sample.md"; 82 | public static final String THROLFIRST = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Sample.md"; 83 | public static final String DEBOUND = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Debounce.md"; 84 | public static final String TIMEOUT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Timeout.md"; 85 | public static final String DISTINCT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Distinct.md"; 86 | public static final String UNTILCHANGED = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Distinct.md"; 87 | public static final String OF_TYPE = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Filter.md"; 88 | public static final String IGNORE_ELEMENT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/IgnoreElements.md"; 89 | 90 | 91 | //combin 92 | public static final String STARTWITH = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Merge.md"; 93 | public static final String MERGE = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Merge.md"; 94 | public static final String MERGEDELAY = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Merge.md"; 95 | public static final String ZIP = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Zip.md"; 96 | public static final String AND = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/And.md"; 97 | public static final String COMBINLASTED = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/CombineLatest.md"; 98 | public static final String JOIN = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Join.md"; 99 | public static final String SWITHONNEXT = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Switch.md"; 100 | 101 | //error 102 | public static final String ERROR = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Catch.md"; 103 | public static final String RETRY = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Retry.md#retry"; 104 | 105 | 106 | //utity 107 | //utility 108 | public static final String Materialize = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Materialize.md"; 109 | public static final String Dematerialize = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Materialize.md"; 110 | public static final String Timestamp = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Timestamp.md"; 111 | public static final String Serialize = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Serialize.md"; 112 | public static final String ObserveOn = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/ObserveOn.md"; 113 | public static final String SubscribeOn = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/SubscribeOn.md"; 114 | public static final String doOnEach = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 115 | public static final String doOnSubscribe = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 116 | public static final String doOnUnsubscribe = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 117 | public static final String doOnCompleted = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 118 | public static final String doOnError = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 119 | public static final String doOnTerminate = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 120 | 121 | public static final String finallyDo = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Do.md"; 122 | public static final String Delay = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Delay.md"; 123 | public static final String delaySubscription = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Delay.md"; 124 | public static final String TimeInterval = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/TimeInterval.md"; 125 | public static final String Using = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Using.md"; 126 | public static final String First = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 127 | public static final String To = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 128 | 129 | 130 | //string 131 | public static final String byLine = MAP; 132 | public static final String decode = FROM; 133 | public static final String encode = MAP; 134 | public static final String from_String = FROM; 135 | public static final String join = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Sum.md"; 136 | public static final String split = FLATMAP; 137 | public static final String stringConcat = join; 138 | //conditional 139 | public static final String amb = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Conditional.md"; 140 | 141 | //boolean 142 | public static final String BOOLEAN_ALL = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Conditional.md"; 143 | public static final String MATH = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Mathematical.md#Average"; 144 | 145 | // math other 146 | public static final String concat = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Mathematical.md#Concat"; 147 | public static final String count = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Mathematical.md#Concat"; 148 | public static final String reduce = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Mathematical.md#Concat"; 149 | public static final String collect = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Mathematical.md#Concat"; 150 | public static final String toList = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 151 | public static final String toSortedList = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 152 | public static final String toMap = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 153 | public static final String toMultiMap = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 154 | public static final String SAMPLE_FIRST = "https://github.com/mcxiaoke/RxDocs/blob/master/topics/How-To-Use-RxJava.md"; 155 | public static final String GUIDE_OPEN = "https://github.com/mcxiaoke/RxDocs/blob/master/topics/Getting-Started.md"; 156 | public static final String OWN_OPERATE = "https://github.com/mcxiaoke/RxDocs/blob/master/topics/Implementing-Your-Own-Operators.md"; 157 | public static final String OWN_CHAJIAN = "https://github.com/mcxiaoke/RxDocs/blob/master/topics/Plugins.md"; 158 | public static final String ANDROID_MODULE = "https://github.com/mcxiaoke/RxDocs/blob/master/topics/The-RxJava-Android-Module.md"; 159 | 160 | public static final String ERROR_HANDLE = "https://github.com/mcxiaoke/RxDocs/blob/master/topics/Error-Handling.md"; 161 | public static String start = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Start.md#start"; 162 | //connect 163 | public static String connect = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Connect.md"; 164 | public static String publish = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Publish.md"; 165 | public static String replay = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Replay.md"; 166 | public static String refCount = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Refcount.md"; 167 | //block 168 | public static String forEach = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Subscribe.md"; 169 | public static String first = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 170 | public static String firstOrDefault = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 171 | public static String lastOrDefault = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Last.md"; 172 | public static String mostRecent = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 173 | public static String next = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/TakeLast.md"; 174 | public static String single = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 175 | public static String singleOrDefault = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/First.md"; 176 | public static String toFuture = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 177 | public static String toIterable = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 178 | public static String getIterator = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/To.md"; 179 | public static String last = "https://github.com/mcxiaoke/RxDocs/blob/master/operators/Last.md"; 180 | 181 | //RxJava2.x 182 | public static String R_2_INDEX = "https://github.com/mcxiaoke/RxDocs/blob/master/RxJava2/What-different-in-2.md"; 183 | public static String R_2_FLOWABLE = "https://github.com/mcxiaoke/RxDocs/blob/master/RxJava2/Flow.md"; 184 | public static String R_2_OTHER = "https://github.com/mcxiaoke/RxDocs/blob/master/RxJava2/other.md"; 185 | 186 | } 187 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/common/SPKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.common; 30 | 31 | /** 32 | * Created by jiang on 16/3/13. 33 | */ 34 | public class SPKey { 35 | public static final String FIRST_ENTER = "first_enter"; 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.database; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | import android.util.Log; 8 | 9 | import de.greenrobot.dao.AbstractDaoMaster; 10 | import de.greenrobot.dao.identityscope.IdentityScopeType; 11 | 12 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 13 | 14 | /** 15 | * Master of DAO (schema version 1): knows all DAOs. 16 | */ 17 | public class DaoMaster extends AbstractDaoMaster { 18 | public static final int SCHEMA_VERSION = 4; 19 | 20 | /** Creates underlying database table using DAOs. */ 21 | public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { 22 | alloperatorsDao.createTable(db, ifNotExists); 23 | operatorsDao.createTable(db, ifNotExists); 24 | } 25 | 26 | /** Drops underlying database table using DAOs. */ 27 | public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { 28 | alloperatorsDao.dropTable(db, ifExists); 29 | operatorsDao.dropTable(db, ifExists); 30 | } 31 | 32 | public static abstract class OpenHelper extends SQLiteOpenHelper { 33 | 34 | public OpenHelper(Context context, String name, CursorFactory factory) { 35 | super(context, name, factory, SCHEMA_VERSION); 36 | } 37 | 38 | @Override 39 | public void onCreate(SQLiteDatabase db) { 40 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 41 | createAllTables(db, false); 42 | } 43 | } 44 | 45 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 46 | public static class DevOpenHelper extends OpenHelper { 47 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 48 | super(context, name, factory); 49 | } 50 | 51 | @Override 52 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 53 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 54 | dropAllTables(db, true); 55 | onCreate(db); 56 | } 57 | } 58 | 59 | public DaoMaster(SQLiteDatabase db) { 60 | super(db, SCHEMA_VERSION); 61 | registerDaoClass(alloperatorsDao.class); 62 | registerDaoClass(operatorsDao.class); 63 | } 64 | 65 | public DaoSession newSession() { 66 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 67 | } 68 | 69 | public DaoSession newSession(IdentityScopeType type) { 70 | return new DaoSession(db, type, daoConfigMap); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.database; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.Map; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.AbstractDaoSession; 9 | import de.greenrobot.dao.identityscope.IdentityScopeType; 10 | import de.greenrobot.dao.internal.DaoConfig; 11 | 12 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 13 | 14 | /** 15 | * {@inheritDoc} 16 | * 17 | * @see AbstractDaoSession 18 | */ 19 | public class DaoSession extends AbstractDaoSession { 20 | 21 | private final DaoConfig operatorsDaoConfig; 22 | private final DaoConfig alloperatorsDaoConfig; 23 | 24 | private final operatorsDao operatorsDao; 25 | private final alloperatorsDao alloperatorsDao; 26 | 27 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 28 | daoConfigMap) { 29 | super(db); 30 | 31 | operatorsDaoConfig = daoConfigMap.get(operatorsDao.class).clone(); 32 | operatorsDaoConfig.initIdentityScope(type); 33 | 34 | alloperatorsDaoConfig = daoConfigMap.get(alloperatorsDao.class).clone(); 35 | alloperatorsDaoConfig.initIdentityScope(type); 36 | 37 | operatorsDao = new operatorsDao(operatorsDaoConfig, this); 38 | alloperatorsDao = new alloperatorsDao(alloperatorsDaoConfig, this); 39 | 40 | registerDao(operators.class, operatorsDao); 41 | registerDao(alloperators.class, alloperatorsDao); 42 | } 43 | 44 | public void clear() { 45 | operatorsDaoConfig.getIdentityScope().clear(); 46 | alloperatorsDaoConfig.getIdentityScope().clear(); 47 | } 48 | 49 | public operatorsDao getOperatorsDao() { 50 | return operatorsDao; 51 | } 52 | 53 | public alloperatorsDao getAlloperatorsDao() { 54 | return alloperatorsDao; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/alloperators.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.database; 2 | 3 | import de.greenrobot.dao.DaoException; 4 | 5 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 6 | /** 7 | * Entity mapped to table "ALLOPERATORS". 8 | */ 9 | public class alloperators { 10 | 11 | private Long id; 12 | /** Not-null value. */ 13 | private String name; 14 | /** Not-null value. */ 15 | private String thread; 16 | /** Not-null value. */ 17 | private String desc; 18 | /** Not-null value. */ 19 | private String img; 20 | /** Not-null value. */ 21 | private String url; 22 | private Long operators_id; 23 | 24 | /** Used to resolve relations */ 25 | private transient DaoSession daoSession; 26 | 27 | /** Used for active entity operations. */ 28 | private transient alloperatorsDao myDao; 29 | 30 | private operators operators; 31 | private Long operators__resolvedKey; 32 | 33 | 34 | public alloperators() { 35 | } 36 | 37 | public alloperators(Long id) { 38 | this.id = id; 39 | } 40 | 41 | public alloperators(Long id, String name, String thread, String desc, String img, String url, Long operators_id) { 42 | this.id = id; 43 | this.name = name; 44 | this.thread = thread; 45 | this.desc = desc; 46 | this.img = img; 47 | this.url = url; 48 | this.operators_id = operators_id; 49 | } 50 | 51 | /** called by internal mechanisms, do not call yourself. */ 52 | public void __setDaoSession(DaoSession daoSession) { 53 | this.daoSession = daoSession; 54 | myDao = daoSession != null ? daoSession.getAlloperatorsDao() : null; 55 | } 56 | 57 | public Long getId() { 58 | return id; 59 | } 60 | 61 | public void setId(Long id) { 62 | this.id = id; 63 | } 64 | 65 | /** Not-null value. */ 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | /** Not-null value; ensure this value is available before it is saved to the database. */ 71 | public void setName(String name) { 72 | this.name = name; 73 | } 74 | 75 | /** Not-null value. */ 76 | public String getThread() { 77 | return thread; 78 | } 79 | 80 | /** Not-null value; ensure this value is available before it is saved to the database. */ 81 | public void setThread(String thread) { 82 | this.thread = thread; 83 | } 84 | 85 | /** Not-null value. */ 86 | public String getDesc() { 87 | return desc; 88 | } 89 | 90 | /** Not-null value; ensure this value is available before it is saved to the database. */ 91 | public void setDesc(String desc) { 92 | this.desc = desc; 93 | } 94 | 95 | /** Not-null value. */ 96 | public String getImg() { 97 | return img; 98 | } 99 | 100 | /** Not-null value; ensure this value is available before it is saved to the database. */ 101 | public void setImg(String img) { 102 | this.img = img; 103 | } 104 | 105 | /** Not-null value. */ 106 | public String getUrl() { 107 | return url; 108 | } 109 | 110 | /** Not-null value; ensure this value is available before it is saved to the database. */ 111 | public void setUrl(String url) { 112 | this.url = url; 113 | } 114 | 115 | public Long getOperators_id() { 116 | return operators_id; 117 | } 118 | 119 | public void setOperators_id(Long operators_id) { 120 | this.operators_id = operators_id; 121 | } 122 | 123 | /** To-one relationship, resolved on first access. */ 124 | public operators getOperators() { 125 | Long __key = this.operators_id; 126 | if (operators__resolvedKey == null || !operators__resolvedKey.equals(__key)) { 127 | if (daoSession == null) { 128 | throw new DaoException("Entity is detached from DAO context"); 129 | } 130 | operatorsDao targetDao = daoSession.getOperatorsDao(); 131 | operators operatorsNew = targetDao.load(__key); 132 | synchronized (this) { 133 | operators = operatorsNew; 134 | operators__resolvedKey = __key; 135 | } 136 | } 137 | return operators; 138 | } 139 | 140 | public void setOperators(operators operators) { 141 | synchronized (this) { 142 | this.operators = operators; 143 | operators_id = operators == null ? null : operators.getId(); 144 | operators__resolvedKey = operators_id; 145 | } 146 | } 147 | 148 | public void delete() { 149 | if (myDao == null) { 150 | throw new DaoException("Entity is detached from DAO context"); 151 | } 152 | myDao.delete(this); 153 | } 154 | 155 | public void update() { 156 | if (myDao == null) { 157 | throw new DaoException("Entity is detached from DAO context"); 158 | } 159 | myDao.update(this); 160 | } 161 | 162 | public void refresh() { 163 | if (myDao == null) { 164 | throw new DaoException("Entity is detached from DAO context"); 165 | } 166 | myDao.refresh(this); 167 | } 168 | 169 | } 170 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/alloperatorsDao.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.database; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import de.greenrobot.dao.AbstractDao; 11 | import de.greenrobot.dao.Property; 12 | import de.greenrobot.dao.internal.DaoConfig; 13 | import de.greenrobot.dao.internal.SqlUtils; 14 | import de.greenrobot.dao.query.Query; 15 | import de.greenrobot.dao.query.QueryBuilder; 16 | 17 | 18 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 19 | /** 20 | * DAO for table "ALLOPERATORS". 21 | */ 22 | public class alloperatorsDao extends AbstractDao { 23 | 24 | public static final String TABLENAME = "ALLOPERATORS"; 25 | 26 | /** 27 | * Properties of entity alloperators.
28 | * Can be used for QueryBuilder and for referencing column names. 29 | */ 30 | public static class Properties { 31 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 32 | public final static Property Name = new Property(1, String.class, "name", false, "NAME"); 33 | public final static Property Thread = new Property(2, String.class, "thread", false, "THREAD"); 34 | public final static Property Desc = new Property(3, String.class, "desc", false, "DESC"); 35 | public final static Property Img = new Property(4, String.class, "img", false, "IMG"); 36 | public final static Property Url = new Property(5, String.class, "url", false, "URL"); 37 | public final static Property Operators_id = new Property(6, Long.class, "operators_id", false, "OPERATORS_ID"); 38 | public final static Property Outer_id = new Property(7, Long.class, "outer_id", false, "OUTER_ID"); 39 | }; 40 | 41 | private DaoSession daoSession; 42 | 43 | private Query operators_AlloperatorsListQuery; 44 | 45 | public alloperatorsDao(DaoConfig config) { 46 | super(config); 47 | } 48 | 49 | public alloperatorsDao(DaoConfig config, DaoSession daoSession) { 50 | super(config, daoSession); 51 | this.daoSession = daoSession; 52 | } 53 | 54 | /** Creates the underlying database table. */ 55 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 56 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 57 | db.execSQL("CREATE TABLE " + constraint + "\"ALLOPERATORS\" (" + // 58 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id 59 | "\"NAME\" TEXT NOT NULL ," + // 1: name 60 | "\"THREAD\" TEXT NOT NULL ," + // 2: thread 61 | "\"DESC\" TEXT NOT NULL ," + // 3: desc 62 | "\"IMG\" TEXT NOT NULL ," + // 4: img 63 | "\"URL\" TEXT NOT NULL ," + // 5: url 64 | "\"OPERATORS_ID\" INTEGER," + // 6: operators_id 65 | "\"OUTER_ID\" INTEGER);"); // 7: outer_id 66 | } 67 | 68 | /** Drops the underlying database table. */ 69 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 70 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"ALLOPERATORS\""; 71 | db.execSQL(sql); 72 | } 73 | 74 | /** @inheritdoc */ 75 | @Override 76 | protected void bindValues(SQLiteStatement stmt, alloperators entity) { 77 | stmt.clearBindings(); 78 | 79 | Long id = entity.getId(); 80 | if (id != null) { 81 | stmt.bindLong(1, id); 82 | } 83 | stmt.bindString(2, entity.getName()); 84 | stmt.bindString(3, entity.getThread()); 85 | stmt.bindString(4, entity.getDesc()); 86 | stmt.bindString(5, entity.getImg()); 87 | stmt.bindString(6, entity.getUrl()); 88 | 89 | Long operators_id = entity.getOperators_id(); 90 | if (operators_id != null) { 91 | stmt.bindLong(7, operators_id); 92 | } 93 | } 94 | 95 | @Override 96 | protected void attachEntity(alloperators entity) { 97 | super.attachEntity(entity); 98 | entity.__setDaoSession(daoSession); 99 | } 100 | 101 | /** @inheritdoc */ 102 | @Override 103 | public Long readKey(Cursor cursor, int offset) { 104 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 105 | } 106 | 107 | /** @inheritdoc */ 108 | @Override 109 | public alloperators readEntity(Cursor cursor, int offset) { 110 | alloperators entity = new alloperators( // 111 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 112 | cursor.getString(offset + 1), // name 113 | cursor.getString(offset + 2), // thread 114 | cursor.getString(offset + 3), // desc 115 | cursor.getString(offset + 4), // img 116 | cursor.getString(offset + 5), // url 117 | cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6) // operators_id 118 | ); 119 | return entity; 120 | } 121 | 122 | /** @inheritdoc */ 123 | @Override 124 | public void readEntity(Cursor cursor, alloperators entity, int offset) { 125 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 126 | entity.setName(cursor.getString(offset + 1)); 127 | entity.setThread(cursor.getString(offset + 2)); 128 | entity.setDesc(cursor.getString(offset + 3)); 129 | entity.setImg(cursor.getString(offset + 4)); 130 | entity.setUrl(cursor.getString(offset + 5)); 131 | entity.setOperators_id(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6)); 132 | } 133 | 134 | /** @inheritdoc */ 135 | @Override 136 | protected Long updateKeyAfterInsert(alloperators entity, long rowId) { 137 | entity.setId(rowId); 138 | return rowId; 139 | } 140 | 141 | /** @inheritdoc */ 142 | @Override 143 | public Long getKey(alloperators entity) { 144 | if(entity != null) { 145 | return entity.getId(); 146 | } else { 147 | return null; 148 | } 149 | } 150 | 151 | /** @inheritdoc */ 152 | @Override 153 | protected boolean isEntityUpdateable() { 154 | return true; 155 | } 156 | 157 | /** Internal query to resolve the "alloperatorsList" to-many relationship of operators. */ 158 | public List _queryOperators_AlloperatorsList(Long outer_id) { 159 | synchronized (this) { 160 | if (operators_AlloperatorsListQuery == null) { 161 | QueryBuilder queryBuilder = queryBuilder(); 162 | queryBuilder.where(Properties.Outer_id.eq(null)); 163 | operators_AlloperatorsListQuery = queryBuilder.build(); 164 | } 165 | } 166 | Query query = operators_AlloperatorsListQuery.forCurrentThread(); 167 | query.setParameter(0, outer_id); 168 | return query.list(); 169 | } 170 | 171 | private String selectDeep; 172 | 173 | protected String getSelectDeep() { 174 | if (selectDeep == null) { 175 | StringBuilder builder = new StringBuilder("SELECT "); 176 | SqlUtils.appendColumns(builder, "T", getAllColumns()); 177 | builder.append(','); 178 | SqlUtils.appendColumns(builder, "T0", daoSession.getOperatorsDao().getAllColumns()); 179 | builder.append(" FROM ALLOPERATORS T"); 180 | builder.append(" LEFT JOIN OPERATORS T0 ON T.\"OPERATORS_ID\"=T0.\"_id\""); 181 | builder.append(' '); 182 | selectDeep = builder.toString(); 183 | } 184 | return selectDeep; 185 | } 186 | 187 | protected alloperators loadCurrentDeep(Cursor cursor, boolean lock) { 188 | alloperators entity = loadCurrent(cursor, 0, lock); 189 | int offset = getAllColumns().length; 190 | 191 | operators operators = loadCurrentOther(daoSession.getOperatorsDao(), cursor, offset); 192 | entity.setOperators(operators); 193 | 194 | return entity; 195 | } 196 | 197 | public alloperators loadDeep(Long key) { 198 | assertSinglePk(); 199 | if (key == null) { 200 | return null; 201 | } 202 | 203 | StringBuilder builder = new StringBuilder(getSelectDeep()); 204 | builder.append("WHERE "); 205 | SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns()); 206 | String sql = builder.toString(); 207 | 208 | String[] keyArray = new String[] { key.toString() }; 209 | Cursor cursor = db.rawQuery(sql, keyArray); 210 | 211 | try { 212 | boolean available = cursor.moveToFirst(); 213 | if (!available) { 214 | return null; 215 | } else if (!cursor.isLast()) { 216 | throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount()); 217 | } 218 | return loadCurrentDeep(cursor, true); 219 | } finally { 220 | cursor.close(); 221 | } 222 | } 223 | 224 | /** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */ 225 | public List loadAllDeepFromCursor(Cursor cursor) { 226 | int count = cursor.getCount(); 227 | List list = new ArrayList(count); 228 | 229 | if (cursor.moveToFirst()) { 230 | if (identityScope != null) { 231 | identityScope.lock(); 232 | identityScope.reserveRoom(count); 233 | } 234 | try { 235 | do { 236 | list.add(loadCurrentDeep(cursor, false)); 237 | } while (cursor.moveToNext()); 238 | } finally { 239 | if (identityScope != null) { 240 | identityScope.unlock(); 241 | } 242 | } 243 | } 244 | return list; 245 | } 246 | 247 | protected List loadDeepAllAndCloseCursor(Cursor cursor) { 248 | try { 249 | return loadAllDeepFromCursor(cursor); 250 | } finally { 251 | cursor.close(); 252 | } 253 | } 254 | 255 | 256 | /** A raw-style query where you can pass any WHERE clause and arguments. */ 257 | public List queryDeep(String where, String... selectionArg) { 258 | Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg); 259 | return loadDeepAllAndCloseCursor(cursor); 260 | } 261 | 262 | } 263 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/helper/AllOperatorsService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.database.helper; 30 | 31 | import com.jiang.android.rxjavaapp.database.alloperators; 32 | 33 | import de.greenrobot.dao.AbstractDao; 34 | 35 | /** 36 | * Created by jiang on 16/3/13. 37 | */ 38 | public class AllOperatorsService extends BaseService { 39 | public AllOperatorsService(AbstractDao dao) { 40 | super(dao); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/helper/BaseService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.database.helper; 30 | 31 | import java.util.List; 32 | 33 | import de.greenrobot.dao.AbstractDao; 34 | import de.greenrobot.dao.query.QueryBuilder; 35 | 36 | /** 37 | * Created by jiang on 16/3/13. 38 | */ 39 | public class BaseService { 40 | 41 | private AbstractDao mDao; 42 | 43 | 44 | public BaseService(AbstractDao dao) { 45 | mDao = dao; 46 | } 47 | 48 | 49 | public void save(T item) { 50 | mDao.insert(item); 51 | } 52 | 53 | public void save(T... items) { 54 | mDao.insertInTx(items); 55 | } 56 | 57 | public void save(List items) { 58 | mDao.insertInTx(items); 59 | } 60 | 61 | public void saveOrUpdate(T item) { 62 | mDao.insertOrReplace(item); 63 | } 64 | 65 | public void saveOrUpdate(T... items) { 66 | mDao.insertOrReplaceInTx(items); 67 | } 68 | 69 | public void saveOrUpdate(List items) { 70 | mDao.insertOrReplaceInTx(items); 71 | } 72 | 73 | public void deleteByKey(K key) { 74 | mDao.deleteByKey(key); 75 | } 76 | 77 | public void delete(T item) { 78 | mDao.delete(item); 79 | } 80 | 81 | public void delete(T... items) { 82 | mDao.deleteInTx(items); 83 | } 84 | 85 | public void delete(List items) { 86 | mDao.deleteInTx(items); 87 | } 88 | 89 | public void deleteAll() { 90 | mDao.deleteAll(); 91 | } 92 | 93 | 94 | public void update(T item) { 95 | mDao.update(item); 96 | } 97 | 98 | public void update(T... items) { 99 | mDao.updateInTx(items); 100 | } 101 | 102 | public void update(List items) { 103 | mDao.updateInTx(items); 104 | } 105 | 106 | public T query(K key) { 107 | return mDao.load(key); 108 | } 109 | 110 | public List queryAll() { 111 | return mDao.loadAll(); 112 | } 113 | 114 | public List query(String where, String... params) { 115 | 116 | return mDao.queryRaw(where, params); 117 | } 118 | 119 | public QueryBuilder queryBuilder() { 120 | 121 | return mDao.queryBuilder(); 122 | } 123 | 124 | public long count() { 125 | return mDao.count(); 126 | } 127 | 128 | public void refresh(T item) { 129 | mDao.refresh(item); 130 | 131 | } 132 | 133 | public void detach(T item) { 134 | mDao.detach(item); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/helper/DbCore.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.database.helper; 30 | 31 | import android.content.Context; 32 | 33 | import com.jiang.android.rxjavaapp.database.DaoMaster; 34 | import com.jiang.android.rxjavaapp.database.DaoSession; 35 | 36 | import de.greenrobot.dao.query.QueryBuilder; 37 | 38 | /** 39 | * Created by jiang on 16/3/13. 40 | */ 41 | public class DbCore { 42 | private static final String DEFAULT_DB_NAME = "rxjava.db"; 43 | private static DaoMaster daoMaster; 44 | private static DaoSession daoSession; 45 | 46 | private static Context mContext; 47 | private static String DB_NAME; 48 | 49 | public static void init(Context context) { 50 | init(context, DEFAULT_DB_NAME); 51 | } 52 | 53 | public static void init(Context context, String dbName) { 54 | if (context == null) { 55 | throw new IllegalArgumentException("context can't be null"); 56 | } 57 | mContext = context.getApplicationContext(); 58 | DB_NAME = dbName; 59 | } 60 | 61 | public static DaoMaster getDaoMaster() { 62 | if (daoMaster == null) { 63 | DaoMaster.OpenHelper helper = new DaoMaster.DevOpenHelper(mContext, DB_NAME, null); 64 | daoMaster = new DaoMaster(helper.getWritableDatabase()); 65 | } 66 | return daoMaster; 67 | } 68 | 69 | public static DaoSession getDaoSession() { 70 | if (daoSession == null) { 71 | if (daoMaster == null) { 72 | daoMaster = getDaoMaster(); 73 | } 74 | daoSession = daoMaster.newSession(); 75 | } 76 | return daoSession; 77 | } 78 | 79 | public static void enableQueryBuilderLog(){ 80 | 81 | QueryBuilder.LOG_SQL = true; 82 | QueryBuilder.LOG_VALUES = true; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/helper/DbUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.database.helper; 30 | 31 | 32 | import com.jiang.android.rxjavaapp.database.alloperatorsDao; 33 | import com.jiang.android.rxjavaapp.database.operatorsDao; 34 | 35 | /** 36 | * Created by jiang on 16/3/13. 37 | */ 38 | public class DbUtil { 39 | 40 | private static AllOperatorsService allOperatorsService; 41 | private static OperatorsService operatorsService; 42 | 43 | 44 | private static operatorsDao getOperatorsDao() { 45 | return DbCore.getDaoSession().getOperatorsDao(); 46 | } 47 | 48 | private static alloperatorsDao getAllOperatorsDao() { 49 | return DbCore.getDaoSession().getAlloperatorsDao(); 50 | } 51 | 52 | public static AllOperatorsService getAllOperatorsService() { 53 | if (allOperatorsService == null) { 54 | allOperatorsService = new AllOperatorsService(getAllOperatorsDao()); 55 | } 56 | return allOperatorsService; 57 | } 58 | 59 | public static OperatorsService getOperatorsService() { 60 | if (operatorsService == null) { 61 | operatorsService = new OperatorsService(getOperatorsDao()); 62 | } 63 | return operatorsService; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/helper/OperatorsService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.database.helper; 30 | 31 | 32 | import com.jiang.android.rxjavaapp.database.operators; 33 | 34 | import de.greenrobot.dao.AbstractDao; 35 | 36 | /** 37 | * Created by jiang on 16/3/13. 38 | */ 39 | public class OperatorsService extends BaseService { 40 | public OperatorsService(AbstractDao dao) { 41 | super(dao); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/operators.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.database; 2 | 3 | import de.greenrobot.dao.DaoException; 4 | 5 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 6 | 7 | /** 8 | * Entity mapped to table "OPERATORS". 9 | */ 10 | public class operators { 11 | 12 | private Long id; 13 | private String name; 14 | private Long outer_id; 15 | 16 | /** Used to resolve relations */ 17 | private transient DaoSession daoSession; 18 | 19 | /** Used for active entity operations. */ 20 | private transient operatorsDao myDao; 21 | 22 | private alloperators alloperators; 23 | private Long alloperators__resolvedKey; 24 | 25 | 26 | public operators() { 27 | } 28 | 29 | public operators(Long id) { 30 | this.id = id; 31 | } 32 | 33 | public operators(Long id, String name, Long outer_id) { 34 | this.id = id; 35 | this.name = name; 36 | this.outer_id = outer_id; 37 | } 38 | 39 | /** called by internal mechanisms, do not call yourself. */ 40 | public void __setDaoSession(DaoSession daoSession) { 41 | this.daoSession = daoSession; 42 | myDao = daoSession != null ? daoSession.getOperatorsDao() : null; 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public void setId(Long id) { 50 | this.id = id; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | public Long getOuter_id() { 62 | return outer_id; 63 | } 64 | 65 | public void setOuter_id(Long outer_id) { 66 | this.outer_id = outer_id; 67 | } 68 | 69 | /** To-one relationship, resolved on first access. */ 70 | public alloperators getAlloperators() { 71 | Long __key = this.outer_id; 72 | if (alloperators__resolvedKey == null || !alloperators__resolvedKey.equals(__key)) { 73 | if (daoSession == null) { 74 | throw new DaoException("Entity is detached from DAO context"); 75 | } 76 | alloperatorsDao targetDao = daoSession.getAlloperatorsDao(); 77 | alloperators alloperatorsNew = targetDao.load(__key); 78 | synchronized (this) { 79 | alloperators = alloperatorsNew; 80 | alloperators__resolvedKey = __key; 81 | } 82 | } 83 | return alloperators; 84 | } 85 | 86 | public void setAlloperators(alloperators alloperators) { 87 | synchronized (this) { 88 | this.alloperators = alloperators; 89 | outer_id = alloperators == null ? null : alloperators.getId(); 90 | alloperators__resolvedKey = outer_id; 91 | } 92 | } 93 | 94 | public void delete() { 95 | if (myDao == null) { 96 | throw new DaoException("Entity is detached from DAO context"); 97 | } 98 | myDao.delete(this); 99 | } 100 | 101 | public void update() { 102 | if (myDao == null) { 103 | throw new DaoException("Entity is detached from DAO context"); 104 | } 105 | myDao.update(this); 106 | } 107 | 108 | public void refresh() { 109 | if (myDao == null) { 110 | throw new DaoException("Entity is detached from DAO context"); 111 | } 112 | myDao.refresh(this); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/database/operatorsDao.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.database; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import de.greenrobot.dao.AbstractDao; 11 | import de.greenrobot.dao.Property; 12 | import de.greenrobot.dao.internal.DaoConfig; 13 | import de.greenrobot.dao.internal.SqlUtils; 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | 17 | /** 18 | * DAO for table "OPERATORS". 19 | */ 20 | public class operatorsDao extends AbstractDao { 21 | 22 | public static final String TABLENAME = "OPERATORS"; 23 | 24 | /** 25 | * Properties of entity operators.
26 | * Can be used for QueryBuilder and for referencing column names. 27 | */ 28 | public static class Properties { 29 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 30 | public final static Property Name = new Property(1, String.class, "name", false, "NAME"); 31 | public final static Property Outer_id = new Property(2, Long.class, "outer_id", false, "OUTER_ID"); 32 | }; 33 | 34 | private DaoSession daoSession; 35 | 36 | 37 | public operatorsDao(DaoConfig config) { 38 | super(config); 39 | } 40 | 41 | public operatorsDao(DaoConfig config, DaoSession daoSession) { 42 | super(config, daoSession); 43 | this.daoSession = daoSession; 44 | } 45 | 46 | /** Creates the underlying database table. */ 47 | public static void createTable(SQLiteDatabase db, boolean ifNotExists) { 48 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 49 | db.execSQL("CREATE TABLE " + constraint + "\"OPERATORS\" (" + // 50 | "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id 51 | "\"NAME\" TEXT," + // 1: name 52 | "\"OUTER_ID\" INTEGER);"); // 2: outer_id 53 | } 54 | 55 | /** Drops the underlying database table. */ 56 | public static void dropTable(SQLiteDatabase db, boolean ifExists) { 57 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"OPERATORS\""; 58 | db.execSQL(sql); 59 | } 60 | 61 | /** @inheritdoc */ 62 | @Override 63 | protected void bindValues(SQLiteStatement stmt, operators entity) { 64 | stmt.clearBindings(); 65 | 66 | Long id = entity.getId(); 67 | if (id != null) { 68 | stmt.bindLong(1, id); 69 | } 70 | 71 | String name = entity.getName(); 72 | if (name != null) { 73 | stmt.bindString(2, name); 74 | } 75 | 76 | Long outer_id = entity.getOuter_id(); 77 | if (outer_id != null) { 78 | stmt.bindLong(3, outer_id); 79 | } 80 | } 81 | 82 | @Override 83 | protected void attachEntity(operators entity) { 84 | super.attachEntity(entity); 85 | entity.__setDaoSession(daoSession); 86 | } 87 | 88 | /** @inheritdoc */ 89 | @Override 90 | public Long readKey(Cursor cursor, int offset) { 91 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 92 | } 93 | 94 | /** @inheritdoc */ 95 | @Override 96 | public operators readEntity(Cursor cursor, int offset) { 97 | operators entity = new operators( // 98 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 99 | cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name 100 | cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2) // outer_id 101 | ); 102 | return entity; 103 | } 104 | 105 | /** @inheritdoc */ 106 | @Override 107 | public void readEntity(Cursor cursor, operators entity, int offset) { 108 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 109 | entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); 110 | entity.setOuter_id(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2)); 111 | } 112 | 113 | /** @inheritdoc */ 114 | @Override 115 | protected Long updateKeyAfterInsert(operators entity, long rowId) { 116 | entity.setId(rowId); 117 | return rowId; 118 | } 119 | 120 | /** @inheritdoc */ 121 | @Override 122 | public Long getKey(operators entity) { 123 | if(entity != null) { 124 | return entity.getId(); 125 | } else { 126 | return null; 127 | } 128 | } 129 | 130 | /** @inheritdoc */ 131 | @Override 132 | protected boolean isEntityUpdateable() { 133 | return true; 134 | } 135 | 136 | private String selectDeep; 137 | 138 | protected String getSelectDeep() { 139 | if (selectDeep == null) { 140 | StringBuilder builder = new StringBuilder("SELECT "); 141 | SqlUtils.appendColumns(builder, "T", getAllColumns()); 142 | builder.append(','); 143 | SqlUtils.appendColumns(builder, "T0", daoSession.getAlloperatorsDao().getAllColumns()); 144 | builder.append(" FROM OPERATORS T"); 145 | builder.append(" LEFT JOIN ALLOPERATORS T0 ON T.\"OUTER_ID\"=T0.\"_id\""); 146 | builder.append(' '); 147 | selectDeep = builder.toString(); 148 | } 149 | return selectDeep; 150 | } 151 | 152 | protected operators loadCurrentDeep(Cursor cursor, boolean lock) { 153 | operators entity = loadCurrent(cursor, 0, lock); 154 | int offset = getAllColumns().length; 155 | 156 | alloperators alloperators = loadCurrentOther(daoSession.getAlloperatorsDao(), cursor, offset); 157 | entity.setAlloperators(alloperators); 158 | 159 | return entity; 160 | } 161 | 162 | public operators loadDeep(Long key) { 163 | assertSinglePk(); 164 | if (key == null) { 165 | return null; 166 | } 167 | 168 | StringBuilder builder = new StringBuilder(getSelectDeep()); 169 | builder.append("WHERE "); 170 | SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns()); 171 | String sql = builder.toString(); 172 | 173 | String[] keyArray = new String[] { key.toString() }; 174 | Cursor cursor = db.rawQuery(sql, keyArray); 175 | 176 | try { 177 | boolean available = cursor.moveToFirst(); 178 | if (!available) { 179 | return null; 180 | } else if (!cursor.isLast()) { 181 | throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount()); 182 | } 183 | return loadCurrentDeep(cursor, true); 184 | } finally { 185 | cursor.close(); 186 | } 187 | } 188 | 189 | /** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */ 190 | public List loadAllDeepFromCursor(Cursor cursor) { 191 | int count = cursor.getCount(); 192 | List list = new ArrayList(count); 193 | 194 | if (cursor.moveToFirst()) { 195 | if (identityScope != null) { 196 | identityScope.lock(); 197 | identityScope.reserveRoom(count); 198 | } 199 | try { 200 | do { 201 | list.add(loadCurrentDeep(cursor, false)); 202 | } while (cursor.moveToNext()); 203 | } finally { 204 | if (identityScope != null) { 205 | identityScope.unlock(); 206 | } 207 | } 208 | } 209 | return list; 210 | } 211 | 212 | protected List loadDeepAllAndCloseCursor(Cursor cursor) { 213 | try { 214 | return loadAllDeepFromCursor(cursor); 215 | } finally { 216 | cursor.close(); 217 | } 218 | } 219 | 220 | 221 | /** A raw-style query where you can pass any WHERE clause and arguments. */ 222 | public List queryDeep(String where, String... selectionArg) { 223 | Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg); 224 | return loadDeepAllAndCloseCursor(cursor); 225 | } 226 | 227 | } 228 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/utils/L.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.utils; 30 | 31 | import android.util.Log; 32 | 33 | /** 34 | * Created by jiang on 16/3/13. 35 | */ 36 | public class L { 37 | 38 | private static final String TAG = "RxJavaApp"; 39 | 40 | public static void i(String msg) { 41 | Log.i(TAG, msg); 42 | } 43 | 44 | public static void d(String msg) { 45 | Log.d(TAG, msg); 46 | } 47 | 48 | public static void e(String msg) { 49 | Log.e(TAG, msg); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/utils/SharePrefUtil.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | /** 7 | * SharePreferences操作工具类 8 | */ 9 | public class SharePrefUtil { 10 | private static String tag = SharePrefUtil.class.getSimpleName(); 11 | private final static String SP_NAME = "rxjava"; 12 | private static SharedPreferences sp; 13 | 14 | 15 | 16 | /** 17 | * 保存布尔值 18 | * 19 | * @param context 20 | * @param key 21 | * @param value 22 | */ 23 | public static void saveBoolean(Context context, String key, boolean value) { 24 | if (sp == null) 25 | sp = context.getSharedPreferences(SP_NAME, 0); 26 | sp.edit().putBoolean(key, value).commit(); 27 | } 28 | 29 | /** 30 | * 保存字符串 31 | * 32 | * @param context 33 | * @param key 34 | * @param value 35 | */ 36 | public static void saveString(Context context, String key, String value) { 37 | if (sp == null) 38 | sp = context.getSharedPreferences(SP_NAME, 0); 39 | sp.edit().putString(key, value).commit(); 40 | 41 | } 42 | 43 | public static void clear(Context context) { 44 | if (sp == null) 45 | sp = context.getSharedPreferences(SP_NAME, 0); 46 | sp.edit().clear().commit(); 47 | } 48 | 49 | public static void removeItem(Context context, String key) { 50 | if (sp == null) 51 | sp = context.getSharedPreferences(SP_NAME, 0); 52 | sp.edit().remove(key).commit(); 53 | } 54 | 55 | /** 56 | * 保存long型 57 | * 58 | * @param context 59 | * @param key 60 | * @param value 61 | */ 62 | public static void saveLong(Context context, String key, long value) { 63 | if (sp == null) 64 | sp = context.getSharedPreferences(SP_NAME, 0); 65 | sp.edit().putLong(key, value).commit(); 66 | } 67 | 68 | /** 69 | * 保存int型 70 | * 71 | * @param context 72 | * @param key 73 | * @param value 74 | */ 75 | public static void saveInt(Context context, String key, int value) { 76 | if (sp == null) 77 | sp = context.getSharedPreferences(SP_NAME, 0); 78 | sp.edit().putInt(key, value).commit(); 79 | } 80 | 81 | /** 82 | * 保存float型 83 | * 84 | * @param context 85 | * @param key 86 | * @param value 87 | */ 88 | public static void saveFloat(Context context, String key, float value) { 89 | if (sp == null) 90 | sp = context.getSharedPreferences(SP_NAME, 0); 91 | sp.edit().putFloat(key, value).commit(); 92 | } 93 | 94 | /** 95 | * 获取字符值 96 | * 97 | * @param context 98 | * @param key 99 | * @param defValue 100 | * @return 101 | */ 102 | public static String getString(Context context, String key, String defValue) { 103 | if (sp == null) 104 | sp = context.getSharedPreferences(SP_NAME, 0); 105 | return sp.getString(key, defValue); 106 | } 107 | 108 | /** 109 | * 获取int值 110 | * 111 | * @param context 112 | * @param key 113 | * @param defValue 114 | * @return 115 | */ 116 | public static int getInt(Context context, String key, int defValue) { 117 | if (sp == null) 118 | sp = context.getSharedPreferences(SP_NAME, 0); 119 | return sp.getInt(key, defValue); 120 | } 121 | 122 | /** 123 | * 获取long值 124 | * 125 | * @param context 126 | * @param key 127 | * @param defValue 128 | * @return 129 | */ 130 | public static long getLong(Context context, String key, long defValue) { 131 | if (sp == null) 132 | sp = context.getSharedPreferences(SP_NAME, 0); 133 | return sp.getLong(key, defValue); 134 | } 135 | 136 | /** 137 | * 获取float值 138 | * 139 | * @param context 140 | * @param key 141 | * @param defValue 142 | * @return 143 | */ 144 | public static float getFloat(Context context, String key, float defValue) { 145 | if (sp == null) 146 | sp = context.getSharedPreferences(SP_NAME, 0); 147 | return sp.getFloat(key, defValue); 148 | } 149 | 150 | /** 151 | * 获取布尔值 152 | * 153 | * @param context 154 | * @param key 155 | * @param defValue 156 | * @return 157 | */ 158 | public static boolean getBoolean(Context context, String key, boolean defValue) { 159 | if (sp == null) 160 | sp = context.getSharedPreferences(SP_NAME, 0); 161 | return sp.getBoolean(key, defValue); 162 | } 163 | 164 | 165 | 166 | 167 | } 168 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/utils/Utils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * created by jiang, 16/3/13 3 | * Copyright (c) 2016, jyuesong@gmail.com All Rights Reserved. 4 | * * # # 5 | * # _oo0oo_ # 6 | * # o8888888o # 7 | * # 88" . "88 # 8 | * # (| -_- |) # 9 | * # 0\ = /0 # 10 | * # ___/`---'\___ # 11 | * # .' \\| |# '. # 12 | * # / \\||| : |||# \ # 13 | * # / _||||| -:- |||||- \ # 14 | * # | | \\\ - #/ | | # 15 | * # | \_| ''\---/'' |_/ | # 16 | * # \ .-\__ '-' ___/-. / # 17 | * # ___'. .' /--.--\ `. .'___ # 18 | * # ."" '< `.___\_<|>_/___.' >' "". # 19 | * # | | : `- \`.;`\ _ /`;.`/ - ` : | | # 20 | * # \ \ `_. \_ __\ /__ _/ .-` / / # 21 | * # =====`-.____`.___ \_____/___.-`___.-'===== # 22 | * # `=---=' # 23 | * # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 24 | * # # 25 | * # 佛祖保佑 永无BUG # 26 | * # # 27 | */ 28 | 29 | package com.jiang.android.rxjavaapp.utils; 30 | 31 | import android.content.Context; 32 | import android.net.Uri; 33 | 34 | /** 35 | * Created by jiang on 16/3/13. 36 | */ 37 | public class Utils { 38 | public static Uri getUri(String url) { 39 | return Uri.parse(url); 40 | 41 | } 42 | 43 | public static int Dp2Px(Context context, float dp) { 44 | final float scale = context.getResources().getDisplayMetrics().density; 45 | return (int) (dp * scale + 0.5f); 46 | } 47 | 48 | public static int Px2Dp(Context context, float px) { 49 | final float scale = context.getResources().getDisplayMetrics().density; 50 | return (int) (px / scale + 0.5f); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/widget/BrowserLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 [1076559197@qq.com | tchen0707@gmail.com] 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License”); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.jiang.android.rxjavaapp.widget; 18 | 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.net.Uri; 22 | import android.text.TextUtils; 23 | import android.util.AttributeSet; 24 | import android.util.TypedValue; 25 | import android.view.LayoutInflater; 26 | import android.view.View; 27 | import android.webkit.WebChromeClient; 28 | import android.webkit.WebSettings; 29 | import android.webkit.WebView; 30 | import android.webkit.WebViewClient; 31 | import android.widget.ImageButton; 32 | import android.widget.LinearLayout; 33 | import android.widget.ProgressBar; 34 | 35 | import com.jiang.android.rxjavaapp.R; 36 | 37 | 38 | public class BrowserLayout extends LinearLayout { 39 | 40 | private Context mContext = null; 41 | private WebView mWebView = null; 42 | private View mBrowserControllerView = null; 43 | private ImageButton mGoBackBtn = null; 44 | private ImageButton mGoForwardBtn = null; 45 | private ImageButton mGoBrowserBtn = null; 46 | private ImageButton mRefreshBtn = null; 47 | 48 | private int mBarHeight = 5; 49 | private ProgressBar mProgressBar = null; 50 | 51 | private String mLoadUrl; 52 | 53 | public BrowserLayout(Context context) { 54 | super(context); 55 | init(context); 56 | } 57 | 58 | public BrowserLayout(Context context, AttributeSet attrs) { 59 | super(context, attrs); 60 | init(context); 61 | } 62 | 63 | private void init(Context context) { 64 | mContext = context; 65 | setOrientation(VERTICAL); 66 | 67 | mProgressBar = (ProgressBar) LayoutInflater.from(context).inflate(R.layout.progress_horizontal, null); 68 | mProgressBar.setMax(100); 69 | mProgressBar.setProgress(0); 70 | addView(mProgressBar, LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mBarHeight, getResources().getDisplayMetrics())); 71 | 72 | mWebView = new WebView(context); 73 | mWebView.getSettings().setJavaScriptEnabled(true); 74 | mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 75 | mWebView.getSettings().setDefaultTextEncodingName("UTF-8"); 76 | mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); 77 | mWebView.getSettings().setBuiltInZoomControls(false); 78 | mWebView.getSettings().setSupportMultipleWindows(true); 79 | mWebView.getSettings().setUseWideViewPort(true); 80 | mWebView.getSettings().setLoadWithOverviewMode(true); 81 | mWebView.getSettings().setSupportZoom(false); 82 | mWebView.getSettings().setPluginState(WebSettings.PluginState.ON); 83 | mWebView.getSettings().setDomStorageEnabled(true); 84 | mWebView.getSettings().setLoadsImagesAutomatically(true); 85 | 86 | LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 1); 87 | addView(mWebView, lps); 88 | 89 | mWebView.setWebChromeClient(new WebChromeClient() { 90 | 91 | @Override 92 | public void onProgressChanged(WebView view, int newProgress) { 93 | super.onProgressChanged(view, newProgress); 94 | if (newProgress == 100) { 95 | mProgressBar.setVisibility(View.GONE); 96 | } else { 97 | mProgressBar.setVisibility(View.VISIBLE); 98 | mProgressBar.setProgress(newProgress); 99 | } 100 | } 101 | }); 102 | 103 | mWebView.setWebViewClient(new WebViewClient() { 104 | 105 | public void onPageFinished(WebView view, String url) { 106 | super.onPageFinished(view, url); 107 | mLoadUrl = url; 108 | } 109 | }); 110 | 111 | mBrowserControllerView = LayoutInflater.from(context).inflate(R.layout.browser_controller, null); 112 | mGoBackBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_back); 113 | mGoForwardBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_forward); 114 | mGoBrowserBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_go); 115 | mRefreshBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_refresh); 116 | 117 | mGoBackBtn.setOnClickListener(new OnClickListener() { 118 | 119 | @Override 120 | public void onClick(View v) { 121 | if (canGoBack()) { 122 | goBack(); 123 | } 124 | } 125 | }); 126 | 127 | mGoForwardBtn.setOnClickListener(new OnClickListener() { 128 | 129 | @Override 130 | public void onClick(View v) { 131 | if (canGoForward()) { 132 | goForward(); 133 | } 134 | } 135 | }); 136 | 137 | mRefreshBtn.setOnClickListener(new OnClickListener() { 138 | 139 | @Override 140 | public void onClick(View v) { 141 | loadUrl(mLoadUrl); 142 | } 143 | }); 144 | 145 | mGoBrowserBtn.setOnClickListener(new OnClickListener() { 146 | 147 | @Override 148 | public void onClick(View v) { 149 | if (!TextUtils.isEmpty(mLoadUrl)) { 150 | Intent intent = new Intent(Intent.ACTION_VIEW); 151 | intent.setData(Uri.parse(mLoadUrl)); 152 | mContext.startActivity(intent); 153 | } 154 | } 155 | }); 156 | 157 | addView(mBrowserControllerView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 158 | } 159 | 160 | public void loadUrl(String url) { 161 | mWebView.loadUrl(url); 162 | } 163 | 164 | public boolean canGoBack() { 165 | return null != mWebView ? mWebView.canGoBack() : false; 166 | } 167 | 168 | public boolean canGoForward() { 169 | return null != mWebView ? mWebView.canGoForward() : false; 170 | } 171 | 172 | public void goBack() { 173 | if (null != mWebView) { 174 | mWebView.goBack(); 175 | } 176 | } 177 | 178 | public void goForward() { 179 | if (null != mWebView) { 180 | mWebView.goForward(); 181 | } 182 | } 183 | 184 | public WebView getWebView() { 185 | return mWebView != null ? mWebView : null; 186 | } 187 | 188 | public void hideBrowserController() { 189 | mBrowserControllerView.setVisibility(View.GONE); 190 | } 191 | 192 | public void showBrowserController() { 193 | mBrowserControllerView.setVisibility(View.VISIBLE); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /app/src/main/java/com/jiang/android/rxjavaapp/widget/HackyViewPager.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp.widget; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | /** 9 | * Found at http://stackoverflow.com/questions/7814017/is-it-possible-to-disable-scrolling-on-a-viewpager. 10 | * Convenient way to temporarily disable ViewPager navigation while interacting with ImageView. 11 | * 12 | * Julia Zudikova 13 | */ 14 | 15 | /** 16 | * Hacky fix for Issue #4 and 17 | * http://code.google.com/p/android/issues/detail?id=18990 18 | *

19 | * ScaleGestureDetector seems to mess up the touch events, which means that 20 | * ViewGroups which make use of onInterceptTouchEvent throw a lot of 21 | * IllegalArgumentException: pointerIndex out of range. 22 | *

23 | * There's not much I can do in my code for now, but we can mask the result by 24 | * just catching the problem and ignoring it. 25 | * 26 | * @author Chris Banes 27 | */ 28 | public class HackyViewPager extends ViewPager { 29 | 30 | private boolean isLocked; 31 | 32 | public HackyViewPager(Context context) { 33 | super(context); 34 | isLocked = false; 35 | } 36 | 37 | public HackyViewPager(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | isLocked = false; 40 | } 41 | 42 | @Override 43 | public boolean onInterceptTouchEvent(MotionEvent ev) { 44 | if (!isLocked) { 45 | try { 46 | return super.onInterceptTouchEvent(ev); 47 | } catch (IllegalArgumentException e) { 48 | e.printStackTrace(); 49 | return false; 50 | } 51 | } 52 | return false; 53 | } 54 | 55 | @Override 56 | public boolean onTouchEvent(MotionEvent event) { 57 | return !isLocked && super.onTouchEvent(event); 58 | } 59 | 60 | public void toggleLock() { 61 | isLocked = !isLocked; 62 | } 63 | 64 | public void setLocked(boolean isLocked) { 65 | this.isLocked = isLocked; 66 | } 67 | 68 | public boolean isLocked() { 69 | return isLocked; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_back_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_back_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_back_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_back_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_export_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_export_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_forward_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_forward_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_forward_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_forward_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_refresh_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_refresh_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/btn_refresh_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/drawable-xhdpi/btn_refresh_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/delector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/dialog_topbar_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/progress_bar_horizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_common_web.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 24 | 25 | 29 | 30 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_photoview.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/browser_controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 26 | 27 | 36 | 37 | 46 | 47 | 56 | 57 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/layout/common_toolbar.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | 22 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_index_content.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 23 | 24 | 33 | 34 | 45 | 46 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_nav_head.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/progress_horizontal.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 | 5 | 9 | 13 | 17 | 21 | 22 | 23 | 24 | 25 | 29 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiang111/RxJavaApp/db19ab7706d32c53f78ca3d2fa28c2c2f87c9716/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #66000000 8 | #000000 9 | #EEEEEE 10 | #FFFFFF 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10dp 4 | 160dp 5 | 6 | 16dp 7 | 16dp 8 | 16dp 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | @android:drawable/ic_menu_camera 3 | @android:drawable/ic_menu_gallery 4 | @android:drawable/ic_menu_slideshow 5 | @android:drawable/ic_menu_manage 6 | @android:drawable/ic_menu_share 7 | @android:drawable/ic_menu_send 8 | #80FFFFFF 9 | @android:color/transparent 10 | @color/colorPrimary 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RxJava操作符 3 | 4 | Open navigation drawer 5 | Close navigation drawer 6 | 7 | Settings 8 | 9 | splashActivity 10 | Dummy Button 11 | DUMMY\nCONTENT 12 | GitHub 13 | 关于 14 | 分享 15 | 更新 16 | 评分 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 23 | 24 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/test/java/com/jiang/android/rxjavaapp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.jiang.android.rxjavaapp; 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 | } -------------------------------------------------------------------------------- /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:2.2.2' 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 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /qrcode/a: -------------------------------------------------------------------------------- 1 | f 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------