Commit 7c01d339cec77ff91bcefc4d4aafc706ad957890

Authored by gaiyaguang
0 parents

v1.0

Showing 45 changed files with 4814 additions and 0 deletions

Too many changes to show.

To preserve performance only 45 of 45+ files are displayed.

  1 +*.iml
  2 +.gradle
  3 +/local.properties
  4 +/.idea/libraries
  5 +/.idea/modules.xml
  6 +/.idea/workspace.xml
  7 +.DS_Store
  8 +/build
  9 +/captures
  10 +.externalNativeBuild
No preview for this file type
  1 +<component name="ProjectCodeStyleConfiguration">
  2 + <code_scheme name="Project" version="173">
  3 + <Objective-C-extensions>
  4 + <file>
  5 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
  6 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
  7 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
  8 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
  9 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
  10 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
  11 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
  12 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
  13 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
  14 + </file>
  15 + <class>
  16 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
  17 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
  18 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
  19 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
  20 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
  21 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
  22 + </class>
  23 + <extensions>
  24 + <pair source="cpp" header="h" fileNamingConvention="NONE" />
  25 + <pair source="c" header="h" fileNamingConvention="NONE" />
  26 + </extensions>
  27 + </Objective-C-extensions>
  28 + </code_scheme>
  29 +</component>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="GradleSettings">
  4 + <option name="linkedExternalProjectsSettings">
  5 + <GradleProjectSettings>
  6 + <option name="distributionType" value="DEFAULT_WRAPPED" />
  7 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
  8 + <option name="modules">
  9 + <set>
  10 + <option value="$PROJECT_DIR$" />
  11 + <option value="$PROJECT_DIR$/app" />
  12 + <option value="$PROJECT_DIR$/login" />
  13 + <option value="$PROJECT_DIR$/mvvmhabit" />
  14 + </set>
  15 + </option>
  16 + <option name="resolveModulePerSourceSet" value="false" />
  17 + </GradleProjectSettings>
  18 + </option>
  19 + </component>
  20 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="NullableNotNullManager">
  4 + <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
  5 + <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
  6 + <option name="myNullables">
  7 + <value>
  8 + <list size="5">
  9 + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
  10 + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
  11 + <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
  12 + <item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
  13 + <item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
  14 + </list>
  15 + </value>
  16 + </option>
  17 + <option name="myNotNulls">
  18 + <value>
  19 + <list size="4">
  20 + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
  21 + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
  22 + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
  23 + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
  24 + </list>
  25 + </value>
  26 + </option>
  27 + </component>
  28 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
  29 + <output url="file://$PROJECT_DIR$/build/classes" />
  30 + </component>
  31 + <component name="ProjectType">
  32 + <option name="id" value="Android" />
  33 + </component>
  34 +</project>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="RunConfigurationProducerService">
  4 + <option name="ignoredProducers">
  5 + <set>
  6 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
  7 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
  8 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
  9 + </set>
  10 + </option>
  11 + </component>
  12 +</project>
  1 +/build
  1 +apply plugin: 'com.android.application'
  2 +
  3 +android {
  4 + compileSdkVersion 27
  5 + defaultConfig {
  6 + applicationId "com.naji.xiaotao"
  7 + minSdkVersion 15
  8 + targetSdkVersion 27
  9 + versionCode 1
  10 + versionName "1.0.1"
  11 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  12 +
  13 + ndk {
  14 + //选择要添加的对应cpu类型的.so库。
  15 + abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
  16 + // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
  17 + }
  18 +
  19 + manifestPlaceholders = [
  20 + JPUSH_PKGNAME : "com.naji.xiaotao",
  21 + JPUSH_APPKEY : "7d1e57b0d37d8d4cdf945912", //JPush上注册的包名对应的appkey.
  22 + JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
  23 + ]
  24 + }
  25 + buildTypes {
  26 + release {
  27 + minifyEnabled false
  28 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  29 + }
  30 + }
  31 + dataBinding {
  32 + enabled true
  33 + }
  34 +}
  35 +
  36 +dependencies {
  37 + implementation fileTree(dir: 'libs', include: ['*.jar'])
  38 + implementation 'com.android.support:appcompat-v7:27.1.1'
  39 + implementation 'com.android.support.constraint:constraint-layout:1.1.2'
  40 + implementation 'com.android.support:design:27.1.1'
  41 + testImplementation 'junit:junit:4.12'
  42 + androidTestImplementation 'com.android.support.test:runner:1.0.2'
  43 + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  44 + implementation('com.jcodecraeer:xrecyclerview:1.5.9', {
  45 + exclude group: 'com.android.support', module: 'design'
  46 + })
  47 + //动态修改状态栏颜色
  48 + implementation 'com.githang:status-bar-compat:0.7'
  49 + //圆角图片
  50 + implementation 'com.github.Othershe:NiceImageView:1.0.1'
  51 +
  52 + implementation 'cn.jiguang.sdk:jpush:3.1.5' // 此处以JPush 3.1.5 版本为例。
  53 + implementation 'cn.jiguang.sdk:jcore:1.2.3' // 此处以JCore 1.2.3 版本为例。
  54 + //MVVMHabit
  55 + implementation project(':mvvmhabit')
  56 +
  57 + annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:4.2.4"
  58 + // gradle 3.0.0 可以使用 implementation,否则用 compile
  59 + implementation "com.github.Raizlabs.DBFlow:dbflow-core:4.2.4"
  60 + implementation "com.github.Raizlabs.DBFlow:dbflow:4.2.4"
  61 +
  62 + //进度条
  63 + implementation 'com.daimajia.numberprogressbar:library:1.4@aar'
  64 +
  65 + //bugly自动升级
  66 + implementation 'com.tencent.bugly:crashreport_upgrade:latest.release'
  67 + implementation 'com.tencent.bugly:nativecrashreport:latest.release'
  68 +}
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
  22 +
  23 +-dontwarn com.tencent.bugly.**
  24 +-keep public class com.tencent.bugly.**{*;}
  25 +-keep class android.support.**{*;}
  1 +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
No preview for this file type
  1 +package com.naji.xiaotao;
  2 +
  3 +import android.content.Context;
  4 +import android.support.test.InstrumentationRegistry;
  5 +import android.support.test.runner.AndroidJUnit4;
  6 +
  7 +import org.junit.Test;
  8 +import org.junit.runner.RunWith;
  9 +
  10 +import static org.junit.Assert.*;
  11 +
  12 +/**
  13 + * Instrumented test, which will execute on an Android device.
  14 + *
  15 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
  16 + */
  17 +@RunWith(AndroidJUnit4.class)
  18 +public class ExampleInstrumentedTest {
  19 + @Test
  20 + public void useAppContext() {
  21 + // Context of the app under test.
  22 + Context appContext = InstrumentationRegistry.getTargetContext();
  23 +
  24 + assertEquals("com.naji.xiaotao", appContext.getPackageName());
  25 + }
  26 +}
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + package="com.naji.xiaotao">
  5 +
  6 + <uses-permission android:name="android.permission.INTERNET" />
  7 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  8 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  9 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  10 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  11 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  12 +
  13 + <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
  14 +
  15 + <!-- Required -->
  16 + <permission
  17 + android:name="com.naji.xiaotao.permission.JPUSH_MESSAGE"
  18 + android:protectionLevel="signature" />
  19 +
  20 + <!-- Required -->
  21 + <uses-permission android:name="您应用的包名.permission.JPUSH_MESSAGE" />
  22 + <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
  23 + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
  24 + <uses-permission android:name="android.permission.WRITE_SETTINGS" />
  25 +
  26 + <!-- Optional. Required for location feature -->
  27 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
  28 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  29 + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  30 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  31 + <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
  32 + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
  33 + <uses-permission android:name="android.permission.GET_TASKS" />
  34 + <uses-permission android:name="android.permission.VIBRATE" />
  35 +
  36 + <uses-permission android:name="android.permission.READ_LOGS" />
  37 +
  38 + <application
  39 + android:name=".App"
  40 + android:allowBackup="true"
  41 + android:icon="@mipmap/ic_launcher"
  42 + android:label="@string/app_name"
  43 + android:roundIcon="@mipmap/ic_launcher"
  44 + android:supportsRtl="true"
  45 + android:theme="@style/AppTheme"
  46 + >
  47 + <activity android:name=".login.ui.LoginActivity"
  48 + android:screenOrientation="landscape"
  49 + >
  50 + <intent-filter>
  51 + <action android:name="android.intent.action.MAIN" />
  52 +
  53 + <category android:name="android.intent.category.LAUNCHER" />
  54 + </intent-filter>
  55 + </activity>
  56 + <activity android:name=".main.ui.MainActivity"
  57 + android:label="主页"
  58 + android:screenOrientation="landscape"
  59 + />
  60 + <activity android:name=".tangshi.ui.TangShiActivity"
  61 + android:label="控制台主页"
  62 + android:screenOrientation="portrait"
  63 + android:launchMode="singleTask"
  64 + />
  65 + <activity android:name=".cookbook.ui.CookBookMainActivity"
  66 + android:label="菜谱主页"
  67 + android:screenOrientation="portrait"
  68 + android:launchMode="singleTask"
  69 + />
  70 + <activity android:name=".cart.ui.CartActivity"
  71 + android:label="购物车"
  72 + android:screenOrientation="portrait"
  73 + android:launchMode="singleTask"
  74 + android:windowSoftInputMode="adjustPan"
  75 + />
  76 + <activity android:name=".cart.ui.RemarkActivity"
  77 + android:label="整单备注"
  78 + android:screenOrientation="portrait"
  79 + android:windowSoftInputMode="adjustPan"
  80 + />
  81 + <activity android:name=".order.ui.OrderActivity"
  82 + android:label="订单详情"
  83 + android:screenOrientation="landscape"
  84 + />
  85 + <activity android:name=".pay.ui.PayActivity"
  86 + android:label="结账"
  87 + android:screenOrientation="portrait"
  88 + />
  89 + <activity android:name=".order.ui.OrderAffirmActivity"
  90 + android:label="订单确认"
  91 + android:screenOrientation="portrait"
  92 + android:windowSoftInputMode="adjustPan"
  93 + />
  94 + <activity android:name=".order.ui.OrderRetireActivity"
  95 + android:label="退菜"
  96 + android:screenOrientation="portrait"
  97 + />
  98 + <activity android:name=".receipt.ui.ReceiptActivity"
  99 + android:label="发票详情"
  100 + />
  101 + <activity android:name=".pay.ui.ZddzActivity"
  102 + android:label="整单打折"
  103 + android:screenOrientation="portrait"
  104 + />
  105 + <activity android:name=".pay.ui.ZdyyhActivity"
  106 + android:label="自定义优惠"
  107 + android:screenOrientation="portrait"
  108 + />
  109 + <activity android:name=".tangshi.ui.TableListActivity"
  110 + android:label="可选桌位列表"
  111 + android:screenOrientation="portrait"
  112 + />
  113 + <activity android:name=".history.ui.HistoryActivity"
  114 + android:label="历史订单"
  115 + android:screenOrientation="portrait"
  116 + />
  117 +
  118 +
  119 +
  120 + <!--版本更新-->
  121 + <provider
  122 + android:name="android.support.v4.content.FileProvider"
  123 + android:authorities="${applicationId}.fileProvider"
  124 + android:exported="false"
  125 + android:grantUriPermissions="true">
  126 + <meta-data
  127 + android:name="android.support.FILE_PROVIDER_PATHS"
  128 + android:resource="@xml/provider_paths"/>
  129 + </provider>
  130 +
  131 + <activity
  132 + android:name="com.tencent.bugly.beta.ui.BetaActivity"
  133 + android:configChanges="keyboardHidden|orientation|screenSize|locale"
  134 + android:theme="@android:style/Theme.Translucent" />
  135 +
  136 +
  137 + <!-- Required SDK 核心功能-->
  138 + <!-- 可配置android:process参数将PushService放在其他进程中 -->
  139 + <service
  140 + android:name="cn.jpush.android.service.PushService"
  141 + android:enabled="true"
  142 + android:exported="false" >
  143 + <intent-filter>
  144 + <action android:name="cn.jpush.android.intent.REGISTER" />
  145 + <action android:name="cn.jpush.android.intent.REPORT" />
  146 + <action android:name="cn.jpush.android.intent.PushService" />
  147 + <action android:name="cn.jpush.android.intent.PUSH_TIME" />
  148 + </intent-filter>
  149 + </service>
  150 +
  151 +
  152 + <!-- since 3.0.9 Required SDK 核心功能-->
  153 + <provider
  154 + android:authorities="com.naji.xiaotao.DataProvider"
  155 + android:name="cn.jpush.android.service.DataProvider"
  156 + android:exported="true"
  157 + tools:replace="android:exported" />
  158 +
  159 + <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
  160 + <!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
  161 + <service
  162 + android:name="cn.jpush.android.service.DaemonService"
  163 + android:enabled="true"
  164 + android:exported="true">
  165 + <intent-filter >
  166 + <action android:name="cn.jpush.android.intent.DaemonService" />
  167 + <category android:name="com.naji.xiaotao"/>
  168 + </intent-filter>
  169 + </service>
  170 +
  171 + <!-- since 3.1.0 Required SDK 核心功能-->
  172 + <provider
  173 + android:authorities="com.naji.xiaotao.DownloadProvider"
  174 + android:name="cn.jpush.android.service.DownloadProvider"
  175 + android:exported="true"
  176 + />
  177 +
  178 + <!-- Required SDK核心功能-->
  179 + <receiver
  180 + android:name="cn.jpush.android.service.PushReceiver"
  181 + android:enabled="true" >
  182 + <intent-filter android:priority="1000">
  183 + <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
  184 + <category android:name="com.naji.xiaotao"/>
  185 + </intent-filter>
  186 + <intent-filter>
  187 + <action android:name="android.intent.action.USER_PRESENT" />
  188 + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
  189 + </intent-filter>
  190 + <!-- Optional -->
  191 + <intent-filter>
  192 + <action android:name="android.intent.action.PACKAGE_ADDED" />
  193 + <action android:name="android.intent.action.PACKAGE_REMOVED" />
  194 + <data android:scheme="package" />
  195 + </intent-filter>
  196 + </receiver>
  197 +
  198 + <!-- Required SDK核心功能-->
  199 + <activity
  200 + android:name="cn.jpush.android.ui.PushActivity"
  201 + android:configChanges="orientation|keyboardHidden"
  202 + android:theme="@android:style/Theme.NoTitleBar"
  203 + android:exported="false" >
  204 + <intent-filter>
  205 + <action android:name="cn.jpush.android.ui.PushActivity" />
  206 + <category android:name="android.intent.category.DEFAULT" />
  207 + <category android:name="com.naji.xiaotao" />
  208 + </intent-filter>
  209 + </activity>
  210 + <!-- SDK核心功能-->
  211 + <activity
  212 + android:name="cn.jpush.android.ui.PopWinActivity"
  213 + android:configChanges="orientation|keyboardHidden"
  214 + android:exported="false"
  215 + android:theme="@style/MyDialogStyle">
  216 + <intent-filter>
  217 + <category android:name="android.intent.category.DEFAULT" />
  218 + <category android:name="com.naji.xiaotao" />
  219 + </intent-filter>
  220 + </activity>
  221 +
  222 + <!-- Required SDK核心功能-->
  223 + <service
  224 + android:name="cn.jpush.android.service.DownloadService"
  225 + android:enabled="true"
  226 + android:exported="false" >
  227 + </service>
  228 +
  229 + <!-- Required SDK核心功能-->
  230 + <receiver android:name="cn.jpush.android.service.AlarmReceiver" />
  231 +
  232 + <!-- Required since 3.0.7 -->
  233 + <!-- 新的tag/alias接口结果返回需要开发者配置一个自定的广播 -->
  234 + <!-- 该广播需要继承JPush提供的JPushMessageReceiver类, 并如下新增一个 Intent-Filter -->
  235 + <receiver
  236 + android:name=".message.receiver.TagReceiver"
  237 + android:enabled="true"
  238 + android:exported="false" >
  239 + <intent-filter>
  240 + <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
  241 + <category android:name="com.naji.xiaotao" />
  242 + </intent-filter>
  243 + </receiver>
  244 +
  245 + <!-- User defined. 用户自定义的广播接收器-->
  246 + <receiver
  247 + android:name=".message.receiver.MessageReceiver"
  248 + android:enabled="true"
  249 + android:exported="false">
  250 + <intent-filter>
  251 + <!--Required 用户注册SDK的intent-->
  252 + <action android:name="cn.jpush.android.intent.REGISTRATION" />
  253 + <!--Required 用户接收SDK消息的intent-->
  254 + <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
  255 + <!--Required 用户接收SDK通知栏信息的intent-->
  256 + <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
  257 + <!--Required 用户打开自定义通知栏的intent-->
  258 + <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
  259 + <!-- 接收网络变化 连接/断开 since 1.6.3 -->
  260 + <action android:name="cn.jpush.android.intent.CONNECTION" />
  261 + <category android:name="com.naji.xiaotao" />
  262 + </intent-filter>
  263 + </receiver>
  264 +
  265 + <!-- Required. For publish channel feature -->
  266 + <!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。-->
  267 + <!-- 例如: -->
  268 + <!-- 发到 Google Play 的APK可以设置为 google-play; -->
  269 + <!-- 发到其他市场的 APK 可以设置为 xxx-market。 -->
  270 + <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
  271 + <!-- Required. AppKey copied from Portal -->
  272 + <meta-data android:name="JPUSH_APPKEY" android:value="7d1e57b0d37d8d4cdf945912"/>
  273 +
  274 +
  275 + </application>
  276 +
  277 +</manifest>
No preview for this file type
  1 +package com.naji.xiaotao;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Context;
  5 +
  6 +import com.githang.statusbar.StatusBarCompat;
  7 +import com.naji.xiaotao.login.ui.LoginActivity;
  8 +import com.naji.xiaotao.main.ui.MainActivity;
  9 +import com.raizlabs.android.dbflow.config.FlowManager;
  10 +import com.tencent.bugly.Bugly;
  11 +import com.tencent.bugly.beta.Beta;
  12 +
  13 +import cn.jpush.android.api.JPushInterface;
  14 +import me.goldze.mvvmhabit.base.BaseApplication;
  15 +import me.goldze.mvvmhabit.crash.CaocConfig;
  16 +import me.goldze.mvvmhabit.utils.KLog;
  17 +
  18 +public class App extends BaseApplication {
  19 +
  20 + @Override
  21 + public void onCreate() {
  22 + super.onCreate();
  23 + Bugly.init(getApplicationContext(), "493c3c1046", false);
  24 + Beta.canShowUpgradeActs.add(MainActivity.class);
  25 + //初始化DbFlow
  26 + FlowManager.init(this);
  27 + //初始化极光推送
  28 + JPushInterface.setDebugMode(false);
  29 + JPushInterface.init(this);
  30 + //开启打印日志
  31 + KLog.init(false);
  32 + //初始化全局异常崩溃
  33 + initCrash();
  34 + }
  35 +
  36 +
  37 + private void initCrash() {
  38 + CaocConfig.Builder.create()
  39 + .backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) //背景模式,开启沉浸式
  40 + .enabled(true) //是否启动全局异常捕获
  41 + .showErrorDetails(true) //是否显示错误详细信息
  42 + .showRestartButton(true) //是否显示重启按钮
  43 + .trackActivities(true) //是否跟踪Activity
  44 + .minTimeBetweenCrashesMs(2000) //崩溃的间隔时间(毫秒)
  45 + .errorDrawable(R.mipmap.ic_launcher) //错误图标
  46 + .restartActivity(LoginActivity.class) //重新启动后的activity
  47 +// .errorActivity(YourCustomErrorActivity.class) //崩溃后的错误activity
  48 +// .eventListener(new YourCustomEventListener()) //崩溃后的错误监听
  49 + .apply();
  50 + }
  51 +}
  1 +package com.naji.xiaotao.cart.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.text.TextUtils;
  5 +import android.view.View;
  6 +import android.widget.TextView;
  7 +
  8 +import com.naji.xiaotao.R;
  9 +import com.naji.xiaotao.cart.entity.ClearDetail;
  10 +import com.naji.xiaotao.cookbook.adapter.RvAdapter;
  11 +import com.naji.xiaotao.cookbook.listener.RvListener;
  12 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  13 +
  14 +import java.util.List;
  15 +
  16 +public class ClearAdapter extends RvAdapter<ClearDetail>{
  17 +
  18 +
  19 + public ClearAdapter(Context context, List<ClearDetail> list){
  20 + super(context,list,null);
  21 + }
  22 +
  23 + @Override
  24 + protected int getLayoutId(int viewType) {
  25 + return R.layout.layout_clear_item;
  26 + }
  27 +
  28 + @Override
  29 + protected RvHolder getHolder(View view, int viewType) {
  30 + return new ClearHolder(view,viewType,null);
  31 + }
  32 +
  33 + public class ClearHolder extends RvHolder<ClearDetail>{
  34 +
  35 + private TextView cookName;
  36 + private TextView cookPractice;
  37 + private TextView cookNum;
  38 + private TextView cookMinNum;
  39 +
  40 + public ClearHolder(View itemView, int type, RvListener rvListener){
  41 + super(itemView,type,rvListener);
  42 + cookName=itemView.findViewById(R.id.cook_name);
  43 + cookPractice=itemView.findViewById(R.id.cook_practice);
  44 + cookNum=itemView.findViewById(R.id.cook_num);
  45 + cookMinNum=itemView.findViewById(R.id.cook_min_num);
  46 + }
  47 +
  48 + @Override
  49 + public void bindHolder(ClearDetail clearDetail, int position) {
  50 + cookName.setText(clearDetail.getName());
  51 + if(TextUtils.isEmpty(clearDetail.getPractice_name())){
  52 + cookPractice.setVisibility(View.INVISIBLE);
  53 + }else{
  54 + cookPractice.setText(clearDetail.getPractice_name());
  55 + cookPractice.setVisibility(View.VISIBLE);
  56 + }
  57 + cookNum.setText(clearDetail.getCount()+"份");
  58 + if(Integer.parseInt(clearDetail.getMin_num())==0){
  59 + cookMinNum.setText("卖光了");
  60 + cookMinNum.setTextColor(mContext.getResources().getColor(R.color.text4));
  61 + }else{
  62 + cookMinNum.setText("本次下单"+clearDetail.getMin_num()+"份");
  63 + cookMinNum.setTextColor(mContext.getResources().getColor(R.color.text5));
  64 + }
  65 + }
  66 + }
  67 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.util.List;
  7 +
  8 +public class CartCookbook implements Parcelable {
  9 +
  10 + private String class_name;
  11 + private List<CartCookbookDetail> list;
  12 + private int total;
  13 +
  14 + public String getClass_name() {
  15 + return class_name;
  16 + }
  17 +
  18 + public void setClass_name(String class_name) {
  19 + this.class_name = class_name;
  20 + }
  21 +
  22 + public List<CartCookbookDetail> getList() {
  23 + return list;
  24 + }
  25 +
  26 + public void setList(List<CartCookbookDetail> list) {
  27 + this.list = list;
  28 + }
  29 +
  30 + public int getTotal() {
  31 + return total;
  32 + }
  33 +
  34 + public void setTotal(int total) {
  35 + this.total = total;
  36 + }
  37 +
  38 + @Override
  39 + public int describeContents() {
  40 + return 0;
  41 + }
  42 +
  43 + @Override
  44 + public void writeToParcel(Parcel dest, int flags) {
  45 + dest.writeString(this.class_name);
  46 + dest.writeTypedList(this.list);
  47 + dest.writeInt(this.total);
  48 + }
  49 +
  50 + public CartCookbook() {
  51 + }
  52 +
  53 + protected CartCookbook(Parcel in) {
  54 + this.class_name = in.readString();
  55 + this.list = in.createTypedArrayList(CartCookbookDetail.CREATOR);
  56 + this.total = in.readInt();
  57 + }
  58 +
  59 + public static final Creator<CartCookbook> CREATOR = new Creator<CartCookbook>() {
  60 + @Override
  61 + public CartCookbook createFromParcel(Parcel source) {
  62 + return new CartCookbook(source);
  63 + }
  64 +
  65 + @Override
  66 + public CartCookbook[] newArray(int size) {
  67 + return new CartCookbook[size];
  68 + }
  69 + };
  70 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +public class CartCookbookDetail implements Parcelable {
  7 +
  8 + private String count;//数量
  9 + private String cookbookid;
  10 + private String price;
  11 + private String member_price;
  12 + private String specid;
  13 + private String fromSource;
  14 + private String openid;
  15 + private String id;
  16 + private String practiceid;
  17 + private String identity;
  18 + private String image;
  19 + private String unit;
  20 + private String name;
  21 + private String class_name;
  22 + private String classid;
  23 + private String spec_price;
  24 + private String spec_member_price;
  25 + private String practice_name;
  26 + private String headerimg;
  27 + private String sellerid;
  28 + private String pnum;
  29 + private String cdate;
  30 + private String meal_fee;
  31 + private String specs;
  32 +
  33 + private String titleName;
  34 + private boolean isTitle;//title标志位
  35 + private String tag;
  36 + private int size;//标题栏下面的item数量
  37 +
  38 + private String retire_reason;//退菜原因
  39 + private String open_name;//操作员
  40 +
  41 + public String getCount() {
  42 + return count;
  43 + }
  44 +
  45 + public void setCount(String count) {
  46 + this.count = count;
  47 + }
  48 +
  49 + public String getCookbookid() {
  50 + return cookbookid;
  51 + }
  52 +
  53 + public void setCookbookid(String cookbookid) {
  54 + this.cookbookid = cookbookid;
  55 + }
  56 +
  57 + public String getPrice() {
  58 + return price;
  59 + }
  60 +
  61 + public void setPrice(String price) {
  62 + this.price = price;
  63 + }
  64 +
  65 + public String getMember_price() {
  66 + return member_price;
  67 + }
  68 +
  69 + public void setMember_price(String member_price) {
  70 + this.member_price = member_price;
  71 + }
  72 +
  73 + public String getSpecid() {
  74 + return specid;
  75 + }
  76 +
  77 + public void setSpecid(String specid) {
  78 + this.specid = specid;
  79 + }
  80 +
  81 + public String getFromSource() {
  82 + return fromSource;
  83 + }
  84 +
  85 + public void setFromSource(String fromSource) {
  86 + this.fromSource = fromSource;
  87 + }
  88 +
  89 + public String getOpenid() {
  90 + return openid;
  91 + }
  92 +
  93 + public void setOpenid(String openid) {
  94 + this.openid = openid;
  95 + }
  96 +
  97 + public String getId() {
  98 + return id;
  99 + }
  100 +
  101 + public void setId(String id) {
  102 + this.id = id;
  103 + }
  104 +
  105 + public String getPracticeid() {
  106 + return practiceid;
  107 + }
  108 +
  109 + public void setPracticeid(String practiceid) {
  110 + this.practiceid = practiceid;
  111 + }
  112 +
  113 + public String getIdentity() {
  114 + return identity;
  115 + }
  116 +
  117 + public void setIdentity(String identity) {
  118 + this.identity = identity;
  119 + }
  120 +
  121 + public String getImage() {
  122 + return image;
  123 + }
  124 +
  125 + public void setImage(String image) {
  126 + this.image = image;
  127 + }
  128 +
  129 + public String getUnit() {
  130 + return unit;
  131 + }
  132 +
  133 + public void setUnit(String unit) {
  134 + this.unit = unit;
  135 + }
  136 +
  137 + public String getName() {
  138 + return name;
  139 + }
  140 +
  141 + public void setName(String name) {
  142 + this.name = name;
  143 + }
  144 +
  145 + public String getClass_name() {
  146 + return class_name;
  147 + }
  148 +
  149 + public void setClass_name(String class_name) {
  150 + this.class_name = class_name;
  151 + }
  152 +
  153 + public String getClassid() {
  154 + return classid;
  155 + }
  156 +
  157 + public void setClassid(String classid) {
  158 + this.classid = classid;
  159 + }
  160 +
  161 + public String getSpec_price() {
  162 + return spec_price;
  163 + }
  164 +
  165 + public void setSpec_price(String spec_price) {
  166 + this.spec_price = spec_price;
  167 + }
  168 +
  169 + public String getSpec_member_price() {
  170 + return spec_member_price;
  171 + }
  172 +
  173 + public void setSpec_member_price(String spec_member_price) {
  174 + this.spec_member_price = spec_member_price;
  175 + }
  176 +
  177 + public String getPractice_name() {
  178 + return practice_name;
  179 + }
  180 +
  181 + public void setPractice_name(String practice_name) {
  182 + this.practice_name = practice_name;
  183 + }
  184 +
  185 + public String getHeaderimg() {
  186 + return headerimg;
  187 + }
  188 +
  189 + public void setHeaderimg(String headerimg) {
  190 + this.headerimg = headerimg;
  191 + }
  192 +
  193 + public String getSellerid() {
  194 + return sellerid;
  195 + }
  196 +
  197 + public void setSellerid(String sellerid) {
  198 + this.sellerid = sellerid;
  199 + }
  200 +
  201 + public String getPnum() {
  202 + return pnum;
  203 + }
  204 +
  205 + public void setPnum(String pnum) {
  206 + this.pnum = pnum;
  207 + }
  208 +
  209 + public String getCdate() {
  210 + return cdate;
  211 + }
  212 +
  213 + public void setCdate(String cdate) {
  214 + this.cdate = cdate;
  215 + }
  216 +
  217 + public String getMeal_fee() {
  218 + return meal_fee;
  219 + }
  220 +
  221 + public void setMeal_fee(String meal_fee) {
  222 + this.meal_fee = meal_fee;
  223 + }
  224 +
  225 + public String getSpecs() {
  226 + return specs;
  227 + }
  228 +
  229 + public void setSpecs(String specs) {
  230 + this.specs = specs;
  231 + }
  232 +
  233 + public String getTitleName() {
  234 + return titleName;
  235 + }
  236 +
  237 + public void setTitleName(String titleName) {
  238 + this.titleName = titleName;
  239 + }
  240 +
  241 + public boolean isTitle() {
  242 + return isTitle;
  243 + }
  244 +
  245 + public void setTitle(boolean title) {
  246 + isTitle = title;
  247 + }
  248 +
  249 + public String getTag() {
  250 + return tag;
  251 + }
  252 +
  253 + public void setTag(String tag) {
  254 + this.tag = tag;
  255 + }
  256 +
  257 + public int getSize() {
  258 + return size;
  259 + }
  260 +
  261 + public void setSize(int size) {
  262 + this.size = size;
  263 + }
  264 +
  265 + public String getRetire_reason() {
  266 + return retire_reason;
  267 + }
  268 +
  269 + public void setRetire_reason(String retire_reason) {
  270 + this.retire_reason = retire_reason;
  271 + }
  272 +
  273 + public String getOpen_name() {
  274 + return open_name;
  275 + }
  276 +
  277 + public void setOpen_name(String open_name) {
  278 + this.open_name = open_name;
  279 + }
  280 +
  281 + @Override
  282 + public int describeContents() {
  283 + return 0;
  284 + }
  285 +
  286 + @Override
  287 + public void writeToParcel(Parcel dest, int flags) {
  288 + dest.writeString(this.count);
  289 + dest.writeString(this.cookbookid);
  290 + dest.writeString(this.price);
  291 + dest.writeString(this.member_price);
  292 + dest.writeString(this.specid);
  293 + dest.writeString(this.fromSource);
  294 + dest.writeString(this.openid);
  295 + dest.writeString(this.id);
  296 + dest.writeString(this.practiceid);
  297 + dest.writeString(this.identity);
  298 + dest.writeString(this.image);
  299 + dest.writeString(this.unit);
  300 + dest.writeString(this.name);
  301 + dest.writeString(this.class_name);
  302 + dest.writeString(this.classid);
  303 + dest.writeString(this.spec_price);
  304 + dest.writeString(this.spec_member_price);
  305 + dest.writeString(this.practice_name);
  306 + dest.writeString(this.headerimg);
  307 + dest.writeString(this.sellerid);
  308 + dest.writeString(this.pnum);
  309 + dest.writeString(this.cdate);
  310 + dest.writeString(this.meal_fee);
  311 + dest.writeString(this.specs);
  312 + dest.writeString(this.titleName);
  313 + dest.writeByte(this.isTitle ? (byte) 1 : (byte) 0);
  314 + dest.writeString(this.tag);
  315 + dest.writeInt(this.size);
  316 + dest.writeString(this.retire_reason);
  317 + dest.writeString(this.open_name);
  318 + }
  319 +
  320 + public CartCookbookDetail() {
  321 + }
  322 +
  323 + protected CartCookbookDetail(Parcel in) {
  324 + this.count = in.readString();
  325 + this.cookbookid = in.readString();
  326 + this.price = in.readString();
  327 + this.member_price = in.readString();
  328 + this.specid = in.readString();
  329 + this.fromSource = in.readString();
  330 + this.openid = in.readString();
  331 + this.id = in.readString();
  332 + this.practiceid = in.readString();
  333 + this.identity = in.readString();
  334 + this.image = in.readString();
  335 + this.unit = in.readString();
  336 + this.name = in.readString();
  337 + this.class_name = in.readString();
  338 + this.classid = in.readString();
  339 + this.spec_price = in.readString();
  340 + this.spec_member_price = in.readString();
  341 + this.practice_name = in.readString();
  342 + this.headerimg = in.readString();
  343 + this.sellerid = in.readString();
  344 + this.pnum = in.readString();
  345 + this.cdate = in.readString();
  346 + this.meal_fee = in.readString();
  347 + this.specs = in.readString();
  348 + this.titleName = in.readString();
  349 + this.isTitle = in.readByte() != 0;
  350 + this.tag = in.readString();
  351 + this.size = in.readInt();
  352 + this.retire_reason = in.readString();
  353 + this.open_name = in.readString();
  354 + }
  355 +
  356 + public static final Creator<CartCookbookDetail> CREATOR = new Creator<CartCookbookDetail>() {
  357 + @Override
  358 + public CartCookbookDetail createFromParcel(Parcel source) {
  359 + return new CartCookbookDetail(source);
  360 + }
  361 +
  362 + @Override
  363 + public CartCookbookDetail[] newArray(int size) {
  364 + return new CartCookbookDetail[size];
  365 + }
  366 + };
  367 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +public class CartEntity implements Parcelable {
  10 +
  11 + private List<OrderEntity> order;
  12 + private List<CartCookbook> cookbooklist;
  13 + private int countTotal;
  14 + private float countPirce;
  15 + private float countMemberPirce;
  16 +
  17 + public List<OrderEntity> getOrder() {
  18 + return order;
  19 + }
  20 +
  21 + public void setOrder(List<OrderEntity> order) {
  22 + this.order = order;
  23 + }
  24 +
  25 + public List<CartCookbook> getCookbooklist() {
  26 + return cookbooklist;
  27 + }
  28 +
  29 + public void setCookbooklist(List<CartCookbook> cookbooklist) {
  30 + this.cookbooklist = cookbooklist;
  31 + }
  32 +
  33 + public int getCountTotal() {
  34 + return countTotal;
  35 + }
  36 +
  37 + public void setCountTotal(int countTotal) {
  38 + this.countTotal = countTotal;
  39 + }
  40 +
  41 + public float getCountPirce() {
  42 + return countPirce;
  43 + }
  44 +
  45 + public void setCountPirce(float countPirce) {
  46 + this.countPirce = countPirce;
  47 + }
  48 +
  49 + public float getCountMemberPirce() {
  50 + return countMemberPirce;
  51 + }
  52 +
  53 + public void setCountMemberPirce(float countMemberPirce) {
  54 + this.countMemberPirce = countMemberPirce;
  55 + }
  56 +
  57 + @Override
  58 + public int describeContents() {
  59 + return 0;
  60 + }
  61 +
  62 + @Override
  63 + public void writeToParcel(Parcel dest, int flags) {
  64 + dest.writeTypedList(this.order);
  65 + dest.writeTypedList(this.cookbooklist);
  66 + dest.writeInt(this.countTotal);
  67 + dest.writeFloat(this.countPirce);
  68 + dest.writeFloat(this.countMemberPirce);
  69 + }
  70 +
  71 + public CartEntity() {
  72 + }
  73 +
  74 + protected CartEntity(Parcel in) {
  75 + this.order = in.createTypedArrayList(OrderEntity.CREATOR);
  76 + this.cookbooklist = in.createTypedArrayList(CartCookbook.CREATOR);
  77 + this.countTotal = in.readInt();
  78 + this.countPirce = in.readFloat();
  79 + this.countMemberPirce = in.readFloat();
  80 + }
  81 +
  82 + public static final Parcelable.Creator<CartEntity> CREATOR = new Parcelable.Creator<CartEntity>() {
  83 + @Override
  84 + public CartEntity createFromParcel(Parcel source) {
  85 + return new CartEntity(source);
  86 + }
  87 +
  88 + @Override
  89 + public CartEntity[] newArray(int size) {
  90 + return new CartEntity[size];
  91 + }
  92 + };
  93 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +public class ClearDetail implements Parcelable {
  7 +
  8 + private String count;
  9 + private String cookbookid;
  10 + private String status;
  11 + private String price;
  12 + private String member_price;
  13 + private String specid;
  14 + private String fromSource;
  15 + private String openid;
  16 + private String id;
  17 + private String practiceid;
  18 + private String identity;
  19 + private String image;
  20 + private String unit;
  21 + private String name;
  22 + private String class_name;
  23 + private String classid;
  24 + private String spec_price;
  25 + private String spec_member_price;
  26 + private String practice_name;
  27 + private String headerimg;
  28 + private String sellerid;
  29 + private String pnum;
  30 + private String cdate;
  31 + private String meal_fee;
  32 + private String min_num;
  33 +
  34 + public String getCount() {
  35 + return count;
  36 + }
  37 +
  38 + public void setCount(String count) {
  39 + this.count = count;
  40 + }
  41 +
  42 + public String getCookbookid() {
  43 + return cookbookid;
  44 + }
  45 +
  46 + public void setCookbookid(String cookbookid) {
  47 + this.cookbookid = cookbookid;
  48 + }
  49 +
  50 + public String getStatus() {
  51 + return status;
  52 + }
  53 +
  54 + public void setStatus(String status) {
  55 + this.status = status;
  56 + }
  57 +
  58 + public String getPrice() {
  59 + return price;
  60 + }
  61 +
  62 + public void setPrice(String price) {
  63 + this.price = price;
  64 + }
  65 +
  66 + public String getMember_price() {
  67 + return member_price;
  68 + }
  69 +
  70 + public void setMember_price(String member_price) {
  71 + this.member_price = member_price;
  72 + }
  73 +
  74 + public String getSpecid() {
  75 + return specid;
  76 + }
  77 +
  78 + public void setSpecid(String specid) {
  79 + this.specid = specid;
  80 + }
  81 +
  82 + public String getFromSource() {
  83 + return fromSource;
  84 + }
  85 +
  86 + public void setFromSource(String fromSource) {
  87 + this.fromSource = fromSource;
  88 + }
  89 +
  90 + public String getOpenid() {
  91 + return openid;
  92 + }
  93 +
  94 + public void setOpenid(String openid) {
  95 + this.openid = openid;
  96 + }
  97 +
  98 + public String getId() {
  99 + return id;
  100 + }
  101 +
  102 + public void setId(String id) {
  103 + this.id = id;
  104 + }
  105 +
  106 + public String getPracticeid() {
  107 + return practiceid;
  108 + }
  109 +
  110 + public void setPracticeid(String practiceid) {
  111 + this.practiceid = practiceid;
  112 + }
  113 +
  114 + public String getIdentity() {
  115 + return identity;
  116 + }
  117 +
  118 + public void setIdentity(String identity) {
  119 + this.identity = identity;
  120 + }
  121 +
  122 + public String getImage() {
  123 + return image;
  124 + }
  125 +
  126 + public void setImage(String image) {
  127 + this.image = image;
  128 + }
  129 +
  130 + public String getUnit() {
  131 + return unit;
  132 + }
  133 +
  134 + public void setUnit(String unit) {
  135 + this.unit = unit;
  136 + }
  137 +
  138 + public String getName() {
  139 + return name;
  140 + }
  141 +
  142 + public void setName(String name) {
  143 + this.name = name;
  144 + }
  145 +
  146 + public String getClass_name() {
  147 + return class_name;
  148 + }
  149 +
  150 + public void setClass_name(String class_name) {
  151 + this.class_name = class_name;
  152 + }
  153 +
  154 + public String getClassid() {
  155 + return classid;
  156 + }
  157 +
  158 + public void setClassid(String classid) {
  159 + this.classid = classid;
  160 + }
  161 +
  162 + public String getSpec_price() {
  163 + return spec_price;
  164 + }
  165 +
  166 + public void setSpec_price(String spec_price) {
  167 + this.spec_price = spec_price;
  168 + }
  169 +
  170 + public String getSpec_member_price() {
  171 + return spec_member_price;
  172 + }
  173 +
  174 + public void setSpec_member_price(String spec_member_price) {
  175 + this.spec_member_price = spec_member_price;
  176 + }
  177 +
  178 + public String getPractice_name() {
  179 + return practice_name;
  180 + }
  181 +
  182 + public void setPractice_name(String practice_name) {
  183 + this.practice_name = practice_name;
  184 + }
  185 +
  186 + public String getHeaderimg() {
  187 + return headerimg;
  188 + }
  189 +
  190 + public void setHeaderimg(String headerimg) {
  191 + this.headerimg = headerimg;
  192 + }
  193 +
  194 + public String getSellerid() {
  195 + return sellerid;
  196 + }
  197 +
  198 + public void setSellerid(String sellerid) {
  199 + this.sellerid = sellerid;
  200 + }
  201 +
  202 + public String getPnum() {
  203 + return pnum;
  204 + }
  205 +
  206 + public void setPnum(String pnum) {
  207 + this.pnum = pnum;
  208 + }
  209 +
  210 + public String getCdate() {
  211 + return cdate;
  212 + }
  213 +
  214 + public void setCdate(String cdate) {
  215 + this.cdate = cdate;
  216 + }
  217 +
  218 + public String getMeal_fee() {
  219 + return meal_fee;
  220 + }
  221 +
  222 + public void setMeal_fee(String meal_fee) {
  223 + this.meal_fee = meal_fee;
  224 + }
  225 +
  226 + public String getMin_num() {
  227 + return min_num;
  228 + }
  229 +
  230 + public void setMin_num(String min_num) {
  231 + this.min_num = min_num;
  232 + }
  233 +
  234 + @Override
  235 + public int describeContents() {
  236 + return 0;
  237 + }
  238 +
  239 + @Override
  240 + public void writeToParcel(Parcel dest, int flags) {
  241 + dest.writeString(this.count);
  242 + dest.writeString(this.cookbookid);
  243 + dest.writeString(this.status);
  244 + dest.writeString(this.price);
  245 + dest.writeString(this.member_price);
  246 + dest.writeString(this.specid);
  247 + dest.writeString(this.fromSource);
  248 + dest.writeString(this.openid);
  249 + dest.writeString(this.id);
  250 + dest.writeString(this.practiceid);
  251 + dest.writeString(this.identity);
  252 + dest.writeString(this.image);
  253 + dest.writeString(this.unit);
  254 + dest.writeString(this.name);
  255 + dest.writeString(this.class_name);
  256 + dest.writeString(this.classid);
  257 + dest.writeString(this.spec_price);
  258 + dest.writeString(this.spec_member_price);
  259 + dest.writeString(this.practice_name);
  260 + dest.writeString(this.headerimg);
  261 + dest.writeString(this.sellerid);
  262 + dest.writeString(this.pnum);
  263 + dest.writeString(this.cdate);
  264 + dest.writeString(this.meal_fee);
  265 + dest.writeString(this.min_num);
  266 + }
  267 +
  268 + public ClearDetail() {
  269 + }
  270 +
  271 + protected ClearDetail(Parcel in) {
  272 + this.count = in.readString();
  273 + this.cookbookid = in.readString();
  274 + this.status = in.readString();
  275 + this.price = in.readString();
  276 + this.member_price = in.readString();
  277 + this.specid = in.readString();
  278 + this.fromSource = in.readString();
  279 + this.openid = in.readString();
  280 + this.id = in.readString();
  281 + this.practiceid = in.readString();
  282 + this.identity = in.readString();
  283 + this.image = in.readString();
  284 + this.unit = in.readString();
  285 + this.name = in.readString();
  286 + this.class_name = in.readString();
  287 + this.classid = in.readString();
  288 + this.spec_price = in.readString();
  289 + this.spec_member_price = in.readString();
  290 + this.practice_name = in.readString();
  291 + this.headerimg = in.readString();
  292 + this.sellerid = in.readString();
  293 + this.pnum = in.readString();
  294 + this.cdate = in.readString();
  295 + this.meal_fee = in.readString();
  296 + this.min_num = in.readString();
  297 + }
  298 +
  299 + public static final Parcelable.Creator<ClearDetail> CREATOR = new Parcelable.Creator<ClearDetail>() {
  300 + @Override
  301 + public ClearDetail createFromParcel(Parcel source) {
  302 + return new ClearDetail(source);
  303 + }
  304 +
  305 + @Override
  306 + public ClearDetail[] newArray(int size) {
  307 + return new ClearDetail[size];
  308 + }
  309 + };
  310 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +public class ClearOutter implements Parcelable {
  10 +
  11 + private List<ClearDetail> min_num;
  12 + private List<ClearDetail> clear_error;
  13 +
  14 + public List<ClearDetail> getMin_num() {
  15 + return min_num;
  16 + }
  17 +
  18 + public void setMin_num(List<ClearDetail> min_num) {
  19 + this.min_num = min_num;
  20 + }
  21 +
  22 + public List<ClearDetail> getClear_error() {
  23 + return clear_error;
  24 + }
  25 +
  26 + public void setClear_error(List<ClearDetail> clear_error) {
  27 + this.clear_error = clear_error;
  28 + }
  29 +
  30 + @Override
  31 + public int describeContents() {
  32 + return 0;
  33 + }
  34 +
  35 + @Override
  36 + public void writeToParcel(Parcel dest, int flags) {
  37 + dest.writeList(this.min_num);
  38 + dest.writeList(this.clear_error);
  39 + }
  40 +
  41 + public ClearOutter() {
  42 + }
  43 +
  44 + protected ClearOutter(Parcel in) {
  45 + this.min_num = new ArrayList<ClearDetail>();
  46 + in.readList(this.min_num, ClearDetail.class.getClassLoader());
  47 + this.clear_error = new ArrayList<ClearDetail>();
  48 + in.readList(this.clear_error, ClearDetail.class.getClassLoader());
  49 + }
  50 +
  51 + public static final Parcelable.Creator<ClearOutter> CREATOR = new Parcelable.Creator<ClearOutter>() {
  52 + @Override
  53 + public ClearOutter createFromParcel(Parcel source) {
  54 + return new ClearOutter(source);
  55 + }
  56 +
  57 + @Override
  58 + public ClearOutter[] newArray(int size) {
  59 + return new ClearOutter[size];
  60 + }
  61 + };
  62 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.util.List;
  7 +
  8 +public class OrderEntity implements Parcelable {
  9 +
  10 + private String id;
  11 + private String no;
  12 + private String row_num;
  13 + private String pnum;
  14 + private String sellerid;
  15 + private String tableid;
  16 + private String openid;
  17 + private String price;
  18 + private String status;
  19 + private String remark;
  20 + private String remarkid;
  21 + private String type;
  22 + private String phone;
  23 + private String behavior;
  24 + private String cdate;
  25 + private String meal_fee;
  26 + private String is_clear_table;
  27 + private String tablename;
  28 + private String table_pnum;
  29 + private String qrcode;
  30 + private String sellername;
  31 + private List<RemarkItemEntity> remarkList;
  32 +
  33 + public String getId() {
  34 + return id;
  35 + }
  36 +
  37 + public void setId(String id) {
  38 + this.id = id;
  39 + }
  40 +
  41 + public String getNo() {
  42 + return no;
  43 + }
  44 +
  45 + public void setNo(String no) {
  46 + this.no = no;
  47 + }
  48 +
  49 + public String getRow_num() {
  50 + return row_num;
  51 + }
  52 +
  53 + public void setRow_num(String row_num) {
  54 + this.row_num = row_num;
  55 + }
  56 +
  57 + public String getPnum() {
  58 + return pnum;
  59 + }
  60 +
  61 + public void setPnum(String pnum) {
  62 + this.pnum = pnum;
  63 + }
  64 +
  65 + public String getSellerid() {
  66 + return sellerid;
  67 + }
  68 +
  69 + public void setSellerid(String sellerid) {
  70 + this.sellerid = sellerid;
  71 + }
  72 +
  73 + public String getTableid() {
  74 + return tableid;
  75 + }
  76 +
  77 + public void setTableid(String tableid) {
  78 + this.tableid = tableid;
  79 + }
  80 +
  81 + public String getOpenid() {
  82 + return openid;
  83 + }
  84 +
  85 + public void setOpenid(String openid) {
  86 + this.openid = openid;
  87 + }
  88 +
  89 + public String getPrice() {
  90 + return price;
  91 + }
  92 +
  93 + public void setPrice(String price) {
  94 + this.price = price;
  95 + }
  96 +
  97 + public String getStatus() {
  98 + return status;
  99 + }
  100 +
  101 + public void setStatus(String status) {
  102 + this.status = status;
  103 + }
  104 +
  105 + public String getRemark() {
  106 + return remark;
  107 + }
  108 +
  109 + public void setRemark(String remark) {
  110 + this.remark = remark;
  111 + }
  112 +
  113 + public String getRemarkid() {
  114 + return remarkid;
  115 + }
  116 +
  117 + public void setRemarkid(String remarkid) {
  118 + this.remarkid = remarkid;
  119 + }
  120 +
  121 + public String getType() {
  122 + return type;
  123 + }
  124 +
  125 + public void setType(String type) {
  126 + this.type = type;
  127 + }
  128 +
  129 + public String getPhone() {
  130 + return phone;
  131 + }
  132 +
  133 + public void setPhone(String phone) {
  134 + this.phone = phone;
  135 + }
  136 +
  137 + public String getBehavior() {
  138 + return behavior;
  139 + }
  140 +
  141 + public void setBehavior(String behavior) {
  142 + this.behavior = behavior;
  143 + }
  144 +
  145 + public String getCdate() {
  146 + return cdate;
  147 + }
  148 +
  149 + public void setCdate(String cdate) {
  150 + this.cdate = cdate;
  151 + }
  152 +
  153 + public String getMeal_fee() {
  154 + return meal_fee;
  155 + }
  156 +
  157 + public void setMeal_fee(String meal_fee) {
  158 + this.meal_fee = meal_fee;
  159 + }
  160 +
  161 + public String getIs_clear_table() {
  162 + return is_clear_table;
  163 + }
  164 +
  165 + public void setIs_clear_table(String is_clear_table) {
  166 + this.is_clear_table = is_clear_table;
  167 + }
  168 +
  169 + public String getTablename() {
  170 + return tablename;
  171 + }
  172 +
  173 + public void setTablename(String tablename) {
  174 + this.tablename = tablename;
  175 + }
  176 +
  177 + public String getTable_pnum() {
  178 + return table_pnum;
  179 + }
  180 +
  181 + public void setTable_pnum(String table_pnum) {
  182 + this.table_pnum = table_pnum;
  183 + }
  184 +
  185 + public String getQrcode() {
  186 + return qrcode;
  187 + }
  188 +
  189 + public void setQrcode(String qrcode) {
  190 + this.qrcode = qrcode;
  191 + }
  192 +
  193 + public String getSellername() {
  194 + return sellername;
  195 + }
  196 +
  197 + public void setSellername(String sellername) {
  198 + this.sellername = sellername;
  199 + }
  200 +
  201 + public List<RemarkItemEntity> getRemarkList() {
  202 + return remarkList;
  203 + }
  204 +
  205 + public void setRemarkList(List<RemarkItemEntity> remarkList) {
  206 + this.remarkList = remarkList;
  207 + }
  208 +
  209 + @Override
  210 + public int describeContents() {
  211 + return 0;
  212 + }
  213 +
  214 + @Override
  215 + public void writeToParcel(Parcel dest, int flags) {
  216 + dest.writeString(this.id);
  217 + dest.writeString(this.no);
  218 + dest.writeString(this.row_num);
  219 + dest.writeString(this.pnum);
  220 + dest.writeString(this.sellerid);
  221 + dest.writeString(this.tableid);
  222 + dest.writeString(this.openid);
  223 + dest.writeString(this.price);
  224 + dest.writeString(this.status);
  225 + dest.writeString(this.remark);
  226 + dest.writeString(this.remarkid);
  227 + dest.writeString(this.type);
  228 + dest.writeString(this.phone);
  229 + dest.writeString(this.behavior);
  230 + dest.writeString(this.cdate);
  231 + dest.writeString(this.meal_fee);
  232 + dest.writeString(this.is_clear_table);
  233 + dest.writeString(this.tablename);
  234 + dest.writeString(this.table_pnum);
  235 + dest.writeString(this.qrcode);
  236 + dest.writeString(this.sellername);
  237 + dest.writeTypedList(this.remarkList);
  238 + }
  239 +
  240 + public OrderEntity() {
  241 + }
  242 +
  243 + protected OrderEntity(Parcel in) {
  244 + this.id = in.readString();
  245 + this.no = in.readString();
  246 + this.row_num = in.readString();
  247 + this.pnum = in.readString();
  248 + this.sellerid = in.readString();
  249 + this.tableid = in.readString();
  250 + this.openid = in.readString();
  251 + this.price = in.readString();
  252 + this.status = in.readString();
  253 + this.remark = in.readString();
  254 + this.remarkid = in.readString();
  255 + this.type = in.readString();
  256 + this.phone = in.readString();
  257 + this.behavior = in.readString();
  258 + this.cdate = in.readString();
  259 + this.meal_fee = in.readString();
  260 + this.is_clear_table = in.readString();
  261 + this.tablename = in.readString();
  262 + this.table_pnum = in.readString();
  263 + this.qrcode = in.readString();
  264 + this.sellername = in.readString();
  265 + this.remarkList = in.createTypedArrayList(RemarkItemEntity.CREATOR);
  266 + }
  267 +
  268 + public static final Creator<OrderEntity> CREATOR = new Creator<OrderEntity>() {
  269 + @Override
  270 + public OrderEntity createFromParcel(Parcel source) {
  271 + return new OrderEntity(source);
  272 + }
  273 +
  274 + @Override
  275 + public OrderEntity[] newArray(int size) {
  276 + return new OrderEntity[size];
  277 + }
  278 + };
  279 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.util.List;
  7 +
  8 +public class RemarkEntity implements Parcelable {
  9 +
  10 + private List<RemarkItemEntity> list;
  11 +
  12 + public List<RemarkItemEntity> getList() {
  13 + return list;
  14 + }
  15 +
  16 + public void setList(List<RemarkItemEntity> list) {
  17 + this.list = list;
  18 + }
  19 +
  20 + @Override
  21 + public int describeContents() {
  22 + return 0;
  23 + }
  24 +
  25 + @Override
  26 + public void writeToParcel(Parcel dest, int flags) {
  27 + dest.writeTypedList(this.list);
  28 + }
  29 +
  30 + public RemarkEntity() {
  31 + }
  32 +
  33 + protected RemarkEntity(Parcel in) {
  34 + this.list = in.createTypedArrayList(RemarkItemEntity.CREATOR);
  35 + }
  36 +
  37 + public static final Parcelable.Creator<RemarkEntity> CREATOR = new Parcelable.Creator<RemarkEntity>() {
  38 + @Override
  39 + public RemarkEntity createFromParcel(Parcel source) {
  40 + return new RemarkEntity(source);
  41 + }
  42 +
  43 + @Override
  44 + public RemarkEntity[] newArray(int size) {
  45 + return new RemarkEntity[size];
  46 + }
  47 + };
  48 +}
  1 +package com.naji.xiaotao.cart.entity;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +public class RemarkItemEntity implements Parcelable {
  7 +
  8 + private String id;
  9 + private String sellerid;
  10 + private String remark;
  11 + private String cdate;
  12 + private String desc;
  13 + private String line;
  14 +
  15 + private boolean selected;
  16 +
  17 + public String getId() {
  18 + return id;
  19 + }
  20 +
  21 + public void setId(String id) {
  22 + this.id = id;
  23 + }
  24 +
  25 + public String getSellerid() {
  26 + return sellerid;
  27 + }
  28 +
  29 + public void setSellerid(String sellerid) {
  30 + this.sellerid = sellerid;
  31 + }
  32 +
  33 + public String getRemark() {
  34 + return remark;
  35 + }
  36 +
  37 + public void setRemark(String remark) {
  38 + this.remark = remark;
  39 + }
  40 +
  41 + public String getCdate() {
  42 + return cdate;
  43 + }
  44 +
  45 + public void setCdate(String cdate) {
  46 + this.cdate = cdate;
  47 + }
  48 +
  49 + public String getDesc() {
  50 + return desc;
  51 + }
  52 +
  53 + public void setDesc(String desc) {
  54 + this.desc = desc;
  55 + }
  56 +
  57 + public String getLine() {
  58 + return line;
  59 + }
  60 +
  61 + public void setLine(String line) {
  62 + this.line = line;
  63 + }
  64 +
  65 + public boolean isSelected() {
  66 + return selected;
  67 + }
  68 +
  69 + public void setSelected(boolean selected) {
  70 + this.selected = selected;
  71 + }
  72 +
  73 + @Override
  74 + public int describeContents() {
  75 + return 0;
  76 + }
  77 +
  78 + @Override
  79 + public void writeToParcel(Parcel dest, int flags) {
  80 + dest.writeString(this.id);
  81 + dest.writeString(this.sellerid);
  82 + dest.writeString(this.remark);
  83 + dest.writeString(this.cdate);
  84 + dest.writeString(this.desc);
  85 + dest.writeString(this.line);
  86 + dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
  87 + }
  88 +
  89 + public RemarkItemEntity() {
  90 + }
  91 +
  92 + protected RemarkItemEntity(Parcel in) {
  93 + this.id = in.readString();
  94 + this.sellerid = in.readString();
  95 + this.remark = in.readString();
  96 + this.cdate = in.readString();
  97 + this.desc = in.readString();
  98 + this.line = in.readString();
  99 + this.selected = in.readByte() != 0;
  100 + }
  101 +
  102 + public static final Creator<RemarkItemEntity> CREATOR = new Creator<RemarkItemEntity>() {
  103 + @Override
  104 + public RemarkItemEntity createFromParcel(Parcel source) {
  105 + return new RemarkItemEntity(source);
  106 + }
  107 +
  108 + @Override
  109 + public RemarkItemEntity[] newArray(int size) {
  110 + return new RemarkItemEntity[size];
  111 + }
  112 + };
  113 +}
  1 +package com.naji.xiaotao.cart.service;
  2 +
  3 +import com.naji.xiaotao.cart.entity.CartEntity;
  4 +import com.naji.xiaotao.cart.entity.ClearOutter;
  5 +import com.naji.xiaotao.cart.entity.RemarkEntity;
  6 +import com.naji.xiaotao.cookbook.bean.OuterEntity;
  7 +
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +
  11 +import io.reactivex.Observable;
  12 +import me.goldze.mvvmhabit.http.BaseResponse;
  13 +import retrofit2.http.GET;
  14 +import retrofit2.http.Query;
  15 +import retrofit2.http.QueryMap;
  16 +
  17 +public interface CartApiService {
  18 +
  19 + //获取订单详情
  20 + @GET("?service=Android.Orders.GetOrderById")
  21 + Observable<BaseResponse<List<CartEntity>>> getOrderById(@QueryMap Map<String,String> params);
  22 +
  23 + //获取备注列表
  24 + @GET("?service=Android.Orders.GetRemarkBySellerid")
  25 + Observable<BaseResponse<List<List<RemarkEntity>>>> getRemarkBySellerid(@QueryMap Map<String,String> params);
  26 +
  27 + //修改订单人数备注
  28 + @GET("?service=Android.Orders.SetOrderById")
  29 + Observable<BaseResponse<List<String>>> setOrderById(@QueryMap Map<String,String> params);
  30 +
  31 + //下单时检测菜品是否充足
  32 + @GET("?service=Android.Orders.SetClearNum")
  33 + Observable<BaseResponse<List<ClearOutter>>> setClearNum(@QueryMap Map<String,String> params);
  34 +
  35 + //去除购物车中数量不足或卖光菜品
  36 + @GET("?service=Android.Orders.ClearCookbook")
  37 + Observable<BaseResponse<List<String>>> clearCookbook(@QueryMap Map<String,String> params);
  38 +
  39 + //下单接口
  40 + @GET("?service=Android.Orders.PlaceOrder")
  41 + Observable<BaseResponse<List<String>>> placeOrder(@QueryMap Map<String,String> params);
  42 +}
  1 +package com.naji.xiaotao.cart.ui;
  2 +
  3 +import android.content.Context;
  4 +import android.databinding.ObservableList;
  5 +import android.os.Bundle;
  6 +import android.text.Editable;
  7 +import android.text.TextUtils;
  8 +import android.text.TextWatcher;
  9 +import android.view.View;
  10 +import android.view.inputmethod.InputMethodManager;
  11 +import android.widget.EditText;
  12 +
  13 +import com.naji.xiaotao.BR;
  14 +import com.naji.xiaotao.R;
  15 +import com.naji.xiaotao.cart.vm.CartItemViewModel;
  16 +import com.naji.xiaotao.cart.vm.CartViewModel;
  17 +import com.naji.xiaotao.databinding.ActivityCartBinding;
  18 +
  19 +import me.goldze.mvvmhabit.base.BaseActivity;
  20 +import me.goldze.mvvmhabit.utils.KLog;
  21 +
  22 +public class CartActivity extends BaseActivity<ActivityCartBinding,CartViewModel>implements CartViewModel.OnRequestFocusListener{
  23 +
  24 + private InputMethodManager mInputMethorManager;
  25 +
  26 + @Override
  27 + public int initContentView(Bundle savedInstanceState) {
  28 + mInputMethorManager=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  29 + return R.layout.activity_cart;
  30 + }
  31 +
  32 + @Override
  33 + public int initVariableId() {
  34 + return BR.viewModel;
  35 + }
  36 +
  37 + @Override
  38 + public CartViewModel initViewModel() {
  39 + return new CartViewModel(this,getIntent().getStringExtra("orderid"),this,getIntent().getStringExtra("fromSource"),getIntent().getBooleanExtra("isFast",false),getIntent().getBooleanExtra("isWaitingSure",false));
  40 + }
  41 +
  42 + @Override
  43 + public void initViewObservable() {
  44 + super.initViewObservable();
  45 + binding.remarkEdt.setCursorVisible(false);
  46 + binding.remarkEdt.setFocusableInTouchMode(false);
  47 + binding.remarkEdt.setFocusable(false);
  48 + viewModel.observableList.addOnListChangedCallback(new ObservableList.OnListChangedCallback<ObservableList<CartItemViewModel>>() {
  49 + @Override
  50 + public void onChanged(ObservableList<CartItemViewModel> sender) {
  51 + KLog.d("AAAAAAAAA");
  52 + }
  53 +
  54 + @Override
  55 + public void onItemRangeChanged(ObservableList<CartItemViewModel> sender, int positionStart, int itemCount) {
  56 + KLog.d("BBBBBBBBB");
  57 + }
  58 +
  59 + @Override
  60 + public void onItemRangeInserted(ObservableList<CartItemViewModel> sender, int positionStart, int itemCount) {
  61 + KLog.d("CCCCCCCC");
  62 + if(viewModel.isSetMealFee.equals("1")){
  63 + if(viewModel.observableList.size()>2){
  64 + binding.empty.setVisibility(View.GONE);
  65 + binding.content.setVisibility(View.VISIBLE);
  66 + }
  67 + }else{
  68 + binding.empty.setVisibility(View.GONE);
  69 + binding.content.setVisibility(View.VISIBLE);
  70 + }
  71 + }
  72 +
  73 + @Override
  74 + public void onItemRangeMoved(ObservableList<CartItemViewModel> sender, int fromPosition, int toPosition, int itemCount) {
  75 + KLog.d("DDDDDDDDDDD");
  76 + }
  77 +
  78 + @Override
  79 + public void onItemRangeRemoved(ObservableList<CartItemViewModel> sender, int positionStart, int itemCount) {
  80 + KLog.d("EEEEEEEEEEE");
  81 + if(!TextUtils.isEmpty(viewModel.orderEntity.getMeal_fee())){
  82 + if(viewModel.observableList.size()<=2){
  83 + binding.content.setVisibility(View.GONE);
  84 + binding.empty.setVisibility(View.VISIBLE);
  85 + }
  86 + }else{
  87 + if(viewModel.observableList.size()<=0){
  88 + binding.content.setVisibility(View.GONE);
  89 + binding.empty.setVisibility(View.VISIBLE);
  90 + }
  91 + }
  92 + }
  93 + });
  94 + }
  95 +
  96 + @Override
  97 + public void onPnumRequestFocus() {
  98 + binding.pnumEdt.setFocusable(true);
  99 + binding.pnumEdt.setFocusableInTouchMode(true);
  100 + binding.pnumEdt.requestFocus();
  101 + binding.pnumEdt.findFocus();
  102 + binding.pnumEdt.setSelection(binding.pnumEdt.getText().toString().length());
  103 + mInputMethorManager.showSoftInput(binding.pnumEdt,InputMethodManager.SHOW_FORCED);
  104 + }
  105 +
  106 + @Override
  107 + public void onRemardRequestFocus() {
  108 + binding.remarkEdt.setFocusable(true);
  109 + binding.remarkEdt.setFocusableInTouchMode(true);
  110 + binding.remarkEdt.requestFocus();
  111 + binding.remarkEdt.findFocus();
  112 + binding.remarkEdt.setSelection(binding.remarkEdt.getText().toString().length());
  113 + mInputMethorManager.showSoftInput(binding.remarkEdt,InputMethodManager.SHOW_FORCED);
  114 + }
  115 +}
  1 +package com.naji.xiaotao.cart.ui;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.os.Bundle;
  6 +import android.os.Handler;
  7 +import android.support.annotation.NonNull;
  8 +import android.support.annotation.Nullable;
  9 +import android.support.v4.app.DialogFragment;
  10 +import android.support.v7.app.AppCompatActivity;
  11 +import android.support.v7.widget.LinearLayoutManager;
  12 +import android.support.v7.widget.RecyclerView;
  13 +import android.text.TextUtils;
  14 +import android.util.DisplayMetrics;
  15 +import android.view.LayoutInflater;
  16 +import android.view.View;
  17 +import android.view.ViewGroup;
  18 +import android.view.Window;
  19 +import android.view.WindowManager;
  20 +import android.widget.Toast;
  21 +
  22 +import com.afollestad.materialdialogs.DialogAction;
  23 +import com.afollestad.materialdialogs.MaterialDialog;
  24 +import com.naji.xiaotao.R;
  25 +import com.naji.xiaotao.cart.adapter.ClearAdapter;
  26 +import com.naji.xiaotao.cart.entity.ClearDetail;
  27 +import com.naji.xiaotao.cart.entity.ClearOutter;
  28 +import com.naji.xiaotao.cart.service.CartApiService;
  29 +import com.naji.xiaotao.common.dialog.RightDialog;
  30 +import com.naji.xiaotao.cookbook.bean.OuterEntity;
  31 +import com.naji.xiaotao.http.RetrofitClient;
  32 +import com.naji.xiaotao.order.ui.OrderActivity;
  33 +import com.naji.xiaotao.tangshi.service.TangshiApiService;
  34 +import com.naji.xiaotao.tangshi.ui.TangShiActivity;
  35 +import com.naji.xiaotao.util.DialogUtil;
  36 +
  37 +import java.util.ArrayList;
  38 +import java.util.HashMap;
  39 +import java.util.List;
  40 +import java.util.Map;
  41 +
  42 +import io.reactivex.disposables.Disposable;
  43 +import io.reactivex.functions.Consumer;
  44 +import me.goldze.mvvmhabit.http.BaseResponse;
  45 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  46 +import me.goldze.mvvmhabit.utils.MaterialDialogUtils;
  47 +import me.goldze.mvvmhabit.utils.RxUtils;
  48 +import me.goldze.mvvmhabit.utils.SPUtils;
  49 +import me.goldze.mvvmhabit.utils.ToastUtils;
  50 +
  51 +public class ClearDialogFragment extends DialogFragment{
  52 +
  53 + private RecyclerView mRecyclerview;
  54 + private ClearAdapter mAdapter;
  55 + private ClearOutter clearOutter;
  56 + private String orderid;
  57 + private String sellerid;
  58 + private boolean isFast;//是否快餐
  59 + private List<ClearDetail> mDatas=new ArrayList<>();
  60 +
  61 + private Context context;
  62 +
  63 + @Override
  64 + public void onCreate(@Nullable Bundle savedInstanceState) {
  65 + super.onCreate(savedInstanceState);
  66 + context=getContext();
  67 + clearOutter=getArguments().getParcelable("clearOuter");
  68 + orderid=getArguments().getString("orderid");
  69 + sellerid= SPUtils.getInstance("user_info").getString("sellerid");
  70 + isFast=getArguments().getBoolean("isFast");
  71 + mDatas.addAll(clearOutter.getMin_num());
  72 + for(ClearDetail detail:clearOutter.getClear_error()){
  73 + detail.setMin_num("0");
  74 + mDatas.add(detail);
  75 + }
  76 + }
  77 +
  78 + @Nullable
  79 + @Override
  80 + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  81 + View view=inflater.inflate(R.layout.dialog_clear,container);
  82 + mRecyclerview=view.findViewById(R.id.recyclerview);
  83 + mRecyclerview.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false));
  84 + mAdapter=new ClearAdapter(getContext(),mDatas);
  85 + mRecyclerview.setAdapter(mAdapter);
  86 + view.findViewById(R.id.think_again).setOnClickListener(new View.OnClickListener() {
  87 + @Override
  88 + public void onClick(View view) {
  89 + dismiss();
  90 + }
  91 + });
  92 + view.findViewById(R.id.place_order).setOnClickListener(new View.OnClickListener() {
  93 + @Override
  94 + public void onClick(View view) {
  95 + dismiss();
  96 + DialogUtil.showDialog(context);
  97 + for(int i=0;i<mDatas.size();i++){
  98 + ClearDetail detail=mDatas.get(i);
  99 + String id=detail.getId();
  100 + int num=Integer.parseInt(detail.getCount())-Integer.parseInt(detail.getMin_num());
  101 + String type="";
  102 + if(detail.getMin_num().equals("0")){
  103 + type="clear_error";
  104 + }else{
  105 + type="min_num";
  106 + }
  107 + clearCookbookRequest(detail.getCookbookid(),detail.getSpecid(),id,num+"",i,type);
  108 + }
  109 + }
  110 + });
  111 + return view;
  112 + }
  113 +
  114 + //去除数量不足菜品或卖光菜品
  115 + private void clearCookbookRequest(String cookbookid,String specid,String id, String num, final int i,String type){
  116 + Map<String,String> params=new HashMap<>();
  117 + params.put("orderid",orderid);
  118 + params.put("cookbookid",cookbookid);
  119 + params.put("type",type);//min_num 菜品不足 clear_error卖光了
  120 + params.put("id",id);//清楚主键idmin_
  121 + params.put("num",num);//清楚数量
  122 + if(!TextUtils.isEmpty(specid)){
  123 + params.put("specid",specid);
  124 + }
  125 + RetrofitClient.getInstance().create(CartApiService.class)
  126 + .clearCookbook(params)
  127 + .compose(RxUtils.schedulersTransformer())
  128 + .compose(RxUtils.exceptionTransformer())
  129 + .doOnSubscribe(new Consumer<Disposable>() {
  130 + @Override
  131 + public void accept(Disposable disposable) throws Exception {
  132 +
  133 + }
  134 + })
  135 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  136 + @Override
  137 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  138 + if(listBaseResponse.getRet()==200){
  139 + if(i==mDatas.size()-1){//去除掉最后一件商品后下单
  140 + placeOrderRequest();
  141 + }
  142 + }else{
  143 + DialogUtil.dismissDialog();
  144 + ToastUtils.showShort(listBaseResponse.getMsg());
  145 + }
  146 + }
  147 + }, new Consumer<ResponseThrowable>() {
  148 + @Override
  149 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  150 + DialogUtil.dismissDialog();
  151 + responseThrowable.printStackTrace();
  152 + ToastUtils.showShort(responseThrowable.msg);
  153 + }
  154 + });
  155 + }
  156 +
  157 + //下单接口
  158 + private void placeOrderRequest(){
  159 + Map<String,String> params=new HashMap<>();
  160 + params.put("sellerid",sellerid);
  161 + params.put("orderid",orderid);
  162 + if(TextUtils.isEmpty(getArguments().getString("fromSource"))){
  163 + params.put("type","1");//下单1、加菜2
  164 + }else{
  165 + params.put("type","2");//下单1、加菜2
  166 + }
  167 + params.put("identity","2");//1 顾客 2 服务员
  168 + RetrofitClient.getInstance().create(CartApiService.class)
  169 + .placeOrder(params)
  170 + .compose(RxUtils.schedulersTransformer())
  171 + .compose(RxUtils.exceptionTransformer())
  172 + .doOnSubscribe(new Consumer<Disposable>() {
  173 + @Override
  174 + public void accept(Disposable disposable) throws Exception {
  175 +
  176 + }
  177 + })
  178 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  179 + @Override
  180 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  181 + DialogUtil.dismissDialog();
  182 + if(listBaseResponse.getRet()==200){
  183 + final RightDialog dialog=new RightDialog();
  184 + Bundle bundle=new Bundle();
  185 + bundle.putString("msg","下单成功");
  186 + dialog.setArguments(bundle);
  187 + new Handler().postDelayed(new Runnable() {
  188 + @Override
  189 + public void run() {
  190 + dialog.dismiss();
  191 + if(isFast){//快速点餐直接跳到订单详情
  192 + Intent intent=new Intent(context, OrderActivity.class);
  193 + intent.putExtra("orderid",orderid);
  194 + context.startActivity(intent);
  195 + }else{
  196 + context.startActivity(new Intent(context, TangShiActivity.class));
  197 + }
  198 + }
  199 + }, 1000);
  200 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"rightDialog");
  201 + }else{
  202 + ToastUtils.showShort(listBaseResponse.getMsg());
  203 + }
  204 + }
  205 + }, new Consumer<ResponseThrowable>() {
  206 + @Override
  207 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  208 + DialogUtil.dismissDialog();
  209 + responseThrowable.printStackTrace();
  210 + ToastUtils.showShort(responseThrowable.msg);
  211 + }
  212 + });
  213 + }
  214 +
  215 + @Override
  216 + public void onStart() {
  217 + super.onStart();
  218 + getDialog().setCanceledOnTouchOutside(false);
  219 + Window window=getDialog().getWindow();
  220 + WindowManager.LayoutParams lp=window.getAttributes();
  221 + DisplayMetrics dm=new DisplayMetrics();
  222 + window.getWindowManager().getDefaultDisplay().getMetrics(dm);
  223 + window.setLayout((int) (dm.widthPixels*0.9),ViewGroup.LayoutParams.WRAP_CONTENT);
  224 + }
  225 +
  226 +
  227 +}
  1 +package com.naji.xiaotao.cart.ui;
  2 +
  3 +import android.os.Bundle;
  4 +import com.naji.xiaotao.R;
  5 +import com.naji.xiaotao.BR;
  6 +import com.naji.xiaotao.cart.vm.RemarkViewModel;
  7 +import com.naji.xiaotao.databinding.ActivityRemarkBinding;
  8 +
  9 +import me.goldze.mvvmhabit.base.BaseActivity;
  10 +
  11 +public class RemarkActivity extends BaseActivity<ActivityRemarkBinding,RemarkViewModel>{
  12 +
  13 + @Override
  14 + public int initContentView(Bundle savedInstanceState) {
  15 + return R.layout.activity_remark;
  16 + }
  17 +
  18 + @Override
  19 + public int initVariableId() {
  20 + return BR.viewModel;
  21 + }
  22 +
  23 + @Override
  24 + public RemarkViewModel initViewModel() {
  25 + return new RemarkViewModel(this,getIntent().getExtras().getString("orderid"),getIntent().getExtras().getString("remarkid"),getIntent().getExtras().getString("remark"));
  26 + }
  27 +}
  1 +package com.naji.xiaotao.cart.vm;
  2 +
  3 +import android.content.Context;
  4 +import android.databinding.ObservableField;
  5 +import android.text.TextUtils;
  6 +import android.view.View;
  7 +import android.widget.ImageView;
  8 +import android.widget.TextView;
  9 +
  10 +import com.naji.xiaotao.cart.entity.CartCookbookDetail;
  11 +import com.naji.xiaotao.cookbook.bean.ResultEntity;
  12 +import com.naji.xiaotao.cookbook.service.CookbookApiService;
  13 +import com.naji.xiaotao.http.RetrofitClient;
  14 +
  15 +import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.Map;
  18 +
  19 +import io.reactivex.disposables.Disposable;
  20 +import io.reactivex.functions.Consumer;
  21 +import me.goldze.mvvmhabit.base.BaseViewModel;
  22 +import me.goldze.mvvmhabit.binding.command.BindingAction;
  23 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  24 +import me.goldze.mvvmhabit.bus.Messenger;
  25 +import me.goldze.mvvmhabit.bus.RxBus;
  26 +import me.goldze.mvvmhabit.bus.RxSubscriptions;
  27 +import me.goldze.mvvmhabit.http.BaseResponse;
  28 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  29 +import me.goldze.mvvmhabit.utils.KLog;
  30 +import me.goldze.mvvmhabit.utils.RxUtils;
  31 +import me.goldze.mvvmhabit.utils.ToastUtils;
  32 +
  33 +public class CartItemViewModel extends BaseViewModel{
  34 +
  35 +
  36 + private String orderid;
  37 + private String fromSource;
  38 + public CartCookbookDetail entity;
  39 + public ObservableField<String> title=new ObservableField<>();//标题栏显示
  40 + public ObservableField<String> count=new ObservableField<>();
  41 +
  42 + private Disposable mSubscription;
  43 +
  44 +
  45 + public CartItemViewModel(Context context,CartCookbookDetail entity,String orderid,String fromSource){
  46 + super(context);
  47 + this.entity=entity;
  48 + this.orderid=orderid;
  49 + this.fromSource=fromSource;
  50 + count.set(entity.getCount());
  51 + if(entity.getTitleName().equals("其它")){
  52 + title.set(entity.getClass_name());
  53 + if(entity.getName()!=null&&entity.getName().equals("餐位费")){
  54 + mSubscription=RxBus.getDefault().toObservable(Integer.class).subscribe(new Consumer<Integer>() {
  55 + @Override
  56 + public void accept(Integer integer) throws Exception {
  57 + count.set(integer+"");
  58 + KLog.d("count:"+count.get().toString());
  59 + }
  60 + });
  61 + RxSubscriptions.add(mSubscription);
  62 + }
  63 + }else{
  64 + title.set(entity.getClass_name()+"("+entity.getSize()+")");
  65 + }
  66 + }
  67 +
  68 + @Override
  69 + public void onDestroy() {
  70 + super.onDestroy();
  71 + if(entity.getName().equals("餐位费")){
  72 + RxSubscriptions.remove(mSubscription);
  73 + }
  74 + }
  75 +
  76 + //减菜按钮
  77 + public BindingCommand onReduceClickCommand=new BindingCommand(new BindingAction() {
  78 + @Override
  79 + public void call() {
  80 + KLog.d("------------------");
  81 + reduceCookFromCart();
  82 + }
  83 + });
  84 +
  85 + //加菜按钮
  86 + public BindingCommand onAddClickCommand=new BindingCommand(new BindingAction() {
  87 + @Override
  88 + public void call() {
  89 + KLog.d("+++++++++++++++++");
  90 + addCookToCart();
  91 + }
  92 + });
  93 +
  94 + //添加菜品到购物车
  95 + private void addCookToCart(){
  96 + Map<String,String> params=new HashMap<>();
  97 + params.put("orderid",orderid);
  98 + params.put("openid",entity.getOpenid());
  99 + params.put("cookbookid",entity.getCookbookid());
  100 + params.put("identity","2");
  101 + if(!TextUtils.isEmpty(entity.getSpecid())){
  102 + params.put("specid",entity.getSpecid());
  103 + }
  104 + if(!TextUtils.isEmpty(entity.getPracticeid())){
  105 + params.put("practiceid",entity.getPracticeid());
  106 + }
  107 + if(!TextUtils.isEmpty(fromSource)){
  108 + params.put("fromSoucre",fromSource);
  109 + }
  110 + RetrofitClient.getInstance().create(CookbookApiService.class)
  111 + .addCookToCart(params)
  112 + .compose(RxUtils.schedulersTransformer())
  113 + .compose(RxUtils.exceptionTransformer())
  114 + .doOnSubscribe(new Consumer<Disposable>() {
  115 + @Override
  116 + public void accept(Disposable disposable) throws Exception {
  117 +
  118 + }
  119 + })
  120 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  121 + @Override
  122 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  123 + if(baseResponse.getRet()==200){
  124 + count.set((Integer.parseInt(count.get())+1)+"");
  125 + int countTotal=baseResponse.getData().get(0).getCountTotal();
  126 + float countPrice=baseResponse.getData().get(0).getCountPirce();
  127 + String title="已点"+countTotal+"个菜,共计¥"+countPrice;
  128 + RxBus.getDefault().post(title);
  129 + }else{
  130 + ToastUtils.showShort(baseResponse.getMsg());
  131 + }
  132 + }
  133 + }, new Consumer<ResponseThrowable>() {
  134 + @Override
  135 + public void accept(ResponseThrowable throwable) throws Exception {
  136 + ToastUtils.showShort(throwable.msg);
  137 + throwable.printStackTrace();
  138 + }
  139 + });
  140 + }
  141 + //删减菜品从购物车
  142 + private void reduceCookFromCart(){
  143 + Map<String,String> params=new HashMap<>();
  144 + params.put("orderid",orderid);
  145 + params.put("openid",entity.getOpenid());
  146 + params.put("cookbookid",entity.getCookbookid());
  147 + params.put("identity","2");
  148 + if(!TextUtils.isEmpty(entity.getSpecid())){
  149 + params.put("specid",entity.getSpecid());
  150 + }
  151 + if(!TextUtils.isEmpty(entity.getPracticeid())){
  152 + params.put("practiceid",entity.getPracticeid());
  153 + }
  154 + if(!TextUtils.isEmpty(fromSource)){
  155 + params.put("fromSoucre",fromSource);
  156 + }
  157 + RetrofitClient.getInstance().create(CookbookApiService.class)
  158 + .reduceCookFromCart(params)
  159 + .compose(RxUtils.schedulersTransformer())
  160 + .compose(RxUtils.exceptionTransformer())
  161 + .doOnSubscribe(new Consumer<Disposable>() {
  162 + @Override
  163 + public void accept(Disposable disposable) throws Exception {
  164 +
  165 + }
  166 + })
  167 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  168 + @Override
  169 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  170 + if(baseResponse.getRet()==200){
  171 + count.set((Integer.parseInt(count.get())-1)+"");
  172 + int countTotal=baseResponse.getData().get(0).getCountTotal();
  173 + float countPrice=baseResponse.getData().get(0).getCountPirce();
  174 + String title="已点"+countTotal+"个菜,共计¥"+countPrice;
  175 + RxBus.getDefault().post(title);
  176 + if(Integer.parseInt(count.get())==0){
  177 + Messenger.getDefault().send(CartItemViewModel.this,CartViewModel.TOKEN_DELETE_ITEM);
  178 + }
  179 + }else{
  180 + ToastUtils.showShort(baseResponse.getMsg());
  181 + }
  182 + }
  183 + }, new Consumer<ResponseThrowable>() {
  184 + @Override
  185 + public void accept(ResponseThrowable throwable) throws Exception {
  186 + ToastUtils.showShort(throwable.msg);
  187 + throwable.printStackTrace();
  188 + }
  189 + });
  190 + }
  191 +}
  1 +package com.naji.xiaotao.cart.vm;
  2 +
  3 +import android.content.Context;
  4 +import android.content.Intent;
  5 +import android.databinding.ObservableArrayList;
  6 +import android.databinding.ObservableBoolean;
  7 +import android.databinding.ObservableField;
  8 +import android.databinding.ObservableInt;
  9 +import android.databinding.ObservableList;
  10 +import android.os.Bundle;
  11 +import android.os.Handler;
  12 +import android.support.annotation.NonNull;
  13 +import android.support.v7.app.AppCompatActivity;
  14 +import android.text.TextUtils;
  15 +import android.view.View;
  16 +import android.widget.Toast;
  17 +
  18 +import com.afollestad.materialdialogs.DialogAction;
  19 +import com.afollestad.materialdialogs.MaterialDialog;
  20 +import com.naji.xiaotao.BR;
  21 +import com.naji.xiaotao.R;
  22 +import com.naji.xiaotao.cart.entity.CartCookbook;
  23 +import com.naji.xiaotao.cart.entity.CartCookbookDetail;
  24 +import com.naji.xiaotao.cart.entity.CartEntity;
  25 +import com.naji.xiaotao.cart.entity.ClearOutter;
  26 +import com.naji.xiaotao.cart.entity.OrderEntity;
  27 +import com.naji.xiaotao.cart.entity.RemarkEntity;
  28 +import com.naji.xiaotao.cart.entity.RemarkItemEntity;
  29 +import com.naji.xiaotao.cart.service.CartApiService;
  30 +import com.naji.xiaotao.cart.ui.CartActivity;
  31 +import com.naji.xiaotao.cart.ui.ClearDialogFragment;
  32 +import com.naji.xiaotao.cart.ui.RemarkActivity;
  33 +import com.naji.xiaotao.common.dialog.RightDialog;
  34 +import com.naji.xiaotao.cookbook.bean.OuterEntity;
  35 +import com.naji.xiaotao.cookbook.ui.CookBookMainActivity;
  36 +import com.naji.xiaotao.http.RetrofitClient;
  37 +import com.naji.xiaotao.login.entity.SellerConfig;
  38 +import com.naji.xiaotao.login.service.LoginApiService;
  39 +import com.naji.xiaotao.order.ui.OrderActivity;
  40 +import com.naji.xiaotao.order.vm.OrderItemViewModel;
  41 +import com.naji.xiaotao.tangshi.ui.TangShiActivity;
  42 +
  43 +import java.text.DecimalFormat;
  44 +import java.util.ArrayList;
  45 +import java.util.HashMap;
  46 +import java.util.List;
  47 +import java.util.Map;
  48 +
  49 +import io.reactivex.disposables.Disposable;
  50 +import io.reactivex.functions.Consumer;
  51 +import me.goldze.mvvmhabit.base.BaseViewModel;
  52 +import me.goldze.mvvmhabit.base.TitleViewModel;
  53 +import me.goldze.mvvmhabit.binding.command.BindingAction;
  54 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  55 +import me.goldze.mvvmhabit.binding.command.BindingConsumer;
  56 +import me.goldze.mvvmhabit.bus.Messenger;
  57 +import me.goldze.mvvmhabit.bus.RxBus;
  58 +import me.goldze.mvvmhabit.bus.RxSubscriptions;
  59 +import me.goldze.mvvmhabit.http.BaseResponse;
  60 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  61 +import me.goldze.mvvmhabit.utils.KLog;
  62 +import me.goldze.mvvmhabit.utils.MaterialDialogUtils;
  63 +import me.goldze.mvvmhabit.utils.RxUtils;
  64 +import me.goldze.mvvmhabit.utils.SPUtils;
  65 +import me.goldze.mvvmhabit.utils.ToastUtils;
  66 +import me.tatarka.bindingcollectionadapter2.ItemBinding;
  67 +import me.tatarka.bindingcollectionadapter2.OnItemBind;
  68 +
  69 +public class CartViewModel extends BaseViewModel{
  70 +
  71 + public static final String TOKEN_DELETE_ITEM="token_delete_item";//删减一个菜品item
  72 +
  73 + public ObservableField<String> no=new ObservableField<>();//单号
  74 + public ObservableField<String> pnum=new ObservableField<>();//当前用餐人数
  75 + public ObservableField<String> tableid=new ObservableField<>();//台号
  76 + public ObservableInt tableVisibility=new ObservableInt(View.GONE);//是否显示台号
  77 + public ObservableField<String> remark=new ObservableField<>();//备注
  78 + public ObservableField<String> title=new ObservableField<>();//list标题
  79 +
  80 + private String orderid;//订单id
  81 +
  82 + public OrderEntity orderEntity;
  83 +
  84 + private ArrayList<CartCookbook> cLists=new ArrayList<>();
  85 +
  86 + private OnRequestFocusListener onRequestFocusListener;
  87 +
  88 +
  89 + private Disposable mSubscription;//订阅者
  90 +
  91 + public TitleViewModel titleViewModel;
  92 +
  93 + private float countPrice;//订单金额
  94 + private int countTotal;//订单人数
  95 +
  96 + public String isSetMealFee;//是否设置餐位费
  97 + private String meelFee;//餐位费
  98 +
  99 + private float ortherMoney=0.00f;//餐位费
  100 +
  101 + private String fromSource;//加菜
  102 + private boolean isFast;//是否快餐
  103 + private boolean isWaitingSure;//待确认
  104 +
  105 + public CartViewModel(Context context,String orderid,OnRequestFocusListener onRequestFocusListener,String fromSource,boolean isFast,boolean isWaitingSure){
  106 + super(context);
  107 + this.orderid=orderid;
  108 + this.onRequestFocusListener=onRequestFocusListener;
  109 + this.titleViewModel=new TitleViewModel(context,"购物车");
  110 + this.fromSource=fromSource;
  111 + this.isFast=isFast;
  112 + this.isWaitingSure=isWaitingSure;
  113 + }
  114 +
  115 + public interface OnRequestFocusListener{
  116 + //人数输入框获取焦点
  117 + void onPnumRequestFocus();
  118 + //备注获取焦点
  119 + void onRemardRequestFocus();
  120 + }
  121 +
  122 + @Override
  123 + public void onStart() {
  124 + super.onStart();
  125 + getOrderDetail();
  126 + }
  127 +
  128 + @Override
  129 + public void registerRxBus() {
  130 + super.registerRxBus();
  131 + //监听总的菜品数量和价格变化
  132 + mSubscription=RxBus.getDefault().toObservable(String.class).subscribe(new Consumer<String>() {
  133 + @Override
  134 + public void accept(String s) throws Exception {
  135 + if(s.contains("¥")){
  136 + countPrice=Float.parseFloat(s.substring(s.indexOf("¥")+1));
  137 + String all= new DecimalFormat("##0.00").format(countPrice+ortherMoney);
  138 + title.set(s.substring(0,s.indexOf("¥")+1)+all);
  139 + }
  140 + }
  141 + });
  142 + RxSubscriptions.add(mSubscription);
  143 + //监听删除掉一个菜品Item
  144 + Messenger.getDefault().register(context, TOKEN_DELETE_ITEM, CartItemViewModel.class, new BindingConsumer<CartItemViewModel>() {
  145 + @Override
  146 + public void call(CartItemViewModel cartItemViewModel) {
  147 + observableList.remove(cartItemViewModel);
  148 + int titleIndex=Integer.parseInt(cartItemViewModel.entity.getTag());
  149 + KLog.d("titleIndex",titleIndex);
  150 + KLog.d("size",observableList.size());
  151 + int size=observableList.get(titleIndex).entity.getSize();
  152 + observableList.get(titleIndex).title.set(cartItemViewModel.entity.getClass_name()+"("+(size-1)+")");
  153 + observableList.get(titleIndex).entity.setSize(--size);
  154 + KLog.d("titleIndex:"+titleIndex+"size:"+size);
  155 + if(size==0){//只剩标题,删除标题
  156 + observableList.remove(titleIndex);
  157 + }
  158 + }
  159 + });
  160 + }
  161 +
  162 + @Override
  163 + public void removeRxBus() {
  164 + super.removeRxBus();
  165 + RxSubscriptions.remove(mSubscription);
  166 + Messenger.getDefault().unregister(context,TOKEN_DELETE_ITEM);
  167 + }
  168 +
  169 +
  170 + public ObservableList<CartItemViewModel> observableList=new ObservableArrayList<>();
  171 + public OnItemBind<CartItemViewModel> onItemBind=new OnItemBind<CartItemViewModel>() {
  172 + @Override
  173 + public void onItemBind(ItemBinding itemBinding, int position, CartItemViewModel item) {
  174 + itemBinding.set(BR.viewModel,item.entity.isTitle()? R.layout.cart_item_title:R.layout.cart_item_content);
  175 + }
  176 + };
  177 +
  178 + //修改就餐人数
  179 + public BindingCommand onPnumClick=new BindingCommand(new BindingAction() {
  180 + @Override
  181 + public void call() {
  182 + if(onRequestFocusListener!=null){
  183 + onRequestFocusListener.onPnumRequestFocus();
  184 + }
  185 + }
  186 + });
  187 +
  188 + //修改备注
  189 + public BindingCommand onRemarkClick=new BindingCommand(new BindingAction() {
  190 + @Override
  191 + public void call() {
  192 + Bundle bundle=new Bundle();
  193 + bundle.putString("orderid",orderid);
  194 + bundle.putString("remarkid",orderEntity.getRemarkid());
  195 + bundle.putString("remark",orderEntity.getRemark());
  196 + startActivity(RemarkActivity.class,bundle);
  197 + }
  198 + });
  199 +
  200 + //获取订单详情
  201 + private void getOrderDetail(){
  202 + HashMap<String,String> params=new HashMap<>();
  203 + params.put("orderid",orderid);
  204 + if(isWaitingSure){
  205 + params.put("status","2");//2 待确认菜品
  206 + }else{
  207 + params.put("status","0");//0 购物车中菜品 1 已下单菜品
  208 + }
  209 +
  210 +
  211 + RetrofitClient.getInstance().create(CartApiService.class)
  212 + .getOrderById(params)
  213 + .compose(RxUtils.schedulersTransformer())
  214 + .compose(RxUtils.exceptionTransformer())
  215 + .doOnSubscribe(new Consumer<Disposable>() {
  216 + @Override
  217 + public void accept(Disposable disposable) throws Exception {
  218 + showDialog();
  219 + }
  220 + })
  221 + .subscribe(new Consumer<BaseResponse<List<CartEntity>>>() {
  222 +
  223 + @Override
  224 + public void accept(BaseResponse<List<CartEntity>> listBaseResponse) throws Exception {
  225 + dismissDialog();
  226 + if(listBaseResponse.getRet()==200){
  227 + orderEntity=listBaseResponse.getData().get(0).getOrder().get(0);
  228 + no.set("单号:"+orderEntity.getRow_num());
  229 + pnum.set(orderEntity.getPnum());
  230 + tableid.set("台号:"+orderEntity.getTablename());
  231 + if(orderEntity.getTablename().equals("快餐")){
  232 + tableVisibility.set(View.GONE);
  233 + }else{
  234 + tableVisibility.set(View.VISIBLE);
  235 + }
  236 + StringBuilder builder=new StringBuilder();
  237 + if(orderEntity.getRemarkList()!=null&&orderEntity.getRemarkList().size()>0){
  238 + for(RemarkItemEntity itemEntity:orderEntity.getRemarkList()){
  239 + builder.append(itemEntity.getRemark()+",");
  240 + }
  241 + }
  242 + if(!TextUtils.isEmpty(orderEntity.getRemark())){
  243 + builder.append(orderEntity.getRemark()+",");
  244 + }
  245 + if(builder.length()>0){
  246 + remark.set(builder.toString().substring(0,builder.toString().length()-1));
  247 + }else{
  248 + remark.set("");
  249 + }
  250 + countTotal=listBaseResponse.getData().get(0).getCountTotal();
  251 + countPrice=listBaseResponse.getData().get(0).getCountPirce();
  252 + cLists.clear();
  253 + cLists.addAll(listBaseResponse.getData().get(0).getCookbooklist());
  254 + getSellerConfig();
  255 + }else{
  256 + ToastUtils.showShort(listBaseResponse.getMsg());
  257 + }
  258 + }
  259 + }, new Consumer<ResponseThrowable>() {
  260 + @Override
  261 + public void accept(ResponseThrowable throwable) throws Exception {
  262 + dismissDialog();
  263 + ToastUtils.showShort(throwable.msg);
  264 + throwable.printStackTrace();
  265 + }
  266 + });
  267 + }
  268 +
  269 + //获取商家配置
  270 + private void getSellerConfig(){
  271 + Map<String,String> params=new HashMap<>();
  272 + params.put("sellerid",SPUtils.getInstance("user_info").getString("sellerid"));
  273 + params.put("type","1");//1堂食配置 2外卖配置
  274 + RetrofitClient.getInstance().create(LoginApiService.class)
  275 + .getSellerConfig(params)
  276 + .compose(RxUtils.schedulersTransformer())
  277 + .compose(RxUtils.exceptionTransformer())
  278 + .doOnSubscribe(new Consumer<Disposable>() {
  279 + @Override
  280 + public void accept(Disposable disposable) throws Exception {
  281 +
  282 + }
  283 + })
  284 + .subscribe(new Consumer<BaseResponse<List<SellerConfig>>>() {
  285 + @Override
  286 + public void accept(BaseResponse<List<SellerConfig>> listBaseResponse) throws Exception {
  287 + if(listBaseResponse.getRet()==200){
  288 + KLog.d("sssssssssssss");
  289 + isSetMealFee=listBaseResponse.getData().get(0).getIs_set_meal_fee();
  290 + meelFee=listBaseResponse.getData().get(0).getMeal_fee();
  291 + if(isSetMealFee.equals("1")){
  292 + ortherMoney=Float.parseFloat(meelFee)*Integer.parseInt(orderEntity.getPnum());
  293 + }
  294 + String all= new DecimalFormat("##0.00").format(countPrice+ortherMoney);
  295 + title.set("已点"+countTotal+"个菜,共计¥"+all);
  296 + initCookbookList();
  297 + }
  298 + }
  299 +
  300 + }, new Consumer<ResponseThrowable>() {
  301 + @Override
  302 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  303 +
  304 + }
  305 + });
  306 + }
  307 +
  308 + private void initCookbookList(){
  309 + observableList.clear();
  310 + int tag=0;
  311 + for(int i=0;i<cLists.size();i++){
  312 + CartCookbookDetail head=new CartCookbookDetail();
  313 + head.setTitle(true);
  314 + head.setClass_name(cLists.get(i).getClass_name());
  315 + head.setTitleName(cLists.get(i).getClass_name()+"("+cLists.get(i).getList().size()+")");
  316 + head.setTag(String.valueOf(i));
  317 + head.setSize(cLists.get(i).getList().size());
  318 + observableList.add(new CartItemViewModel(context,head,orderid,fromSource));
  319 + int titleIndex=tag;
  320 + for(int j=0;j<cLists.get(i).getList().size();j++){
  321 + tag++;
  322 + CartCookbookDetail content=cLists.get(i).getList().get(j);
  323 + content.setTitleName(cLists.get(i).getClass_name()+"("+cLists.get(i).getList().size()+")");
  324 + content.setTag(String.valueOf(titleIndex));
  325 + observableList.add(new CartItemViewModel(context,content,orderid,fromSource));
  326 + }
  327 + tag++;
  328 + }
  329 + if(isSetMealFee.equals("1")){
  330 + CartCookbookDetail head=new CartCookbookDetail();
  331 + head.setTitle(true);
  332 + head.setClass_name("其它");
  333 + head.setTitleName("其它");
  334 + observableList.add(new CartItemViewModel(context,head,orderid,fromSource));
  335 + CartCookbookDetail content=new CartCookbookDetail();
  336 + content.setTitleName("其它");
  337 + content.setName("餐位费");
  338 + content.setPrice(meelFee);
  339 + content.setUnit("位");
  340 + content.setCount(orderEntity.getPnum());
  341 + observableList.add(new CartItemViewModel(context,content,orderid,fromSource));
  342 + }
  343 + }
  344 +
  345 + //修改人数
  346 + public BindingCommand textChangeCommand=new BindingCommand(new BindingConsumer<String>() {
  347 + @Override
  348 + public void call(String s) {
  349 + if(!TextUtils.isEmpty(s)){
  350 + int pnum=Integer.parseInt(s);
  351 + if(isSetMealFee!=null&&isSetMealFee.equals("1")){
  352 + ortherMoney=Float.parseFloat(meelFee)* pnum;
  353 + String titleText=title.get().toString();
  354 + KLog.d("titleText:"+titleText);
  355 + String all= new DecimalFormat("##0.00").format(countPrice+ortherMoney);
  356 + title.set(titleText.substring(0,titleText.indexOf("¥")+1)+all);
  357 + KLog.d(countPrice);
  358 + KLog.d(ortherMoney);
  359 + KLog.d("title:"+(titleText.substring(0,titleText.indexOf("¥")+1)));
  360 + RxBus.getDefault().post(pnum);
  361 + }
  362 + setOrderById(pnum);
  363 + }
  364 + }
  365 + });
  366 +
  367 + //继续点菜
  368 + public BindingCommand onContinueClickCommand=new BindingCommand(new BindingAction() {
  369 + @Override
  370 + public void call() {
  371 + Intent intent=new Intent(context,CookBookMainActivity.class);
  372 + intent.putExtra("orderid",orderid);
  373 + intent.putExtra("isFast",isFast);
  374 + intent.putExtra("fromSource",fromSource);
  375 + context.startActivity(intent);
  376 + }
  377 + });
  378 +
  379 + //点击确认下单按钮
  380 + public BindingCommand onSureClickCommand=new BindingCommand(new BindingAction() {
  381 + @Override
  382 + public void call() {
  383 + setClearNum();
  384 + }
  385 + });
  386 +
  387 +
  388 + //修改订单人数备注
  389 + private void setOrderById(int pnum){
  390 + Map<String,String> params=new HashMap<>();
  391 + params.put("orderid",orderid);
  392 + params.put("pnum",pnum+"");
  393 + RetrofitClient.getInstance().create(CartApiService.class)
  394 + .setOrderById(params)
  395 + .compose(RxUtils.schedulersTransformer())
  396 + .compose(RxUtils.exceptionTransformer())
  397 + .doOnSubscribe(new Consumer<Disposable>() {
  398 + @Override
  399 + public void accept(Disposable disposable) throws Exception {
  400 + }
  401 + })
  402 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  403 + @Override
  404 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  405 +
  406 + if(listBaseResponse.getRet()==200){
  407 +
  408 + }else{
  409 + ToastUtils.showShort(listBaseResponse.getMsg());
  410 + }
  411 + }
  412 + }, new Consumer<ResponseThrowable>() {
  413 + @Override
  414 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  415 + responseThrowable.printStackTrace();
  416 + ToastUtils.showShort(responseThrowable.msg);
  417 + }
  418 + });
  419 + }
  420 +
  421 + //下单时检测菜品是否充足
  422 + private void setClearNum(){
  423 + if(TextUtils.isEmpty(pnum.get())){
  424 + ToastUtils.showShort("请输入用餐人数");
  425 + return;
  426 + }
  427 + Map<String,String> params=new HashMap<>();
  428 + params.put("orderid",orderEntity.getId());
  429 + if(TextUtils.isEmpty(fromSource)){
  430 + params.put("type","1");//下单1、加菜2
  431 + }else{
  432 + params.put("type","2");//下单1、加菜2
  433 + }
  434 +
  435 + params.put("identity","2");//1 顾客 2 服务员
  436 + RetrofitClient.getInstance().create(CartApiService.class)
  437 + .setClearNum(params)
  438 + .compose(RxUtils.schedulersTransformer())
  439 + .compose(RxUtils.exceptionTransformer())
  440 + .doOnSubscribe(new Consumer<Disposable>() {
  441 + @Override
  442 + public void accept(Disposable disposable) throws Exception {
  443 + showDialog();
  444 + }
  445 + })
  446 + .subscribe(new Consumer<BaseResponse<List<ClearOutter>>>() {
  447 + @Override
  448 + public void accept(BaseResponse<List<ClearOutter>> listBaseResponse) throws Exception {
  449 + if(listBaseResponse.getRet()==200){
  450 + if(listBaseResponse.getData().size()==0){//没有仓储不足菜品直接下单
  451 + placeOrder();
  452 + }else{
  453 + dismissDialog();
  454 + ClearDialogFragment dialog=new ClearDialogFragment();
  455 + Bundle bundle=new Bundle();
  456 + bundle.putParcelable("clearOuter",listBaseResponse.getData().get(0));
  457 + bundle.putString("orderid",orderid);
  458 + bundle.putString("fromSource",fromSource);
  459 + bundle.putBoolean("isFast",isFast);
  460 + dialog.setArguments(bundle);
  461 + dialog.show(((CartActivity)context).getSupportFragmentManager(),"clearFragment");
  462 + }
  463 + }else{
  464 + dismissDialog();
  465 + ToastUtils.showShort(listBaseResponse.getMsg());
  466 + }
  467 + }
  468 + }, new Consumer<ResponseThrowable>() {
  469 + @Override
  470 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  471 + dismissDialog();
  472 + responseThrowable.printStackTrace();
  473 + ToastUtils.showShort(responseThrowable.msg);
  474 + }
  475 + });
  476 + }
  477 +
  478 + //下单接口
  479 + private void placeOrder(){
  480 + Map<String,String> params=new HashMap<>();
  481 + params.put("sellerid",orderEntity.getSellerid());
  482 + params.put("orderid",orderEntity.getId());
  483 + if(TextUtils.isEmpty(fromSource)){
  484 + params.put("type","1");//下单1、加菜2
  485 + }else{
  486 + params.put("type","2");//下单1、加菜2
  487 + }
  488 + params.put("identity","2");//1 顾客 2 服务员
  489 + RetrofitClient.getInstance().create(CartApiService.class)
  490 + .placeOrder(params)
  491 + .compose(RxUtils.schedulersTransformer())
  492 + .compose(RxUtils.exceptionTransformer())
  493 + .doOnSubscribe(new Consumer<Disposable>() {
  494 + @Override
  495 + public void accept(Disposable disposable) throws Exception {
  496 +
  497 + }
  498 + })
  499 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  500 + @Override
  501 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  502 + dismissDialog();
  503 + if(listBaseResponse.getRet()==200){
  504 + final RightDialog dialog=new RightDialog();
  505 + Bundle bundle=new Bundle();
  506 + bundle.putString("msg","下单成功");
  507 + dialog.setArguments(bundle);
  508 + new Handler().postDelayed(new Runnable() {
  509 + @Override
  510 + public void run() {
  511 + dialog.dismiss();
  512 + if(isFast){//快速点餐直接跳到订单详情
  513 + Intent intent=new Intent(context, OrderActivity.class);
  514 + intent.putExtra("orderid",orderid);
  515 + context.startActivity(intent);
  516 + }else{
  517 + startActivity(TangShiActivity.class);
  518 + }
  519 + }
  520 + },1000);
  521 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"rightDialog");
  522 + }else{
  523 + ToastUtils.showShort(listBaseResponse.getMsg());
  524 + }
  525 + }
  526 + }, new Consumer<ResponseThrowable>() {
  527 + @Override
  528 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  529 + dismissDialog();
  530 + responseThrowable.printStackTrace();
  531 + ToastUtils.showShort(responseThrowable.msg);
  532 + }
  533 + });
  534 + }
  535 +}
  1 +package com.naji.xiaotao.cart.vm;
  2 +
  3 +import android.content.Context;
  4 +import android.databinding.ObservableBoolean;
  5 +
  6 +
  7 +import com.naji.xiaotao.cart.entity.RemarkEntity;
  8 +import com.naji.xiaotao.cart.entity.RemarkItemEntity;
  9 +
  10 +import me.goldze.mvvmhabit.base.BaseViewModel;
  11 +import me.goldze.mvvmhabit.binding.command.BindingAction;
  12 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  13 +
  14 +public class RemarkItemViewModel extends BaseViewModel{
  15 +
  16 + public RemarkEntity entity;
  17 +
  18 + public RemarkItemEntity one,two,three;
  19 + public ObservableBoolean oneSelected=new ObservableBoolean(false);
  20 + public ObservableBoolean twoSelected=new ObservableBoolean(false);
  21 + public ObservableBoolean threeSelected=new ObservableBoolean(false);
  22 +
  23 + public RemarkItemViewModel(Context context, RemarkEntity entity){
  24 + super(context);
  25 + this.entity=entity;
  26 + one=entity.getList().get(0);
  27 + two=entity.getList().get(1);
  28 + if(entity.getList().size()>=3){
  29 + three=entity.getList().get(2);
  30 + }
  31 + if(entity.getList().get(0).isSelected()){
  32 + oneSelected.set(true);
  33 + }
  34 + if(entity.getList().get(1).isSelected()){
  35 + twoSelected.set(true);
  36 + }
  37 + if(entity.getList().size()>=3&&entity.getList().get(2).isSelected()){
  38 + threeSelected.set(true);
  39 + }
  40 + }
  41 +
  42 + public BindingCommand OnOneClickCommand=new BindingCommand(new BindingAction() {
  43 + @Override
  44 + public void call() {
  45 + oneSelected.set(!oneSelected.get());
  46 + entity.getList().get(0).setSelected(!entity.getList().get(0).isSelected());
  47 + }
  48 + });
  49 + public BindingCommand OnTwoClickCommand=new BindingCommand(new BindingAction() {
  50 + @Override
  51 + public void call() {
  52 + twoSelected.set(!twoSelected.get());
  53 + entity.getList().get(1).setSelected(!entity.getList().get(1).isSelected());
  54 + }
  55 + });
  56 + public BindingCommand OnThreeClickCommand=new BindingCommand(new BindingAction() {
  57 + @Override
  58 + public void call() {
  59 + threeSelected.set(!threeSelected.get());
  60 + entity.getList().get(2).setSelected(!entity.getList().get(2).isSelected());
  61 + }
  62 + });
  63 +}
  1 +package com.naji.xiaotao.cart.vm;
  2 +
  3 +import android.content.Context;
  4 +import android.databinding.ObservableArrayList;
  5 +import android.databinding.ObservableField;
  6 +import android.databinding.ObservableList;
  7 +import android.os.Bundle;
  8 +import android.os.Handler;
  9 +import android.support.v7.app.AppCompatActivity;
  10 +import android.text.TextUtils;
  11 +
  12 +import com.naji.xiaotao.R;
  13 +import com.naji.xiaotao.BR;
  14 +import com.naji.xiaotao.cart.entity.RemarkEntity;
  15 +import com.naji.xiaotao.cart.entity.RemarkItemEntity;
  16 +import com.naji.xiaotao.cart.service.CartApiService;
  17 +import com.naji.xiaotao.cart.ui.RemarkActivity;
  18 +import com.naji.xiaotao.common.dialog.RightDialog;
  19 +import com.naji.xiaotao.http.RetrofitClient;
  20 +import com.naji.xiaotao.tangshi.ui.TangShiActivity;
  21 +
  22 +import java.util.HashMap;
  23 +import java.util.List;
  24 +import java.util.Map;
  25 +
  26 +import io.reactivex.disposables.Disposable;
  27 +import io.reactivex.functions.Consumer;
  28 +import me.goldze.mvvmhabit.base.BaseViewModel;
  29 +import me.goldze.mvvmhabit.base.TitleViewModel;
  30 +import me.goldze.mvvmhabit.binding.command.BindingAction;
  31 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  32 +import me.goldze.mvvmhabit.http.BaseResponse;
  33 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  34 +import me.goldze.mvvmhabit.utils.KLog;
  35 +import me.goldze.mvvmhabit.utils.RxUtils;
  36 +import me.goldze.mvvmhabit.utils.SPUtils;
  37 +import me.goldze.mvvmhabit.utils.ToastUtils;
  38 +import me.tatarka.bindingcollectionadapter2.ItemBinding;
  39 +import me.tatarka.bindingcollectionadapter2.OnItemBind;
  40 +
  41 +public class RemarkViewModel extends BaseViewModel{
  42 +
  43 + public TitleViewModel titleViewModel;
  44 + private String orderid;
  45 + private String remarkid;
  46 + public ObservableField<String> remark=new ObservableField<>();
  47 +
  48 + @Override
  49 + public void onCreate() {
  50 + super.onCreate();
  51 + getRemarkBySellerid();
  52 + }
  53 +
  54 + public RemarkViewModel(Context context,String orderid,String remarkid,String remark){
  55 + super(context);
  56 + titleViewModel=new TitleViewModel(context,"整单备注");
  57 + this.orderid=orderid;
  58 + this.remarkid=remarkid;
  59 + if(!TextUtils.isEmpty(remark)){
  60 + this.remark.set(remark);
  61 + }
  62 + }
  63 +
  64 +
  65 + public ObservableList<RemarkItemViewModel> observableList=new ObservableArrayList<>();
  66 + public OnItemBind<RemarkItemViewModel> itemBinding=new OnItemBind<RemarkItemViewModel>() {
  67 + @Override
  68 + public void onItemBind(ItemBinding itemBinding, int position, RemarkItemViewModel item) {
  69 + if(item.entity.getList().size()>2){
  70 + itemBinding.set(BR.viewModel,R.layout.layout_remark_three_item);
  71 + }else{
  72 + itemBinding.set(BR.viewModel,R.layout.layout_remark_two_item);
  73 + }
  74 + }
  75 + };
  76 +
  77 +
  78 + private void getRemarkBySellerid(){
  79 + Map<String,String> params=new HashMap<>();
  80 + params.put("sellerid", SPUtils.getInstance("user_info").getString("sellerid"));
  81 + params.put("orderid",orderid);
  82 + RetrofitClient.getInstance().create(CartApiService.class)
  83 + .getRemarkBySellerid(params)
  84 + .compose(RxUtils.schedulersTransformer())
  85 + .compose(RxUtils.exceptionTransformer())
  86 + .doOnSubscribe(new Consumer<Disposable>() {
  87 + @Override
  88 + public void accept(Disposable disposable) throws Exception {
  89 +
  90 + }
  91 + })
  92 + .subscribe(new Consumer<BaseResponse<List<List<RemarkEntity>>>>() {
  93 + @Override
  94 + public void accept(BaseResponse<List<List<RemarkEntity>>> listBaseResponse) throws Exception {
  95 + if(listBaseResponse.getRet()==200){
  96 + observableList.clear();
  97 + for(RemarkEntity entity:listBaseResponse.getData().get(0)){
  98 + if(!TextUtils.isEmpty(remarkid)){
  99 + String[] remarkids=remarkid.split(",");
  100 + KLog.d("remarkids",remarkids);
  101 + for(RemarkItemEntity itemEntity:entity.getList()){
  102 + for(int i=0;i<remarkids.length;i++){
  103 + if(remarkids[i].equals(itemEntity.getId())){
  104 + itemEntity.setSelected(true);
  105 + }
  106 + }
  107 + }
  108 + }
  109 + observableList.add(new RemarkItemViewModel(context,entity));
  110 + }
  111 + }else{
  112 + ToastUtils.showShort(listBaseResponse.getMsg());
  113 + }
  114 + }
  115 +
  116 + }, new Consumer<ResponseThrowable>() {
  117 + @Override
  118 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  119 + responseThrowable.printStackTrace();
  120 + ToastUtils.showShort(responseThrowable.msg);
  121 + }
  122 + });
  123 + }
  124 +
  125 +
  126 + //保存备注
  127 + public BindingCommand onRemarkSaveCommand=new BindingCommand(new BindingAction() {
  128 + @Override
  129 + public void call() {
  130 + StringBuilder builder=new StringBuilder();
  131 + for(RemarkItemViewModel itemViewModel:observableList){
  132 + for(RemarkItemEntity item:itemViewModel.entity.getList()){
  133 + if(item.isSelected()){
  134 + builder.append(item.getId()+",");
  135 + }
  136 + }
  137 + }
  138 + String remrkid="";
  139 + if(builder.length()>0){
  140 + remrkid=builder.toString().substring(0,builder.length()-1);
  141 + }
  142 + KLog.d("remarkid",remrkid);
  143 + setOrderById(remrkid);
  144 + }
  145 + });
  146 +
  147 +
  148 + //修改订单人数备注
  149 + private void setOrderById(String remarkid){
  150 + Map<String,String> params=new HashMap<>();
  151 + params.put("orderid",orderid);
  152 + params.put("remark",TextUtils.isEmpty(remark.get())?"":remark.get());
  153 + params.put("remarkid",remarkid);
  154 + RetrofitClient.getInstance().create(CartApiService.class)
  155 + .setOrderById(params)
  156 + .compose(RxUtils.schedulersTransformer())
  157 + .compose(RxUtils.exceptionTransformer())
  158 + .doOnSubscribe(new Consumer<Disposable>() {
  159 + @Override
  160 + public void accept(Disposable disposable) throws Exception {
  161 + showDialog();
  162 + }
  163 + })
  164 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  165 + @Override
  166 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  167 + dismissDialog();
  168 + if(listBaseResponse.getRet()==200){
  169 + final RightDialog dialog=new RightDialog();
  170 + Bundle bundle=new Bundle();
  171 + bundle.putString("msg","备注成功");
  172 + dialog.setArguments(bundle);
  173 + new Handler().postDelayed(new Runnable() {
  174 + @Override
  175 + public void run() {
  176 + dialog.dismiss();
  177 + ((RemarkActivity)context).finish();
  178 + }
  179 + }, 1000);
  180 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"rightDialog");
  181 + }else{
  182 + dismissDialog();
  183 + ToastUtils.showShort(listBaseResponse.getMsg());
  184 + }
  185 + }
  186 + }, new Consumer<ResponseThrowable>() {
  187 + @Override
  188 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  189 + dismissDialog();
  190 + responseThrowable.printStackTrace();
  191 + ToastUtils.showShort(responseThrowable.msg);
  192 + }
  193 + });
  194 + }
  195 +}
  1 +package com.naji.xiaotao.common.binding.xrecyclerview;
  2 +
  3 +import android.databinding.BindingAdapter;
  4 +import android.support.design.widget.TabLayout;
  5 +
  6 +import com.jcodecraeer.xrecyclerview.XRecyclerView;
  7 +
  8 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  9 +
  10 +public class ViewAdapter {
  11 +
  12 + @BindingAdapter(value = {"onRefreshCommand","onLoadMoreCommand"},requireAll = false)
  13 + public static void onRefreshCommand(XRecyclerView xRecyclerView, final BindingCommand onRefreshCommand, final BindingCommand onLoadMoreCommand){
  14 + xRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
  15 + @Override
  16 + public void onRefresh() {
  17 + if(onRefreshCommand!=null){
  18 + onRefreshCommand.execute();
  19 + }
  20 + }
  21 +
  22 + @Override
  23 + public void onLoadMore() {
  24 + if(onLoadMoreCommand!=null){
  25 + onLoadMoreCommand.execute();
  26 + }
  27 + }
  28 + });
  29 + }
  30 + @BindingAdapter(value = {"OnTabSelectCommand"},requireAll = false)
  31 + public static void onTabSelectCommand(TabLayout tabLayout,final BindingCommand<Integer> onTabSelectCommand){
  32 + tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
  33 + @Override
  34 + public void onTabSelected(TabLayout.Tab tab) {
  35 + onTabSelectCommand.execute(tab.getPosition());
  36 + }
  37 +
  38 + @Override
  39 + public void onTabUnselected(TabLayout.Tab tab) {
  40 +
  41 + }
  42 +
  43 + @Override
  44 + public void onTabReselected(TabLayout.Tab tab) {
  45 +
  46 + }
  47 + });
  48 + }
  49 +}
  1 +package com.naji.xiaotao.common.db;
  2 +
  3 +import com.raizlabs.android.dbflow.annotation.Database;
  4 +
  5 +@Database(version = AppDataBase.version)
  6 +public class AppDataBase {
  7 + public static final int version=1;
  8 +}
  1 +package com.naji.xiaotao.common.dialog;
  2 +
  3 +import android.graphics.Color;
  4 +import android.graphics.drawable.ColorDrawable;
  5 +import android.os.Bundle;
  6 +import android.support.annotation.Nullable;
  7 +import android.support.v4.app.DialogFragment;
  8 +import android.view.LayoutInflater;
  9 +import android.view.View;
  10 +import android.view.ViewGroup;
  11 +import android.view.Window;
  12 +import android.widget.TextView;
  13 +
  14 +import com.naji.xiaotao.R;
  15 +
  16 +public class RightDialog extends DialogFragment {
  17 +
  18 + @Nullable
  19 + @Override
  20 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
  21 + getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
  22 + getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  23 + getDialog().setCanceledOnTouchOutside(false);
  24 + View view=inflater.inflate(R.layout.dialog_right,container);
  25 + ((TextView)view.findViewById(R.id.message)).setText(getArguments().getString("msg"));
  26 + return view;
  27 + }
  28 +}
  1 +package com.naji.xiaotao.cookbook.adapter;
  2 +import android.content.Context;
  3 +import android.os.Bundle;
  4 +import android.os.Parcelable;
  5 +import android.support.v7.app.AppCompatActivity;
  6 +import android.text.TextUtils;
  7 +import android.util.TypedValue;
  8 +import android.view.View;
  9 +import android.widget.ImageView;
  10 +import android.widget.LinearLayout;
  11 +import android.widget.TextView;
  12 +
  13 +import com.bumptech.glide.Glide;
  14 +import com.bumptech.glide.request.RequestOptions;
  15 +import com.naji.xiaotao.R;
  16 +import com.naji.xiaotao.cookbook.bean.CookbookDetailEntity;
  17 +import com.naji.xiaotao.cookbook.bean.ReduceBean;
  18 +import com.naji.xiaotao.cookbook.bean.ResultEntity;
  19 +import com.naji.xiaotao.cookbook.dialog.ReduceFragmentDialog;
  20 +import com.naji.xiaotao.cookbook.dialog.SelectFragmentDialog;
  21 +import com.naji.xiaotao.cookbook.service.CookbookApiService;
  22 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  23 +import com.naji.xiaotao.cookbook.listener.RvListener;
  24 +import com.naji.xiaotao.http.RetrofitClient;
  25 +import com.naji.xiaotao.tangshi.entity.OrderEntity;
  26 +import com.othershe.library.NiceImageView;
  27 +
  28 +import java.util.ArrayList;
  29 +import java.util.HashMap;
  30 +import java.util.List;
  31 +import java.util.Map;
  32 +
  33 +import io.reactivex.disposables.Disposable;
  34 +import io.reactivex.functions.Consumer;
  35 +import me.goldze.mvvmhabit.bus.RxBus;
  36 +import me.goldze.mvvmhabit.http.BaseResponse;
  37 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  38 +import me.goldze.mvvmhabit.utils.RxUtils;
  39 +import me.goldze.mvvmhabit.utils.SPUtils;
  40 +import me.goldze.mvvmhabit.utils.ToastUtils;
  41 +
  42 +
  43 +public class ClassifyDetailAdapter extends RvAdapter<CookbookDetailEntity> {
  44 +
  45 + private Context context;
  46 + private String orderid;
  47 + private String fromSource;
  48 +
  49 + public ClassifyDetailAdapter(Context context, List<CookbookDetailEntity> list, String orderid,String fromSource,RvListener listener) {
  50 + super(context, list, listener);
  51 + this.context=context;
  52 + this.orderid=orderid;
  53 + this.fromSource=fromSource;
  54 + }
  55 +
  56 +
  57 + @Override
  58 + protected int getLayoutId(int viewType) {
  59 + return viewType == 0 ? R.layout.cookbook_item_title : R.layout.cookbook_item__detail;
  60 + }
  61 +
  62 + @Override
  63 + public int getItemViewType(int position) {
  64 + return list.get(position).isTitle() ? 0 : 1;
  65 + }
  66 +
  67 + @Override
  68 + protected RvHolder getHolder(View view, int viewType) {
  69 + return new ClassifyHolder(view, viewType, listener);
  70 + }
  71 +
  72 + public class ClassifyHolder extends RvHolder<CookbookDetailEntity> {
  73 + TextView tvTitle;//标题栏标题
  74 + TextView tvCook;//菜品名称
  75 + ImageView noMoreImg;//卖光了
  76 + TextView tvYidian;//点过标志
  77 + LinearLayout tagLayout;//标签容器
  78 + TextView tvPrice;//价格
  79 + TextView lastNum;//剩余菜品数量
  80 + ImageView jianImg;//减图标
  81 + TextView havingNum;//已点数量
  82 + ImageView addImg;//加图标
  83 + NiceImageView cookImg;//菜品图标
  84 +
  85 + public ClassifyHolder(View itemView, int type, RvListener listener) {
  86 + super(itemView, type, listener);
  87 + switch (type) {
  88 + case 0:
  89 + tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
  90 + break;
  91 + case 1:
  92 + tvCook= (TextView) itemView.findViewById(R.id.tv_cook);
  93 + noMoreImg=itemView.findViewById(R.id.nomore);
  94 + tvYidian=itemView.findViewById(R.id.yidian);
  95 + tagLayout=itemView.findViewById(R.id.tag_layout);
  96 + tvPrice=itemView.findViewById(R.id.price);
  97 + lastNum=itemView.findViewById(R.id.lastnum);
  98 + jianImg=itemView.findViewById(R.id.jianImg);
  99 + havingNum=itemView.findViewById(R.id.havingnum);
  100 + addImg=itemView.findViewById(R.id.addImg);
  101 + cookImg=itemView.findViewById(R.id.cook_img);
  102 + break;
  103 + }
  104 +
  105 + }
  106 +
  107 + @Override
  108 + public void bindHolder(final CookbookDetailEntity sortBean, final int position) {
  109 + int itemViewType = ClassifyDetailAdapter.this.getItemViewType(position);
  110 + switch (itemViewType) {
  111 + case 0:
  112 + tvTitle.setText(sortBean.getTitleName());
  113 + break;
  114 + case 1:
  115 + tvCook.setText(sortBean.getName());
  116 + tvPrice.setText(sortBean.getPrice()+"元/"+sortBean.getUnit());
  117 + havingNum.setText(sortBean.getNum()+"");
  118 + if(!TextUtils.isEmpty(sortBean.getClear_num())&&Integer.parseInt(sortBean.getClear_num())<=0){
  119 + lastNum.setVisibility(View.GONE);
  120 + noMoreImg.setVisibility(View.VISIBLE);
  121 + addImg.setVisibility(View.GONE);
  122 + }else{
  123 + if(!TextUtils.isEmpty(sortBean.getClear_num())&&Integer.parseInt(sortBean.getClear_num())<=10){
  124 + lastNum.setVisibility(View.VISIBLE);
  125 + lastNum.setText("剩余"+sortBean.getClear_num()+"份");
  126 + }else{
  127 + lastNum.setVisibility(View.GONE);
  128 + lastNum.setText("剩余"+sortBean.getClear_num()+"份");
  129 + }
  130 + noMoreImg.setVisibility(View.INVISIBLE);
  131 + addImg.setVisibility(View.VISIBLE);
  132 + }
  133 + if(sortBean.getNum()>0){
  134 + jianImg.setVisibility(View.VISIBLE);
  135 + havingNum.setVisibility(View.VISIBLE);
  136 + }else{
  137 + jianImg.setVisibility(View.INVISIBLE);
  138 + havingNum.setVisibility(View.INVISIBLE);
  139 + }
  140 + if(!TextUtils.isEmpty(sortBean.getImage())){
  141 + //使用Glide框架加载图片
  142 + Glide.with(cookImg.getContext())
  143 + .load(sortBean.getImage())
  144 + .apply(new RequestOptions().placeholder(null))
  145 + .into(cookImg);
  146 + cookImg.setVisibility(View.VISIBLE);
  147 + }else{
  148 + cookImg.setVisibility(View.GONE);
  149 + }
  150 + tagLayout.removeAllViews();
  151 + if(sortBean.getLabelList()!=null&&sortBean.getLabelList().size()>0){
  152 + LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT);
  153 + params.rightMargin= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,10,mContext.getResources().getDisplayMetrics());
  154 + for(int i=0;i<sortBean.getLabelList().size();i++){
  155 + ImageView imageView=new ImageView(mContext);
  156 + Glide.with(imageView.getContext())
  157 + .load(sortBean.getLabelList().get(i))
  158 + .apply(new RequestOptions().placeholder(null))
  159 + .into(imageView);
  160 + tagLayout.addView(imageView,params);
  161 + }
  162 + }
  163 + addImg.setOnClickListener(new View.OnClickListener() {
  164 + @Override
  165 + public void onClick(View view) {
  166 + if(!TextUtils.isEmpty(list.get(position).getClear_num())&&list.get(position).getNum()==Integer.parseInt(list.get(position).getClear_num())){
  167 + ToastUtils.showShort("菜品沽清不足");
  168 + return;
  169 + }
  170 + if(sortBean.getPractice().size()>0||sortBean.getSpec().size()>0){//有菜品规格或者做法
  171 + SelectFragmentDialog dialog=new SelectFragmentDialog();
  172 + dialog.setOnSureClickListener(new SelectFragmentDialog.onSureClickListener() {
  173 + @Override
  174 + public void onSureClick(String specid, String practiceid,String spec,String practice) {
  175 + addCookToCart(position,specid,practiceid,spec,practice,jianImg,havingNum);
  176 + }
  177 + });
  178 + Bundle bundle=new Bundle();
  179 + bundle.putSerializable("cook",list.get(position));
  180 + dialog.setArguments(bundle);
  181 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"selectFragmentDialog");
  182 + return;
  183 + }
  184 + addCookToCart(position,"","","","",jianImg,havingNum);
  185 +
  186 + }
  187 + });
  188 + jianImg.setOnClickListener(new View.OnClickListener() {
  189 + @Override
  190 + public void onClick(View view) {
  191 + if(sortBean.getPractice().size()>0||sortBean.getSpec().size()>0){//有菜品规格或做法
  192 + //获取一点菜品规则做法列表
  193 + Map<String,String> params=new HashMap<>();
  194 + params.put("sellerid",SPUtils.getInstance("user_info").getString("sellerid"));
  195 + params.put("orderid",orderid);
  196 + params.put("cookbookid",sortBean.getId());
  197 + RetrofitClient.getInstance().create(CookbookApiService.class)
  198 + .getCookbookSelBySpecsId(params)
  199 + .compose(RxUtils.schedulersTransformer())
  200 + .compose(RxUtils.exceptionTransformer())
  201 + .doOnSubscribe(new Consumer<Disposable>() {
  202 + @Override
  203 + public void accept(Disposable disposable) throws Exception {
  204 +
  205 + }
  206 + })
  207 + .subscribe(new Consumer<BaseResponse<List<List<ReduceBean>>>>() {
  208 + @Override
  209 + public void accept(BaseResponse<List<List<ReduceBean>>> listBaseResponse) throws Exception {
  210 + if(listBaseResponse.getRet()==200){
  211 + final ReduceFragmentDialog dialog=new ReduceFragmentDialog();
  212 + dialog.setListener(new ReduceFragmentDialog.ReduceListener() {
  213 + @Override
  214 + public void onAddSuccess(int position,ReduceBean bean) {
  215 + list.get(position).setNum(list.get(position).getNum()+1);
  216 + havingNum.setText(list.get(position).getNum()+"");
  217 + }
  218 +
  219 + @Override
  220 + public void onReduceSuccess(int position,ReduceBean bean) {
  221 + list.get(position).setNum(list.get(position).getNum()-1);
  222 + havingNum.setText(list.get(position).getNum()+"");
  223 + if(list.get(position).getNum()==0){
  224 + jianImg.setVisibility(View.INVISIBLE);
  225 + havingNum.setVisibility(View.INVISIBLE);
  226 + dialog.dismiss();
  227 + }
  228 + }
  229 + });
  230 + Bundle bundle=new Bundle();
  231 + bundle.putInt("position",position);
  232 + bundle.putString("cookname",sortBean.getName());
  233 + bundle.putString("fromSource",fromSource);
  234 + bundle.putString("clear_num",sortBean.getClear_num());
  235 + bundle.putParcelableArrayList("list", (ArrayList<? extends Parcelable>) listBaseResponse.getData().get(0));
  236 + dialog.setArguments(bundle);
  237 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"selectFragmentDialog");
  238 + }else{
  239 + ToastUtils.showShort(listBaseResponse.getMsg());
  240 + }
  241 + }
  242 + }, new Consumer<ResponseThrowable>() {
  243 + @Override
  244 + public void accept(ResponseThrowable throwable) throws Exception {
  245 + throwable.printStackTrace();
  246 + ToastUtils.showShort(throwable.msg);
  247 + }
  248 + });
  249 + return;
  250 + }
  251 + reduceCookFromCart(position,"","",jianImg,havingNum);
  252 + }
  253 + });
  254 + break;
  255 + }
  256 + }
  257 + }
  258 +
  259 + //添加菜品到购物车
  260 + private void addCookToCart(final int position, final String specid, final String practiceid, final String spec, final String practice, final ImageView reduceImg, final TextView havingNum){
  261 + Map<String,String> params=new HashMap<>();
  262 + params.put("orderid",orderid);
  263 + params.put("openid", SPUtils.getInstance("user_info").getString("openid"));
  264 + params.put("cookbookid",list.get(position).getId());
  265 + params.put("identity","2");
  266 + if(!TextUtils.isEmpty(specid)){
  267 + params.put("specid",specid);
  268 + }
  269 + if(!TextUtils.isEmpty(practiceid)){
  270 + params.put("practiceid",practiceid);
  271 + }
  272 + if(!TextUtils.isEmpty(fromSource)){
  273 + params.put("fromSoucre",fromSource);
  274 + }
  275 + RetrofitClient.getInstance().create(CookbookApiService.class)
  276 + .addCookToCart(params)
  277 + .compose(RxUtils.schedulersTransformer())
  278 + .compose(RxUtils.exceptionTransformer())
  279 + .doOnSubscribe(new Consumer<Disposable>() {
  280 + @Override
  281 + public void accept(Disposable disposable) throws Exception {
  282 +
  283 + }
  284 + })
  285 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  286 + @Override
  287 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  288 + if(baseResponse.getRet()==200){
  289 + list.get(position).setNum(list.get(position).getNum()+1);
  290 + havingNum.setText(list.get(position).getNum()+"");
  291 + reduceImg.setVisibility(View.VISIBLE);
  292 + havingNum.setVisibility(View.VISIBLE);
  293 + //通知CookbookMainActivity改变购物车数量
  294 + RxBus.getDefault().post(1);
  295 + }else{
  296 + ToastUtils.showShort(baseResponse.getMsg());
  297 + }
  298 + }
  299 + }, new Consumer<ResponseThrowable>() {
  300 + @Override
  301 + public void accept(ResponseThrowable throwable) throws Exception {
  302 + ToastUtils.showShort(throwable.msg);
  303 + throwable.printStackTrace();
  304 + }
  305 + });
  306 + }
  307 + //删减菜品从购物车
  308 + private void reduceCookFromCart(final int position,final String specid,final String practiceid,final ImageView reduceImg, final TextView havingNum){
  309 + Map<String,String> params=new HashMap<>();
  310 + params.put("orderid",orderid);
  311 + params.put("cookbookid",list.get(position).getId());
  312 + params.put("identity","2");
  313 + if(!TextUtils.isEmpty(specid)){
  314 + params.put("specid",specid);
  315 + }
  316 + if(!TextUtils.isEmpty(practiceid)){
  317 + params.put("practiceid",practiceid);
  318 + }
  319 + if(!TextUtils.isEmpty(fromSource)){
  320 + params.put("fromSoucre",fromSource);
  321 + }
  322 + RetrofitClient.getInstance().create(CookbookApiService.class)
  323 + .reduceCookFromCart(params)
  324 + .compose(RxUtils.schedulersTransformer())
  325 + .compose(RxUtils.exceptionTransformer())
  326 + .doOnSubscribe(new Consumer<Disposable>() {
  327 + @Override
  328 + public void accept(Disposable disposable) throws Exception {
  329 +
  330 + }
  331 + })
  332 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  333 + @Override
  334 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  335 + if(baseResponse.getRet()==200){
  336 + list.get(position).setNum(list.get(position).getNum()-1);
  337 + havingNum.setText(list.get(position).getNum()+"");
  338 + if(list.get(position).getNum()<=0){
  339 + reduceImg.setVisibility(View.INVISIBLE);
  340 + havingNum.setVisibility(View.INVISIBLE);
  341 + }
  342 + //通知CookbookMainActivity改变购物车数量
  343 + RxBus.getDefault().post(-1);
  344 + }else{
  345 + ToastUtils.showShort(baseResponse.getMsg());
  346 + }
  347 + }
  348 + }, new Consumer<ResponseThrowable>() {
  349 + @Override
  350 + public void accept(ResponseThrowable throwable) throws Exception {
  351 + ToastUtils.showShort(throwable.msg);
  352 + throwable.printStackTrace();
  353 + }
  354 + });
  355 + }
  356 +
  357 +}
  1 +package com.naji.xiaotao.cookbook.adapter;
  2 +
  3 +import android.annotation.SuppressLint;
  4 +import android.content.Context;
  5 +import android.text.TextUtils;
  6 +import android.view.View;
  7 +import android.widget.ImageView;
  8 +import android.widget.TextView;
  9 +
  10 +import com.naji.xiaotao.R;
  11 +import com.naji.xiaotao.cookbook.bean.ReduceBean;
  12 +import com.naji.xiaotao.cookbook.bean.ResultEntity;
  13 +import com.naji.xiaotao.cookbook.dialog.ReduceFragmentDialog;
  14 +import com.naji.xiaotao.cookbook.listener.RvListener;
  15 +import com.naji.xiaotao.cookbook.service.CookbookApiService;
  16 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  17 +import com.naji.xiaotao.http.RetrofitClient;
  18 +
  19 +import java.util.HashMap;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +import io.reactivex.disposables.Disposable;
  24 +import io.reactivex.functions.Consumer;
  25 +import me.goldze.mvvmhabit.bus.RxBus;
  26 +import me.goldze.mvvmhabit.http.BaseResponse;
  27 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  28 +import me.goldze.mvvmhabit.utils.RxUtils;
  29 +import me.goldze.mvvmhabit.utils.SPUtils;
  30 +import me.goldze.mvvmhabit.utils.ToastUtils;
  31 +
  32 +public class ReduceAdapter extends RvAdapter<ReduceBean>{
  33 +
  34 + private ReduceFragmentDialog.ReduceListener reduceListener;
  35 + private int position;
  36 + private String fromSource;
  37 + private String clear_num;//菜品沽清数量
  38 +
  39 + public ReduceAdapter(Context context, List<ReduceBean> list, ReduceFragmentDialog.ReduceListener reduceListener,int position,String fromSource,String clear_num){
  40 + super(context,list,null);
  41 + this.reduceListener=reduceListener;
  42 + this.position=position;
  43 + this.fromSource=fromSource;
  44 + this.clear_num=clear_num;
  45 + }
  46 +
  47 + @Override
  48 + protected int getLayoutId(int viewType) {
  49 + return R.layout.dialog_reduce_item;
  50 + }
  51 +
  52 + @Override
  53 + protected RvHolder getHolder(View view, int viewType) {
  54 + return new ReduceHolder(view,viewType,null);
  55 + }
  56 +
  57 + public class ReduceHolder extends RvHolder<ReduceBean>{
  58 +
  59 + private TextView cookbookTv;
  60 + private ImageView addBn;
  61 + private TextView countTv;
  62 + private ImageView reduceBn;
  63 +
  64 + public ReduceHolder(View itemView, int type, RvListener rvListener){
  65 + super(itemView,type,rvListener);
  66 + cookbookTv=itemView.findViewById(R.id.cookbook);
  67 + addBn=itemView.findViewById(R.id.add);
  68 + countTv=itemView.findViewById(R.id.count);
  69 + reduceBn=itemView.findViewById(R.id.reduce);
  70 + }
  71 +
  72 + @Override
  73 + public void bindHolder(final ReduceBean reduceBean, final int position) {
  74 + if(!TextUtils.isEmpty(reduceBean.getPtitle())&&!TextUtils.isEmpty(reduceBean.getTitle())){
  75 + cookbookTv.setText(reduceBean.getTitle()+","+reduceBean.getPtitle());
  76 + }else if(!TextUtils.isEmpty(reduceBean.getTitle())){
  77 + cookbookTv.setText(reduceBean.getTitle());
  78 + }else if(!TextUtils.isEmpty(reduceBean.getPtitle())){
  79 + cookbookTv.setText(reduceBean.getPtitle());
  80 + }
  81 + countTv.setText(reduceBean.getPractNum());
  82 + addBn.setOnClickListener(new View.OnClickListener() {
  83 + @Override
  84 + public void onClick(View view) {
  85 + if(!TextUtils.isEmpty(clear_num)&&Integer.parseInt(list.get(position).getPractNum())==Integer.parseInt(clear_num)){
  86 + ToastUtils.showShort("菜品沽清不足");
  87 + return;
  88 + }
  89 + addCookToCart(countTv,position,reduceBean);
  90 + }
  91 + });
  92 + reduceBn.setOnClickListener(new View.OnClickListener() {
  93 + @Override
  94 + public void onClick(View view) {
  95 + reduceCookFromCart(position,reduceBean);
  96 + }
  97 + });
  98 + }
  99 + }
  100 +
  101 + //添加菜品到购物车
  102 + private void addCookToCart(final TextView countTv, final int pos, final ReduceBean bean){
  103 + Map<String,String> params=new HashMap<>();
  104 + params.put("orderid",bean.getOrderid());
  105 + params.put("openid", SPUtils.getInstance("user_info").getString("openid"));
  106 + params.put("cookbookid",bean.getCookbookid());
  107 + params.put("identity","2");
  108 + if(!TextUtils.isEmpty(bean.getSpecid())){
  109 + params.put("specid",bean.getSpecid());
  110 + }
  111 + if(!TextUtils.isEmpty(bean.getPracticeid())){
  112 + params.put("practiceid",bean.getPracticeid());
  113 + }
  114 + if(!TextUtils.isEmpty(fromSource)){
  115 + params.put("fromSoucre",fromSource);
  116 + }
  117 + RetrofitClient.getInstance().create(CookbookApiService.class)
  118 + .addCookToCart(params)
  119 + .compose(RxUtils.schedulersTransformer())
  120 + .compose(RxUtils.exceptionTransformer())
  121 + .doOnSubscribe(new Consumer<Disposable>() {
  122 + @Override
  123 + public void accept(Disposable disposable) throws Exception {
  124 +
  125 + }
  126 + })
  127 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  128 + @Override
  129 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  130 + if(baseResponse.getRet()==200){
  131 + list.get(pos).setPractNum((Integer.parseInt(list.get(pos).getPractNum())+1)+"");
  132 + countTv.setText(list.get(pos).getPractNum());
  133 + if(reduceListener!=null){
  134 + reduceListener.onAddSuccess(position,bean);
  135 + }
  136 + //通知CookbookMainActivity改变购物车数量
  137 + RxBus.getDefault().post(1);
  138 + }else{
  139 + ToastUtils.showShort(baseResponse.getMsg());
  140 + }
  141 + }
  142 + }, new Consumer<ResponseThrowable>() {
  143 + @Override
  144 + public void accept(ResponseThrowable throwable) throws Exception {
  145 + ToastUtils.showShort(throwable.msg);
  146 + throwable.printStackTrace();
  147 + }
  148 + });
  149 + }
  150 + //删减菜品从购物车esult")
  151 + private void reduceCookFromCart(final int pos, final ReduceBean bean){
  152 + Map<String,String> params=new HashMap<>();
  153 + params.put("orderid",bean.getOrderid());
  154 + params.put("cookbookid",bean.getCookbookid());
  155 + params.put("identity","2");
  156 + if(!TextUtils.isEmpty(bean.getSpecid())){
  157 + params.put("specid",bean.getSpecid());
  158 + }
  159 + if(!TextUtils.isEmpty(bean.getPracticeid())){
  160 + params.put("practiceid",bean.getPracticeid());
  161 + }
  162 + if(!TextUtils.isEmpty(fromSource)){
  163 + params.put("fromSoucre",fromSource);
  164 + }
  165 + RetrofitClient.getInstance().create(CookbookApiService.class)
  166 + .reduceCookFromCart(params)
  167 + .compose(RxUtils.schedulersTransformer())
  168 + .compose(RxUtils.exceptionTransformer())
  169 + .doOnSubscribe(new Consumer<Disposable>() {
  170 + @Override
  171 + public void accept(Disposable disposable) throws Exception {
  172 +
  173 + }
  174 + })
  175 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  176 + @Override
  177 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  178 + if(baseResponse.getRet()==200){
  179 + list.get(pos).setPractNum((Integer.parseInt(list.get(pos).getPractNum())-1)+"");
  180 + if(Integer.parseInt(list.get(pos).getPractNum())==0){
  181 + list.remove(pos);
  182 + if(list.size()<=0){
  183 +
  184 + }
  185 + }
  186 + notifyDataSetChanged();
  187 + if(reduceListener!=null){
  188 + reduceListener.onReduceSuccess(position,bean);
  189 + }
  190 + //通知CookbookMainActivity改变购物车数量
  191 + RxBus.getDefault().post(-1);
  192 + }else{
  193 + ToastUtils.showShort(baseResponse.getMsg());
  194 + }
  195 + }
  196 + }, new Consumer<ResponseThrowable>() {
  197 + @Override
  198 + public void accept(ResponseThrowable throwable) throws Exception {
  199 + ToastUtils.showShort(throwable.msg);
  200 + throwable.printStackTrace();
  201 + }
  202 + });
  203 + }
  204 +}
  1 +package com.naji.xiaotao.cookbook.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.support.v7.widget.RecyclerView;
  5 +import android.view.LayoutInflater;
  6 +import android.view.View;
  7 +import android.view.ViewGroup;
  8 +
  9 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  10 +import com.naji.xiaotao.cookbook.listener.RvListener;
  11 +
  12 +import java.util.List;
  13 +
  14 +@SuppressWarnings("unchecked")
  15 +public abstract class RvAdapter<T> extends RecyclerView.Adapter<RvHolder> {
  16 + protected List<T> list;
  17 + protected Context mContext;
  18 + protected RvListener listener;
  19 + protected LayoutInflater mInflater;
  20 +
  21 + private RecyclerView mRecyclerView;
  22 + public RvAdapter(Context context, List<T> list, RvListener listener) {
  23 + mContext = context;
  24 + mInflater = LayoutInflater.from(context);
  25 + this.list = list;
  26 + this.listener = listener;
  27 + }
  28 +
  29 + @Override
  30 + public RvHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  31 + View view = mInflater.inflate(getLayoutId(viewType), parent, false);
  32 + return getHolder(view, viewType);
  33 + }
  34 +
  35 + protected abstract int getLayoutId(int viewType);
  36 +
  37 + @Override
  38 + public void onBindViewHolder(RvHolder holder, int position) {
  39 + holder.bindHolder(list.get(position), position);
  40 + }
  41 +
  42 + @Override
  43 + public int getItemCount() {
  44 + return list.size();
  45 + }
  46 +
  47 + @Override
  48 + public int getItemViewType(int position) {
  49 + return 0;
  50 + }
  51 +
  52 + protected abstract RvHolder getHolder(View view, int viewType);
  53 +
  54 +}
  1 +package com.naji.xiaotao.cookbook.adapter;
  2 +
  3 +
  4 +import android.content.Context;
  5 +import android.graphics.Color;
  6 +import android.view.View;
  7 +import android.widget.TextView;
  8 +
  9 +import com.naji.xiaotao.R;
  10 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  11 +import com.naji.xiaotao.cookbook.listener.RvListener;
  12 +
  13 +import java.util.List;
  14 +
  15 +public class SortAdapter extends RvAdapter<String> {
  16 +
  17 + private int checkedPosition;
  18 +
  19 + public void setCheckedPosition(int checkedPosition) {
  20 + this.checkedPosition = checkedPosition;
  21 + notifyDataSetChanged();
  22 + }
  23 +
  24 + public SortAdapter(Context context, List<String> list, RvListener listener) {
  25 + super(context, list, listener);
  26 + }
  27 +
  28 + @Override
  29 + protected int getLayoutId(int viewType) {
  30 + return R.layout.cookbook_item_sort_list;
  31 + }
  32 +
  33 + @Override
  34 + protected RvHolder getHolder(View view, int viewType) {
  35 + return new SortHolder(view, viewType, listener);
  36 + }
  37 +
  38 + private class SortHolder extends RvHolder<String> {
  39 +
  40 + private View line;
  41 + private TextView tvName;
  42 + private View mView;
  43 +
  44 + SortHolder(View itemView, int type, RvListener listener) {
  45 + super(itemView, type, listener);
  46 + this.mView = itemView;
  47 + line=itemView.findViewById(R.id.line);
  48 + tvName = (TextView) itemView.findViewById(R.id.tv_sort);
  49 + }
  50 +
  51 + @Override
  52 + public void bindHolder(String string, int position) {
  53 + tvName.setText(string);
  54 + if (position == checkedPosition) {
  55 + mView.setBackgroundColor(Color.parseColor("#ffffff"));
  56 + tvName.setTextColor(Color.parseColor("#61a5d1"));
  57 + line.setVisibility(View.VISIBLE);
  58 + } else {
  59 + mView.setBackgroundColor(Color.parseColor("#F5f5f5"));
  60 + tvName.setTextColor(Color.parseColor("#999999"));
  61 + line.setVisibility(View.INVISIBLE);
  62 + }
  63 + }
  64 +
  65 + }
  66 +}
  1 +package com.naji.xiaotao.cookbook.bean;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.io.Serializable;
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
  10 +public class CookbookDetailEntity implements Serializable, Parcelable {
  11 +
  12 + private String id;
  13 + private String cid;
  14 + private String lid;
  15 + private String unit;
  16 + private String name;
  17 + private String price;
  18 + private String member_price;
  19 + private String first_name;
  20 + private String search_code;
  21 + private String give;
  22 + private String status;
  23 + private String order_o;
  24 + private String image;
  25 + private String clear_num;//0卖光了
  26 + private String cdate;
  27 + private int isSpec;//1 为有规格的菜品 为无规格菜品
  28 + private List<CookbookSize> spec;//菜品规格列表
  29 + private List<CookbookPractice> practice;//菜品做法列表
  30 + private List<String> labelList;//标签列表
  31 + private int num;//已点数量
  32 +
  33 +
  34 + private String titleName;
  35 + private boolean isTitle;//title标志位
  36 + private String tag;
  37 +
  38 + public String getId() {
  39 + return id;
  40 + }
  41 +
  42 + public void setId(String id) {
  43 + this.id = id;
  44 + }
  45 +
  46 + public String getCid() {
  47 + return cid;
  48 + }
  49 +
  50 + public void setCid(String cid) {
  51 + this.cid = cid;
  52 + }
  53 +
  54 + public String getLid() {
  55 + return lid;
  56 + }
  57 +
  58 + public void setLid(String lid) {
  59 + this.lid = lid;
  60 + }
  61 +
  62 + public String getUnit() {
  63 + return unit;
  64 + }
  65 +
  66 + public void setUnit(String unit) {
  67 + this.unit = unit;
  68 + }
  69 +
  70 + public String getName() {
  71 + return name;
  72 + }
  73 +
  74 + public void setName(String name) {
  75 + this.name = name;
  76 + }
  77 +
  78 + public String getPrice() {
  79 + return price;
  80 + }
  81 +
  82 + public void setPrice(String price) {
  83 + this.price = price;
  84 + }
  85 +
  86 + public String getMember_price() {
  87 + return member_price;
  88 + }
  89 +
  90 + public void setMember_price(String member_price) {
  91 + this.member_price = member_price;
  92 + }
  93 +
  94 + public String getFirst_name() {
  95 + return first_name;
  96 + }
  97 +
  98 + public void setFirst_name(String first_name) {
  99 + this.first_name = first_name;
  100 + }
  101 +
  102 + public String getSearch_code() {
  103 + return search_code;
  104 + }
  105 +
  106 + public void setSearch_code(String search_code) {
  107 + this.search_code = search_code;
  108 + }
  109 +
  110 + public String getGive() {
  111 + return give;
  112 + }
  113 +
  114 + public void setGive(String give) {
  115 + this.give = give;
  116 + }
  117 +
  118 + public String getStatus() {
  119 + return status;
  120 + }
  121 +
  122 + public void setStatus(String status) {
  123 + this.status = status;
  124 + }
  125 +
  126 + public String getOrder_o() {
  127 + return order_o;
  128 + }
  129 +
  130 + public void setOrder_o(String order_o) {
  131 + this.order_o = order_o;
  132 + }
  133 +
  134 + public String getImage() {
  135 + return image;
  136 + }
  137 +
  138 + public void setImage(String image) {
  139 + this.image = image;
  140 + }
  141 +
  142 + public String getClear_num() {
  143 + return clear_num;
  144 + }
  145 +
  146 + public void setClear_num(String clear_num) {
  147 + this.clear_num = clear_num;
  148 + }
  149 +
  150 + public String getCdate() {
  151 + return cdate;
  152 + }
  153 +
  154 + public void setCdate(String cdate) {
  155 + this.cdate = cdate;
  156 + }
  157 +
  158 + public int getIsSpec() {
  159 + return isSpec;
  160 + }
  161 +
  162 + public void setIsSpec(int isSpec) {
  163 + this.isSpec = isSpec;
  164 + }
  165 +
  166 + public List<CookbookSize> getSpec() {
  167 + return spec;
  168 + }
  169 +
  170 + public void setSpec(List<CookbookSize> spec) {
  171 + this.spec = spec;
  172 + }
  173 +
  174 + public List<CookbookPractice> getPractice() {
  175 + return practice;
  176 + }
  177 +
  178 + public void setPractice(List<CookbookPractice> practice) {
  179 + this.practice = practice;
  180 + }
  181 +
  182 + public List<String> getLabelList() {
  183 + return labelList;
  184 + }
  185 +
  186 + public void setLabelList(List<String> labelList) {
  187 + this.labelList = labelList;
  188 + }
  189 +
  190 + public int getNum() {
  191 + return num;
  192 + }
  193 +
  194 + public void setNum(int num) {
  195 + this.num = num;
  196 + }
  197 +
  198 + public String getTitleName() {
  199 + return titleName;
  200 + }
  201 +
  202 + public void setTitleName(String titleName) {
  203 + this.titleName = titleName;
  204 + }
  205 +
  206 + public boolean isTitle() {
  207 + return isTitle;
  208 + }
  209 +
  210 + public void setTitle(boolean title) {
  211 + isTitle = title;
  212 + }
  213 +
  214 + public String getTag() {
  215 + return tag;
  216 + }
  217 +
  218 + public void setTag(String tag) {
  219 + this.tag = tag;
  220 + }
  221 +
  222 + @Override
  223 + public int describeContents() {
  224 + return 0;
  225 + }
  226 +
  227 + @Override
  228 + public void writeToParcel(Parcel dest, int flags) {
  229 + dest.writeString(this.id);
  230 + dest.writeString(this.cid);
  231 + dest.writeString(this.lid);
  232 + dest.writeString(this.unit);
  233 + dest.writeString(this.name);
  234 + dest.writeString(this.price);
  235 + dest.writeString(this.member_price);
  236 + dest.writeString(this.first_name);
  237 + dest.writeString(this.search_code);
  238 + dest.writeString(this.give);
  239 + dest.writeString(this.status);
  240 + dest.writeString(this.order_o);
  241 + dest.writeString(this.image);
  242 + dest.writeString(this.clear_num);
  243 + dest.writeString(this.cdate);
  244 + dest.writeInt(this.isSpec);
  245 + dest.writeList(this.spec);
  246 + dest.writeList(this.practice);
  247 + dest.writeStringList(this.labelList);
  248 + dest.writeInt(this.num);
  249 + dest.writeString(this.titleName);
  250 + dest.writeByte(this.isTitle ? (byte) 1 : (byte) 0);
  251 + dest.writeString(this.tag);
  252 + }
  253 +
  254 + public CookbookDetailEntity() {
  255 + }
  256 +
  257 + protected CookbookDetailEntity(Parcel in) {
  258 + this.id = in.readString();
  259 + this.cid = in.readString();
  260 + this.lid = in.readString();
  261 + this.unit = in.readString();
  262 + this.name = in.readString();
  263 + this.price = in.readString();
  264 + this.member_price = in.readString();
  265 + this.first_name = in.readString();
  266 + this.search_code = in.readString();
  267 + this.give = in.readString();
  268 + this.status = in.readString();
  269 + this.order_o = in.readString();
  270 + this.image = in.readString();
  271 + this.clear_num = in.readString();
  272 + this.cdate = in.readString();
  273 + this.isSpec = in.readInt();
  274 + this.spec = new ArrayList<CookbookSize>();
  275 + in.readList(this.spec, CookbookSize.class.getClassLoader());
  276 + this.practice = new ArrayList<CookbookPractice>();
  277 + in.readList(this.practice, CookbookPractice.class.getClassLoader());
  278 + this.labelList = in.createStringArrayList();
  279 + this.num = in.readInt();
  280 + this.titleName = in.readString();
  281 + this.isTitle = in.readByte() != 0;
  282 + this.tag = in.readString();
  283 + }
  284 +
  285 + public static final Creator<CookbookDetailEntity> CREATOR = new Creator<CookbookDetailEntity>() {
  286 + @Override
  287 + public CookbookDetailEntity createFromParcel(Parcel source) {
  288 + return new CookbookDetailEntity(source);
  289 + }
  290 +
  291 + @Override
  292 + public CookbookDetailEntity[] newArray(int size) {
  293 + return new CookbookDetailEntity[size];
  294 + }
  295 + };
  296 +}
  1 +package com.naji.xiaotao.cookbook.bean;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.io.Serializable;
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
  10 +public class CookbookEntity implements Serializable{
  11 +
  12 + private String id;
  13 + private String sellerid;
  14 + private String class_label;
  15 + private String class_name;
  16 + private String order;
  17 + private String status;
  18 + private String class_type;
  19 + private List<List<CookbookDetailEntity>> cookbooklist;
  20 +
  21 + public CookbookEntity(CookbookEntity entity){
  22 + this.id=entity.getId();
  23 + this.sellerid=entity.getSellerid();
  24 + this.class_label=entity.getClass_label();
  25 + this.class_name=entity.getClass_name();
  26 + this.order=entity.getOrder();
  27 + this.status=entity.getStatus();
  28 + this.class_type=entity.getClass_type();
  29 + }
  30 +
  31 +
  32 + public String getId() {
  33 + return id;
  34 + }
  35 +
  36 + public void setId(String id) {
  37 + this.id = id;
  38 + }
  39 +
  40 + public String getSellerid() {
  41 + return sellerid;
  42 + }
  43 +
  44 + public void setSellerid(String sellerid) {
  45 + this.sellerid = sellerid;
  46 + }
  47 +
  48 + public String getClass_label() {
  49 + return class_label;
  50 + }
  51 +
  52 + public void setClass_label(String class_label) {
  53 + this.class_label = class_label;
  54 + }
  55 +
  56 + public String getClass_name() {
  57 + return class_name;
  58 + }
  59 +
  60 + public void setClass_name(String class_name) {
  61 + this.class_name = class_name;
  62 + }
  63 +
  64 + public String getOrder() {
  65 + return order;
  66 + }
  67 +
  68 + public void setOrder(String order) {
  69 + this.order = order;
  70 + }
  71 +
  72 + public String getStatus() {
  73 + return status;
  74 + }
  75 +
  76 + public void setStatus(String status) {
  77 + this.status = status;
  78 + }
  79 +
  80 + public String getClass_type() {
  81 + return class_type;
  82 + }
  83 +
  84 + public void setClass_type(String class_type) {
  85 + this.class_type = class_type;
  86 + }
  87 +
  88 + public List<List<CookbookDetailEntity>> getCookbooklist() {
  89 + return cookbooklist;
  90 + }
  91 +
  92 + public void setCookbooklist(List<List<CookbookDetailEntity>> cookbooklist) {
  93 + this.cookbooklist = cookbooklist;
  94 + }
  95 +
  96 +}
  1 +package com.naji.xiaotao.cookbook.bean;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.io.Serializable;
  7 +
  8 +public class CookbookPractice implements Serializable {
  9 +
  10 + private String id;
  11 + private String cid;
  12 + private String practice;
  13 + private String name;
  14 + private String price;
  15 + private String member_price;
  16 +
  17 + public String getId() {
  18 + return id;
  19 + }
  20 +
  21 + public void setId(String id) {
  22 + this.id = id;
  23 + }
  24 +
  25 + public String getCid() {
  26 + return cid;
  27 + }
  28 +
  29 + public void setCid(String cid) {
  30 + this.cid = cid;
  31 + }
  32 +
  33 + public String getPractice() {
  34 + return practice;
  35 + }
  36 +
  37 + public void setPractice(String practice) {
  38 + this.practice = practice;
  39 + }
  40 +
  41 + public String getName() {
  42 + return name;
  43 + }
  44 +
  45 + public void setName(String name) {
  46 + this.name = name;
  47 + }
  48 +
  49 + public String getPrice() {
  50 + return price;
  51 + }
  52 +
  53 + public void setPrice(String price) {
  54 + this.price = price;
  55 + }
  56 +
  57 + public String getMember_price() {
  58 + return member_price;
  59 + }
  60 +
  61 + public void setMember_price(String member_price) {
  62 + this.member_price = member_price;
  63 + }
  64 +
  65 +
  66 +}
  1 +package com.naji.xiaotao.cookbook.bean;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +public class CookbookSize implements Serializable{
  6 +
  7 + private String id;
  8 + private String cid;
  9 + private String specid;
  10 + private String specs;
  11 + private String price;
  12 + private String member_price;
  13 + private String clear_num;
  14 +
  15 + public String getId() {
  16 + return id;
  17 + }
  18 +
  19 + public void setId(String id) {
  20 + this.id = id;
  21 + }
  22 +
  23 + public String getCid() {
  24 + return cid;
  25 + }
  26 +
  27 + public void setCid(String cid) {
  28 + this.cid = cid;
  29 + }
  30 +
  31 + public String getSpecid() {
  32 + return specid;
  33 + }
  34 +
  35 + public void setSpecid(String specid) {
  36 + this.specid = specid;
  37 + }
  38 +
  39 + public String getSpecs() {
  40 + return specs;
  41 + }
  42 +
  43 + public void setSpecs(String specs) {
  44 + this.specs = specs;
  45 + }
  46 +
  47 + public String getPrice() {
  48 + return price;
  49 + }
  50 +
  51 + public void setPrice(String price) {
  52 + this.price = price;
  53 + }
  54 +
  55 + public String getMember_price() {
  56 + return member_price;
  57 + }
  58 +
  59 + public void setMember_price(String member_price) {
  60 + this.member_price = member_price;
  61 + }
  62 +
  63 + public String getClear_num() {
  64 + return clear_num;
  65 + }
  66 +
  67 + public void setClear_num(String clear_num) {
  68 + this.clear_num = clear_num;
  69 + }
  70 +}
  1 +package com.naji.xiaotao.cookbook.bean;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +import java.io.Serializable;
  7 +import java.util.ArrayList;
  8 +import java.util.List;
  9 +
  10 +public class OuterEntity implements Serializable{
  11 +
  12 + private ArrayList<CookbookEntity> list;
  13 + private int countTotal;//购物车菜品数量
  14 + private float countPirce;//购物车菜品价格
  15 +
  16 + public ArrayList<CookbookEntity> getList() {
  17 + return list;
  18 + }
  19 +
  20 + public void setList(ArrayList<CookbookEntity> list) {
  21 + this.list = list;
  22 + }
  23 +
  24 + public int getCountTotal() {
  25 + return countTotal;
  26 + }
  27 +
  28 + public void setCountTotal(int countTotal) {
  29 + this.countTotal = countTotal;
  30 + }
  31 +
  32 + public float getCountPirce() {
  33 + return countPirce;
  34 + }
  35 +
  36 + public void setCountPirce(float countPirce) {
  37 + this.countPirce = countPirce;
  38 + }
  39 +}
  1 +package com.naji.xiaotao.cookbook.bean;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +public class ReduceBean implements Parcelable {
  7 +
  8 + private String orderid;//订单id
  9 + private String cookbookid;//菜品id
  10 + private String specid;//规则id
  11 + private String practiceid;//做法id
  12 + private String title;//规格名称
  13 + private String ptitle;//做法名称
  14 + private String foodNum;//数量
  15 + private String practNum;//菜品数量
  16 +
  17 + public String getOrderid() {
  18 + return orderid;
  19 + }
  20 +
  21 + public void setOrderid(String orderid) {
  22 + this.orderid = orderid;
  23 + }
  24 +
  25 + public String getCookbookid() {
  26 + return cookbookid;
  27 + }
  28 +
  29 + public void setCookbookid(String cookbookid) {
  30 + this.cookbookid = cookbookid;
  31 + }
  32 +
  33 + public String getSpecid() {
  34 + return specid;
  35 + }
  36 +
  37 + public void setSpecid(String specid) {
  38 + this.specid = specid;
  39 + }
  40 +
  41 + public String getPracticeid() {
  42 + return practiceid;
  43 + }
  44 +
  45 + public void setPracticeid(String practiceid) {
  46 + this.practiceid = practiceid;
  47 + }
  48 +
  49 + public String getTitle() {
  50 + return title;
  51 + }
  52 +
  53 + public void setTitle(String title) {
  54 + this.title = title;
  55 + }
  56 +
  57 + public String getPtitle() {
  58 + return ptitle;
  59 + }
  60 +
  61 + public void setPtitle(String ptitle) {
  62 + this.ptitle = ptitle;
  63 + }
  64 +
  65 + public String getFoodNum() {
  66 + return foodNum;
  67 + }
  68 +
  69 + public void setFoodNum(String foodNum) {
  70 + this.foodNum = foodNum;
  71 + }
  72 +
  73 + public String getPractNum() {
  74 + return practNum;
  75 + }
  76 +
  77 + public void setPractNum(String practNum) {
  78 + this.practNum = practNum;
  79 + }
  80 +
  81 + @Override
  82 + public int describeContents() {
  83 + return 0;
  84 + }
  85 +
  86 + @Override
  87 + public void writeToParcel(Parcel dest, int flags) {
  88 + dest.writeString(this.orderid);
  89 + dest.writeString(this.cookbookid);
  90 + dest.writeString(this.specid);
  91 + dest.writeString(this.practiceid);
  92 + dest.writeString(this.title);
  93 + dest.writeString(this.ptitle);
  94 + dest.writeString(this.foodNum);
  95 + dest.writeString(this.practNum);
  96 + }
  97 +
  98 + public ReduceBean() {
  99 + }
  100 +
  101 + protected ReduceBean(Parcel in) {
  102 + this.orderid = in.readString();
  103 + this.cookbookid = in.readString();
  104 + this.specid = in.readString();
  105 + this.practiceid = in.readString();
  106 + this.title = in.readString();
  107 + this.ptitle = in.readString();
  108 + this.foodNum = in.readString();
  109 + this.practNum = in.readString();
  110 + }
  111 +
  112 + public static final Creator<ReduceBean> CREATOR = new Creator<ReduceBean>() {
  113 + @Override
  114 + public ReduceBean createFromParcel(Parcel source) {
  115 + return new ReduceBean(source);
  116 + }
  117 +
  118 + @Override
  119 + public ReduceBean[] newArray(int size) {
  120 + return new ReduceBean[size];
  121 + }
  122 + };
  123 +}