├── .gitee ├── ISSUE_TEMPLATE.zh-CN.md └── PULL_REQUEST_TEMPLATE.zh-CN.md ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── idaniu │ │ └── maga │ │ └── shopping │ │ ├── Constant.java │ │ ├── DESUtil.java │ │ ├── ShoppingApplication.java │ │ ├── activity │ │ ├── BannerActivity.java │ │ ├── BaseActivity.java │ │ ├── LoginActivity.java │ │ ├── MainActivity.java │ │ └── RegisterActivity.java │ │ ├── adapter │ │ ├── CartRecyclerAdapter.java │ │ ├── HomeRecyclerAdapter.java │ │ └── HotRecyclerAdapter.java │ │ ├── bean │ │ ├── BannerBean.java │ │ ├── HomeBean.java │ │ ├── HotResultBean.java │ │ ├── LoginBean.java │ │ ├── ProductBean.java │ │ ├── ShoppingCartBean.java │ │ └── UserBean.java │ │ ├── fragment │ │ ├── BaseFragment.java │ │ ├── Fragment1.java │ │ ├── Fragment2.java │ │ ├── Fragment3.java │ │ ├── Fragment4.java │ │ └── Fragment5.java │ │ └── manager │ │ ├── CartManager.java │ │ └── UserManager.java │ └── res │ ├── drawable-hdpi │ ├── icon_alipay_72.png │ ├── icon_bd_72.png │ ├── icon_cancel_128.png │ ├── icon_check_false.png │ ├── icon_check_true.png │ ├── icon_right_64.png │ ├── icon_success_128.png │ ├── icon_wechat_72.png │ ├── indicate_circle_gray.png │ ├── indicate_circle_red.png │ ├── selector_checkbox_green.xml │ ├── shape_button.xml │ ├── tab_iv_1_gray.png │ ├── tab_iv_1_red.png │ ├── tab_iv_2_gray.png │ ├── tab_iv_2_red.png │ ├── tab_iv_3_gray.png │ ├── tab_iv_3_red.png │ ├── tab_iv_4_gray.png │ ├── tab_iv_4_red.png │ ├── tab_iv_5_gray.png │ └── tab_iv_5_red.png │ ├── drawable-xhdpi │ ├── default_head.png │ ├── icon_add.png │ ├── icon_back_32px.png │ ├── icon_cart.png │ ├── icon_cartfill_press.png │ ├── icon_check_32.png │ ├── icon_check_checked_32.png │ ├── icon_delete_32.png │ ├── icon_discover.png │ ├── icon_discover_press.png │ ├── icon_edit_32.png │ ├── icon_favorite.png │ ├── icon_grid_32.png │ ├── icon_home.png │ ├── icon_home_press.png │ ├── icon_hot.png │ ├── icon_hot_press.png │ ├── icon_list_32.png │ ├── icon_list_o.png │ ├── icon_location.png │ ├── icon_lock.png │ ├── icon_msg.png │ ├── icon_my_info.png │ ├── icon_search.png │ ├── icon_telphone_32.png │ ├── icon_trash_32.png │ ├── icon_user.png │ └── icon_user_press.png │ ├── layout │ ├── activity_banner.xml │ ├── activity_login.xml │ ├── activity_main.xml │ ├── activity_register.xml │ ├── cart_item.xml │ ├── frag1.xml │ ├── frag2.xml │ ├── frag3.xml │ ├── frag4.xml │ ├── frag5.xml │ ├── home_item.xml │ ├── hot_item.xml │ └── hot_loading_more.xml │ ├── menu │ ├── menu_banner.xml │ └── menu_login.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── yb_images ├── Screenshot_1.png ├── Screenshot_2.png └── Screenshot_3.png /.gitee/ISSUE_TEMPLATE.zh-CN.md: -------------------------------------------------------------------------------- 1 | ### 该问题是怎么引起的? 2 | 3 | 4 | 5 | ### 重现步骤 6 | 7 | 8 | 9 | ### 报错信息 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md: -------------------------------------------------------------------------------- 1 | ### 该Pull Request关联的Issue 2 | 3 | 4 | ### 修改描述 5 | 6 | 7 | 8 | ### 测试用例 9 | 10 | 11 | 12 | ### 修复效果的截屏 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | .DS_Store 6 | build 7 | /captures 8 | .externalNativeBuild 9 | *.apk 10 | .settings 11 | .project 12 | .classpath 13 | .pydevproject 14 | bin 15 | gen 16 | obj 17 | proguard 18 | build.xml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "{}" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright 2017 曼嘉 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # shopping 2 | android手机商城实战项目 --yuanbao 3 | 4 | ### app界面截图 5 | 1.主页 6 | 7 | 8 | 2.热卖页 9 | 10 | 11 | 3.购物车页 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.0" 7 | 8 | defaultConfig { 9 | applicationId "com.idaniu.maga.shopping" 10 | minSdkVersion 14 11 | targetSdkVersion 23 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | sourceSets { 24 | main { 25 | aidl.srcDirs = ['src/main/java'] 26 | jniLibs.srcDirs = ['libs'] 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | compile fileTree(include: ['*.jar'], dir: 'libs') 33 | compile 'com.android.support:appcompat-v7:26.0.0-alpha1' 34 | compile 'com.android.support:support-v4:26.0.0-alpha1' 35 | compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' 36 | compile 'com.squareup.okhttp3:okhttp:3.4.1' 37 | compile 'com.google.code.gson:gson:2.7' 38 | compile 'com.squareup.picasso:picasso:2.5.2' 39 | } 40 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/maga/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/Constant.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping; 2 | 3 | import okhttp3.MediaType; 4 | 5 | /** 6 | * Created by yuanbao15 on 2017/10/9. 7 | */ 8 | public class Constant { 9 | //首页图片轮播的图片资源地址 10 | // public static final String HEAD_URL = "http://112.124.22.238:8081/course_api/banner/query"; //初始 11 | public static final String HEAD_URL = "http://www.yuanbao15.club/ybfile/bannerimage.json"; //yb自己的....成功了。注意json数据格式 12 | 13 | 14 | //主页瀑布流的网络资源地址 15 | // public static final String HOME_URL = "http://112.124.22.238:8081/course_api/campaign/recommend"; //初始 16 | public static final String HOME_URL = "http://www.yuanbao15.club/ybfile/home.json"; //yb自己的 17 | 18 | public static final String HOST = "http://train.dolphin.com"; 19 | //热卖页瀑布流的网络资源地址 20 | // public static final String HOT_URL = HOST + "/course_api/wares/hot"; //这是之前的,现在这个服务业面关闭了 21 | public static final String HOT_URL = "http://www.yuanbao15.club/ybfile/hot.json"; //yb自己的 22 | 23 | public static final String LOGIN_URL = HOST + "/course_api/auth/login"; //登录url; 24 | public static final String REGISTER_URL = HOST + "/course_api/auth/reg"; //注册url; 25 | public static final String DES_KEY="12345670"; //加密算法的密钥。 26 | 27 | public static final MediaType CONTENT_TYPE = MediaType.parse("application/x-www-form-urlencoded"); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/DESUtil.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping; 2 | 3 | import java.security.Key; 4 | import java.security.spec.AlgorithmParameterSpec; 5 | import java.util.Locale; 6 | import javax.crypto.Cipher; 7 | import javax.crypto.SecretKeyFactory; 8 | import javax.crypto.spec.DESKeySpec; 9 | import javax.crypto.spec.IvParameterSpec; 10 | 11 | /** 12 | * Created by yuanbao15 on 2017/11/2. 13 | * DES对称加密,防止密码明文传输 14 | */ 15 | public class DESUtil { 16 | 17 | public static final String ALGORITHM_DES = "DES/CBC/PKCS5Padding"; 18 | 19 | /** 20 | * DES算法,加密 21 | * 22 | * @param key 加密私钥,长度不能够小于8位 23 | * @param data 待加密字符串 24 | * @return 加密后的字节数组,一般结合Base64编码使用 25 | * @throws Exception 26 | */ 27 | public static String encode(String key, String data) { 28 | if (data == null) 29 | return null; 30 | try { 31 | DESKeySpec dks = new DESKeySpec(key.getBytes()); 32 | SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); 33 | // key的长度不能够小于8位字节 34 | Key secretKey = keyFactory.generateSecret(dks); 35 | Cipher cipher = Cipher.getInstance(ALGORITHM_DES); 36 | IvParameterSpec iv = new IvParameterSpec("12345678".getBytes()); 37 | AlgorithmParameterSpec paramSpec = iv; 38 | cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec); 39 | byte[] bytes = cipher.doFinal(data.getBytes()); 40 | return byte2String(bytes); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | return data; 44 | } 45 | } 46 | 47 | 48 | /** 49 | * 二行制转字符串 50 | * 51 | * @param b 52 | * @return 53 | */ 54 | private static String byte2String(byte[] b) { 55 | StringBuilder hs = new StringBuilder(); 56 | String stmp; 57 | for (int n = 0; b != null && n < b.length; n++) { 58 | stmp = Integer.toHexString(b[n] & 0XFF); 59 | if (stmp.length() == 1) 60 | hs.append('0'); 61 | hs.append(stmp); 62 | } 63 | return hs.toString().toUpperCase(Locale.CHINA); 64 | } 65 | 66 | /** 67 | * 二进制转化成16进制 68 | * 69 | * @param b 70 | * @return 71 | */ 72 | private static byte[] byte2hex(byte[] b) { 73 | if ((b.length % 2) != 0) 74 | throw new IllegalArgumentException(); 75 | byte[] b2 = new byte[b.length / 2]; 76 | for (int n = 0; n < b.length; n += 2) { 77 | String item = new String(b, n, 2); 78 | b2[n / 2] = (byte) Integer.parseInt(item, 16); 79 | } 80 | return b2; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/ShoppingApplication.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Application 类似单例设计模式 但没有构造函数也没new出新的对象 7 | * Created by yuanbao15 on 2017/10/3. 8 | */ 9 | 10 | public class ShoppingApplication extends Application { 11 | 12 | private static ShoppingApplication sInstance; 13 | 14 | public static ShoppingApplication getInstance(){ 15 | return sInstance; 16 | } 17 | 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | 22 | sInstance = this; 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/activity/BannerActivity.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.activity; 2 | 3 | import android.support.v7.app.ActionBarActivity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.webkit.WebView; 8 | import android.webkit.WebViewClient; 9 | 10 | import com.idaniu.maga.shopping.R; 11 | 12 | /** 13 | * yb新建的用于点击头图后跳到的下一级页面,写了一个webview来展示自己的一个首页。 14 | */ 15 | public class BannerActivity extends ActionBarActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | // setContentView(R.layout.activity_banner); //不需要用这个了, 21 | WebView webView = new WebView(this); 22 | webView.getSettings().setJavaScriptEnabled(true); 23 | webView.setWebViewClient(new WebViewClient()); 24 | webView.loadUrl("https://yuanbao15.github.io"); 25 | setContentView(webView); 26 | 27 | } 28 | 29 | @Override 30 | public boolean onCreateOptionsMenu(Menu menu) { 31 | // Inflate the menu; this adds items to the action bar if it is present. 32 | getMenuInflater().inflate(R.menu.menu_banner, menu); 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean onOptionsItemSelected(MenuItem item) { 38 | // Handle action bar item clicks here. The action bar will 39 | // automatically handle clicks on the Home/Up button, so long 40 | // as you specify a parent activity in AndroidManifest.xml. 41 | int id = item.getItemId(); 42 | 43 | //noinspection SimplifiableIfStatement 44 | if (id == R.id.action_settings) { 45 | return true; 46 | } 47 | 48 | return super.onOptionsItemSelected(item); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/activity/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.activity; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | /** 8 | * Created by maga on 2017/10/3. 9 | * 10 | */ 11 | public class BaseActivity extends AppCompatActivity { 12 | 13 | 14 | @Override 15 | protected void onCreate(@Nullable Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | } 18 | 19 | @Override 20 | protected void onStart() { 21 | super.onStart(); 22 | } 23 | 24 | @Override 25 | protected void onResume() { 26 | super.onResume(); 27 | } 28 | 29 | @Override 30 | protected void onPause() { 31 | super.onPause(); 32 | } 33 | 34 | @Override 35 | protected void onStop() { 36 | super.onStop(); 37 | } 38 | 39 | @Override 40 | protected void onDestroy() { 41 | super.onDestroy(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/activity/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.activity; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Intent; 5 | import android.support.v7.app.ActionBarActivity; 6 | import android.os.Bundle; 7 | import android.text.TextUtils; 8 | import android.view.View; 9 | import android.widget.EditText; 10 | import android.widget.TextView; 11 | import android.widget.Toast; 12 | 13 | import com.idaniu.maga.shopping.R; 14 | import com.idaniu.maga.shopping.manager.UserManager; 15 | 16 | /** 17 | * 登录界面.实现登录时检验账号和密码及注册的问题,用pref本地实现。但登陆成功后跳转的问题to do 18 | * Created by yuanbao on 2017-11-2 19 | * 20 | */ 21 | public class LoginActivity extends BaseActivity { 22 | 23 | private static final String TAG = "LoginActivity"; 24 | public static final int LOGIN_CODE = 10001; //登录成功标识 25 | 26 | private TextView mRegisterButton, mFogetButton, mLoginButton; 27 | private EditText mPhoneEdit, mPasswordEdit; 28 | private ProgressDialog mProgressDialog; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_login); 34 | 35 | initView(); 36 | } 37 | 38 | private void initView() { 39 | mPhoneEdit = (EditText) findViewById(R.id.phoneEditText); 40 | mPasswordEdit = (EditText) findViewById(R.id.passwordEditText); 41 | 42 | mRegisterButton = (TextView) findViewById(R.id.registerButton); 43 | mFogetButton = (TextView) findViewById(R.id.forgetButton); 44 | mLoginButton = (TextView) findViewById(R.id.loginButton); 45 | 46 | //注册按钮 47 | mRegisterButton.setOnClickListener(new View.OnClickListener() { 48 | @Override 49 | public void onClick(View v) { 50 | Intent intent = new Intent(LoginActivity.this, RegisterActivity.class); 51 | startActivity(intent); 52 | } 53 | }); 54 | 55 | //登录按钮 56 | mLoginButton.setOnClickListener(new View.OnClickListener() { 57 | @Override 58 | public void onClick(View v) { 59 | //phone、password都不能为空 60 | String phone = mPhoneEdit.getText().toString(); 61 | String password = mPasswordEdit.getText().toString(); 62 | if (TextUtils.isEmpty(phone) || TextUtils.isEmpty(phone.trim()) || TextUtils.isEmpty(password) || TextUtils.isEmpty(password.trim())) { 63 | Toast.makeText(LoginActivity.this, "请输入手机号与密码", Toast.LENGTH_SHORT).show(); 64 | return; 65 | } 66 | 67 | //开始登录 68 | login(phone, password); 69 | } 70 | }); 71 | 72 | //如果曾经登录成功过,自动填入 73 | mPhoneEdit.setText(UserManager.getInstance().getPhone()); 74 | mPasswordEdit.setText(UserManager.getInstance().getPassword()); 75 | } 76 | 77 | private void login(String phone, String password) { 78 | showDialog();//显示登录进度框,像这些显示隐藏的逻辑一定要记得出入口,一个出口都不要漏掉哦!!! 79 | 80 | UserManager.getInstance().login(phone, password, new UserManager.OnLoginListener() { 81 | @Override 82 | public void onLogin() { 83 | runOnUiThread(new Runnable() { 84 | @Override 85 | public void run() { 86 | hideDialog();//不管成功还是失败,第一件事就是取消掉进度框 87 | 88 | Toast.makeText(LoginActivity.this, "登录成功", Toast.LENGTH_SHORT).show(); 89 | setResult(RESULT_OK);//设置登录成功标志,前一个Activity根据这个标志进行下一步操作 90 | 91 | Intent intent = new Intent(LoginActivity.this, MainActivity.class); 92 | startActivityForResult(intent, 10001); // 93 | 94 | //登录成功后,这个页面不再有用,直接杀掉 95 | finish(); 96 | } 97 | }); 98 | } 99 | 100 | @Override 101 | public void onError(String msg) { 102 | runOnUiThread(new Runnable() { 103 | @Override 104 | public void run() { 105 | hideDialog(); 106 | 107 | Toast.makeText(LoginActivity.this, "登录失败,请检查用户名或密码是否准确", Toast.LENGTH_SHORT).show(); 108 | } 109 | }); 110 | } 111 | }); 112 | } 113 | 114 | @Override 115 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 116 | super.onActivityResult(requestCode, resultCode, data); 117 | if(requestCode == 10002){ //表示注册成功,销毁掉上一个activity 118 | if(resultCode == RESULT_OK){ 119 | finish(); 120 | } 121 | } 122 | } 123 | 124 | private void showDialog(){ 125 | hideDialog(); 126 | 127 | mProgressDialog = new ProgressDialog(this); 128 | mProgressDialog.setIndeterminate(true); 129 | mProgressDialog.setMessage("yb正在加载"); 130 | mProgressDialog.show(); 131 | } 132 | 133 | private void hideDialog(){ 134 | if(mProgressDialog != null){ 135 | mProgressDialog.cancel(); 136 | mProgressDialog = null; 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.activity; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentActivity; 7 | import android.support.v4.app.FragmentPagerAdapter; 8 | import android.support.v4.view.ViewPager; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | import android.widget.LinearLayout; 12 | import android.widget.TextView; 13 | 14 | import com.idaniu.maga.shopping.R; 15 | import com.idaniu.maga.shopping.fragment.Fragment1; 16 | import com.idaniu.maga.shopping.fragment.Fragment2; 17 | import com.idaniu.maga.shopping.fragment.Fragment3; 18 | import com.idaniu.maga.shopping.fragment.Fragment4; 19 | import com.idaniu.maga.shopping.fragment.Fragment5; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | /** 25 | * description: 主页 26 | */ 27 | public class MainActivity extends FragmentActivity implements View.OnClickListener { 28 | 29 | private ViewPager mViewPager; //用来展示五个fragment的ViewPager 30 | private FragmentPagerAdapter mAdaper; //FragmentPager的适配器 31 | private List fragmentList; //用来存放几个Fragment 32 | 33 | private LinearLayout ll1; //五个标题栏 34 | private LinearLayout ll2; 35 | private LinearLayout ll3; 36 | private LinearLayout ll4; 37 | private LinearLayout ll5; 38 | 39 | //标题栏中的图片和文字控件 40 | private ImageView iv1; 41 | private ImageView iv2; 42 | private ImageView iv3; 43 | private ImageView iv4; 44 | private ImageView iv5; 45 | private TextView tv1; 46 | private TextView tv2; 47 | private TextView tv3; 48 | private TextView tv4; 49 | private TextView tv5; 50 | 51 | @Override 52 | protected void onCreate(Bundle savedInstanceState) { 53 | super.onCreate(savedInstanceState); 54 | setContentView(R.layout.activity_main); 55 | 56 | initView(); 57 | 58 | } 59 | 60 | //布局初始化 61 | private void initView() { 62 | mViewPager = (ViewPager) findViewById(R.id.viewpager); 63 | fragmentList = new ArrayList(); 64 | 65 | //5个标题,并设置监听 66 | ll1 = (LinearLayout) findViewById(R.id.ll_1); //下面标题栏的布局,找到这个容器用于添加数字 67 | ll2 = (LinearLayout) findViewById(R.id.ll_2); 68 | ll3 = (LinearLayout) findViewById(R.id.ll_3); 69 | ll4 = (LinearLayout) findViewById(R.id.ll_4); 70 | ll5 = (LinearLayout) findViewById(R.id.ll_5); 71 | //为点击这几个标题设置监听 72 | //创建几个Fragment的实例 添加到fragmentList中 73 | Fragment1 fragment1 = new Fragment1(); 74 | Fragment2 fragment2 = new Fragment2(); 75 | Fragment3 fragment3 = new Fragment3(); 76 | Fragment4 fragment4 = new Fragment4(); 77 | Fragment5 fragment5 = new Fragment5(); 78 | ll1.setOnClickListener(this); 79 | ll2.setOnClickListener(this); 80 | ll3.setOnClickListener(this); 81 | ll4.setOnClickListener(this); 82 | ll5.setOnClickListener(this); 83 | 84 | fragmentList.add(fragment1); 85 | fragmentList.add(fragment2); 86 | fragmentList.add(fragment3); 87 | fragmentList.add(fragment4); 88 | fragmentList.add(fragment5); 89 | 90 | initTab(); //标题里的控件初始化 91 | 92 | //对Adapter进行设置 93 | mAdaper = new FragmentPagerAdapter(getSupportFragmentManager()) { 94 | @Override 95 | public Fragment getItem(int i) { 96 | return fragmentList.get(i); 97 | } 98 | 99 | @Override 100 | public int getCount() { 101 | return fragmentList.size(); 102 | } 103 | }; 104 | 105 | //为viewpager控件添加适配器 106 | mViewPager.setAdapter(mAdaper); 107 | 108 | //页面改变监听事件,标题字体的颜色对应着发生变化 109 | /*mViewPager.setOnClickListener(new View.OnClickListener() { 110 | @Override 111 | public void onClick(View v) { 112 | 113 | } 114 | });*/ 115 | mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { 116 | 117 | @Override 118 | public void onPageSelected(int position) { 119 | resetTabView(); //先初始化 120 | 121 | switch (position) { 122 | case 0: 123 | iv1.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_1_red)); 124 | tv1.setTextColor(Color.RED); 125 | break; 126 | case 1: 127 | iv2.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_2_red)); 128 | tv2.setTextColor(Color.RED); 129 | break; 130 | case 2: 131 | iv3.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_3_red)); 132 | tv3.setTextColor(Color.RED); 133 | break; 134 | case 3: 135 | iv4.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_4_red)); 136 | tv4.setTextColor(Color.RED); 137 | break; 138 | case 4: 139 | iv5.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_5_red)); 140 | tv5.setTextColor(Color.RED); 141 | break; 142 | default: 143 | break; 144 | } 145 | } 146 | 147 | @Override 148 | public void onPageScrolled(int arg0, float arg1, int arg2) { 149 | //arg0 为position页面码, float arg1为offset页面翻转完成百分比, int arg2为offsetPx页面翻转完成的像素值 150 | 151 | 152 | /* 153 | Log.d("tabline", arg0 + "," + arg1 + "," + arg2); 154 | //设置tabline的左边距离 155 | LinearLayout.LayoutParams lllp = (android.widget.LinearLayout.LayoutParams) tabLine.getLayoutParams(); 156 | lllp.leftMargin = (int) (arg0*screen1_3 + arg1*screen1_3); 157 | tabLine.setLayoutParams(lllp); 158 | */ 159 | } 160 | 161 | @Override 162 | public void onPageScrollStateChanged(int arg0) { 163 | 164 | } 165 | }); 166 | } 167 | 168 | //标题栏里的控件引用初始化 169 | private void initTab() { 170 | iv1 = (ImageView)findViewById(R.id.iv_1); 171 | iv2 = (ImageView)findViewById(R.id.iv_2); 172 | iv3 = (ImageView)findViewById(R.id.iv_3); 173 | iv4 = (ImageView)findViewById(R.id.iv_4); 174 | iv5 = (ImageView)findViewById(R.id.iv_5); 175 | 176 | tv1 = (TextView)findViewById(R.id.tv_1); 177 | tv2 = (TextView)findViewById(R.id.tv_2); 178 | tv3 = (TextView)findViewById(R.id.tv_3); 179 | tv4 = (TextView)findViewById(R.id.tv_4); 180 | tv5 = (TextView)findViewById(R.id.tv_5); 181 | 182 | //默认状态。第一个页面 183 | resetTabView(); 184 | iv1.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_1_red)); 185 | tv1.setTextColor(Color.RED); 186 | } 187 | 188 | //标题栏显示初始状态:图片、文字。每次切换时首先恢复初始状态 189 | private void resetTabView() { 190 | iv1.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_1_gray)); 191 | iv2.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_2_gray)); 192 | iv3.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_3_gray)); 193 | iv4.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_4_gray)); 194 | iv5.setImageDrawable(getResources().getDrawable(R.drawable.tab_iv_5_gray)); 195 | 196 | tv1.setTextColor(Color.GRAY); 197 | tv2.setTextColor(Color.GRAY); 198 | tv3.setTextColor(Color.GRAY); 199 | tv4.setTextColor(Color.GRAY); 200 | tv5.setTextColor(Color.GRAY); 201 | 202 | } 203 | 204 | //点击下面标题栏显示不同页面 205 | @Override 206 | public void onClick(View v) { 207 | int index = 0; //所在页面索引值 208 | 209 | switch (v.getId()) { 210 | case R.id.ll_1: 211 | index = 0; 212 | break; 213 | case R.id.ll_2: 214 | index = 1; 215 | break; 216 | case R.id.ll_3: 217 | index = 2; 218 | break; 219 | case R.id.ll_4: 220 | index = 3; 221 | break; 222 | case R.id.ll_5: 223 | index = 4; 224 | break; 225 | default: 226 | break; 227 | } 228 | 229 | mViewPager.setCurrentItem(index); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/activity/RegisterActivity.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.activity; 2 | 3 | import android.app.ProgressDialog; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.text.TextUtils; 7 | import android.view.View; 8 | import android.widget.EditText; 9 | import android.widget.TextView; 10 | import android.widget.Toast; 11 | 12 | import com.idaniu.maga.shopping.R; 13 | import com.idaniu.maga.shopping.manager.UserManager; 14 | 15 | /** 16 | * 注册界面 17 | * Created by yuanbao15 on 2017/11/2. 18 | */ 19 | public class RegisterActivity extends BaseActivity{ 20 | private static final String TAG = "RegisterActivity"; 21 | private static final int VERIRY_CODE = 1000; 22 | 23 | private EditText mPhoneEditText, mPasswordEditText; 24 | private TextView mRegisterButton; 25 | private ProgressDialog mProgressDialog; 26 | 27 | @Override 28 | protected void onCreate(@Nullable Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_register); 31 | 32 | mPhoneEditText = (EditText) findViewById(R.id.phoneEditText); 33 | mPasswordEditText = (EditText) findViewById(R.id.passwordEditText); 34 | mRegisterButton = (TextView) findViewById(R.id.registerButton); 35 | 36 | mRegisterButton.setOnClickListener(new View.OnClickListener() { 37 | @Override 38 | public void onClick(View v) { 39 | String phone = mPhoneEditText.getText().toString(); 40 | String password = mPasswordEditText.getText().toString(); 41 | 42 | if(TextUtils.isEmpty(phone) || TextUtils.isEmpty(password)){ 43 | Toast.makeText(RegisterActivity.this, "请完整输入手机号码和密码", Toast.LENGTH_SHORT).show(); 44 | return; 45 | } 46 | 47 | showDialog(); 48 | 49 | UserManager.getInstance().register(phone, password, new UserManager.OnRegisterListener() { 50 | @Override 51 | public void onRegister() { 52 | runOnUiThread(new Runnable() { 53 | @Override 54 | public void run() { 55 | hideDialog(); 56 | Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT).show(); 57 | setResult(RESULT_OK); 58 | finish(); 59 | } 60 | }); 61 | } 62 | 63 | @Override 64 | public void onError(String msg) { 65 | runOnUiThread(new Runnable() { 66 | @Override 67 | public void run() { 68 | hideDialog(); 69 | Toast.makeText(RegisterActivity.this, "注册失败", Toast.LENGTH_SHORT).show(); 70 | } 71 | }); 72 | } 73 | }); 74 | } 75 | }); 76 | 77 | mPhoneEditText.setText(UserManager.getInstance().getPhone()); //回调显示在登录界面yb 78 | mPasswordEditText.setText(UserManager.getInstance().getPassword()); 79 | 80 | } 81 | 82 | //返回按键 83 | public void back(View v){ 84 | finish(); 85 | } 86 | 87 | //显示对话框 88 | private void showDialog(){ 89 | hideDialog(); 90 | 91 | mProgressDialog = new ProgressDialog(this); 92 | mProgressDialog.setIndeterminate(true); 93 | mProgressDialog.setMessage("yb正在加载"); 94 | mProgressDialog.show(); 95 | } 96 | 97 | //毁掉进度条对话框 98 | private void hideDialog() { 99 | if (mProgressDialog != null){ 100 | mProgressDialog.cancel(); 101 | mProgressDialog = null; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/adapter/CartRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.Log; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | import android.widget.CheckBox; 11 | import android.widget.EditText; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | import com.idaniu.maga.shopping.R; 16 | import com.idaniu.maga.shopping.bean.ShoppingCartBean; 17 | import com.idaniu.maga.shopping.manager.CartManager; 18 | import com.squareup.picasso.Picasso; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * Created by yuanbao15 on 2017/12/8. 24 | */ 25 | public class CartRecyclerAdapter extends RecyclerView.Adapter { 26 | private static final String TAG = "CartRecyclerAdapter"; 27 | 28 | private Context context; 29 | private List cartBeanList; 30 | private OnCartUpdateListener onCartUpdateListener; 31 | 32 | @Override 33 | public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { 34 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.cart_item, viewGroup, false); 35 | return new ViewHolder(view); 36 | } 37 | 38 | @Override 39 | public void onBindViewHolder(final ViewHolder viewHolder, final int i) { 40 | 41 | final ShoppingCartBean bean = cartBeanList.get(i); 42 | 43 | viewHolder.checkBox.setChecked(bean.isChecked()); 44 | Picasso.with(context).load(bean.getImgUrl()).into(viewHolder.imageView); 45 | viewHolder.titleView.setText(bean.getName()); 46 | viewHolder.priceView.setText(bean.getPrice()); 47 | viewHolder.numEditText.setText(bean.getCount() + ""); //整型转字符串,否则报错 48 | 49 | /*//控件设置监听,用于更新数据 50 | viewHolder.itemView.setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | if(onCartUpdateListener != null){ 54 | onCartUpdateListener.onUpdateChecked(i); 55 | } 56 | } 57 | });*/ 58 | //为是否勾选控件设置监听 59 | viewHolder.checkBox.setOnClickListener(new View.OnClickListener() { 60 | @Override 61 | public void onClick(View v) { 62 | bean.setChecked(!bean.isChecked()); 63 | //还要更新到Manager中 64 | onCartUpdateListener.onUpdateChecked(i); 65 | /* if(bean.isChecked()){ //控件图片变化 //不用写这个系统自动变化,自己写的图形不同了 66 | viewHolder.checkBox.setBackgroundResource(R.drawable.icon_check_true); 67 | }else{ 68 | viewHolder.checkBox.setBackgroundResource(R.drawable.icon_check_false); 69 | }*/ 70 | Log.e(TAG, "该项目被勾选了吗?"+bean.isChecked()); 71 | } 72 | }); 73 | 74 | //为加减按钮设置监听 75 | viewHolder.reduceButton.setOnClickListener(new View.OnClickListener() { 76 | @Override 77 | public void onClick(View v) { 78 | bean.setCount(bean.getCount() - 1); 79 | //还要更新到Manager,并显示 80 | onCartUpdateListener.onUpdatecount(i); 81 | } 82 | }); 83 | viewHolder.addButton.setOnClickListener(new View.OnClickListener() { 84 | @Override 85 | public void onClick(View v) { 86 | bean.setCount(bean.getCount() + 1); 87 | 88 | onCartUpdateListener.onUpdatecount(i); 89 | } 90 | }); 91 | 92 | 93 | 94 | } 95 | 96 | @Override 97 | public int getItemCount() { 98 | return cartBeanList.size(); 99 | } 100 | 101 | //内部类 102 | class ViewHolder extends RecyclerView.ViewHolder{ 103 | CheckBox checkBox; 104 | ImageView imageView; 105 | TextView titleView, priceView; 106 | EditText numEditText; //数量 107 | Button reduceButton, addButton; //加减 108 | 109 | public ViewHolder(View itemView) { 110 | super(itemView); 111 | checkBox = (CheckBox) itemView.findViewById(R.id.cart_single_checkbox); 112 | imageView = (ImageView) itemView.findViewById(R.id.iv_cart_single); 113 | titleView = (TextView) itemView.findViewById(R.id.tv_cart_single_title); 114 | priceView = (TextView) itemView.findViewById(R.id.tv_cart_single_price); 115 | numEditText = (EditText) itemView.findViewById(R.id.et_cart_num); 116 | reduceButton = (Button) itemView.findViewById(R.id.btn_cart_reduce); 117 | addButton = (Button) itemView.findViewById(R.id.btn_cart_add); 118 | } 119 | } 120 | 121 | //构造器 122 | public CartRecyclerAdapter(Context context, List cartBeanList, OnCartUpdateListener listener) { 123 | this.context = context; 124 | this.cartBeanList = cartBeanList; 125 | this.onCartUpdateListener = listener; 126 | } 127 | 128 | 129 | //写一个更新的接口,包含是否选中、购买数量两个方法 130 | public interface OnCartUpdateListener{ 131 | void onUpdateChecked(int i); 132 | void onUpdatecount(int i); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/adapter/HomeRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.Log; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | import android.widget.Toast; 12 | 13 | import com.idaniu.maga.shopping.R; 14 | import com.idaniu.maga.shopping.bean.HomeBean; 15 | import com.squareup.picasso.Picasso; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * 21 | * 应用Picasso,Android图片下载缓存库 22 | * Created by yuanbao15 on 2017/10/10. 23 | */ 24 | public class HomeRecyclerAdapter extends RecyclerView.Adapter{ 25 | 26 | private Context context; 27 | private List homeBeanList; 28 | private OnMoreListener onMoreListener; //下拉刷新的接口 29 | 30 | static class ViewHolder extends RecyclerView.ViewHolder{ 31 | ImageView imageView1; 32 | ImageView imageView2; 33 | ImageView imageView3; 34 | TextView textView; 35 | 36 | View homeBeanView; //定义这个视图用于处理recyclerView里的的点击事件 37 | 38 | public ViewHolder(View view) { 39 | super(view); 40 | homeBeanView = view; 41 | textView = (TextView) view.findViewById(R.id.item_title); 42 | imageView1 = (ImageView) view.findViewById(R.id.item_image1); 43 | imageView2 = (ImageView) view.findViewById(R.id.item_image2); 44 | imageView3 = (ImageView) view.findViewById(R.id.item_image3); 45 | 46 | } 47 | } 48 | 49 | //构造函数1 50 | public HomeRecyclerAdapter(Context context, List homeBeanList) { 51 | this.context = context; 52 | this.homeBeanList = homeBeanList; 53 | } 54 | //增加下拉刷新接口后重写一个构造函数2 55 | public HomeRecyclerAdapter(Context context, List homeBeanList, OnMoreListener mOnMoreListener) { 56 | this.context = context; 57 | this.homeBeanList = homeBeanList; 58 | this.onMoreListener = mOnMoreListener; 59 | } 60 | 61 | @Override 62 | public int getItemViewType(int position) { 63 | // return super.getItemViewType(position); 64 | return position%2; //按照老师的改的 65 | } 66 | 67 | @Override 68 | public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { 69 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.home_item, viewGroup, false); 70 | final ViewHolder holder = new ViewHolder(view); 71 | 72 | //设置点击事件监听处理:这里是整个视图的。不设置子项或者点击的不是子项的部分,就会执行整个视图的点击响应 73 | holder.homeBeanView.setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | int i = holder.getAdapterPosition(); 77 | HomeBean homeBean = homeBeanList.get(i); 78 | Toast.makeText(v.getContext(),"yb点击了View"+homeBean.getTitle(),Toast.LENGTH_SHORT).show(); 79 | } 80 | }); 81 | 82 | //这里是每个子项的 83 | holder.imageView1.setOnClickListener(new View.OnClickListener() { 84 | @Override 85 | public void onClick(View v) { 86 | int i = holder.getAdapterPosition(); 87 | HomeBean homeBean = homeBeanList.get(i); 88 | Toast.makeText(v.getContext(),"yb点击了Image"+homeBean.getCpOne().getTitle(),Toast.LENGTH_SHORT).show(); 89 | } 90 | }); 91 | holder.imageView2.setOnClickListener(new View.OnClickListener() { 92 | @Override 93 | public void onClick(View v) { 94 | int i = holder.getAdapterPosition(); 95 | HomeBean homeBean = homeBeanList.get(i); 96 | Toast.makeText(v.getContext(),"yb点击了Image"+homeBean.getCpTwo().getTitle(),Toast.LENGTH_SHORT).show(); 97 | } 98 | }); 99 | holder.imageView3.setOnClickListener(new View.OnClickListener() { 100 | @Override 101 | public void onClick(View v) { 102 | int i = holder.getAdapterPosition(); 103 | HomeBean homeBean = homeBeanList.get(i); 104 | Toast.makeText(v.getContext(),"yb点击了Image"+homeBean.getCpThree().getTitle(),Toast.LENGTH_SHORT).show(); 105 | } 106 | }); 107 | 108 | return holder; 109 | } 110 | 111 | @Override 112 | public void onBindViewHolder(ViewHolder holder, int i) { 113 | HomeBean homeBean = homeBeanList.get(i); 114 | Log.d("RecyclerViewAdapter", "显示图片" + i); 115 | holder.textView.setText(homeBean.getTitle()); 116 | // holder.imageView1.setImageResource(R.drawable.icon_wechat_72); //本地图片就用这种方式,网络的话用Picasso缓存库 117 | Picasso.with(context).load(homeBean.getCpOne().getImgUrl()).into(holder.imageView1); //这里需要上下文 118 | Picasso.with(context).load(homeBean.getCpTwo().getImgUrl()).into(holder.imageView2); //这里需要上下文 119 | Picasso.with(context).load(homeBean.getCpThree().getImgUrl()).into(holder.imageView3); //这里需要上下文 120 | 121 | 122 | } 123 | 124 | @Override 125 | public int getItemCount() { 126 | // if (homeBeanList == null) return 0; 127 | return homeBeanList.size(); 128 | } 129 | 130 | //下拉刷新更多的接口 131 | public interface OnMoreListener{ 132 | void onMore(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/adapter/HotRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.Log; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | import android.widget.ImageView; 11 | import android.widget.ProgressBar; 12 | import android.widget.TextView; 13 | import android.widget.Toast; 14 | 15 | import com.idaniu.maga.shopping.R; 16 | import com.idaniu.maga.shopping.bean.ProductBean; 17 | import com.idaniu.maga.shopping.bean.ShoppingCartBean; 18 | import com.idaniu.maga.shopping.manager.CartManager; 19 | import com.squareup.picasso.Picasso; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * Fragment2的适配器,实现下拉刷新、上拉加载的逻辑 25 | * 上拉加载:当最后一个item被绑定时,说明已经滑动到最下面了,可以开始加载更多数据 26 | * Created by yuanbao15 on 2017/12/4. 27 | */ 28 | public class HotRecyclerAdapter extends RecyclerView.Adapter{ 29 | 30 | private static final int TYPE_NORMAL = 0; //作为判断是处于正常还是加载更多的viewType 31 | private static final int TYPE_MORE = 1; 32 | 33 | private Context context; 34 | private List productBeanList; 35 | private OnMoreListener onMoreListener; //下拉刷新的接口 36 | 37 | private boolean isGetMore = true; //获取更多的判断标志位 38 | 39 | 40 | @Override 41 | public HotRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { 42 | View view; 43 | if(viewType == TYPE_NORMAL){ //正常显示, 44 | view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.hot_item, viewGroup, false); 45 | }else{ //滑到最底部上,加载更多 46 | view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.hot_loading_more, viewGroup, false); 47 | } 48 | return new HotRecyclerAdapter.ViewHolder(view); 49 | } 50 | 51 | @Override 52 | public void onBindViewHolder(HotRecyclerAdapter.ViewHolder viewHolder, int i) { 53 | 54 | if(i == productBeanList.size()){ 55 | if(isGetMore){ 56 | viewHolder.textViewMoreTitle.setText("正在加载中。。。wait yb"); 57 | viewHolder.progressBar.setVisibility(View.VISIBLE); 58 | }else{ 59 | viewHolder.textViewMoreTitle.setText("已全部加载完毕,到底了。"); 60 | viewHolder.progressBar.setVisibility(View.GONE); 61 | } 62 | } 63 | Log.d("Hot.Adapter", "productBeanList.size()大小为:"+productBeanList.size()); 64 | 65 | //设置每个控件的内容 66 | Log.d("Hot页面----","更新到商品信息"+i); 67 | final ProductBean productBean = productBeanList.get(i); 68 | viewHolder.textViewTitle.setText(productBean.getName()); 69 | viewHolder.textViewPrice.setText("¥" + productBean.getPrice()); 70 | //商品的图片实现,Picasso 71 | Picasso.with(context).load(productBean.getImgUrl()).into(viewHolder.imageViewProduct); 72 | //按键,添加到购物车 73 | viewHolder.buttonBuy.setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | ShoppingCartBean shoppingCartBean = new ShoppingCartBean(productBean); 77 | shoppingCartBean.setCount(shoppingCartBean.getCount()+1); 78 | shoppingCartBean.setChecked(true); 79 | CartManager.getInstance().put(shoppingCartBean); //让hot页面的数据过渡到购物车页面 80 | Toast.makeText(context, "已添加到购物车", Toast.LENGTH_SHORT).show(); 81 | } 82 | }); 83 | 84 | viewHolder.itemView.setOnClickListener(new View.OnClickListener() { 85 | @Override 86 | public void onClick(View v) { 87 | //查看商品详情页 88 | 89 | } 90 | }); 91 | } 92 | 93 | @Override 94 | public int getItemCount() { 95 | return productBeanList.size(); 96 | } 97 | 98 | //构造器 99 | public HotRecyclerAdapter(Context context, List productBeanList, OnMoreListener onMoreListener) { 100 | this.context = context; 101 | this.productBeanList = productBeanList; 102 | this.onMoreListener = onMoreListener; 103 | } 104 | 105 | // public void showMore(boolean isGetMore){ 106 | // this.isGetMore = isGetMore; 107 | // } 108 | 109 | //自己写HotRecyclerAdapter的ViewHolder内部类 110 | public class ViewHolder extends RecyclerView.ViewHolder{ 111 | 112 | ImageView imageViewProduct; 113 | TextView textViewTitle,textViewPrice; 114 | Button buttonBuy; 115 | 116 | TextView textViewMoreTitle; //获取更多的文本展示 117 | ProgressBar progressBar; //获取更多的进度条 118 | 119 | public ViewHolder(View view) { 120 | super(view); 121 | 122 | //控件初始化 123 | imageViewProduct = (ImageView) view.findViewById(R.id.iv_product); 124 | textViewTitle = (TextView) view.findViewById(R.id.tv_title); 125 | textViewPrice = (TextView) view.findViewById(R.id.tv_price); 126 | buttonBuy = (Button) view.findViewById(R.id.bt_buy); 127 | 128 | textViewMoreTitle = (TextView) view.findViewById(R.id.tv_moretitle); 129 | progressBar = (ProgressBar) view.findViewById(R.id.pg_progressbar); 130 | } 131 | } 132 | 133 | //自己写一个下拉刷新更多的接口 134 | public interface OnMoreListener{ 135 | void onMore(); 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/BannerBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | /** 4 | * 轮播图片的javabean类 5 | * Created by yuanbao15 on 2017/10/9. 6 | */ 7 | public class BannerBean { 8 | private long id; 9 | private String name; 10 | private String imgUrl; 11 | private String description; 12 | 13 | public long getId() { 14 | return id; 15 | } 16 | 17 | public void setId(long id) { 18 | this.id = id; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getImgUrl() { 30 | return imgUrl; 31 | } 32 | 33 | public void setImgUrl(String imgUrl) { 34 | this.imgUrl = imgUrl; 35 | } 36 | 37 | public String getDescription() { 38 | return description; 39 | } 40 | 41 | public void setDescription(String description) { 42 | this.description = description; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return id+","+name+","+imgUrl+","+description; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/HomeBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | /** 4 | * frag1主页的瀑布流的数据,每条对应一个homebean对象 5 | * Created by yuanbao15 on 2017/10/10. 6 | */ 7 | public class HomeBean { 8 | 9 | private long id; 10 | private String title; 11 | private HomeItemBean cpOne; //三个对象,每个对象里都有一张图片、id、标题 12 | private HomeItemBean cpTwo; 13 | private HomeItemBean cpThree; 14 | 15 | public long getId() { 16 | return id; 17 | } 18 | 19 | public void setId(long id) { 20 | this.id = id; 21 | } 22 | 23 | public String getTitle() { 24 | return title; 25 | } 26 | 27 | public void setTitle(String title) { 28 | this.title = title; 29 | } 30 | 31 | public HomeItemBean getCpOne() { 32 | return cpOne; 33 | } 34 | 35 | public void setCpOne(HomeItemBean cpOne) { 36 | this.cpOne = cpOne; 37 | } 38 | 39 | public HomeItemBean getCpTwo() { 40 | return cpTwo; 41 | } 42 | 43 | public void setCpTwo(HomeItemBean cpTwo) { 44 | this.cpTwo = cpTwo; 45 | } 46 | 47 | public HomeItemBean getCpThree() { 48 | return cpThree; 49 | } 50 | 51 | public void setCpThree(HomeItemBean cpThree) { 52 | this.cpThree = cpThree; 53 | } 54 | 55 | //HomeBean内部类 56 | public class HomeItemBean{ 57 | private long id; 58 | private String title; 59 | private String imgUrl; 60 | 61 | public long getId() { 62 | return id; 63 | } 64 | 65 | public void setId(long id) { 66 | this.id = id; 67 | } 68 | 69 | public String getTitle() { 70 | return title; 71 | } 72 | 73 | public void setTitle(String title) { 74 | this.title = title; 75 | } 76 | 77 | public String getImgUrl() { 78 | return imgUrl; 79 | } 80 | 81 | public void setImgUrl(String imgUrl) { 82 | this.imgUrl = imgUrl; 83 | } 84 | } 85 | 86 | 87 | /* 88 | //test用 没有下一级子对象图片的简单情况 89 | private long id; 90 | private String name; 91 | private String imgUrl; 92 | 93 | public long getId() { 94 | return id; 95 | } 96 | 97 | public void setId(long id) { 98 | this.id = id; 99 | } 100 | 101 | 102 | public String getName() { 103 | return name; 104 | } 105 | 106 | public void setName(String name) { 107 | this.name = name; 108 | } 109 | 110 | public String getImgUrl() { 111 | return imgUrl; 112 | } 113 | 114 | public void setImgUrl(String imgUrl) { 115 | this.imgUrl = imgUrl; 116 | } 117 | 118 | @Override 119 | public String toString() { 120 | return id+","+name+","+imgUrl+"\n"; 121 | }*/ 122 | } 123 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/HotResultBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 表示热卖页hot下载的商品数据信息的javabean类 7 | * Created by yuanbao15 on 2017/12/4. 8 | */ 9 | public class HotResultBean { 10 | private int totalCount; //商品数量 11 | private int currentPage; //当前页面 12 | private int totalPage; //页面数量 13 | private int pageSize; //页面中展示商品容量 14 | private List list; 15 | 16 | public int getTotalCount() { 17 | return totalCount; 18 | } 19 | 20 | public void setTotalCount(int totalCount) { 21 | this.totalCount = totalCount; 22 | } 23 | 24 | public int getCurrentPage() { 25 | return currentPage; 26 | } 27 | 28 | public void setCurrentPage(int currentPage) { 29 | this.currentPage = currentPage; 30 | } 31 | 32 | public int getTotalPage() { 33 | return totalPage; 34 | } 35 | 36 | public void setTotalPage(int totalPage) { 37 | this.totalPage = totalPage; 38 | } 39 | 40 | public int getPageSize() { 41 | return pageSize; 42 | } 43 | 44 | public void setPageSize(int pageSize) { 45 | this.pageSize = pageSize; 46 | } 47 | 48 | public List getList() { 49 | return list; 50 | } 51 | 52 | public void setList(List list) { 53 | this.list = list; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "HotResultBean{" + 59 | "totalCount=" + totalCount + 60 | ", currentPage=" + currentPage + 61 | ", totalPage=" + totalPage + 62 | ", pageSize=" + pageSize + 63 | ", list=" + list + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/LoginBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | /** 4 | * Created by yuanbao15 on 2017/11/2. 5 | * 登录结果 6 | */ 7 | public class LoginBean { 8 | 9 | private int status; 10 | private String message; 11 | private String token; 12 | private UserBean data; 13 | 14 | public int getStatus() { 15 | return status; 16 | } 17 | 18 | public void setStatus(int status) { 19 | this.status = status; 20 | } 21 | 22 | public String getMessage() { 23 | return message; 24 | } 25 | 26 | public void setMessage(String message) { 27 | this.message = message; 28 | } 29 | 30 | public String getToken() { 31 | return token; 32 | } 33 | 34 | public void setToken(String token) { 35 | this.token = token; 36 | } 37 | 38 | public UserBean getData() { 39 | return data; 40 | } 41 | 42 | public void setData(UserBean data) { 43 | this.data = data; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/ProductBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 商品信息的javabean类 7 | * Created by yuanbao15 on 2017/12/4. 8 | */ 9 | public class ProductBean implements Serializable{ 10 | private long id; 11 | private String name; 12 | private String imgUrl; 13 | private String price; 14 | private String description; 15 | 16 | public long getId() { 17 | return id; 18 | } 19 | 20 | public void setId(long id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getImgUrl() { 33 | return imgUrl; 34 | } 35 | 36 | public void setImgUrl(String imgUrl) { 37 | this.imgUrl = imgUrl; 38 | } 39 | 40 | public String getPrice() { 41 | return price; 42 | } 43 | 44 | public void setPrice(String price) { 45 | this.price = price; 46 | } 47 | 48 | public String getDescription() { 49 | return description; 50 | } 51 | 52 | public void setDescription(String description) { 53 | this.description = description; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "Product{" + 59 | "id=" + id + 60 | ", name='" + name + '\'' + 61 | ", imgUrl='" + imgUrl + '\'' + 62 | ", price='" + price + '\'' + 63 | ", description='" + description + '\'' + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/ShoppingCartBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | /** 4 | * 购物车的javabean类,继承了商品信息ProductBean类,并增加数量和是否被选中 5 | * Created by yuanbao15 on 2017/12/4. 6 | */ 7 | public class ShoppingCartBean extends ProductBean{ 8 | private int count; //购买数量 9 | private boolean checked; //是否被选中 10 | 11 | public int getCount() { 12 | return count; 13 | } 14 | 15 | public void setCount(int count) { 16 | this.count = count; 17 | } 18 | 19 | public boolean isChecked() { 20 | return checked; 21 | } 22 | 23 | public void setChecked(boolean checked) { 24 | this.checked = checked; 25 | } 26 | 27 | //构造器,以商品信息为参量导入 28 | public ShoppingCartBean(ProductBean bean){ 29 | this.setId(bean.getId()); 30 | this.setName(bean.getName()); 31 | this.setPrice(bean.getPrice()); 32 | this.setImgUrl(bean.getImgUrl()); 33 | this.setDescription(bean.getDescription()); 34 | this.setCount(0); 35 | this.setChecked(false); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/bean/UserBean.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.bean; 2 | 3 | /** 4 | * Created by yuanbao15 on 2017/11/2. 5 | * 用户信息的javabean类 6 | */ 7 | public class UserBean { 8 | private long id; 9 | private String phone; 10 | private String email; 11 | private String username; 12 | private String logo_url; 13 | 14 | public long getId() { 15 | return id; 16 | } 17 | 18 | public void setId(long id) { 19 | this.id = id; 20 | } 21 | 22 | public String getPhone() { 23 | return phone; 24 | } 25 | 26 | public void setPhone(String phone) { 27 | this.phone = phone; 28 | } 29 | 30 | public String getEmail() { 31 | return email; 32 | } 33 | 34 | public void setEmail(String email) { 35 | this.email = email; 36 | } 37 | 38 | public String getUsername() { 39 | return username; 40 | } 41 | 42 | public void setUsername(String username) { 43 | this.username = username; 44 | } 45 | 46 | public String getLogo_url() { 47 | return logo_url; 48 | } 49 | 50 | public void setLogo_url(String logo_url) { 51 | this.logo_url = logo_url; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/fragment/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | /** 11 | * Created by maga on 2017/10/3. 12 | * 13 | */ 14 | 15 | public class BaseFragment extends Fragment { 16 | 17 | @Nullable 18 | @Override 19 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 20 | return super.onCreateView(inflater, container, savedInstanceState); 21 | } 22 | 23 | @Override 24 | public void onResume() { 25 | super.onResume(); 26 | } 27 | 28 | @Override 29 | public void onPause() { 30 | super.onPause(); 31 | } 32 | 33 | @Override 34 | public void onDestroy() { 35 | super.onDestroy(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/fragment/Fragment1.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.fragment; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v4.view.PagerAdapter; 10 | import android.support.v4.view.ViewPager; 11 | import android.support.v7.widget.RecyclerView; 12 | import android.support.v7.widget.StaggeredGridLayoutManager; 13 | import android.util.Log; 14 | import android.view.LayoutInflater; 15 | import android.view.MotionEvent; 16 | import android.view.View; 17 | import android.view.ViewGroup; 18 | import android.widget.ImageView; 19 | import android.widget.LinearLayout; 20 | import android.widget.TextView; 21 | import android.widget.Toast; 22 | 23 | import com.google.gson.Gson; 24 | import com.google.gson.reflect.TypeToken; 25 | import com.idaniu.maga.shopping.Constant; 26 | import com.idaniu.maga.shopping.R; 27 | import com.idaniu.maga.shopping.ShoppingApplication; 28 | import com.idaniu.maga.shopping.activity.BannerActivity; 29 | import com.idaniu.maga.shopping.adapter.HomeRecyclerAdapter; 30 | import com.idaniu.maga.shopping.bean.BannerBean; 31 | import com.idaniu.maga.shopping.bean.HomeBean; 32 | import com.squareup.picasso.Picasso; 33 | 34 | import java.io.IOException; 35 | import java.lang.ref.WeakReference; 36 | import java.lang.reflect.Type; 37 | import java.util.ArrayList; 38 | import java.util.List; 39 | import java.util.logging.LogRecord; 40 | 41 | import okhttp3.Call; 42 | import okhttp3.Callback; 43 | import okhttp3.OkHttpClient; 44 | import okhttp3.Request; 45 | import okhttp3.Response; 46 | 47 | /** 48 | * 第一个fragment,展示主页,包含一个图片轮播banner和一个瀑布流视图 49 | * Created by yuanbao15 on 2017/10/8. 50 | */ 51 | public class Fragment1 extends Fragment{ 52 | private static final String TAG = "HomeFragment"; 53 | 54 | private ViewPager mBannerViewPager; //图片轮播里的ViewPager 55 | private BannerPagerAdapter mBannerPagerAdapter; 56 | private LinearLayout mIndicateLinearLayout; //圆点指示器 57 | private TextView mBannerTitleTextView; //图片轮播中每张图片的标题 58 | // Handler handler = new BannerHandler(); //为了弄手动停止图片轮播,学习handler方式 59 | // private static final int BANNER_NEXT = 1; 60 | // private static final int BANNER_PAUSE = 2; 61 | // private static final int BANNER_RESUME = 3; 62 | 63 | 64 | private List mBannerList; 65 | private List mIndicateList = new ArrayList<>(); //圆点集合 66 | private List mBannerViewsList = new ArrayList<>(); //图片展示的集合 67 | 68 | private List homeBeanList = new ArrayList<>(); //主页瀑布流的部分 69 | private HomeRecyclerAdapter homeRecyclerAdapter; 70 | private RecyclerView recyclerView; 71 | 72 | /* 73 | public static Fragment1 newInstance(String tabName){ 74 | Fragment1 fragment = new Fragment1(); 75 | // fragment.mTabName = tabName; 76 | return fragment; 77 | }*/ 78 | 79 | 80 | @Override 81 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 82 | Bundle savedInstanceState) { 83 | 84 | View v = inflater.inflate(R.layout.frag1, container, false); 85 | initView(v); 86 | // getLayoutInflater(savedInstanceState).inflate(R.layout.home_item,container); 87 | // 没有这句报错,因为否则就不知道把哪一个布局放到瀑布流中。也不对,viewHolder里有对R.layout.home_item的引用 88 | return v; 89 | } 90 | 91 | private void initView(View v) { 92 | mBannerViewPager = (ViewPager) v.findViewById(R.id.viewpager_hotnews); 93 | mBannerTitleTextView =(TextView) v.findViewById(R.id.tv_title_hotnews); 94 | mIndicateLinearLayout =(LinearLayout) v.findViewById(R.id.ll_hotnews_indicator); 95 | 96 | 97 | mBannerPagerAdapter = new BannerPagerAdapter(); 98 | mBannerViewPager.setAdapter(mBannerPagerAdapter); //给mViewPager绑定这个适配器 99 | 100 | //图片轮播的viewpager在页面改变时候 101 | mBannerViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 102 | @Override 103 | public void onPageScrolled(int i, float v, int i1) { 104 | 105 | } 106 | 107 | @Override 108 | public void onPageSelected(int i) { 109 | for (int j = 0; j < mIndicateLinearLayout.getChildCount(); j++) { //选到哪页就跳转到哪一页 110 | View view = mIndicateLinearLayout.getChildAt(j); 111 | if (j == i) { 112 | view.setSelected(true); 113 | mIndicateList.get(j).setBackgroundResource(R.drawable.indicate_circle_red); //实现指示圆点的状态变化 114 | } else { 115 | view.setSelected(false); 116 | mIndicateList.get(j).setBackgroundResource(R.drawable.indicate_circle_gray); 117 | } 118 | } 119 | //标题内容也要随之相应的更改 120 | mBannerTitleTextView.setText(mBannerList.get(i).getName()); 121 | } 122 | 123 | @Override 124 | public void onPageScrollStateChanged(int state) { 125 | //这里写长按时停止自动滚动......没有成功。发现:这里的对应着ViewPager本身真实的是否轮播状态,与手指是否滑动无关 126 | switch (state){ 127 | case ViewPager.SCROLL_STATE_DRAGGING: 128 | //用户正在拖拽,暂停轮播 129 | // handler.sendEmptyMessage(BANNER_PAUSE); 130 | // Log.d(TAG, "图片轮播手指拖拽中"+state); 131 | break; 132 | case ViewPager.SCROLL_STATE_IDLE: 133 | //手指已移开,继续轮播 134 | // handler.sendEmptyMessageDelayed(BANNER_NEXT, 3000); 135 | // Log.d(TAG, "图片轮播手指已松开" + state); 136 | break; 137 | default: 138 | break; 139 | } 140 | } 141 | }); 142 | 143 | // handler.sendEmptyMessageDelayed(BANNER_NEXT, 3000); 144 | 145 | loadBannerData(); //下载 图片轮播的图片资源 146 | 147 | loadHomeData(); //下载 主页瀑布流的数据 148 | 149 | //主页瀑布流部分初始化 150 | recyclerView = (RecyclerView) v.findViewById(R.id.recycler_view_home); 151 | //瀑布流效果 152 | StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL); //分成几列 153 | recyclerView.setLayoutManager(layoutManager); 154 | // recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); //普通线性展示 155 | // homeRecyclerAdapter = new HomeRecyclerAdapter(getActivity(), homeBeanList); //这是没有下拉刷新的,下面的有 156 | homeRecyclerAdapter = new HomeRecyclerAdapter(getContext(),homeBeanList, new HomeRecyclerAdapter.OnMoreListener() { 157 | @Override 158 | public void onMore() { //没实现 159 | loadHomeData(); 160 | Toast.makeText(ShoppingApplication.getInstance(), "you refresh this page!", Toast.LENGTH_SHORT).show(); 161 | } 162 | }); 163 | 164 | recyclerView.setAdapter(homeRecyclerAdapter); 165 | // Log.d(TAG, "frag1执行到这2"); 166 | 167 | } 168 | 169 | //下载主页Fragment1的homebean数据,使用okhttp方式。 170 | private void loadHomeData() { 171 | OkHttpClient client = new OkHttpClient(); //创建网络实例 172 | //创建请求 173 | Request request = new Request.Builder() 174 | .url(Constant.HOME_URL + "?type=1") 175 | .build(); 176 | //返回数据 177 | client.newCall(request).enqueue(new Callback() { //书上使用的execute()方法,同步方式。老师的是enqueue(new Callback())这个是没有返回值的,异步方式。 178 | @Override 179 | public void onFailure(Call call, IOException e) { 180 | if(getActivity() == null) return; 181 | getActivity().runOnUiThread(new Runnable() { 182 | @Override 183 | public void run() { 184 | Toast.makeText(ShoppingApplication.getInstance(), "load data failed!", Toast.LENGTH_SHORT).show(); 185 | } 186 | }); 187 | } 188 | 189 | @Override 190 | public void onResponse(Call call, Response response) throws IOException { 191 | String responseData = response.body().string(); 192 | System.out.println(responseData); 193 | Gson gson = new Gson(); //用Gson解析Json数据 194 | Type type = new TypeToken>(){}.getType(); //这句不知道是干嘛,获取类型?!!!!这里要改HomeBean,调试了好久才查出错误产生的并不是HomeBean对象 195 | 196 | //homeBeanList = gson.fromJson(responseData, type);发现这儿的homeBeanList有数据,但外部没有,所以不能这样写 197 | homeBeanList.clear(); 198 | List list = gson.fromJson(responseData, type); 199 | homeBeanList.addAll(list); 200 | /*//debug 201 | for (HomeBean homeBean:homeBeanList){ 202 | Log.d(TAG,homeBean.toString()); 203 | }*/ 204 | getActivity().runOnUiThread(new Runnable() { 205 | @Override 206 | public void run() { 207 | homeRecyclerAdapter.notifyDataSetChanged(); 208 | } 209 | }); 210 | } 211 | }); 212 | } 213 | 214 | //下载头图轮播的图片资源,使用okhttp方式。 215 | private void loadBannerData() { 216 | OkHttpClient client = new OkHttpClient(); //创建网络实例 217 | //创建请求 218 | Request request = new Request.Builder() 219 | .url(Constant.HEAD_URL + "?type=1") //接口文档中type为1的数据(广告图片) 220 | .build(); 221 | //返回数据 222 | client.newCall(request).enqueue(new Callback() { //书上使用的execute()方法,同步方式。老师的是enqueue(new Callback())这个是没有返回值的,异步方式。 223 | @Override 224 | public void onFailure(Call call, IOException e) { 225 | if(getActivity() == null) return; 226 | getActivity().runOnUiThread(new Runnable() { 227 | @Override 228 | public void run() { 229 | Toast.makeText(ShoppingApplication.getInstance(), "load data failed!", Toast.LENGTH_SHORT).show(); 230 | } 231 | }); 232 | } 233 | 234 | @Override 235 | public void onResponse(Call call, Response response) throws IOException { 236 | String responseData = response.body().string(); 237 | // System.out.println(responseData); 238 | Gson gson = new Gson(); //用Gson解析Json数据 239 | Type type = new TypeToken>(){}.getType(); //这句不知道是干嘛,获取类型? 240 | mBannerList = gson.fromJson(responseData, type); //gson获取到的数据成为一个个bannerbean对象然后添加到mbannerlist列表中 241 | 242 | getActivity().runOnUiThread(new Runnable() { 243 | @Override 244 | public void run() { 245 | if(mBannerList != null && mBannerList.size()>=0){ 246 | mIndicateLinearLayout.removeAllViews(); //先清除再重新加载 247 | mBannerViewsList.clear(); 248 | mIndicateLinearLayout.removeAllViews(); 249 | 250 | for (int j=0; j weakReference; 387 | 388 | public BannerHandler(WeakReference weakReference) { 389 | this.weakReference = weakReference; 390 | } 391 | 392 | 393 | @Override 394 | public void handleMessage(Message msg) { 395 | Fragment1 fragment1 = weakReference.get(); 396 | //fragment1不存在了,就不需要再处理了 397 | if (fragment1 == null) { 398 | return; 399 | } 400 | //如果已经有消息了,先移除消息 401 | if (fragment1.handler.hasMessages(BANNER_NEXT)) { 402 | fragment1.handler.removeMessages(BANNER_NEXT); 403 | } 404 | 405 | switch (msg.what){ 406 | case BANNER_NEXT: 407 | //跳到下一页 408 | int currentItem = mBannerViewPager.getCurrentItem(); 409 | fragment1.mBannerViewPager.setCurrentItem(++currentItem); 410 | //3秒后继续轮播 411 | fragment1.handler.sendEmptyMessageDelayed(BANNER_NEXT, 3000); 412 | break; 413 | case BANNER_PAUSE: 414 | //暂停,不自动轮播 415 | break; 416 | case BANNER_RESUME: 417 | //继续轮播 418 | fragment1.handler.sendEmptyMessageDelayed(BANNER_NEXT, 3000); 419 | break; 420 | } 421 | 422 | super.handleMessage(msg); 423 | } 424 | }*/ 425 | 426 | 427 | 428 | } 429 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/fragment/Fragment2.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.fragment; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import android.support.v4.app.Fragment; 6 | import android.os.Bundle; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.support.v7.widget.StaggeredGridLayoutManager; 9 | import android.util.Log; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.Toast; 14 | 15 | import com.google.gson.Gson; 16 | import com.google.gson.reflect.TypeToken; 17 | import com.idaniu.maga.shopping.Constant; 18 | import com.idaniu.maga.shopping.R; 19 | import com.idaniu.maga.shopping.ShoppingApplication; 20 | import com.idaniu.maga.shopping.adapter.HotRecyclerAdapter; 21 | import com.idaniu.maga.shopping.bean.HomeBean; 22 | import com.idaniu.maga.shopping.bean.HotResultBean; 23 | import com.idaniu.maga.shopping.bean.ProductBean; 24 | 25 | import java.io.IOException; 26 | import java.lang.reflect.Type; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import okhttp3.Call; 31 | import okhttp3.Callback; 32 | import okhttp3.OkHttpClient; 33 | import okhttp3.Request; 34 | import okhttp3.Response; 35 | 36 | /** 37 | * 第二个页面:热卖,recyclerView 展示。下拉刷新还没实现,上拉加载更多通过RecyclerView.addOnScrollListener()实现 38 | * Created by yuanbao15 on 2017/10/8. 39 | */ 40 | public class Fragment2 extends Fragment{ 41 | private static final String TAG = "HotFragment"; 42 | private static final int PAGE_SIZE = 10; //hot页面一次下载显示商品的数量 43 | 44 | private int currentPage = 1; //第多少个page,是个变量,根据下载数据的量决定 45 | private int totalCount = 0; //总的商品数量 46 | 47 | private volatile boolean isLoadingMore = false; //作为是否下拉刷新获取更多信息的标志位 48 | 49 | private List productBeanList = new ArrayList(); 50 | private HotRecyclerAdapter hotRecyclerAdapter; 51 | private RecyclerView recyclerView; 52 | 53 | 54 | @Override 55 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 56 | Bundle savedInstanceState) { 57 | View v = inflater.inflate(R.layout.frag2, container, false); 58 | initView(v); 59 | return v; 60 | } 61 | 62 | //frag2中的控件初始化 63 | private void initView(View v) { 64 | loadHotData(); //下载 热卖页瀑布流的数据 65 | 66 | //主页瀑布流部分初始化 67 | recyclerView = (RecyclerView) v.findViewById(R.id.recycler_view_hot); 68 | final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1,StaggeredGridLayoutManager.VERTICAL); //分成几列 69 | recyclerView.setLayoutManager(layoutManager); 70 | 71 | hotRecyclerAdapter = new HotRecyclerAdapter(getContext(), productBeanList, new HotRecyclerAdapter.OnMoreListener() { 72 | @Override 73 | public void onMore() { 74 | loadMoreHotData(); 75 | Toast.makeText(ShoppingApplication.getInstance(), "you refresh this page2!", Toast.LENGTH_SHORT).show(); 76 | } 77 | }); 78 | recyclerView.setAdapter(hotRecyclerAdapter); 79 | 80 | 81 | //实现上拉加载更多 82 | recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { 83 | @Override 84 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 85 | super.onScrollStateChanged(recyclerView, newState); 86 | 87 | Log.d(TAG, "currentPage为:" + currentPage + ";共有项目:" + totalCount); 88 | if (newState == RecyclerView.SCROLL_STATE_IDLE && !isLoadingMore){ 89 | if(currentPage <= totalCount/PAGE_SIZE+1){ 90 | Log.d(TAG, "执行到这了,加载更多中.."); 91 | isLoadingMore = false; 92 | hotRecyclerAdapter.notifyDataSetChanged(); 93 | new Handler().postDelayed(new Runnable() { 94 | @Override 95 | public void run() { 96 | loadMoreHotData(); 97 | 98 | } 99 | }, 2000); 100 | }else { 101 | } 102 | } 103 | 104 | } 105 | 106 | @Override 107 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 108 | super.onScrolled(recyclerView, dx, dy); 109 | } 110 | }); 111 | 112 | 113 | 114 | } 115 | 116 | 117 | //是否加载更多的信息 118 | private void loadMoreHotData(){ 119 | if(isLoadingMore) return; 120 | 121 | if(productBeanList.size() >= totalCount) return; 122 | 123 | currentPage ++; 124 | loadHotData(); 125 | } 126 | 127 | //下载 热卖页瀑布流的数据,使用okhttp方式。 128 | private void loadHotData() { 129 | OkHttpClient client = new OkHttpClient(); //创建网络实例 130 | //创建请求 131 | Request request = new Request.Builder() 132 | .url(Constant.HOT_URL + "?curPage="+currentPage+"&pageSize="+PAGE_SIZE) //url不对程序就会错 133 | .build(); 134 | //返回数据 135 | client.newCall(request).enqueue(new Callback() { //书上使用的execute()方法,同步方式。老师的是enqueue(new Callback())这个是没有返回值的,异步方式。 136 | @Override 137 | public void onFailure(Call call, IOException e) { 138 | if (getActivity() == null) return; 139 | getActivity().runOnUiThread(new Runnable() { 140 | @Override 141 | public void run() { 142 | Toast.makeText(ShoppingApplication.getInstance(), "load data failed!", Toast.LENGTH_SHORT).show(); 143 | } 144 | }); 145 | } 146 | 147 | @Override 148 | public void onResponse(Call call, Response response) throws IOException { 149 | String responseData = response.body().string(); 150 | System.out.println(responseData); 151 | Gson gson = new Gson(); //用Gson解析Json数据 152 | 153 | HotResultBean hotResultBean = gson.fromJson(responseData, HotResultBean.class); 154 | totalCount = hotResultBean.getTotalCount(); 155 | productBeanList.addAll(hotResultBean.getList()); 156 | 157 | 158 | // //检查数据是否接收到 159 | // for (ProductBean bean : productBeanList) { 160 | // System.out.println(bean.toString()); 161 | // } 162 | getActivity().runOnUiThread(new Runnable() { 163 | @Override 164 | public void run() { 165 | // setState(false); 166 | hotRecyclerAdapter.notifyDataSetChanged(); 167 | } 168 | }); 169 | } 170 | }); 171 | } 172 | 173 | // private void setState(boolean error){ 174 | // //判断是否还有数据,用于设置底部状态 175 | // if(productBeanList.size() >= totalCount){ 176 | // hotRecyclerAdapter.showMore(false); 177 | // }else { 178 | // hotRecyclerAdapter.showMore(true); 179 | // } 180 | // 181 | // //mCurrentPager为1表示刷新操作 182 | //// if(currentPage == 1){ 183 | //// mSwipeRefreshLayout.setRefreshing(false); 184 | //// } 185 | // 186 | //// if(error){ 187 | //// hotRecyclerAdapter.showError(error); 188 | //// } 189 | // } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/fragment/Fragment3.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.fragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.os.Bundle; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.idaniu.maga.shopping.R; 10 | 11 | /** 12 | * 13 | * Created by yuanbao15 on 2017/10/8. 14 | */ 15 | public class Fragment3 extends Fragment{ 16 | @Override 17 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 18 | Bundle savedInstanceState) { 19 | return inflater.inflate(R.layout.frag3, container, false); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/fragment/Fragment4.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.fragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.CheckBox; 11 | import android.widget.ImageView; 12 | import android.widget.TextView; 13 | 14 | import com.idaniu.maga.shopping.R; 15 | import com.idaniu.maga.shopping.adapter.CartRecyclerAdapter; 16 | import com.idaniu.maga.shopping.bean.ShoppingCartBean; 17 | import com.idaniu.maga.shopping.manager.CartManager; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * 购物车页面 24 | * Created by yuanbao15 on 2017/10/8. 25 | */ 26 | public class Fragment4 extends Fragment{ 27 | 28 | private static final String TAG = "CartFragment"; 29 | 30 | List cartBeanList; 31 | 32 | private CartRecyclerAdapter cartRecyclerAdapter; 33 | private RecyclerView recyclerView; 34 | 35 | private TextView totalPriceTextView; //合计总价 36 | private CheckBox allCheckBox; //是否全选 37 | private static int allCheckedFlag = 0; //全选标志 38 | private static final int ALL_CHECKED = 1; 39 | private static final int ALL_NOT_CHECKED = 0; 40 | 41 | @Override 42 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 43 | Bundle savedInstanceState) { 44 | View view = inflater.inflate(R.layout.frag4, container, false); 45 | initView(view); 46 | return view; 47 | } 48 | 49 | private void initView(View view) { 50 | cartBeanList = CartManager.getInstance().getAll(); 51 | 52 | //下排的控件 53 | totalPriceTextView = (TextView) view.findViewById(R.id.tv_cart_totalprice); 54 | allCheckBox = (CheckBox) view.findViewById(R.id.checkbox_cart_all); 55 | allCheckBox.setOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View v) { 58 | if(allCheckedFlag != ALL_CHECKED){ 59 | allCheckedFlag = ALL_CHECKED; 60 | for(ShoppingCartBean bean:cartBeanList){ 61 | bean.setChecked(true); 62 | CartManager.getInstance().update(bean); 63 | } 64 | }else{ 65 | allCheckedFlag = ALL_NOT_CHECKED; 66 | for(ShoppingCartBean bean:cartBeanList){ 67 | bean.setChecked(false); 68 | CartManager.getInstance().update(bean); 69 | } 70 | } 71 | //更新显示 72 | updateCartData(); 73 | } 74 | }); 75 | 76 | recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_cart); 77 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); 78 | cartRecyclerAdapter = new CartRecyclerAdapter(getActivity(), cartBeanList, new CartRecyclerAdapter.OnCartUpdateListener() { 79 | @Override 80 | public void onUpdateChecked(int i) { 81 | ShoppingCartBean bean = cartBeanList.get(i); 82 | CartManager.getInstance().update(bean); 83 | updateCartData(); 84 | } 85 | 86 | @Override 87 | public void onUpdatecount(int i) { 88 | ShoppingCartBean bean = cartBeanList.get(i); 89 | CartManager.getInstance().update(bean); 90 | updateCartData(); 91 | } 92 | }); 93 | recyclerView.setAdapter(cartRecyclerAdapter); 94 | 95 | updateCartData(); 96 | } 97 | 98 | //更新一次购物车信息 99 | private void updateCartData() { 100 | cartBeanList.clear(); 101 | cartBeanList.addAll(CartManager.getInstance().getAll()); 102 | cartRecyclerAdapter.notifyDataSetChanged(); 103 | //计算已勾选物品的总价 104 | float sum = getTotalPrice(); 105 | totalPriceTextView.setText("合计:¥"+sum); 106 | } 107 | 108 | //计算总价 109 | public float getTotalPrice() { 110 | float sum=0.0f; //总价的变量 111 | for(ShoppingCartBean bean:cartBeanList){ 112 | if(bean.isChecked()){ 113 | float price = Float.parseFloat(bean.getPrice()); //先将这个的String转化为float 114 | sum += bean.getCount()*price; 115 | } 116 | } 117 | return sum; 118 | } 119 | 120 | //获取放到购物车的信息 还是订单信息 121 | // public List getCartBeanList(){ 122 | // List cartBeanList = new ArrayList<>(); 123 | // return null; 124 | // } 125 | } 126 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/fragment/Fragment5.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.fragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.os.Bundle; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.idaniu.maga.shopping.R; 10 | 11 | /** 12 | * 13 | * Created by yuanbao15 on 2017/10/8. 14 | */ 15 | public class Fragment5 extends Fragment{ 16 | @Override 17 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 18 | Bundle savedInstanceState) { 19 | return inflater.inflate(R.layout.frag5, container, false); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/manager/CartManager.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.manager; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.text.TextUtils; 6 | import android.util.SparseArray; 7 | 8 | import com.google.gson.Gson; 9 | import com.google.gson.reflect.TypeToken; 10 | import com.idaniu.maga.shopping.ShoppingApplication; 11 | import com.idaniu.maga.shopping.bean.ShoppingCartBean; 12 | 13 | import java.lang.reflect.Type; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * 购物车管理类,单例模式。 19 | * 20 | * 主要是put(添加)、update(更新数量以及选中状态)、delete(删除)、getAll(获取购物车内容) 21 | * 这里为了简单,没有使用数据库保存,而是使用的SharedPreferences 22 | * 由于SharedPreferences不能存储对象,所以将对象转为json格式存储 23 | * 24 | * Created by not yuanbao15 but maga on 2017/12/8. 25 | */ 26 | public class CartManager { 27 | 28 | private static final String TAG = "CartManager"; 29 | private static final String CART_KEY = "cart_list"; 30 | 31 | private volatile static CartManager sInstance; 32 | private SharedPreferences mSharedPreferences; 33 | private SparseArray mData; 34 | 35 | //单例模式 36 | public static CartManager getInstance(){ 37 | if(sInstance == null){ 38 | synchronized (CartManager.class){ 39 | if(sInstance == null){ 40 | sInstance = new CartManager(); 41 | } 42 | } 43 | } 44 | return sInstance; 45 | } 46 | 47 | //构造器 48 | private CartManager(){ 49 | //初始化数据 50 | mSharedPreferences = ShoppingApplication.getInstance().getSharedPreferences("cart", Context.MODE_PRIVATE); 51 | mData = new SparseArray<>(10); 52 | 53 | getDataFromLocal(); //加载所有数据 54 | } 55 | 56 | /** 57 | * 从SharedPreference中获取数据 58 | */ 59 | private void getDataFromLocal(){ 60 | String json = mSharedPreferences.getString(CART_KEY, "[]"); 61 | if(!TextUtils.isEmpty(json)){ 62 | Gson gson = new Gson(); 63 | Type type = new TypeToken>(){}.getType(); 64 | List data = gson.fromJson(json, type); 65 | for(ShoppingCartBean bean : data){ 66 | mData.put((int) bean.getId(), bean); 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * 将商品添加到购物车 73 | * 如果有就数量加1,没有就直接添加 74 | * @param item 75 | */ 76 | public void put(ShoppingCartBean item){ 77 | if(item == null) return; 78 | 79 | ShoppingCartBean bean = mData.get((int) item.getId()); 80 | if(bean == null){ 81 | bean = item; 82 | }else { 83 | bean.setCount(bean.getCount() + 1); 84 | } 85 | 86 | mData.put((int) item.getId(), bean); 87 | putDataToLocal(); 88 | 89 | } 90 | 91 | /** 92 | * 更新购物车数据,主要是更新数量和选中状态 93 | * @param item 94 | */ 95 | public void update(ShoppingCartBean item) { 96 | mData.put((int) item.getId(), item); 97 | putDataToLocal(); 98 | } 99 | 100 | /** 101 | * 删除数据 102 | * @param item 103 | */ 104 | public void delete(ShoppingCartBean item){ 105 | mData.delete((int) item.getId()); 106 | putDataToLocal(); 107 | } 108 | 109 | /** 110 | * 获取所有数据 111 | * @return 112 | */ 113 | public List getAll(){ 114 | int size = mData.size(); 115 | ArrayList list = new ArrayList<>(size); 116 | for(int i = 0; i < size; i++){ 117 | list.add(mData.valueAt(i)); 118 | } 119 | return list; 120 | } 121 | 122 | /** 123 | * 把修改后的数据同步到SharedPreference中 124 | */ 125 | private void putDataToLocal(){ 126 | int size = mData.size(); 127 | ArrayList list = new ArrayList<>(size); 128 | for(int i = 0; i < size; i++){ 129 | list.add(mData.valueAt(i)); 130 | } 131 | 132 | Gson gson = new Gson(); 133 | Type type = new TypeToken>(){}.getType(); 134 | String json = gson.toJson(list, type); 135 | SharedPreferences.Editor editor = mSharedPreferences.edit(); 136 | editor.putString(CART_KEY, json); 137 | editor.apply(); 138 | } 139 | 140 | 141 | } -------------------------------------------------------------------------------- /app/src/main/java/com/idaniu/maga/shopping/manager/UserManager.java: -------------------------------------------------------------------------------- 1 | package com.idaniu.maga.shopping.manager; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import java.io.IOException; 7 | import java.lang.ref.WeakReference; 8 | import android.text.TextUtils; 9 | 10 | import com.google.gson.Gson; 11 | import com.idaniu.maga.shopping.Constant; 12 | import com.idaniu.maga.shopping.DESUtil; 13 | import com.idaniu.maga.shopping.ShoppingApplication; 14 | import com.idaniu.maga.shopping.bean.LoginBean; 15 | import com.idaniu.maga.shopping.bean.UserBean; 16 | 17 | import okhttp3.Call; 18 | import okhttp3.Callback; 19 | import okhttp3.OkHttpClient; 20 | import okhttp3.Request; 21 | import okhttp3.RequestBody; 22 | import okhttp3.Response; 23 | 24 | /** 25 | * Created by yuanbao15 on 2017/11/2. 26 | * 27 | * 用户管理类,单例模式 28 | * 包含用户登录、登出、注册的逻辑,管理用户信息 29 | */ 30 | public class UserManager { 31 | private static final String TAG = "UserManager"; 32 | 33 | private static final String PREF_NAME = "user"; 34 | private static final String TOKEN_KEY = "token"; 35 | private static final String USER_KEY = "user"; 36 | private static final String USERNAME_KEY = "username"; 37 | private static final String PASSWORD_KEY = "password"; 38 | 39 | private volatile static UserManager sInstance; 40 | 41 | private SharedPreferences mSharedPreferences; 42 | private UserBean mUserInfo; 43 | private String mToken; 44 | private WeakReference mLoginListener; 45 | private WeakReference mRegisterListener; 46 | 47 | public static UserManager getInstance(){ 48 | if(sInstance == null){ 49 | synchronized (UserManager.class){ 50 | if(sInstance == null){ 51 | sInstance = new UserManager(); 52 | } 53 | } 54 | } 55 | return sInstance; 56 | } 57 | 58 | private UserManager(){ 59 | mSharedPreferences = ShoppingApplication.getInstance().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); 60 | 61 | //获取保存的用户信息 62 | mToken = mSharedPreferences.getString(TOKEN_KEY, ""); 63 | if(TextUtils.isEmpty(mToken)){ 64 | mToken = null; 65 | }else { 66 | String json = mSharedPreferences.getString(USER_KEY, ""); 67 | if(TextUtils.isEmpty(json)){ 68 | mToken = null; 69 | }else { 70 | Gson gson = new Gson(); 71 | UserBean data = gson.fromJson(json, UserBean.class); 72 | if(data == null){ 73 | mToken = null; 74 | }else { 75 | mUserInfo = data; 76 | } 77 | } 78 | } 79 | } 80 | 81 | /** 82 | * 登录方法模块 83 | * 84 | * @param phone 电话号码 85 | * @param password 密码 86 | * @param listener 登录监听 87 | */ 88 | public void login(final String phone, final String password, OnLoginListener listener){ 89 | if(TextUtils.isEmpty(phone) || TextUtils.isEmpty(password)){ 90 | return; 91 | } 92 | mLoginListener = new WeakReference(listener); 93 | OkHttpClient okHttpClient = new OkHttpClient(); 94 | 95 | String params = "phone=" + phone + "&password=" + DESUtil.encode(Constant.DES_KEY, password); 96 | 97 | Request request = new Request.Builder() 98 | .url(Constant.LOGIN_URL) 99 | .post(RequestBody.create(Constant.CONTENT_TYPE, params)) 100 | .build(); 101 | 102 | okHttpClient.newCall(request).enqueue(new Callback() { 103 | @Override 104 | public void onFailure(Call call, IOException e) { 105 | if(mLoginListener != null && mLoginListener.get() != null){ 106 | mLoginListener.get().onError(e.getMessage()); 107 | } 108 | } 109 | 110 | 111 | @Override 112 | public void onResponse(Call call, Response response) throws IOException { 113 | if(response == null || response.body() == null){ 114 | onFailure(call, new IOException("response is empty")); 115 | return; 116 | } 117 | 118 | String result = response.body().string(); 119 | Gson gson = new Gson(); 120 | LoginBean data = gson.fromJson(result, LoginBean.class); 121 | if(data.getStatus() != 1){ 122 | onFailure(call, new IOException(data.getMessage())); 123 | return; 124 | } 125 | 126 | saveUser(data.getData(), phone, password); 127 | saveToken(data.getToken()); 128 | 129 | if(mLoginListener != null && mLoginListener.get() != null){ 130 | mLoginListener.get().onLogin(); 131 | } 132 | } 133 | }); 134 | } 135 | 136 | /** 137 | * 注册方法模块 138 | * 139 | * @param phone 电话号码 140 | * @param password 密码 141 | * @param listener 注册侦听器 142 | */ 143 | public void register(final String phone, final String password, OnRegisterListener listener){ 144 | if(TextUtils.isEmpty(phone) || TextUtils.isEmpty(password)){ 145 | return; 146 | } 147 | 148 | mRegisterListener = new WeakReference<>(listener); 149 | 150 | OkHttpClient okHttpClient = new OkHttpClient(); 151 | 152 | String params = "phone=" + phone + "&password=" + DESUtil.encode(Constant.DES_KEY, password); 153 | 154 | Request request = new Request.Builder() 155 | .url(Constant.REGISTER_URL) 156 | .post(RequestBody.create(Constant.CONTENT_TYPE, params)) 157 | .build(); 158 | okHttpClient.newCall(request).enqueue(new Callback() { 159 | @Override 160 | public void onFailure(Call call, IOException e) { 161 | if(mRegisterListener != null && mRegisterListener.get() != null){ 162 | mRegisterListener.get().onError(e.getMessage()); 163 | } 164 | } 165 | 166 | @Override 167 | public void onResponse(Call call, Response response) throws IOException { 168 | if(response == null || response.body() == null){ 169 | onFailure(call, new IOException("response is empty")); 170 | return; 171 | } 172 | 173 | String result = response.body().string(); 174 | Gson gson = new Gson(); 175 | LoginBean data = gson.fromJson(result, LoginBean.class); 176 | if(data.getStatus() != 1){ 177 | onFailure(call, new IOException(data.getMessage())); 178 | return; 179 | } 180 | 181 | saveUser(data.getData(), phone, password); 182 | saveToken(data.getToken()); 183 | 184 | if(mRegisterListener != null && mRegisterListener.get() != null){ 185 | mRegisterListener.get().onRegister(); 186 | } 187 | } 188 | }); 189 | } 190 | 191 | 192 | //电话号码 193 | public String getPhone(){ 194 | return mSharedPreferences.getString(USERNAME_KEY, ""); 195 | } 196 | 197 | //用户密码 198 | public String getPassword(){ 199 | return mSharedPreferences.getString(PASSWORD_KEY, ""); 200 | } 201 | 202 | //用户id 203 | public int getId(){ 204 | if(mUserInfo != null){ 205 | return (int) mUserInfo.getId(); 206 | } 207 | return 0; 208 | } 209 | 210 | //用户名 211 | public String getUserName(){ 212 | if(mUserInfo != null){ 213 | return mUserInfo.getUsername(); 214 | } 215 | return null; 216 | } 217 | 218 | //头像 219 | public String getAvatar(){ 220 | if(mUserInfo != null){ 221 | return mUserInfo.getLogo_url(); 222 | } 223 | return null; 224 | } 225 | 226 | //token 227 | public String getToken(){ 228 | return mToken; 229 | } 230 | 231 | //是否登录 232 | public boolean isLogin(){ 233 | return mUserInfo != null && !TextUtils.isEmpty(mToken); 234 | } 235 | 236 | 237 | //保存登录后获取的用户数据 238 | private void saveUser(UserBean user, String phone, String password){ 239 | mUserInfo = user; 240 | Gson gson = new Gson(); 241 | String json = gson.toJson(mUserInfo, UserBean.class); 242 | SharedPreferences.Editor editor = mSharedPreferences.edit(); 243 | editor.putString(USER_KEY, json); 244 | editor.putString(USERNAME_KEY, phone); 245 | editor.putString(PASSWORD_KEY, password); 246 | editor.apply(); 247 | } 248 | 249 | //保存token 信息 250 | private void saveToken(String token){ 251 | mToken = token; 252 | SharedPreferences.Editor editor = mSharedPreferences.edit(); 253 | editor.putString(TOKEN_KEY, token); 254 | editor.apply(); 255 | } 256 | 257 | 258 | //侦听器 259 | public interface OnLoginListener{ 260 | void onLogin(); 261 | void onError(String msg); 262 | } 263 | 264 | public interface OnRegisterListener{ 265 | void onRegister(); 266 | void onError(String msg); 267 | } 268 | 269 | } 270 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_alipay_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_alipay_72.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_bd_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_bd_72.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_cancel_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_cancel_128.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_check_false.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_check_false.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_check_true.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_check_true.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_right_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_right_64.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_success_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_success_128.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_wechat_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/icon_wechat_72.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/indicate_circle_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/indicate_circle_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/indicate_circle_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/indicate_circle_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/selector_checkbox_green.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/shape_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | android:shape="rectangle"> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_1_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_1_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_1_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_1_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_2_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_2_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_2_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_2_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_3_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_3_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_3_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_3_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_4_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_4_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_4_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_4_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_5_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_5_gray.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tab_iv_5_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-hdpi/tab_iv_5_red.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/default_head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/default_head.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_back_32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_back_32px.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_cart.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_cartfill_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_cartfill_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_check_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_check_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_check_checked_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_check_checked_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_delete_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_delete_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_discover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_discover.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_discover_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_discover_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_edit_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_edit_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_favorite.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_grid_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_grid_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_home_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_home_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_hot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_hot.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_hot_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_hot_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_list_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_list_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_list_o.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_list_o.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_location.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_lock.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_msg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_msg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_my_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_my_info.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_telphone_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_telphone_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_trash_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_trash_32.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_user.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon_user_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuanbao15/MobileShop/1f0858433410ebc1686f3840931d832e0c1ba27e/app/src/main/res/drawable-xhdpi/icon_user_press.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_banner.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 21 | 22 | 30 | 31 | 32 | 40 | 41 | 47 | 54 | 64 | 65 | 66 | 69 | 70 | 76 | 83 | 93 | 94 | 95 | 96 | 108 | 109 | 115 | 116 | 124 | 125 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 17 | 18 | 25 | 29 | 37 | 38 | 39 | 46 | 50 | 57 | 58 | 59 | 66 | 70 | 77 | 78 | 79 | 86 | 90 | 97 | 98 | 105 | 109 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 129 | 130 | 131 | 136 | 137 | 138 | 139 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_register.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 19 | 20 | 28 | 29 | 30 | 39 | 40 | 45 | 46 | 53 | 54 | 61 | 62 | 63 | 68 | 69 | 75 | 81 | 83 | 93 | 94 | 95 | 100 | 101 | 107 | 113 | 115 | 125 | 126 | 127 | 128 | 129 | 141 | 142 | 151 | -------------------------------------------------------------------------------- /app/src/main/res/layout/cart_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 21 | 22 | 30 | 40 | 41 | 49 |