├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── halyson.xml ├── encodings.xml ├── gradle.xml ├── libraries │ ├── appcompat_v7_21_0_3.xml │ ├── pagerslidingtabstrip_1_0_1.xml │ ├── picasso_2_3_4.xml │ ├── support_annotations_21_0_3.xml │ └── support_v4_21_0_3.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml ├── vcs.xml └── workspace.xml ├── CONTRIBUTING.md ├── LICENSE ├── Material-Design-Example.iml ├── README.md ├── app ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── br │ │ └── com │ │ └── halyson │ │ └── materialdesign │ │ ├── MaterialDesignApplication.java │ │ ├── activity │ │ ├── DetailsActivity.java │ │ ├── HomeActivity.java │ │ └── api │ │ │ └── BaseActivity.java │ │ ├── adapter │ │ ├── DrawerMenuAdapter.java │ │ ├── HomePagerAdapter.java │ │ └── RecyclerViewCardsAdapter.java │ │ ├── constants │ │ ├── DrawerMenu.java │ │ └── FragmentNames.java │ │ ├── events │ │ ├── LoadColorsTabsDisk.java │ │ └── LoadTitleTabsDisk.java │ │ ├── fragment │ │ ├── DefaultFragment.java │ │ ├── Fragment2.java │ │ ├── Fragment3.java │ │ ├── HomeFragment.java │ │ ├── NavigationDrawerFragment.java │ │ ├── RecylerViewFragment.java │ │ └── api │ │ │ └── BaseFragment.java │ │ ├── interfaces │ │ ├── A.java │ │ └── home │ │ │ ├── HomePresenter.java │ │ │ ├── HomeRepository.java │ │ │ ├── HomeService.java │ │ │ └── HomeView.java │ │ ├── model │ │ ├── CardViewBean.java │ │ ├── DrawerMenuBean.java │ │ └── SectionsTabsBean.java │ │ ├── presenter │ │ └── HomePresenterImpl.java │ │ ├── repository │ │ └── HomeRepositoryDiskImpl.java │ │ ├── service │ │ └── HomeServiceImpl.java │ │ └── utility │ │ ├── BusProvider.java │ │ └── PreferencesEditor.java │ └── res │ ├── drawable-nodpi │ └── placeholder_card_view.png │ ├── drawable-xxhdpi │ ├── example.jpeg │ └── ic_drawer_menu_shadow.9.png │ ├── drawable │ └── gradient_header_background.xml │ ├── layout │ ├── fragment_2.xml │ ├── fragment_3.xml │ ├── fragment_default.xml │ ├── fragment_drawer_menu.xml │ ├── fragment_drawer_menu_comp.xml │ ├── fragment_recycler_view.xml │ ├── fragment_recycler_view_comp.xml │ ├── screen_default.xml │ └── screen_details.xml │ ├── mipmap-xxhdpi │ ├── ic_float_button_add.png │ └── ic_launcher.png │ ├── values-v21 │ └── theme.xml │ └── values │ ├── color.xml │ ├── dimens.xml │ ├── strings_default.xml │ ├── strings_fragment.xml │ ├── strings_screen.xml │ └── theme.xml ├── art ├── GooglePlay.png ├── MaterialExampleDesign1.png └── MaterialExampleDesign2.png ├── build.gradle ├── gif └── MaterialDesignExample.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Java ### 4 | *.class 5 | 6 | 7 | ### Intellij ### 8 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 9 | 10 | *.iml 11 | 12 | ## Directory-based project format: 13 | .idea/ 14 | # if you remove the above rule, at least ignore the follwing: 15 | 16 | # User-specific stuff: 17 | # .idea/workspace.xml 18 | # .idea/tasks.xml 19 | # .idea/dictionaries 20 | 21 | # Sensitive or high-churn files: 22 | # .idea/dataSources.ids 23 | # .idea/dataSources.xml 24 | # .idea/sqlDataSources.xml 25 | # .idea/dynamic.xml 26 | # .idea/uiDesigner.xml 27 | 28 | # Gradle: 29 | # .idea/gradle.xml 30 | # .idea/libraries 31 | 32 | ## File-based project format: 33 | # *.ipr 34 | # *.iws 35 | 36 | ## Plugin-specific files: 37 | 38 | # IntelliJ 39 | out/ 40 | 41 | # mpeltonen/sbt-idea plugin 42 | .idea_modules/ 43 | 44 | # JIRA plugin 45 | atlassian-ide-plugin.xml 46 | 47 | # Crashlytics plugin (for Android Studio and IntelliJ) 48 | com_crashlytics_export_strings.xml 49 | 50 | #Generated files 51 | build/ 52 | 53 | #Build folders of Android Studio 54 | **/build/ 55 | 56 | ### Android ### 57 | # Built application files 58 | *.apk 59 | # *.ap_ 60 | 61 | # Files for the Dalvik VM 62 | *.dex 63 | 64 | # Generated files 65 | bin/ 66 | gen/ 67 | 68 | # Gradle files 69 | .gradle/ 70 | 71 | # Local configuration file (sdk path, etc) 72 | local.properties 73 | 74 | # Proguard folder generated by Eclipse 75 | # proguard/ 76 | 77 | # Log Files 78 | *.log 79 | 80 | #Ignorando SVN!! 81 | **/.svn/ 82 | .svn/ 83 | 84 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Material-Design-Example -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/halyson.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/appcompat_v7_21_0_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/pagerslidingtabstrip_1_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/picasso_2_3_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_annotations_21_0_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/support_v4_21_0_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Abstraction issues 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 1.7 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Thank you for your contribution! 2 | 3 | Any contributions will be greatly appreciated. 4 | 5 | Before submitting a new issue, please check the following guideline. 6 | 7 | ## Describe your issue as much as possible 8 | 9 | The example itself only provides the scroll information, 10 | and creating awesome scrolling effects depends deeply on how you use it: layout 11 | 12 | Therefore, if you find an issue, please describe not only the issue itself but also the following information: 13 | 14 | ### If you find it in the sample app of this project 15 | 16 | * Required 17 | * Activity name 18 | * Operation to produce the issue 19 | * Modified code 20 | * If you modified some codes in the sample, it should be described with modified codes 21 | * Preferred 22 | * Version (git commit hash) of the codes 23 | * Android OS version 24 | * device 25 | * Nexus5, x86 emulator, etc. 26 | 27 | ### If you find it in your app 28 | 29 | * Required 30 | * Operation to produce the issue 31 | * Related code 32 | * Without the related codes, I can't say anything. 33 | Screenshot / movie is useful to understand the issue, 34 | but not enough to discuss the cause of the issue. 35 | * Preferred 36 | * Version of the example 37 | * Android OS version 38 | * device 39 | * Nexus5, x86 emulator, etc. 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /Material-Design-Example.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Material Design Example 2 | ======================== 3 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--ObservableScrollView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/3/1296) 4 | 5 | Material Design Example is a sample application for the new design concept made by Google, Material Design. Besides the design, we have the new APIs introduced in Android SDK Lollipop: 6 | 7 | * Custom theme colors 8 | * Circular reveal 9 | * Activity transitions 10 | * Toolbar 11 | * Recycler View 12 | * Card View 13 | * Floating Action Button 14 | * ObservableScrollView 15 | 16 | Pre-requisites 17 | -------------- 18 | 19 | * Android SDK v14 20 | * Android Support Repository 21 | 22 | Screenshots 23 | ------------- 24 | 25 | Screenshot 26 | Screenshot 27 | 28 | 29 | Getting Started 30 | --------------- 31 | 32 | This sample uses the Gradle build system. To build this project, use the 33 | "gradlew build" command or use "Import Project" in Android Studio. 34 | 35 | Support 36 | ------- 37 | 38 | If you've found an error in this sample, please file an issue: 39 | https://github.com/halysongoncalves/Material-Design-Example 40 | 41 | Patches are encouraged, and may be submitted by forking this project and 42 | submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details. 43 | 44 | Contributions 45 | --------------- 46 | Any contributions are welcome! 47 | Please check the [contributing guideline](https://github.com/halysongoncalves/Material-Design-Example/blob/master/CONTRIBUTING.md) before submitting a new issue. 48 | 49 | Credits 50 | --------------- 51 | * Inspired by `ObservableScrollView` in [romannurik-code](https://code.google.com/p/romannurik-code/). 52 | * Inspired by `Android-ObservableScrollView` in [ksoichiro](https://github.com/ksoichiro/Android-ObservableScrollView). 53 | 54 | Samples 55 | --------------- 56 | [![Google Play](http://developer.android.com/images/brand/en_generic_rgb_wo_45.png)](https://play.google.com/store/apps/details?id=br.com.halyson.materialdesign) 57 | 58 |

Copyright

59 | 60 | Copyright 2014 Halyson Gonçalves. All rights reserved. 61 | 62 | Licensed under the Apache License, Version 2.0 (the "License"); 63 | you may not use this file except in compliance with the License. 64 | You may obtain a copy of the License at 65 | 66 | http://www.apache.org/licenses/LICENSE-2.0 67 | 68 | Unless required by applicable law or agreed to in writing, software 69 | distributed under the License is distributed on an "AS IS" BASIS, 70 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 71 | See the License for the specific language governing permissions and 72 | limitations under the License. 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "br.com.halyson.materialdesign" 9 | minSdkVersion 14 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0.0" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | zipAlignEnabled true 18 | minifyEnabled false 19 | shrinkResources false 20 | debuggable false 21 | proguardFiles 'proguard-rules.pro' 22 | } 23 | 24 | debug { 25 | minifyEnabled false 26 | debuggable true 27 | proguardFiles 'proguard-rules.pro' 28 | } 29 | } 30 | } 31 | 32 | dependencies { 33 | compile fileTree(dir: 'libs', include: ['*.jar']) 34 | compile 'com.android.support:support-v4:21.0.3' 35 | compile 'com.android.support:appcompat-v7:21.0.3' 36 | compile 'com.android.support:recyclerview-v7:21.0.0' 37 | compile 'com.android.support:cardview-v7:21.0.0' 38 | compile 'com.squareup:otto:1.3.5' 39 | compile 'com.squareup.picasso:picasso:2.3.4' 40 | compile 'com.squareup.okhttp:okhttp:2.1.+' 41 | compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.+' 42 | compile 'com.squareup.retrofit:retrofit:1.8.+' 43 | compile 'com.melnykov:floatingactionbutton:1.1.0' 44 | compile 'com.github.ksoichiro:android-observablescrollview:1.4.0' 45 | compile 'com.astuetz:pagerslidingtabstrip:1.0.1' 46 | } 47 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | ########################################### Default ########################################### 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -verbose 5 | -dontoptimize 6 | -dontpreverify 7 | 8 | 9 | -keep class com.squareup.okhttp.** { *; } 10 | -keep interface com.squareup.okhttp.** { *; } 11 | -dontwarn com.squareup.okhttp.** 12 | 13 | -dontwarn rx.** 14 | -dontwarn retrofit.** 15 | -keep class retrofit.** { *; } 16 | -keepclasseswithmembers class * { 17 | @retrofit.http.* ; 18 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/MaterialDesignApplication.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | /** 7 | * Created by Halyson on 20/01/15. 8 | */ 9 | public class MaterialDesignApplication extends Application { 10 | private static MaterialDesignApplication mMaterialDesignApplication; 11 | 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | mMaterialDesignApplication = this; 16 | } 17 | 18 | 19 | public static MaterialDesignApplication getApplication() { 20 | return mMaterialDesignApplication; 21 | } 22 | 23 | public static Context getApplicationCtx() { 24 | return mMaterialDesignApplication.getApplicationContext(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/activity/DetailsActivity.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.activity; 2 | 3 | import android.content.res.TypedArray; 4 | import android.graphics.Color; 5 | import android.os.Bundle; 6 | import android.support.v7.app.ActionBarActivity; 7 | import android.support.v7.widget.Toolbar; 8 | import android.util.TypedValue; 9 | import android.view.View; 10 | import android.widget.AbsListView; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.ListView; 13 | import android.widget.TextView; 14 | 15 | import com.github.ksoichiro.android.observablescrollview.ObservableListView; 16 | import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; 17 | import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks; 18 | import com.github.ksoichiro.android.observablescrollview.ScrollState; 19 | import com.github.ksoichiro.android.observablescrollview.ScrollUtils; 20 | import com.nineoldandroids.view.ViewHelper; 21 | 22 | import java.util.ArrayList; 23 | 24 | import br.com.halyson.materialdesign.R; 25 | 26 | /** 27 | * Created by Halyson on 20/01/15. 28 | */ 29 | public class DetailsActivity extends ActionBarActivity implements ObservableScrollViewCallbacks { 30 | private View mImageView; 31 | private View mToolbarView; 32 | private ObservableScrollView mScrollView; 33 | private int mParallaxImageHeight; 34 | 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.screen_details); 40 | 41 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 42 | setSupportActionBar(toolbar); 43 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 44 | 45 | 46 | mImageView = findViewById(R.id.image); 47 | mToolbarView = findViewById(R.id.toolbar); 48 | mToolbarView.setBackgroundColor(ScrollUtils.getColorWithAlpha(0, getResources().getColor(R.color.theme_dialer_primary))); 49 | 50 | mScrollView = (ObservableScrollView) findViewById(R.id.scroll); 51 | mScrollView.setScrollViewCallbacks(this); 52 | 53 | mParallaxImageHeight = getResources().getDimensionPixelSize(R.dimen.drawer_menu_width); 54 | } 55 | 56 | @Override 57 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 58 | super.onRestoreInstanceState(savedInstanceState); 59 | onScrollChanged(mScrollView.getCurrentScrollY(), false, false); 60 | } 61 | 62 | @Override 63 | public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { 64 | int baseColor = getResources().getColor(R.color.theme_dialer_primary); 65 | float alpha = 1 - (float) Math.max(0, mParallaxImageHeight - scrollY) / mParallaxImageHeight; 66 | mToolbarView.setBackgroundColor(ScrollUtils.getColorWithAlpha(alpha, baseColor)); 67 | ViewHelper.setTranslationY(mImageView, scrollY / 2); 68 | } 69 | 70 | @Override 71 | public void onDownMotionEvent() { 72 | } 73 | 74 | @Override 75 | public void onUpOrCancelMotionEvent(ScrollState scrollState) { 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/activity/HomeActivity.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.activity; 2 | 3 | import android.os.Bundle; 4 | 5 | import br.com.halyson.materialdesign.R; 6 | import br.com.halyson.materialdesign.activity.api.BaseActivity; 7 | import br.com.halyson.materialdesign.constants.FragmentNames; 8 | import br.com.halyson.materialdesign.fragment.HomeFragment; 9 | 10 | 11 | public class HomeActivity extends BaseActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | if (savedInstanceState == null) { 17 | getSupportFragmentManager().beginTransaction().add(R.id.screen_default_container, new HomeFragment(), FragmentNames.FRAGMENT_HOME_).commit(); 18 | } 19 | } 20 | 21 | @Override 22 | protected int setLayoutResourceIdentifier() { 23 | return R.layout.screen_default; 24 | } 25 | 26 | @Override 27 | protected int getTitleToolBar() { 28 | return R.string.app_name; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/activity/api/BaseActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Antonio Leiva Gordillo. 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 br.com.halyson.materialdesign.activity.api; 18 | 19 | import android.os.Bundle; 20 | import android.support.v4.app.Fragment; 21 | import android.support.v4.widget.DrawerLayout; 22 | import android.support.v7.app.ActionBarActivity; 23 | import android.support.v7.widget.Toolbar; 24 | 25 | import br.com.halyson.materialdesign.R; 26 | import br.com.halyson.materialdesign.constants.DrawerMenu; 27 | import br.com.halyson.materialdesign.fragment.HomeFragment; 28 | import br.com.halyson.materialdesign.fragment.NavigationDrawerFragment; 29 | 30 | public abstract class BaseActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks { 31 | protected Toolbar mToolBar; 32 | private NavigationDrawerFragment mNavigationDrawerFragment; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(setLayoutResourceIdentifier()); 38 | 39 | loadViewComponents(); 40 | loadInfoToolbar(); 41 | loadInfoDrawerMenu(); 42 | } 43 | 44 | private void loadViewComponents() { 45 | mNavigationDrawerFragment = (NavigationDrawerFragment) 46 | getSupportFragmentManager().findFragmentById(R.id.screen_default_navigation_drawer); 47 | mToolBar = (Toolbar) findViewById(R.id.screen_default_toolbar); 48 | } 49 | 50 | 51 | private void loadInfoToolbar() { 52 | setSupportActionBar(mToolBar); 53 | getSupportActionBar().setTitle(getTitleToolBar()); 54 | } 55 | 56 | 57 | private void loadInfoDrawerMenu() { 58 | mNavigationDrawerFragment.setUp( 59 | R.id.screen_default_navigation_drawer, 60 | (DrawerLayout) findViewById(R.id.screen_default_drawer_layout)); 61 | } 62 | 63 | @Override 64 | public void onNavigationDrawerItemSelected(int position) { 65 | switch (position) { 66 | case DrawerMenu.HOME: 67 | fragmentTransaction(new HomeFragment()); 68 | break; 69 | case DrawerMenu.FRAGMENT1: 70 | fragmentTransaction(new HomeFragment()); 71 | break; 72 | case DrawerMenu.FRAGMENT2: 73 | fragmentTransaction(new HomeFragment()); 74 | break; 75 | } 76 | } 77 | 78 | private void fragmentTransaction(Fragment fragment) { 79 | if (fragment != null) { 80 | getSupportFragmentManager().beginTransaction() 81 | .replace(R.id.screen_default_container, fragment) 82 | .commit(); 83 | } 84 | } 85 | 86 | protected abstract int setLayoutResourceIdentifier(); 87 | 88 | protected abstract int getTitleToolBar(); 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/adapter/DrawerMenuAdapter.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.adapter; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.BaseAdapter; 9 | import android.widget.TextView; 10 | 11 | import java.util.ArrayList; 12 | 13 | import br.com.halyson.materialdesign.model.DrawerMenuBean; 14 | import br.com.halyson.materialdesign.R; 15 | 16 | 17 | public class DrawerMenuAdapter extends BaseAdapter { 18 | private Context mContext; 19 | private ArrayList mListItensDrawerMenuBean; 20 | 21 | public DrawerMenuAdapter(Context mContext, ArrayList mListItensDrawer) { 22 | this.mContext = mContext; 23 | this.mListItensDrawerMenuBean = mListItensDrawer; 24 | } 25 | 26 | @Override 27 | public int getCount() { 28 | return mListItensDrawerMenuBean.size(); 29 | } 30 | 31 | @Override 32 | public Object getItem(int position) { 33 | return mListItensDrawerMenuBean.get(position); 34 | } 35 | 36 | @Override 37 | public long getItemId(int position) { 38 | return position; 39 | } 40 | 41 | @Override 42 | public View getView(int position, View convertView, ViewGroup parent) { 43 | ViewHolder holder; 44 | 45 | if (convertView == null) { 46 | LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); 47 | convertView = mInflater.inflate(R.layout.fragment_drawer_menu_comp, null); 48 | 49 | holder = new ViewHolder(); 50 | holder.mTitle = (TextView) convertView.findViewById(R.id.fragment_drawerMenu_comp_title); 51 | convertView.setTag(holder); 52 | } else { 53 | holder = (ViewHolder) convertView.getTag(); 54 | } 55 | holder.mTitle.setText(mListItensDrawerMenuBean.get(position).getTitle()); 56 | 57 | return convertView; 58 | } 59 | 60 | private static class ViewHolder { 61 | TextView mTitle; 62 | } 63 | } -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/adapter/HomePagerAdapter.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | import java.util.List; 8 | 9 | import br.com.halyson.materialdesign.fragment.RecylerViewFragment; 10 | import br.com.halyson.materialdesign.fragment.DefaultFragment; 11 | import br.com.halyson.materialdesign.fragment.Fragment2; 12 | import br.com.halyson.materialdesign.fragment.Fragment3; 13 | 14 | /** 15 | * Created by halyson on 18/12/14. 16 | */ 17 | public class HomePagerAdapter extends FragmentPagerAdapter { 18 | private List mListTitleTabs; 19 | 20 | public HomePagerAdapter(List listTitleTabs, FragmentManager childFragmentManager) { 21 | super(childFragmentManager ); 22 | this.mListTitleTabs = listTitleTabs; 23 | } 24 | 25 | @Override 26 | public CharSequence getPageTitle(int position) { 27 | if (mListTitleTabs == null || mListTitleTabs.isEmpty()) { 28 | return ""; 29 | } 30 | return mListTitleTabs.get(position); 31 | } 32 | 33 | @Override 34 | public int getCount() { 35 | if (mListTitleTabs == null || mListTitleTabs.isEmpty()) { 36 | return 0; 37 | } 38 | return mListTitleTabs.size(); 39 | } 40 | 41 | @Override 42 | public Fragment getItem(int position) { 43 | switch (position) { 44 | case 0: 45 | return RecylerViewFragment.newInstance(); 46 | case 1: 47 | return Fragment2.newInstance(); 48 | case 2: 49 | return Fragment3.newInstance(); 50 | default: 51 | return DefaultFragment.newInstance(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/adapter/RecyclerViewCardsAdapter.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.adapter; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | 11 | import com.squareup.picasso.Picasso; 12 | 13 | import java.util.List; 14 | 15 | import br.com.halyson.materialdesign.R; 16 | import br.com.halyson.materialdesign.activity.DetailsActivity; 17 | import br.com.halyson.materialdesign.model.CardViewBean; 18 | 19 | /** 20 | * Created by Halyson on 19/12/14. 21 | */ 22 | public class RecyclerViewCardsAdapter extends RecyclerView.Adapter { 23 | private final List mListItemsCard; 24 | private Activity mActivity; 25 | 26 | public RecyclerViewCardsAdapter(Activity activity, List listItemsCard) { 27 | this.mListItemsCard = listItemsCard; 28 | this.mActivity = activity; 29 | } 30 | 31 | @Override 32 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 33 | return new ViewHolder(mActivity,LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_recycler_view_comp, parent, false)); 34 | } 35 | 36 | @Override 37 | public void onBindViewHolder(final ViewHolder holder, int position) { 38 | final CardViewBean itemCardView = mListItemsCard.get(position); 39 | holder.itemView.setTag(itemCardView); 40 | Picasso.with(holder.imageView.getContext()) 41 | .load(mListItemsCard.get(position) 42 | .getUrlImage()) 43 | .error(R.drawable.placeholder_card_view) 44 | .placeholder(R.drawable.placeholder_card_view) 45 | .into(holder.imageView); 46 | } 47 | 48 | @Override 49 | public int getItemCount() { 50 | return mListItemsCard.size(); 51 | } 52 | 53 | 54 | public static class ViewHolder extends RecyclerView.ViewHolder { 55 | public ImageView imageView; 56 | private Activity mActivity; 57 | 58 | public ViewHolder(Activity activity , View itemView) { 59 | super(itemView); 60 | mActivity = activity; 61 | imageView = (ImageView) itemView.findViewById(R.id.material_com_card_view_image); 62 | 63 | 64 | itemView.setOnClickListener(new View.OnClickListener() { 65 | @Override 66 | public void onClick(View v) { 67 | mActivity.startActivity(new Intent(mActivity, DetailsActivity.class)); 68 | } 69 | }); 70 | } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/constants/DrawerMenu.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.constants; 2 | 3 | /** 4 | * Created by halysonlimagoncalves on 20/07/14. 5 | */ 6 | public class DrawerMenu { 7 | /** 8 | * The fragment argument representing the section number for this 9 | * fragment. 10 | */ 11 | public static final String ARG_SECTION_NUMBER = "section_number"; 12 | 13 | 14 | public static final int HOME = 0; 15 | public static final int FRAGMENT1 = 1; 16 | public static final int FRAGMENT2 = 2; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/constants/FragmentNames.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.constants; 2 | 3 | /** 4 | * Created by halyson on 18/12/14. 5 | */ 6 | public class FragmentNames { 7 | public static final String FRAGMENT_HOME_ = "fragment_default"; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/events/LoadColorsTabsDisk.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.events; 2 | 3 | /** 4 | * Created by Halyson on 31/12/14. 5 | */ 6 | public class LoadColorsTabsDisk { 7 | private int colorTab; 8 | private int dividerColorTab; 9 | private int indicatorColorTab; 10 | 11 | public LoadColorsTabsDisk(int colorTab, int dividerColorTab, int indicatorColorTab) { 12 | this.colorTab = colorTab; 13 | this.dividerColorTab = dividerColorTab; 14 | this.indicatorColorTab = indicatorColorTab; 15 | } 16 | 17 | public int getColorTab() { 18 | return colorTab; 19 | } 20 | 21 | public void setColorTab(int colorTab) { 22 | this.colorTab = colorTab; 23 | } 24 | 25 | public int getDividerColorTab() { 26 | return dividerColorTab; 27 | } 28 | 29 | public void setDividerColorTab(int dividerColorTab) { 30 | this.dividerColorTab = dividerColorTab; 31 | } 32 | 33 | public int getIndicatorColorTab() { 34 | return indicatorColorTab; 35 | } 36 | 37 | public void setIndicatorColorTab(int indicatorColorTab) { 38 | this.indicatorColorTab = indicatorColorTab; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/events/LoadTitleTabsDisk.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.events; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Halyson on 31/12/14. 7 | */ 8 | public class LoadTitleTabsDisk { 9 | private List listTitleTabs; 10 | 11 | public LoadTitleTabsDisk(List listTitleTabs) { 12 | this.listTitleTabs = listTitleTabs; 13 | } 14 | 15 | public List getListTitleTabs() { 16 | return listTitleTabs; 17 | } 18 | 19 | public void setListTitleTabs(List listTitleTabs) { 20 | this.listTitleTabs = listTitleTabs; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/DefaultFragment.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import br.com.halyson.materialdesign.R; 10 | 11 | /** 12 | * Created by halyson on 18/12/14. 13 | */ 14 | public class DefaultFragment extends Fragment { 15 | public static DefaultFragment newInstance() { 16 | return new DefaultFragment(); 17 | } 18 | private View mViewFragmentDefault; 19 | 20 | @Override 21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 22 | mViewFragmentDefault = inflater.inflate(R.layout.fragment_recycler_view, container, false); 23 | 24 | return mViewFragmentDefault; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/Fragment2.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import br.com.halyson.materialdesign.R; 10 | 11 | /** 12 | * Created by halyson on 18/12/14. 13 | */ 14 | public class Fragment2 extends Fragment { 15 | public static Fragment2 newInstance() { 16 | return new Fragment2(); 17 | } 18 | private View mViewFragment2; 19 | 20 | @Override 21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 22 | mViewFragment2 = inflater.inflate(R.layout.fragment_2, container, false); 23 | 24 | return mViewFragment2; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/Fragment3.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import br.com.halyson.materialdesign.R; 10 | 11 | /** 12 | * Created by halyson on 18/12/14. 13 | */ 14 | public class Fragment3 extends Fragment { 15 | public static Fragment3 newInstance() { 16 | return new Fragment3(); 17 | } 18 | private View mViewFragment3; 19 | 20 | @Override 21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 22 | mViewFragment3 = inflater.inflate(R.layout.fragment_3, container, false); 23 | 24 | return mViewFragment3; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/HomeFragment.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.v4.view.ViewPager; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.astuetz.PagerSlidingTabStrip; 11 | 12 | import java.util.List; 13 | 14 | import br.com.halyson.materialdesign.R; 15 | import br.com.halyson.materialdesign.adapter.HomePagerAdapter; 16 | import br.com.halyson.materialdesign.fragment.api.BaseFragment; 17 | import br.com.halyson.materialdesign.interfaces.home.HomeView; 18 | import br.com.halyson.materialdesign.presenter.HomePresenterImpl; 19 | 20 | 21 | public class HomeFragment extends BaseFragment implements HomeView { 22 | private static final String TAG = HomeFragment.class.getSimpleName(); 23 | private View mViewHome; 24 | private PagerSlidingTabStrip mPagerSlidingTabStrip; 25 | private ViewPager mViewPager; 26 | private HomePresenterImpl mHomePresenter; 27 | 28 | @Override 29 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 30 | mViewHome = inflater.inflate(R.layout.fragment_default, container, false); 31 | 32 | loadViewComponents(); 33 | initPresenter(); 34 | loadSectionsTabs(); 35 | 36 | return mViewHome; 37 | } 38 | 39 | @Override 40 | public void onDestroy() { 41 | mHomePresenter.onDestroy(); 42 | super.onDestroy(); 43 | } 44 | 45 | @Override 46 | public void loadViewComponents() { 47 | mPagerSlidingTabStrip = (PagerSlidingTabStrip) mViewHome.findViewById(R.id.fragment_home_pager_sliding_tab); 48 | mViewPager = (ViewPager) mViewHome.findViewById(R.id.fragment_home_view_pager); 49 | } 50 | 51 | @Override 52 | public void initPresenter() { 53 | mHomePresenter = new HomePresenterImpl(this); 54 | } 55 | 56 | @Override 57 | public void loadSectionsTabs() { 58 | mHomePresenter.loadSectionsTabs(); 59 | } 60 | 61 | @Override 62 | public void loadViewPager(List listTitleTabs) { 63 | mViewPager.setAdapter(new HomePagerAdapter(listTitleTabs, getChildFragmentManager())); 64 | } 65 | 66 | @Override 67 | public void setColorTabs(int color) { 68 | mPagerSlidingTabStrip.setTextColor(color); 69 | } 70 | 71 | @Override 72 | public void setDividerColorTabs(int color) { 73 | mPagerSlidingTabStrip.setDividerColor(mViewHome.getResources().getColor(R.color.theme_dialer_primary)); 74 | } 75 | 76 | @Override 77 | public void setIndicatorColorTabs(int color) { 78 | mPagerSlidingTabStrip.setDividerColor(color); 79 | } 80 | 81 | @Override 82 | public void loadTabs() { 83 | mPagerSlidingTabStrip.setViewPager(mViewPager); 84 | } 85 | } -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/NavigationDrawerFragment.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment; 2 | 3 | import android.app.Activity; 4 | import android.content.SharedPreferences; 5 | import android.content.res.Configuration; 6 | import android.content.res.Resources; 7 | import android.os.Bundle; 8 | import android.preference.PreferenceManager; 9 | import android.support.v4.view.GravityCompat; 10 | import android.support.v4.widget.DrawerLayout; 11 | import android.support.v7.app.ActionBarDrawerToggle; 12 | import android.util.Log; 13 | import android.view.LayoutInflater; 14 | import android.view.MenuItem; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.AdapterView; 18 | import android.widget.ListView; 19 | 20 | import java.util.ArrayList; 21 | 22 | import br.com.halyson.materialdesign.R; 23 | import br.com.halyson.materialdesign.adapter.DrawerMenuAdapter; 24 | import br.com.halyson.materialdesign.fragment.api.BaseFragment; 25 | import br.com.halyson.materialdesign.model.DrawerMenuBean; 26 | 27 | 28 | /** 29 | * Fragment utilizado para o gerenciamento de interações para e apresentação do menu drawer. 30 | */ 31 | public class 32 | NavigationDrawerFragment extends BaseFragment { 33 | private static final String TAG = NavigationDrawerFragment.class.getSimpleName(); 34 | 35 | /** 36 | * Lembra a posição do item selecionado. 37 | */ 38 | private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; 39 | 40 | /** 41 | * Por as diretrizes de design, você deve mostrar o menu drawer até que o usuário expande ele manualmente. 42 | */ 43 | private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; 44 | 45 | /** 46 | * A pointer to the current callbacks instance (the Activity). 47 | */ 48 | private NavigationDrawerCallbacks mCallbacks; 49 | 50 | /** 51 | * Componente 52 | */ 53 | private ActionBarDrawerToggle mDrawerToggle; 54 | private DrawerLayout mDrawerLayout; 55 | private ListView mDrawerListView; 56 | private View mFragmentContainerView; 57 | private int mCurrentSelectedPosition = 0; 58 | private boolean mFromSavedInstanceState; 59 | private boolean mUserLearnedDrawer; 60 | 61 | @Override 62 | public void onCreate(Bundle savedInstanceState) { 63 | super.onCreate(savedInstanceState); 64 | 65 | // Read in the flag indicating whether or not the user has 66 | // s demonstrated awareness of the 67 | // drawer. See PREF_USER_LEARNED_DRAWER for details. 68 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); 69 | mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); 70 | 71 | if (savedInstanceState != null) { 72 | mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); 73 | mFromSavedInstanceState = true; 74 | } 75 | } 76 | 77 | 78 | @Override 79 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 80 | Bundle savedInstanceState) { 81 | mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_drawer_menu, container, false); 82 | 83 | loadListeners(); 84 | loadInfoView(); 85 | 86 | return mDrawerListView; 87 | } 88 | 89 | @Override 90 | public void onActivityCreated(Bundle savedInstanceState) { 91 | super.onActivityCreated(savedInstanceState); 92 | setHasOptionsMenu(true); 93 | } 94 | 95 | @Override 96 | public void onAttach(Activity activity) { 97 | super.onAttach(activity); 98 | try { 99 | mCallbacks = (NavigationDrawerCallbacks) activity; 100 | } catch (ClassCastException e) { 101 | throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); 102 | } 103 | } 104 | 105 | @Override 106 | public void onDetach() { 107 | super.onDetach(); 108 | mCallbacks = null; 109 | } 110 | 111 | @Override 112 | public void onSaveInstanceState(Bundle outState) { 113 | super.onSaveInstanceState(outState); 114 | outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition); 115 | } 116 | 117 | @Override 118 | public void onConfigurationChanged(Configuration newConfig) { 119 | super.onConfigurationChanged(newConfig); 120 | // Forward the new configuration the drawer toggle component. 121 | mDrawerToggle.onConfigurationChanged(newConfig); 122 | } 123 | 124 | @Override 125 | public boolean onOptionsItemSelected(MenuItem item) { 126 | if (item.getItemId() == android.R.id.home) { 127 | if (mDrawerLayout != null) { 128 | if (isDrawerOpen()) { 129 | mDrawerLayout.closeDrawer(mFragmentContainerView); 130 | } else { 131 | mDrawerLayout.openDrawer(mFragmentContainerView); 132 | } 133 | } else { 134 | getActivity().finish(); 135 | } 136 | } 137 | return super.onOptionsItemSelected(item); 138 | } 139 | 140 | private void loadListeners() { 141 | mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 142 | @Override 143 | public void onItemClick(AdapterView parent, View view, int position, long id) { 144 | selectItem(position); 145 | } 146 | }); 147 | } 148 | 149 | private void loadInfoView() { 150 | ArrayList menuDrawerListItens = loadMenuDrawerItens(); 151 | if (menuDrawerListItens != null) { 152 | DrawerMenuAdapter drawerMenuAdapter = new DrawerMenuAdapter(mContext, menuDrawerListItens); 153 | 154 | mDrawerListView.setAdapter(drawerMenuAdapter); 155 | mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); 156 | } 157 | } 158 | 159 | private ArrayList loadMenuDrawerItens() { 160 | String[] menuDrawerTitleArray; 161 | ArrayList menuDrawerListItens = null; 162 | 163 | try { 164 | menuDrawerTitleArray = getActivity().getResources().getStringArray(R.array.fragment_drawerMenu_title); 165 | 166 | menuDrawerListItens = new ArrayList<>(); 167 | for (String aMenuDrawerTitleArray : menuDrawerTitleArray) { 168 | menuDrawerListItens.add(new DrawerMenuBean(aMenuDrawerTitleArray)); 169 | } 170 | return menuDrawerListItens; 171 | } catch (Resources.NotFoundException notFoundExcepetion) { 172 | Log.e(TAG, "Error Getting The Array", notFoundExcepetion); 173 | } 174 | return menuDrawerListItens; 175 | } 176 | 177 | 178 | public boolean isDrawerOpen() { 179 | return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView); 180 | } 181 | 182 | public void setUp(int fragmentId, DrawerLayout drawerLayout) { 183 | mFragmentContainerView = getActivity().findViewById(fragmentId); 184 | mDrawerLayout = drawerLayout; 185 | 186 | // set a custom shadow that overlays the main content when the drawer opens 187 | mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_menu_shadow, GravityCompat.START); 188 | // set up the drawer's list view with items and click listener 189 | 190 | 191 | // ActionBarDrawerToggle ties together the the proper interactions 192 | // between the navigation drawer and the action bar app icon. 193 | mDrawerToggle = new ActionBarDrawerToggle( 194 | getActivity(), /* host Activity */ 195 | mDrawerLayout, /* DrawerLayout object */ 196 | R.string.app_name, /* "open drawer" description for accessibility */ 197 | R.string.app_name /* "close drawer" description for accessibility */ 198 | ) { 199 | @Override 200 | public void onDrawerClosed(View drawerView) { 201 | super.onDrawerClosed(drawerView); 202 | if (!isAdded()) { 203 | return; 204 | } 205 | 206 | getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() 207 | } 208 | 209 | @Override 210 | public void onDrawerOpened(View drawerView) { 211 | super.onDrawerOpened(drawerView); 212 | if (!isAdded()) { 213 | return; 214 | } 215 | 216 | if (!mUserLearnedDrawer) { 217 | // The user manually opened the drawer; store this flag to prevent auto-showing 218 | // the navigation drawer automatically in the future. 219 | mUserLearnedDrawer = true; 220 | SharedPreferences sp = PreferenceManager 221 | .getDefaultSharedPreferences(getActivity()); 222 | sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); 223 | } 224 | 225 | getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() 226 | } 227 | }; 228 | 229 | // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, 230 | // per the navigation drawer design guidelines. 231 | if (!mUserLearnedDrawer && !mFromSavedInstanceState) { 232 | mDrawerLayout.openDrawer(mFragmentContainerView); 233 | } 234 | 235 | // Defer code dependent on restoration of previous instance state. 236 | mDrawerLayout.post(new Runnable() { 237 | @Override 238 | public void run() { 239 | mDrawerToggle.syncState(); 240 | } 241 | }); 242 | 243 | mDrawerLayout.setDrawerListener(mDrawerToggle); 244 | } 245 | 246 | private void selectItem(int position) { 247 | mCurrentSelectedPosition = position; 248 | if (mDrawerListView != null) { 249 | mDrawerListView.setItemChecked(position, true); 250 | } 251 | if (mDrawerLayout != null) { 252 | mDrawerLayout.closeDrawer(mFragmentContainerView); 253 | } 254 | if (mCallbacks != null) { 255 | mCallbacks.onNavigationDrawerItemSelected(position); 256 | } 257 | } 258 | 259 | public static interface NavigationDrawerCallbacks { 260 | /** 261 | * Called when an item in the navigation drawer is selected. 262 | */ 263 | void onNavigationDrawerItemSelected(int position); 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/RecylerViewFragment.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.melnykov.fab.FloatingActionButton; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | import br.com.halyson.materialdesign.R; 16 | import br.com.halyson.materialdesign.adapter.RecyclerViewCardsAdapter; 17 | import br.com.halyson.materialdesign.fragment.api.BaseFragment; 18 | import br.com.halyson.materialdesign.model.CardViewBean; 19 | 20 | /** 21 | * Created by halyson on 18/12/14. 22 | */ 23 | public class RecylerViewFragment extends BaseFragment { 24 | private static final String MOCK_URL = "http://lorempixel.com/800/400/nightlife/"; 25 | private View mViewRecyclerCardsView; 26 | private RecyclerView mRecyclerView; 27 | private FloatingActionButton mFloatingActionButton; 28 | 29 | public static RecylerViewFragment newInstance() { 30 | return new RecylerViewFragment(); 31 | } 32 | 33 | @Override 34 | public void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | } 37 | 38 | @Override 39 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 40 | mViewRecyclerCardsView = inflater.inflate(R.layout.fragment_recycler_view, container, false); 41 | 42 | loadViewComponents(); 43 | loadInfoView(); 44 | 45 | return mViewRecyclerCardsView; 46 | } 47 | 48 | private void loadViewComponents() { 49 | mRecyclerView = (RecyclerView) mViewRecyclerCardsView.findViewById(R.id.fragment_recyler_view_content_main); 50 | mFloatingActionButton = (FloatingActionButton) mViewRecyclerCardsView.findViewById(R.id.fragment_recyler_view_float_action_button); 51 | } 52 | 53 | private void loadInfoView() { 54 | mFloatingActionButton.attachToRecyclerView(mRecyclerView); 55 | LinearLayoutManager layoutManager = new LinearLayoutManager(mContext); 56 | layoutManager.setOrientation(LinearLayoutManager.VERTICAL); 57 | mRecyclerView.setHasFixedSize(true); 58 | mRecyclerView.setLayoutManager(layoutManager); 59 | mRecyclerView.setAdapter(new RecyclerViewCardsAdapter(getActivity(),createMockList())); 60 | } 61 | 62 | private List createMockList() { 63 | List listCard = new ArrayList<>(); 64 | for (int i = 0; i < 10; i++) { 65 | listCard.add(new CardViewBean(MOCK_URL + i)); 66 | } 67 | return listCard; 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/fragment/api/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.fragment.api; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.support.v4.app.Fragment; 6 | 7 | public class BaseFragment extends Fragment { 8 | protected Context mContext; 9 | protected Activity mActivity; 10 | 11 | public BaseFragment() { 12 | super(); 13 | } 14 | 15 | @Override 16 | public void onAttach(Activity activity) { 17 | super.onAttach(activity); 18 | this.mActivity = activity; 19 | this.mContext = mActivity.getApplicationContext(); 20 | } 21 | 22 | @Override 23 | public void onDestroy() { 24 | super.onDestroy(); 25 | mActivity = null; 26 | mContext = null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/interfaces/A.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.interfaces; 2 | 3 | /** 4 | * Created by Halyson on 20/01/15. 5 | */ 6 | public class A { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/interfaces/home/HomePresenter.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.interfaces.home; 2 | 3 | import com.squareup.otto.Subscribe; 4 | 5 | import br.com.halyson.materialdesign.events.LoadColorsTabsDisk; 6 | import br.com.halyson.materialdesign.events.LoadTitleTabsDisk; 7 | 8 | /** 9 | * Created by Halyson on 20/01/15. 10 | */ 11 | public interface HomePresenter { 12 | void loadSectionsTabs(); 13 | 14 | @Subscribe 15 | void onLoadTitleTabsDiskSuccess(LoadTitleTabsDisk loadTitleTabsDisk); 16 | 17 | @Subscribe 18 | void onLoadColorTabsDiskSuccess(LoadColorsTabsDisk loadColorsTabsDisk); 19 | 20 | void onDestroy(); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/interfaces/home/HomeRepository.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.interfaces.home; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Halyson on 20/01/15. 7 | */ 8 | public interface HomeRepository { 9 | void recoverTitleTabs(); 10 | 11 | void recoverColorsTabs(); 12 | 13 | int getColorTab(); 14 | 15 | int getDividerColorTab(); 16 | 17 | int getIndicatorColorTab(); 18 | 19 | void onDestroy(); 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/interfaces/home/HomeService.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.interfaces.home; 2 | 3 | /** 4 | * Created by Halyson on 20/01/15. 5 | */ 6 | public interface HomeService { 7 | void recoverTitleTabs(); 8 | 9 | void recoverColorTabs(); 10 | 11 | void onDestroy(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/interfaces/home/HomeView.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.interfaces.home; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Halyson on 20/01/15. 7 | */ 8 | public interface HomeView { 9 | void loadViewComponents(); 10 | 11 | void initPresenter(); 12 | 13 | void loadSectionsTabs(); 14 | 15 | void loadViewPager(List listTitleTabs); 16 | 17 | void setColorTabs(int color); 18 | 19 | void setDividerColorTabs(int color); 20 | 21 | void setIndicatorColorTabs(int color); 22 | 23 | void loadTabs(); 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/model/CardViewBean.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.model; 2 | 3 | /** 4 | * Created by halyson on 19/12/14. 5 | */ 6 | public class CardViewBean { 7 | String urlImage; 8 | 9 | public CardViewBean(String urlImage) { 10 | this.urlImage = urlImage; 11 | } 12 | 13 | public String getUrlImage() { 14 | return urlImage; 15 | } 16 | 17 | public void setUrlImage(String urlImage) { 18 | this.urlImage = urlImage; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/model/DrawerMenuBean.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.model; 2 | 3 | public class DrawerMenuBean { 4 | private String title; 5 | 6 | public DrawerMenuBean(String title) { 7 | this.title = title; 8 | } 9 | 10 | public String getTitle() { 11 | return title; 12 | } 13 | 14 | public void setTitle(String title) { 15 | this.title = title; 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/model/SectionsTabsBean.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.model; 2 | 3 | /** 4 | * Created by halyson on 18/12/14. 5 | */ 6 | public class SectionsTabsBean { 7 | private String title; 8 | 9 | public SectionsTabsBean(String title) { 10 | this.title = title; 11 | } 12 | 13 | public String getTitle() { 14 | return title; 15 | } 16 | 17 | public void setTitle(String title) { 18 | this.title = title; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/presenter/HomePresenterImpl.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.presenter; 2 | 3 | import com.squareup.otto.Subscribe; 4 | 5 | import br.com.halyson.materialdesign.events.LoadColorsTabsDisk; 6 | import br.com.halyson.materialdesign.events.LoadTitleTabsDisk; 7 | import br.com.halyson.materialdesign.interfaces.home.HomePresenter; 8 | import br.com.halyson.materialdesign.interfaces.home.HomeView; 9 | import br.com.halyson.materialdesign.service.HomeServiceImpl; 10 | import br.com.halyson.materialdesign.utility.BusProvider; 11 | 12 | /** 13 | * Created by Halyson on 20/01/15. 14 | */ 15 | public class HomePresenterImpl implements HomePresenter { 16 | private static final String TAG = HomePresenterImpl.class.getSimpleName(); 17 | private HomeView mHomeView; 18 | private HomeServiceImpl mHomeService; 19 | 20 | public HomePresenterImpl(HomeView homeView) { 21 | BusProvider.getInstance().register(this); 22 | mHomeView = homeView; 23 | mHomeService = new HomeServiceImpl(); 24 | } 25 | 26 | @Override 27 | public void loadSectionsTabs() { 28 | mHomeService.recoverTitleTabs(); 29 | } 30 | 31 | @Subscribe 32 | public void onLoadTitleTabsDiskSuccess(LoadTitleTabsDisk loadTitleTabsDisk) { 33 | mHomeView.loadViewPager(loadTitleTabsDisk.getListTitleTabs()); 34 | mHomeService.recoverColorTabs(); 35 | } 36 | 37 | @Subscribe 38 | public void onLoadColorTabsDiskSuccess(LoadColorsTabsDisk loadColorsTabsDisk) { 39 | mHomeView.setColorTabs(loadColorsTabsDisk.getColorTab()); 40 | mHomeView.setDividerColorTabs(loadColorsTabsDisk.getDividerColorTab()); 41 | mHomeView.setIndicatorColorTabs(loadColorsTabsDisk.getIndicatorColorTab()); 42 | mHomeView.loadTabs(); 43 | } 44 | 45 | @Override 46 | public void onDestroy() { 47 | BusProvider.getInstance().unregister(this); 48 | mHomeService.onDestroy(); 49 | mHomeService = null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/repository/HomeRepositoryDiskImpl.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.repository; 2 | 3 | import android.content.res.Resources; 4 | import android.util.Log; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | import br.com.halyson.materialdesign.MaterialDesignApplication; 10 | import br.com.halyson.materialdesign.R; 11 | import br.com.halyson.materialdesign.events.LoadColorsTabsDisk; 12 | import br.com.halyson.materialdesign.events.LoadTitleTabsDisk; 13 | import br.com.halyson.materialdesign.interfaces.home.HomeRepository; 14 | import br.com.halyson.materialdesign.utility.BusProvider; 15 | 16 | /** 17 | * Created by Halyson on 20/01/15. 18 | */ 19 | public class HomeRepositoryDiskImpl implements HomeRepository { 20 | private static final String TAG = HomeRepositoryDiskImpl.class.getSimpleName(); 21 | 22 | public HomeRepositoryDiskImpl() { 23 | BusProvider.getInstance().register(this); 24 | } 25 | 26 | @Override 27 | public void recoverTitleTabs() { 28 | try { 29 | List listTitleTabs = Arrays.asList(MaterialDesignApplication.getApplicationCtx().getResources().getStringArray(R.array.fragment_home_sections_tabs_title)); 30 | 31 | BusProvider.getInstance().post(new LoadTitleTabsDisk(listTitleTabs)); 32 | } catch (Resources.NotFoundException notFoundExcepetion) { 33 | Log.e(TAG, "Error Getting The Array", notFoundExcepetion); 34 | } 35 | } 36 | 37 | @Override 38 | public void recoverColorsTabs() { 39 | BusProvider.getInstance().post(new LoadColorsTabsDisk(getColorTab(), getDividerColorTab(), getIndicatorColorTab())); 40 | } 41 | 42 | @Override 43 | public int getColorTab() { 44 | return MaterialDesignApplication.getApplicationCtx().getResources().getColor(android.R.color.white); 45 | 46 | } 47 | 48 | @Override 49 | public int getDividerColorTab() { 50 | return MaterialDesignApplication.getApplicationCtx().getResources().getColor(R.color.theme_dialer_primary); 51 | } 52 | 53 | @Override 54 | public int getIndicatorColorTab() { 55 | return MaterialDesignApplication.getApplicationCtx().getResources().getColor(android.R.color.transparent); 56 | } 57 | 58 | @Override 59 | public void onDestroy() { 60 | BusProvider.getInstance().unregister(this); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/service/HomeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.service; 2 | 3 | import br.com.halyson.materialdesign.interfaces.home.HomeService; 4 | import br.com.halyson.materialdesign.repository.HomeRepositoryDiskImpl; 5 | 6 | /** 7 | * Created by Halyson on 20/01/15. 8 | */ 9 | public class HomeServiceImpl implements HomeService { 10 | private static final String TAG = HomeServiceImpl.class.getSimpleName(); 11 | private HomeRepositoryDiskImpl mHomeRepositoryDisk; 12 | 13 | public HomeServiceImpl() { 14 | mHomeRepositoryDisk = new HomeRepositoryDiskImpl(); 15 | } 16 | 17 | @Override 18 | public void recoverTitleTabs() { 19 | mHomeRepositoryDisk.recoverTitleTabs(); 20 | } 21 | 22 | @Override 23 | public void recoverColorTabs() { 24 | mHomeRepositoryDisk.recoverColorsTabs(); 25 | } 26 | 27 | @Override 28 | public void onDestroy() { 29 | mHomeRepositoryDisk.onDestroy(); 30 | mHomeRepositoryDisk = null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/utility/BusProvider.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.utility; 2 | 3 | import android.content.Context; 4 | 5 | import com.squareup.otto.Bus; 6 | 7 | import br.com.halyson.materialdesign.MaterialDesignApplication; 8 | 9 | /** 10 | * Created by Halyson on 05/01/15. 11 | */ 12 | public class BusProvider { 13 | private static final String TAG = PreferencesEditor.class.getSimpleName(); 14 | private static Bus mBus; 15 | 16 | private static Bus getBus(Context context) { 17 | if (mBus == null) { 18 | synchronized (BusProvider.class) { 19 | if (mBus == null) { 20 | mBus = new Bus(); 21 | } 22 | } 23 | } 24 | return mBus; 25 | } 26 | 27 | public static Bus getInstance() { 28 | return getBus(MaterialDesignApplication.getApplicationCtx()); 29 | } 30 | 31 | public static void shutdown() { 32 | mBus = null; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/br/com/halyson/materialdesign/utility/PreferencesEditor.java: -------------------------------------------------------------------------------- 1 | package br.com.halyson.materialdesign.utility; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.content.SharedPreferences.Editor; 6 | 7 | public class PreferencesEditor { 8 | private static SharedPreferences mSingletonPreferences; 9 | 10 | private static SharedPreferences getSharedPreferences(Context context) { 11 | if (mSingletonPreferences == null) { 12 | synchronized (PreferencesEditor.class) { 13 | if (mSingletonPreferences == null) { 14 | mSingletonPreferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); 15 | } 16 | } 17 | } 18 | return mSingletonPreferences; 19 | } 20 | 21 | public static void shutdown() { 22 | mSingletonPreferences = null; 23 | } 24 | 25 | public static void clearPreferences(Context context) { 26 | Editor editor = getSharedPreferences(context).edit(); 27 | editor.clear(); 28 | editor.apply(); 29 | shutdown(); 30 | } 31 | 32 | public static boolean getBooleanPreference(Context context, int resId, boolean defaultValue) { 33 | return getSharedPreferences(context).getBoolean(context.getString(resId), defaultValue); 34 | } 35 | 36 | public static boolean getBooleanPreference(Context context, String prefKey, boolean defaultValue) { 37 | return getSharedPreferences(context).getBoolean(prefKey, defaultValue); 38 | } 39 | 40 | public static int getIntPreference(Context context, int resId, int defaultValue) { 41 | return getSharedPreferences(context).getInt(context.getString(resId), defaultValue); 42 | } 43 | 44 | public static int getIntPreference(Context context, String prefKey, int defaultValue) { 45 | return getSharedPreferences(context).getInt(prefKey, defaultValue); 46 | } 47 | 48 | public static String getStringPreference(Context context, int resId, String defaultValue) { 49 | return getSharedPreferences(context).getString(context.getString(resId), defaultValue); 50 | } 51 | 52 | public static String getStringPreference(Context context, String prefKey, String defaultValue) { 53 | return getSharedPreferences(context).getString(prefKey, defaultValue); 54 | } 55 | 56 | public static void savePreference(Context context, int resId, int newValue) { 57 | Editor editor = getSharedPreferences(context).edit(); 58 | editor.putInt(context.getString(resId), newValue); 59 | editor.apply(); 60 | } 61 | 62 | public static void savePreference(Context context, String prefKey, int newValue) { 63 | Editor editor = getSharedPreferences(context).edit(); 64 | editor.putInt(prefKey, newValue); 65 | editor.apply(); 66 | } 67 | 68 | public static void savePreference(Context context, int resId, String newValue) { 69 | Editor editor = getSharedPreferences(context).edit(); 70 | editor.putString(context.getString(resId), newValue); 71 | editor.apply(); 72 | } 73 | 74 | public static void savePreference(Context context, String prefKey, String newValue) { 75 | Editor editor = getSharedPreferences(context).edit(); 76 | editor.putString(prefKey, newValue); 77 | editor.apply(); 78 | } 79 | 80 | public static void savePreference(Context context, int resId, Boolean newValue) { 81 | Editor editor = getSharedPreferences(context).edit(); 82 | editor.putBoolean(context.getString(resId), newValue); 83 | editor.apply(); 84 | } 85 | 86 | public static void savePreference(Context context, String prefKey, Boolean newValue) { 87 | Editor editor = getSharedPreferences(context).edit(); 88 | editor.putBoolean(prefKey, newValue); 89 | editor.apply(); 90 | } 91 | 92 | public static void removePreference(Context context, int resId) { 93 | Editor editor = getSharedPreferences(context).edit(); 94 | editor.remove(context.getString(resId)); 95 | editor.apply(); 96 | } 97 | 98 | public static void removePreference(Context context, String prefKey) { 99 | Editor editor = getSharedPreferences(context).edit(); 100 | editor.remove(prefKey); 101 | editor.apply(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/placeholder_card_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/app/src/main/res/drawable-nodpi/placeholder_card_view.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/example.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/app/src/main/res/drawable-xxhdpi/example.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer_menu_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/app/src/main/res/drawable-xxhdpi/ic_drawer_menu_shadow.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gradient_header_background.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_default.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_drawer_menu.xml: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_drawer_menu_comp.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_recycler_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_recycler_view_comp.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/screen_default.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 20 | 21 | 27 | 28 | 29 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/screen_details.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 16 | 17 | 23 | 24 | 39 | 40 | 41 | 42 | 43 | 48 | 49 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_float_button_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/app/src/main/res/mipmap-xxhdpi/ic_float_button_add.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/theme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #F48FB1 7 | #EC407A 8 | #2A2A2A 9 | #ff4081 10 | #ff515252 11 | 12 | 13 | #009688 14 | #00796b 15 | #F4FF81 16 | 17 | 18 | #00C853 19 | #0277BD 20 | #0288D1 21 | #FFF 22 | 23 | 24 | #4fc3f7 25 | #009688 26 | 27 | #42bd41 28 | #673AB7 29 | 30 | #ffb74d 31 | #E91E63 32 | 33 | #ff8a65 34 | #d500f9 35 | 36 | 37 | #ff80ab 38 | #f50057 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2dp 5 | 4dp 6 | 6dp 7 | 8dp 8 | 10dp 9 | 12dp 10 | 14dp 11 | 16dp 12 | 18dp 13 | 20dp 14 | 22dp 15 | 24dp 16 | 24dp 17 | 28dp 18 | 19 | 20 | 2dp 21 | 4dp 22 | 6dp 23 | 8dp 24 | 10dp 25 | 12dp 26 | 14dp 27 | 16dp 28 | 18dp 29 | 20dp 30 | 22dp 31 | 24dp 32 | 24dp 33 | 28dp 34 | 35 | 36 | @dimen/two 37 | @dimen/four 38 | @dimen/six 39 | @dimen/eight 40 | @dimen/ten 41 | @dimen/twelve 42 | @dimen/fourteen 43 | @dimen/sixteen 44 | @dimen/eighteen 45 | @dimen/twenty 46 | @dimen/twenty_two 47 | @dimen/twenty_four 48 | @dimen/twenty_six 49 | @dimen/twenty_eight 50 | 51 | 52 | @dimen/two 53 | @dimen/four 54 | @dimen/six 55 | @dimen/eight 56 | @dimen/ten 57 | @dimen/twelve 58 | @dimen/fourteen 59 | @dimen/sixteen 60 | @dimen/eighteen 61 | @dimen/twenty 62 | @dimen/twenty_two 63 | @dimen/twenty_four 64 | @dimen/twenty_six 65 | @dimen/twenty_eight 66 | 67 | 68 | @dimen/two 69 | @dimen/four 70 | @dimen/six 71 | @dimen/eight 72 | @dimen/ten 73 | @dimen/twelve 74 | @dimen/fourteen 75 | @dimen/sixteen 76 | @dimen/eighteen 77 | @dimen/twenty 78 | @dimen/twenty_two 79 | @dimen/twenty_four 80 | @dimen/twenty_six 81 | @dimen/twenty_eight 82 | 83 | 84 | 85 | @dimen/two 86 | @dimen/four 87 | @dimen/six 88 | @dimen/eight 89 | @dimen/ten 90 | @dimen/twelve 91 | @dimen/fourteen 92 | @dimen/sixteen 93 | @dimen/eighteen 94 | @dimen/twenty 95 | @dimen/twenty_two 96 | @dimen/twenty_four 97 | @dimen/twenty_six 98 | @dimen/twenty_eight 99 | 100 | 101 | 240dp 102 | 103 | 104 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings_default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Material Design Example 5 | 6 | 7 | Menu 1 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fragment 1 6 | 7 | 8 | Fragment 1 9 | Fragment 2 10 | Fragment 3 11 | 12 | 13 | 14 | @string/fragment_drawerMenu_text_fragment1 15 | @string/fragment_drawerMenu_text_fragment2 16 | @string/fragment_drawerMenu_text_fragment3 17 | 18 | 19 | 20 | 21 | 22 | Fragment 1 23 | Fragment 2 24 | Fragment 3 25 | 26 | 27 | 28 | @string/fragment_home_fragment1_title 29 | @string/fragment_home_fragment2_title 30 | @string/fragment_home_fragment3_title 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/theme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | -------------------------------------------------------------------------------- /art/GooglePlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/art/GooglePlay.png -------------------------------------------------------------------------------- /art/MaterialExampleDesign1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/art/MaterialExampleDesign1.png -------------------------------------------------------------------------------- /art/MaterialExampleDesign2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/art/MaterialExampleDesign2.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:1.0.0' 8 | } 9 | } 10 | 11 | allprojects { 12 | repositories { 13 | jcenter() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /gif/MaterialDesignExample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/gif/MaterialDesignExample.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/halysongoncalves/Material-Design-Example/ff9146c42bf24ebf7ec1564cbc70c6b237335d99/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 15 16:52:29 BRST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------