Commit 7706db63a35b77700de04f2887b5574d3cb53b28

Authored by gaiyaguang
0 parents

2018-10-10

Showing 49 changed files with 4853 additions and 0 deletions

Too many changes to show.

To preserve performance only 49 of 49+ 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
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="WizardSettings">
  4 + <option name="children">
  5 + <map>
  6 + <entry key="imageWizard">
  7 + <value>
  8 + <PersistentState />
  9 + </value>
  10 + </entry>
  11 + </map>
  12 + </option>
  13 + </component>
  14 +</project>
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="Encoding">
  4 + <file url="file://$PROJECT_DIR$/app/src/main/assets/xiaotao.jks" charset="UTF-8" />
  5 + </component>
  6 +</project>
  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$/mvvmhabit" />
  13 + </set>
  14 + </option>
  15 + <option name="resolveModulePerSourceSet" value="false" />
  16 + </GradleProjectSettings>
  17 + </option>
  18 + </component>
  19 +</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_7" 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 4
  10 + versionName "1.0.4"
  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
  1 +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"1.0.4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
No preview for this file type
No preview for this file type
No preview for this file type
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="android.permission.RECEIVE_USER_PRESENT" />
  22 + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
  23 + <uses-permission android:name="android.permission.WRITE_SETTINGS" />
  24 +
  25 + <!-- Optional. Required for location feature -->
  26 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
  27 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  28 + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  29 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  30 + <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
  31 + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
  32 + <uses-permission android:name="android.permission.GET_TASKS" />
  33 + <uses-permission android:name="android.permission.VIBRATE" />
  34 +
  35 + <uses-permission android:name="android.permission.READ_LOGS" />
  36 +
  37 + <application
  38 + android:name=".App"
  39 + android:allowBackup="true"
  40 + android:icon="@mipmap/ic_launcher"
  41 + android:label="@string/app_name"
  42 + android:roundIcon="@mipmap/ic_launcher"
  43 + android:supportsRtl="true"
  44 + android:theme="@style/AppTheme"
  45 + >
  46 + <activity android:name=".login.ui.LoginActivity"
  47 + android:screenOrientation="portrait"
  48 + >
  49 + <intent-filter>
  50 + <action android:name="android.intent.action.MAIN" />
  51 +
  52 + <category android:name="android.intent.category.LAUNCHER" />
  53 + </intent-filter>
  54 + </activity>
  55 + <activity android:name=".tangshi.ui.TangShiActivity"
  56 + android:label="控制台主页"
  57 + android:screenOrientation="portrait"
  58 + android:launchMode="singleTask"
  59 + />
  60 + <activity android:name=".cookbook.ui.CookBookMainActivity"
  61 + android:label="菜谱主页"
  62 + android:screenOrientation="portrait"
  63 + android:launchMode="singleTask"
  64 + />
  65 + <activity android:name=".cart.ui.CartActivity"
  66 + android:label="购物车"
  67 + android:screenOrientation="portrait"
  68 + android:launchMode="singleTask"
  69 + android:windowSoftInputMode="adjustPan"
  70 + />
  71 + <activity android:name=".cart.ui.RemarkActivity"
  72 + android:label="整单备注"
  73 + android:screenOrientation="portrait"
  74 + android:windowSoftInputMode="adjustPan"
  75 + />
  76 + <activity android:name=".order.ui.OrderActivity"
  77 + android:label="订单详情"
  78 + android:screenOrientation="portrait"
  79 + android:windowSoftInputMode="adjustPan"
  80 + />
  81 + <activity android:name=".pay.ui.PayActivity"
  82 + android:label="结账"
  83 + android:screenOrientation="portrait"
  84 + />
  85 + <activity android:name=".order.ui.OrderAffirmActivity"
  86 + android:label="订单确认"
  87 + android:screenOrientation="portrait"
  88 + android:windowSoftInputMode="adjustPan"
  89 + />
  90 + <activity android:name=".order.ui.OrderRetireActivity"
  91 + android:label="退菜"
  92 + android:screenOrientation="portrait"
  93 + />
  94 + <activity android:name=".receipt.ui.ReceiptActivity"
  95 + android:label="发票详情"
  96 + android:screenOrientation="portrait"
  97 + />
  98 + <activity android:name=".pay.ui.ZddzActivity"
  99 + android:label="整单打折"
  100 + android:screenOrientation="portrait"
  101 + />
  102 + <activity android:name=".pay.ui.ZdyyhActivity"
  103 + android:label="自定义优惠"
  104 + android:screenOrientation="portrait"
  105 + />
  106 + <activity android:name=".tangshi.ui.TableListActivity"
  107 + android:label="可选桌位列表"
  108 + android:screenOrientation="portrait"
  109 + />
  110 + <activity android:name=".history.ui.HistoryActivity"
  111 + android:label="历史订单"
  112 + android:screenOrientation="portrait"
  113 + android:launchMode="singleTask"
  114 + />
  115 +
  116 +
  117 +
  118 + <!--版本更新-->
  119 + <provider
  120 + android:name="android.support.v4.content.FileProvider"
  121 + android:authorities="${applicationId}.fileProvider"
  122 + android:exported="false"
  123 + android:grantUriPermissions="true">
  124 + <meta-data
  125 + android:name="android.support.FILE_PROVIDER_PATHS"
  126 + android:resource="@xml/provider_paths"/>
  127 + </provider>
  128 +
  129 +
  130 + <!-- Required SDK 核心功能-->
  131 + <!-- 可配置android:process参数将PushService放在其他进程中 -->
  132 + <service
  133 + android:name="cn.jpush.android.service.PushService"
  134 + android:enabled="true"
  135 + android:exported="false" >
  136 + <intent-filter>
  137 + <action android:name="cn.jpush.android.intent.REGISTER" />
  138 + <action android:name="cn.jpush.android.intent.REPORT" />
  139 + <action android:name="cn.jpush.android.intent.PushService" />
  140 + <action android:name="cn.jpush.android.intent.PUSH_TIME" />
  141 + </intent-filter>
  142 + </service>
  143 +
  144 +
  145 + <!-- since 3.0.9 Required SDK 核心功能-->
  146 + <provider
  147 + android:authorities="com.naji.xiaotao.DataProvider"
  148 + android:name="cn.jpush.android.service.DataProvider"
  149 + android:exported="true"
  150 + tools:replace="android:exported" />
  151 +
  152 + <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
  153 + <!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
  154 + <service
  155 + android:name="cn.jpush.android.service.DaemonService"
  156 + android:enabled="true"
  157 + android:exported="true">
  158 + <intent-filter >
  159 + <action android:name="cn.jpush.android.intent.DaemonService" />
  160 + <category android:name="com.naji.xiaotao"/>
  161 + </intent-filter>
  162 + </service>
  163 +
  164 + <!-- since 3.1.0 Required SDK 核心功能-->
  165 + <provider
  166 + android:authorities="com.naji.xiaotao.DownloadProvider"
  167 + android:name="cn.jpush.android.service.DownloadProvider"
  168 + android:exported="true"
  169 + />
  170 +
  171 + <!-- Required SDK核心功能-->
  172 + <receiver
  173 + android:name="cn.jpush.android.service.PushReceiver"
  174 + android:enabled="true" >
  175 + <intent-filter android:priority="1000">
  176 + <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
  177 + <category android:name="com.naji.xiaotao"/>
  178 + </intent-filter>
  179 + <intent-filter>
  180 + <action android:name="android.intent.action.USER_PRESENT" />
  181 + <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
  182 + </intent-filter>
  183 + <!-- Optional -->
  184 + <intent-filter>
  185 + <action android:name="android.intent.action.PACKAGE_ADDED" />
  186 + <action android:name="android.intent.action.PACKAGE_REMOVED" />
  187 + <data android:scheme="package" />
  188 + </intent-filter>
  189 + </receiver>
  190 +
  191 + <!-- Required SDK核心功能-->
  192 + <activity
  193 + android:name="cn.jpush.android.ui.PushActivity"
  194 + android:configChanges="orientation|keyboardHidden"
  195 + android:theme="@android:style/Theme.NoTitleBar"
  196 + android:exported="false" >
  197 + <intent-filter>
  198 + <action android:name="cn.jpush.android.ui.PushActivity" />
  199 + <category android:name="android.intent.category.DEFAULT" />
  200 + <category android:name="com.naji.xiaotao" />
  201 + </intent-filter>
  202 + </activity>
  203 + <!-- SDK核心功能-->
  204 + <activity
  205 + android:name="cn.jpush.android.ui.PopWinActivity"
  206 + android:configChanges="orientation|keyboardHidden"
  207 + android:exported="false"
  208 + android:theme="@style/MyDialogStyle">
  209 + <intent-filter>
  210 + <category android:name="android.intent.category.DEFAULT" />
  211 + <category android:name="com.naji.xiaotao" />
  212 + </intent-filter>
  213 + </activity>
  214 +
  215 + <!-- Required SDK核心功能-->
  216 + <service
  217 + android:name="cn.jpush.android.service.DownloadService"
  218 + android:enabled="true"
  219 + android:exported="false" >
  220 + </service>
  221 +
  222 + <!-- Required SDK核心功能-->
  223 + <receiver android:name="cn.jpush.android.service.AlarmReceiver" />
  224 +
  225 + <!-- Required since 3.0.7 -->
  226 + <!-- 新的tag/alias接口结果返回需要开发者配置一个自定的广播 -->
  227 + <!-- 该广播需要继承JPush提供的JPushMessageReceiver类, 并如下新增一个 Intent-Filter -->
  228 + <receiver
  229 + android:name=".message.receiver.TagReceiver"
  230 + android:enabled="true"
  231 + android:exported="false" >
  232 + <intent-filter>
  233 + <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
  234 + <category android:name="com.naji.xiaotao" />
  235 + </intent-filter>
  236 + </receiver>
  237 +
  238 + <!-- User defined. 用户自定义的广播接收器-->
  239 + <receiver
  240 + android:name=".message.receiver.MessageReceiver"
  241 + android:enabled="true"
  242 + android:exported="false">
  243 + <intent-filter>
  244 + <!--Required 用户注册SDK的intent-->
  245 + <action android:name="cn.jpush.android.intent.REGISTRATION" />
  246 + <!--Required 用户接收SDK消息的intent-->
  247 + <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
  248 + <!--Required 用户接收SDK通知栏信息的intent-->
  249 + <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
  250 + <!--Required 用户打开自定义通知栏的intent-->
  251 + <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
  252 + <!-- 接收网络变化 连接/断开 since 1.6.3 -->
  253 + <action android:name="cn.jpush.android.intent.CONNECTION" />
  254 + <category android:name="com.naji.xiaotao" />
  255 + </intent-filter>
  256 + </receiver>
  257 +
  258 + <!-- Required. For publish channel feature -->
  259 + <!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。-->
  260 + <!-- 例如: -->
  261 + <!-- 发到 Google Play 的APK可以设置为 google-play; -->
  262 + <!-- 发到其他市场的 APK 可以设置为 xxx-market。 -->
  263 + <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
  264 + <!-- Required. AppKey copied from Portal -->
  265 + <meta-data android:name="JPUSH_APPKEY" android:value="7d1e57b0d37d8d4cdf945912"/>
  266 +
  267 +
  268 + </application>
  269 +
  270 +</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.tangshi.ui.TangShiActivity;
  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(TangShiActivity.class);
  25 + //初始化DbFlow
  26 + FlowManager.init(this);
  27 + //初始化极光推送
  28 + JPushInterface.init(this);
  29 + JPushInterface.setDebugMode(false);
  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.text.SimpleDateFormat;
  7 +import java.util.Date;
  8 +import java.util.List;
  9 +
  10 +public class OrderEntity implements Parcelable {
  11 +
  12 + private String id;
  13 + private String no;
  14 + private String row_num;
  15 + private String pnum;
  16 + private String sellerid;
  17 + private String tableid;
  18 + private String openid;
  19 + private String price;
  20 + private String status;
  21 + private String remark;
  22 + private String remarkid;
  23 + private String type;
  24 + private String phone;
  25 + private String behavior;
  26 + private String cdate;
  27 + private String meal_fee;
  28 + private String is_clear_table;
  29 + private String tablename;
  30 + private String table_pnum;
  31 + private String qrcode;
  32 + private String sellername;
  33 + private List<RemarkItemEntity> remarkList;
  34 +
  35 + public String getId() {
  36 + return id;
  37 + }
  38 +
  39 + public void setId(String id) {
  40 + this.id = id;
  41 + }
  42 +
  43 + public String getNo() {
  44 + return no;
  45 + }
  46 +
  47 + public void setNo(String no) {
  48 + this.no = no;
  49 + }
  50 +
  51 + public String getRow_num() {
  52 + return row_num;
  53 + }
  54 +
  55 + public void setRow_num(String row_num) {
  56 + this.row_num = row_num;
  57 + }
  58 +
  59 + public String getPnum() {
  60 + return pnum;
  61 + }
  62 +
  63 + public void setPnum(String pnum) {
  64 + this.pnum = pnum;
  65 + }
  66 +
  67 + public String getSellerid() {
  68 + return sellerid;
  69 + }
  70 +
  71 + public void setSellerid(String sellerid) {
  72 + this.sellerid = sellerid;
  73 + }
  74 +
  75 + public String getTableid() {
  76 + return tableid;
  77 + }
  78 +
  79 + public void setTableid(String tableid) {
  80 + this.tableid = tableid;
  81 + }
  82 +
  83 + public String getOpenid() {
  84 + return openid;
  85 + }
  86 +
  87 + public void setOpenid(String openid) {
  88 + this.openid = openid;
  89 + }
  90 +
  91 + public String getPrice() {
  92 + return price;
  93 + }
  94 +
  95 + public void setPrice(String price) {
  96 + this.price = price;
  97 + }
  98 +
  99 + public String getStatus() {
  100 + return status;
  101 + }
  102 +
  103 + public void setStatus(String status) {
  104 + this.status = status;
  105 + }
  106 +
  107 + public String getRemark() {
  108 + return remark;
  109 + }
  110 +
  111 + public void setRemark(String remark) {
  112 + this.remark = remark;
  113 + }
  114 +
  115 + public String getRemarkid() {
  116 + return remarkid;
  117 + }
  118 +
  119 + public void setRemarkid(String remarkid) {
  120 + this.remarkid = remarkid;
  121 + }
  122 +
  123 + public String getType() {
  124 + return type;
  125 + }
  126 +
  127 + public void setType(String type) {
  128 + this.type = type;
  129 + }
  130 +
  131 + public String getPhone() {
  132 + return phone;
  133 + }
  134 +
  135 + public void setPhone(String phone) {
  136 + this.phone = phone;
  137 + }
  138 +
  139 + public String getBehavior() {
  140 + return behavior;
  141 + }
  142 +
  143 + public void setBehavior(String behavior) {
  144 + this.behavior = behavior;
  145 + }
  146 +
  147 + public String getCdate() {
  148 + return cdate;
  149 + }
  150 +
  151 + public void setCdate(String cdate) {
  152 + this.cdate = cdate;
  153 + }
  154 +
  155 + public String getMeal_fee() {
  156 + return meal_fee;
  157 + }
  158 +
  159 + public void setMeal_fee(String meal_fee) {
  160 + this.meal_fee = meal_fee;
  161 + }
  162 +
  163 + public String getIs_clear_table() {
  164 + return is_clear_table;
  165 + }
  166 +
  167 + public void setIs_clear_table(String is_clear_table) {
  168 + this.is_clear_table = is_clear_table;
  169 + }
  170 +
  171 + public String getTablename() {
  172 + return tablename;
  173 + }
  174 +
  175 + public void setTablename(String tablename) {
  176 + this.tablename = tablename;
  177 + }
  178 +
  179 + public String getTable_pnum() {
  180 + return table_pnum;
  181 + }
  182 +
  183 + public void setTable_pnum(String table_pnum) {
  184 + this.table_pnum = table_pnum;
  185 + }
  186 +
  187 + public String getQrcode() {
  188 + return qrcode;
  189 + }
  190 +
  191 + public void setQrcode(String qrcode) {
  192 + this.qrcode = qrcode;
  193 + }
  194 +
  195 + public String getSellername() {
  196 + return sellername;
  197 + }
  198 +
  199 + public void setSellername(String sellername) {
  200 + this.sellername = sellername;
  201 + }
  202 +
  203 + public List<RemarkItemEntity> getRemarkList() {
  204 + return remarkList;
  205 + }
  206 +
  207 + public void setRemarkList(List<RemarkItemEntity> remarkList) {
  208 + this.remarkList = remarkList;
  209 + }
  210 +
  211 + @Override
  212 + public int describeContents() {
  213 + return 0;
  214 + }
  215 +
  216 + @Override
  217 + public void writeToParcel(Parcel dest, int flags) {
  218 + dest.writeString(this.id);
  219 + dest.writeString(this.no);
  220 + dest.writeString(this.row_num);
  221 + dest.writeString(this.pnum);
  222 + dest.writeString(this.sellerid);
  223 + dest.writeString(this.tableid);
  224 + dest.writeString(this.openid);
  225 + dest.writeString(this.price);
  226 + dest.writeString(this.status);
  227 + dest.writeString(this.remark);
  228 + dest.writeString(this.remarkid);
  229 + dest.writeString(this.type);
  230 + dest.writeString(this.phone);
  231 + dest.writeString(this.behavior);
  232 + dest.writeString(this.cdate);
  233 + dest.writeString(this.meal_fee);
  234 + dest.writeString(this.is_clear_table);
  235 + dest.writeString(this.tablename);
  236 + dest.writeString(this.table_pnum);
  237 + dest.writeString(this.qrcode);
  238 + dest.writeString(this.sellername);
  239 + dest.writeTypedList(this.remarkList);
  240 + }
  241 +
  242 + public OrderEntity() {
  243 + }
  244 +
  245 + protected OrderEntity(Parcel in) {
  246 + this.id = in.readString();
  247 + this.no = in.readString();
  248 + this.row_num = in.readString();
  249 + this.pnum = in.readString();
  250 + this.sellerid = in.readString();
  251 + this.tableid = in.readString();
  252 + this.openid = in.readString();
  253 + this.price = in.readString();
  254 + this.status = in.readString();
  255 + this.remark = in.readString();
  256 + this.remarkid = in.readString();
  257 + this.type = in.readString();
  258 + this.phone = in.readString();
  259 + this.behavior = in.readString();
  260 + this.cdate = in.readString();
  261 + this.meal_fee = in.readString();
  262 + this.is_clear_table = in.readString();
  263 + this.tablename = in.readString();
  264 + this.table_pnum = in.readString();
  265 + this.qrcode = in.readString();
  266 + this.sellername = in.readString();
  267 + this.remarkList = in.createTypedArrayList(RemarkItemEntity.CREATOR);
  268 + }
  269 +
  270 + public static final Creator<OrderEntity> CREATOR = new Creator<OrderEntity>() {
  271 + @Override
  272 + public OrderEntity createFromParcel(Parcel source) {
  273 + return new OrderEntity(source);
  274 + }
  275 +
  276 + @Override
  277 + public OrderEntity[] newArray(int size) {
  278 + return new OrderEntity[size];
  279 + }
  280 + };
  281 +}
  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),getIntent().getStringExtra("messageid"));
  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 messageid;
  58 + private String sellerid;
  59 + private boolean isFast;//是否快餐
  60 + private List<ClearDetail> mDatas=new ArrayList<>();
  61 +
  62 + private Context context;
  63 +
  64 + @Override
  65 + public void onCreate(@Nullable Bundle savedInstanceState) {
  66 + super.onCreate(savedInstanceState);
  67 + context=getContext();
  68 + clearOutter=getArguments().getParcelable("clearOuter");
  69 + orderid=getArguments().getString("orderid");
  70 + messageid=getArguments().getString("messageid");
  71 + sellerid= SPUtils.getInstance("user_info").getString("sellerid");
  72 + isFast=getArguments().getBoolean("isFast");
  73 + mDatas.addAll(clearOutter.getMin_num());
  74 + for(ClearDetail detail:clearOutter.getClear_error()){
  75 + detail.setMin_num("0");
  76 + mDatas.add(detail);
  77 + }
  78 + }
  79 +
  80 + @Nullable
  81 + @Override
  82 + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  83 + View view=inflater.inflate(R.layout.dialog_clear,container);
  84 + mRecyclerview=view.findViewById(R.id.recyclerview);
  85 + mRecyclerview.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false));
  86 + mAdapter=new ClearAdapter(getContext(),mDatas);
  87 + mRecyclerview.setAdapter(mAdapter);
  88 + view.findViewById(R.id.think_again).setOnClickListener(new View.OnClickListener() {
  89 + @Override
  90 + public void onClick(View view) {
  91 + dismiss();
  92 + }
  93 + });
  94 + view.findViewById(R.id.place_order).setOnClickListener(new View.OnClickListener() {
  95 + @Override
  96 + public void onClick(View view) {
  97 + dismiss();
  98 + DialogUtil.showDialog(context);
  99 + for(int i=0;i<mDatas.size();i++){
  100 + ClearDetail detail=mDatas.get(i);
  101 + String id=detail.getId();
  102 + int num=Integer.parseInt(detail.getCount())-Integer.parseInt(detail.getMin_num());
  103 + String type="";
  104 + if(detail.getMin_num().equals("0")){
  105 + type="clear_error";
  106 + }else{
  107 + type="min_num";
  108 + }
  109 + clearCookbookRequest(detail.getCookbookid(),detail.getSpecid(),id,num+"",i,type);
  110 + }
  111 + }
  112 + });
  113 + return view;
  114 + }
  115 +
  116 + //去除数量不足菜品或卖光菜品
  117 + private void clearCookbookRequest(String cookbookid,String specid,String id, String num, final int i,String type){
  118 + Map<String,String> params=new HashMap<>();
  119 + params.put("orderid",orderid);
  120 + params.put("cookbookid",cookbookid);
  121 + params.put("type",type);//min_num 菜品不足 clear_error卖光了
  122 + params.put("id",id);//清楚主键idmin_
  123 + params.put("num",num);//清楚数量
  124 + if(!TextUtils.isEmpty(specid)){
  125 + params.put("specid",specid);
  126 + }
  127 + RetrofitClient.getInstance().create(CartApiService.class)
  128 + .clearCookbook(params)
  129 + .compose(RxUtils.schedulersTransformer())
  130 + .compose(RxUtils.exceptionTransformer())
  131 + .doOnSubscribe(new Consumer<Disposable>() {
  132 + @Override
  133 + public void accept(Disposable disposable) throws Exception {
  134 +
  135 + }
  136 + })
  137 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  138 + @Override
  139 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  140 + if(listBaseResponse.getRet()==200){
  141 + if(i==mDatas.size()-1){//去除掉最后一件商品后下单
  142 + placeOrderRequest();
  143 + }
  144 + }else{
  145 + DialogUtil.dismissDialog();
  146 + ToastUtils.showShort(listBaseResponse.getMsg());
  147 + }
  148 + }
  149 + }, new Consumer<ResponseThrowable>() {
  150 + @Override
  151 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  152 + DialogUtil.dismissDialog();
  153 + responseThrowable.printStackTrace();
  154 + ToastUtils.showShort(responseThrowable.msg);
  155 + }
  156 + });
  157 + }
  158 +
  159 + //下单接口
  160 + private void placeOrderRequest(){
  161 + Map<String,String> params=new HashMap<>();
  162 + params.put("sellerid",sellerid);
  163 + params.put("orderid",orderid);
  164 + if(TextUtils.isEmpty(getArguments().getString("fromSource"))){
  165 + params.put("type","1");//下单1、加菜2
  166 + }else{
  167 + params.put("type","2");//下单1、加菜2
  168 + }
  169 + params.put("identity","2");//1 顾客 2 服务员
  170 + RetrofitClient.getInstance().create(CartApiService.class)
  171 + .placeOrder(params)
  172 + .compose(RxUtils.schedulersTransformer())
  173 + .compose(RxUtils.exceptionTransformer())
  174 + .doOnSubscribe(new Consumer<Disposable>() {
  175 + @Override
  176 + public void accept(Disposable disposable) throws Exception {
  177 +
  178 + }
  179 + })
  180 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  181 + @Override
  182 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  183 + DialogUtil.dismissDialog();
  184 + if(listBaseResponse.getRet()==200){
  185 + if (!TextUtils.isEmpty(messageid)){
  186 + getAppHandle(messageid);
  187 + }
  188 + final RightDialog dialog=new RightDialog();
  189 + Bundle bundle=new Bundle();
  190 + bundle.putString("msg","下单成功");
  191 + dialog.setArguments(bundle);
  192 + new Handler().postDelayed(new Runnable() {
  193 + @Override
  194 + public void run() {
  195 + dialog.dismiss();
  196 + if(isFast){//快速点餐直接跳到订单详情
  197 + Intent intent=new Intent(context, OrderActivity.class);
  198 + intent.putExtra("orderid",orderid);
  199 + context.startActivity(intent);
  200 + }else{
  201 + context.startActivity(new Intent(context, TangShiActivity.class));
  202 + }
  203 + }
  204 + }, 1000);
  205 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"rightDialog");
  206 + }else{
  207 + ToastUtils.showShort(listBaseResponse.getMsg());
  208 + }
  209 + }
  210 + }, new Consumer<ResponseThrowable>() {
  211 + @Override
  212 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  213 + DialogUtil.dismissDialog();
  214 + responseThrowable.printStackTrace();
  215 + ToastUtils.showShort(responseThrowable.msg);
  216 + }
  217 + });
  218 + }
  219 +
  220 + //告诉后台前端消息已处理
  221 + private void getAppHandle(String messageid){
  222 + Map<String,String> params=new HashMap<>();
  223 + params.put("message_id",messageid);
  224 + RetrofitClient.getInstance().create(TangshiApiService.class)
  225 + .getAppHandle(params)
  226 + .compose(RxUtils.schedulersTransformer())
  227 + .compose(RxUtils.exceptionTransformer())
  228 + .doOnSubscribe(new Consumer<Disposable>() {
  229 + @Override
  230 + public void accept(Disposable disposable) throws Exception {
  231 +
  232 + }
  233 + })
  234 + .subscribe(new Consumer<BaseResponse<String>>() {
  235 + @Override
  236 + public void accept(BaseResponse<String> stringBaseResponse) throws Exception {
  237 + if(stringBaseResponse.getRet()==200){}
  238 + }
  239 + }, new Consumer<Throwable>() {
  240 + @Override
  241 + public void accept(Throwable throwable) throws Exception {
  242 +
  243 + }
  244 + });
  245 + }
  246 +
  247 + @Override
  248 + public void onStart() {
  249 + super.onStart();
  250 + getDialog().setCanceledOnTouchOutside(false);
  251 + Window window=getDialog().getWindow();
  252 + WindowManager.LayoutParams lp=window.getAttributes();
  253 + DisplayMetrics dm=new DisplayMetrics();
  254 + window.getWindowManager().getDefaultDisplay().getMetrics(dm);
  255 + window.setLayout((int) (dm.widthPixels*0.9),ViewGroup.LayoutParams.WRAP_CONTENT);
  256 + }
  257 +
  258 +
  259 +}
  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 + private boolean isWaitingSure;//待确认订单
  39 + public CartCookbookDetail entity;
  40 + public ObservableField<String> title=new ObservableField<>();//标题栏显示
  41 + public ObservableField<String> count=new ObservableField<>();
  42 +
  43 + private Disposable mSubscription;
  44 +
  45 +
  46 + public CartItemViewModel(Context context,CartCookbookDetail entity,String orderid,String fromSource,boolean isWaitingSure){
  47 + super(context);
  48 + this.entity=entity;
  49 + this.orderid=orderid;
  50 + this.fromSource=fromSource;
  51 + this.isWaitingSure=isWaitingSure;
  52 + count.set(entity.getCount());
  53 + if(entity.getTitleName().equals("其它")){
  54 + title.set(entity.getClass_name());
  55 + if(entity.getName()!=null&&entity.getName().equals("餐位费")){
  56 + mSubscription=RxBus.getDefault().toObservable(Integer.class).subscribe(new Consumer<Integer>() {
  57 + @Override
  58 + public void accept(Integer integer) throws Exception {
  59 + count.set(integer+"");
  60 + KLog.d("count:"+count.get().toString());
  61 + }
  62 + });
  63 + RxSubscriptions.add(mSubscription);
  64 + }
  65 + }else{
  66 + title.set(entity.getClass_name()+"("+entity.getSize()+")");
  67 + }
  68 + }
  69 +
  70 + @Override
  71 + public void onDestroy() {
  72 + super.onDestroy();
  73 + if(entity.getName().equals("餐位费")){
  74 + RxSubscriptions.remove(mSubscription);
  75 + }
  76 + }
  77 +
  78 + //减菜按钮
  79 + public BindingCommand onReduceClickCommand=new BindingCommand(new BindingAction() {
  80 + @Override
  81 + public void call() {
  82 + KLog.d("------------------");
  83 + reduceCookFromCart();
  84 + }
  85 + });
  86 +
  87 + //加菜按钮
  88 + public BindingCommand onAddClickCommand=new BindingCommand(new BindingAction() {
  89 + @Override
  90 + public void call() {
  91 + KLog.d("+++++++++++++++++");
  92 + addCookToCart();
  93 + }
  94 + });
  95 +
  96 + //添加菜品到购物车
  97 + private void addCookToCart(){
  98 + Map<String,String> params=new HashMap<>();
  99 + params.put("orderid",orderid);
  100 + params.put("openid",entity.getOpenid());
  101 + params.put("cookbookid",entity.getCookbookid());
  102 + params.put("identity","2");
  103 + if(TextUtils.isEmpty(entity.getSpecs())){
  104 + params.put("price",entity.getPrice());
  105 + }else{
  106 + params.put("price",entity.getSpec_price());
  107 + }
  108 +
  109 + if(!TextUtils.isEmpty(entity.getSpecid())){
  110 + params.put("specid",entity.getSpecid());
  111 + }
  112 + if(!TextUtils.isEmpty(entity.getPracticeid())){
  113 + params.put("practiceid",entity.getPracticeid());
  114 + }
  115 + if(!TextUtils.isEmpty(fromSource)){
  116 + params.put("fromSoucre",fromSource);
  117 + }
  118 + RetrofitClient.getInstance().create(CookbookApiService.class)
  119 + .addCookToCart(params)
  120 + .compose(RxUtils.schedulersTransformer())
  121 + .compose(RxUtils.exceptionTransformer())
  122 + .doOnSubscribe(new Consumer<Disposable>() {
  123 + @Override
  124 + public void accept(Disposable disposable) throws Exception {
  125 +
  126 + }
  127 + })
  128 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  129 + @Override
  130 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  131 + if(baseResponse.getRet()==200){
  132 + count.set((Integer.parseInt(count.get())+1)+"");
  133 + int countTotal=baseResponse.getData().get(0).getCountTotal();
  134 + float countPrice=baseResponse.getData().get(0).getCountPirce();
  135 + String title="已点"+countTotal+"个菜,共计¥"+countPrice;
  136 + RxBus.getDefault().post(title);
  137 + }else{
  138 + ToastUtils.showShort(baseResponse.getMsg());
  139 + }
  140 + }
  141 + }, new Consumer<ResponseThrowable>() {
  142 + @Override
  143 + public void accept(ResponseThrowable throwable) throws Exception {
  144 + ToastUtils.showShort(throwable.msg);
  145 + throwable.printStackTrace();
  146 + }
  147 + });
  148 + }
  149 + //删减菜品从购物车
  150 + private void reduceCookFromCart(){
  151 + Map<String,String> params=new HashMap<>();
  152 + params.put("orderid",orderid);
  153 + params.put("openid",entity.getOpenid());
  154 + params.put("cookbookid",entity.getCookbookid());
  155 + params.put("identity","2");
  156 + if(!TextUtils.isEmpty(entity.getSpecid())){
  157 + params.put("specid",entity.getSpecid());
  158 + }
  159 + if(!TextUtils.isEmpty(entity.getPracticeid())){
  160 + params.put("practiceid",entity.getPracticeid());
  161 + }
  162 + if(!TextUtils.isEmpty(fromSource)){
  163 + params.put("fromSoucre",fromSource);
  164 + }
  165 + if(isWaitingSure){
  166 + params.put("request_uri","1");
  167 + }
  168 + RetrofitClient.getInstance().create(CookbookApiService.class)
  169 + .reduceCookFromCart(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<ResultEntity>>>() {
  179 + @Override
  180 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  181 + if(baseResponse.getRet()==200){
  182 + count.set((Integer.parseInt(count.get())-1)+"");
  183 + int countTotal=baseResponse.getData().get(0).getCountTotal();
  184 + float countPrice=baseResponse.getData().get(0).getCountPirce();
  185 + String title="已点"+countTotal+"个菜,共计¥"+countPrice;
  186 + RxBus.getDefault().post(title);
  187 + if(Integer.parseInt(count.get())==0){
  188 + Messenger.getDefault().send(CartItemViewModel.this,CartViewModel.TOKEN_DELETE_ITEM);
  189 + }
  190 + }else{
  191 + ToastUtils.showShort(baseResponse.getMsg());
  192 + }
  193 + }
  194 + }, new Consumer<ResponseThrowable>() {
  195 + @Override
  196 + public void accept(ResponseThrowable throwable) throws Exception {
  197 + ToastUtils.showShort(throwable.msg);
  198 + throwable.printStackTrace();
  199 + }
  200 + });
  201 + }
  202 +}
  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.service.TangshiApiService;
  42 +import com.naji.xiaotao.tangshi.ui.TangShiActivity;
  43 +
  44 +import java.text.DecimalFormat;
  45 +import java.util.ArrayList;
  46 +import java.util.HashMap;
  47 +import java.util.List;
  48 +import java.util.Map;
  49 +
  50 +import io.reactivex.disposables.Disposable;
  51 +import io.reactivex.functions.Consumer;
  52 +import me.goldze.mvvmhabit.base.BaseViewModel;
  53 +import me.goldze.mvvmhabit.base.TitleViewModel;
  54 +import me.goldze.mvvmhabit.binding.command.BindingAction;
  55 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  56 +import me.goldze.mvvmhabit.binding.command.BindingConsumer;
  57 +import me.goldze.mvvmhabit.bus.Messenger;
  58 +import me.goldze.mvvmhabit.bus.RxBus;
  59 +import me.goldze.mvvmhabit.bus.RxSubscriptions;
  60 +import me.goldze.mvvmhabit.http.BaseResponse;
  61 +import me.goldze.mvvmhabit.http.ResponseThrowable;
  62 +import me.goldze.mvvmhabit.utils.KLog;
  63 +import me.goldze.mvvmhabit.utils.MaterialDialogUtils;
  64 +import me.goldze.mvvmhabit.utils.RxUtils;
  65 +import me.goldze.mvvmhabit.utils.SPUtils;
  66 +import me.goldze.mvvmhabit.utils.ToastUtils;
  67 +import me.tatarka.bindingcollectionadapter2.ItemBinding;
  68 +import me.tatarka.bindingcollectionadapter2.OnItemBind;
  69 +
  70 +public class CartViewModel extends BaseViewModel{
  71 +
  72 + public static final String TOKEN_DELETE_ITEM="token_delete_item";//删减一个菜品item
  73 +
  74 + public ObservableField<String> no=new ObservableField<>();//单号
  75 + public ObservableField<String> pnum=new ObservableField<>();//当前用餐人数
  76 + public ObservableField<String> tableid=new ObservableField<>();//台号
  77 + public ObservableInt tableVisibility=new ObservableInt(View.GONE);//是否显示台号
  78 + public ObservableField<String> remark=new ObservableField<>();//备注
  79 + public ObservableField<String> title=new ObservableField<>();//list标题
  80 +
  81 + private String orderid;//订单id
  82 +
  83 + public OrderEntity orderEntity;
  84 +
  85 + private ArrayList<CartCookbook> cLists=new ArrayList<>();
  86 +
  87 + private OnRequestFocusListener onRequestFocusListener;
  88 +
  89 +
  90 + private Disposable mSubscription;//订阅者
  91 +
  92 + public TitleViewModel titleViewModel;
  93 +
  94 + private float countPrice;//订单金额
  95 + private int countTotal;//订单人数
  96 +
  97 + public String isSetMealFee;//是否设置餐位费
  98 + private String meelFee;//餐位费
  99 +
  100 + private float ortherMoney=0.00f;//餐位费
  101 +
  102 + private String fromSource;//加菜
  103 + private boolean isFast;//是否快餐
  104 + private boolean isWaitingSure;//待确认
  105 + private String messageid;//消息id
  106 +
  107 + public CartViewModel(Context context,String orderid,OnRequestFocusListener onRequestFocusListener,String fromSource,boolean isFast,boolean isWaitingSure,String messageid){
  108 + super(context);
  109 + this.orderid=orderid;
  110 + this.onRequestFocusListener=onRequestFocusListener;
  111 + this.titleViewModel=new TitleViewModel(context,"购物车");
  112 + this.fromSource=fromSource;
  113 + this.isFast=isFast;
  114 + this.isWaitingSure=isWaitingSure;
  115 + this.messageid=messageid;
  116 + }
  117 +
  118 + public interface OnRequestFocusListener{
  119 + //人数输入框获取焦点
  120 + void onPnumRequestFocus();
  121 + //备注获取焦点
  122 + void onRemardRequestFocus();
  123 + }
  124 +
  125 + @Override
  126 + public void onStart() {
  127 + super.onStart();
  128 + getOrderDetail();
  129 + }
  130 +
  131 + @Override
  132 + public void registerRxBus() {
  133 + super.registerRxBus();
  134 + //监听总的菜品数量和价格变化
  135 + mSubscription=RxBus.getDefault().toObservable(String.class).subscribe(new Consumer<String>() {
  136 + @Override
  137 + public void accept(String s) throws Exception {
  138 + if(s.contains("¥")){
  139 + countPrice=Float.parseFloat(s.substring(s.indexOf("¥")+1));
  140 + String all= new DecimalFormat("##0.00").format(countPrice+ortherMoney);
  141 + title.set(s.substring(0,s.indexOf("¥")+1)+all);
  142 + }
  143 + }
  144 + });
  145 + RxSubscriptions.add(mSubscription);
  146 + //监听删除掉一个菜品Item
  147 + Messenger.getDefault().register(context, TOKEN_DELETE_ITEM, CartItemViewModel.class, new BindingConsumer<CartItemViewModel>() {
  148 + @Override
  149 + public void call(CartItemViewModel cartItemViewModel) {
  150 + int titleIndex=Integer.parseInt(cartItemViewModel.entity.getTag());
  151 + KLog.d("titleIndex",titleIndex);
  152 + KLog.d("size",observableList.size());
  153 + int size=observableList.get(titleIndex).entity.getSize();
  154 + observableList.get(titleIndex).title.set(cartItemViewModel.entity.getClass_name()+"("+(size-1)+")");
  155 + observableList.get(titleIndex).entity.setSize(--size);
  156 + KLog.d("titleIndex:"+titleIndex+"size:"+size);
  157 + if(size==0){//只剩标题,删除标题
  158 + observableList.remove(titleIndex);
  159 + }
  160 + observableList.remove(cartItemViewModel);
  161 + }
  162 + });
  163 + }
  164 +
  165 + @Override
  166 + public void removeRxBus() {
  167 + super.removeRxBus();
  168 + RxSubscriptions.remove(mSubscription);
  169 + Messenger.getDefault().unregister(context,TOKEN_DELETE_ITEM);
  170 + }
  171 +
  172 +
  173 + public ObservableList<CartItemViewModel> observableList=new ObservableArrayList<>();
  174 + public OnItemBind<CartItemViewModel> onItemBind=new OnItemBind<CartItemViewModel>() {
  175 + @Override
  176 + public void onItemBind(ItemBinding itemBinding, int position, CartItemViewModel item) {
  177 + itemBinding.set(BR.viewModel,item.entity.isTitle()? R.layout.cart_item_title:R.layout.cart_item_content);
  178 + }
  179 + };
  180 +
  181 + //修改就餐人数
  182 + public BindingCommand onPnumClick=new BindingCommand(new BindingAction() {
  183 + @Override
  184 + public void call() {
  185 + if(onRequestFocusListener!=null){
  186 + onRequestFocusListener.onPnumRequestFocus();
  187 + }
  188 + }
  189 + });
  190 +
  191 + //修改备注
  192 + public BindingCommand onRemarkClick=new BindingCommand(new BindingAction() {
  193 + @Override
  194 + public void call() {
  195 + Bundle bundle=new Bundle();
  196 + bundle.putString("orderid",orderid);
  197 + bundle.putString("remarkid",orderEntity.getRemarkid());
  198 + bundle.putString("remark",orderEntity.getRemark());
  199 + startActivity(RemarkActivity.class,bundle);
  200 + }
  201 + });
  202 +
  203 + //获取订单详情
  204 + private void getOrderDetail(){
  205 + HashMap<String,String> params=new HashMap<>();
  206 + params.put("orderid",orderid);
  207 + if(isWaitingSure){
  208 + params.put("status","2");//2 待确认菜品
  209 + }else{
  210 + params.put("status","0");//0 购物车中菜品 1 已下单菜品
  211 + }
  212 +
  213 +
  214 + RetrofitClient.getInstance().create(CartApiService.class)
  215 + .getOrderById(params)
  216 + .compose(RxUtils.schedulersTransformer())
  217 + .compose(RxUtils.exceptionTransformer())
  218 + .doOnSubscribe(new Consumer<Disposable>() {
  219 + @Override
  220 + public void accept(Disposable disposable) throws Exception {
  221 + showDialog();
  222 + }
  223 + })
  224 + .subscribe(new Consumer<BaseResponse<List<CartEntity>>>() {
  225 +
  226 + @Override
  227 + public void accept(BaseResponse<List<CartEntity>> listBaseResponse) throws Exception {
  228 + dismissDialog();
  229 + if(listBaseResponse.getRet()==200){
  230 + orderEntity=listBaseResponse.getData().get(0).getOrder().get(0);
  231 + no.set("单号:"+orderEntity.getRow_num());
  232 + pnum.set(orderEntity.getPnum());
  233 + tableid.set("台号:"+orderEntity.getTablename());
  234 + if(orderEntity.getTablename().equals("快餐")){
  235 + tableVisibility.set(View.GONE);
  236 + }else{
  237 + tableVisibility.set(View.VISIBLE);
  238 + }
  239 + StringBuilder builder=new StringBuilder();
  240 + if(orderEntity.getRemarkList()!=null&&orderEntity.getRemarkList().size()>0){
  241 + for(RemarkItemEntity itemEntity:orderEntity.getRemarkList()){
  242 + builder.append(itemEntity.getRemark()+",");
  243 + }
  244 + }
  245 + if(!TextUtils.isEmpty(orderEntity.getRemark())){
  246 + builder.append(orderEntity.getRemark()+",");
  247 + }
  248 + if(builder.length()>0){
  249 + remark.set(builder.toString().substring(0,builder.toString().length()-1));
  250 + }else{
  251 + remark.set("");
  252 + }
  253 + countTotal=listBaseResponse.getData().get(0).getCountTotal();
  254 + countPrice=listBaseResponse.getData().get(0).getCountPirce();
  255 + cLists.clear();
  256 + cLists.addAll(listBaseResponse.getData().get(0).getCookbooklist());
  257 + getSellerConfig();
  258 + }else{
  259 + ToastUtils.showShort(listBaseResponse.getMsg());
  260 + }
  261 + }
  262 + }, new Consumer<ResponseThrowable>() {
  263 + @Override
  264 + public void accept(ResponseThrowable throwable) throws Exception {
  265 + dismissDialog();
  266 + ToastUtils.showShort(throwable.msg);
  267 + throwable.printStackTrace();
  268 + }
  269 + });
  270 + }
  271 +
  272 + //获取商家配置
  273 + private void getSellerConfig(){
  274 + Map<String,String> params=new HashMap<>();
  275 + params.put("sellerid",SPUtils.getInstance("user_info").getString("sellerid"));
  276 + params.put("type","1");//1堂食配置 2外卖配置
  277 + RetrofitClient.getInstance().create(LoginApiService.class)
  278 + .getSellerConfig(params)
  279 + .compose(RxUtils.schedulersTransformer())
  280 + .compose(RxUtils.exceptionTransformer())
  281 + .doOnSubscribe(new Consumer<Disposable>() {
  282 + @Override
  283 + public void accept(Disposable disposable) throws Exception {
  284 +
  285 + }
  286 + })
  287 + .subscribe(new Consumer<BaseResponse<List<SellerConfig>>>() {
  288 + @Override
  289 + public void accept(BaseResponse<List<SellerConfig>> listBaseResponse) throws Exception {
  290 + if(listBaseResponse.getRet()==200){
  291 + KLog.d("sssssssssssss");
  292 + isSetMealFee=listBaseResponse.getData().get(0).getIs_set_meal_fee();
  293 + meelFee=listBaseResponse.getData().get(0).getMeal_fee();
  294 + if(isSetMealFee.equals("1")){
  295 + ortherMoney=Float.parseFloat(meelFee)*Integer.parseInt(orderEntity.getPnum());
  296 + }
  297 + String all= new DecimalFormat("##0.00").format(countPrice+ortherMoney);
  298 + title.set("已点"+countTotal+"个菜,共计¥"+all);
  299 + initCookbookList();
  300 + }
  301 + }
  302 +
  303 + }, new Consumer<ResponseThrowable>() {
  304 + @Override
  305 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  306 +
  307 + }
  308 + });
  309 + }
  310 +
  311 + private void initCookbookList(){
  312 + observableList.clear();
  313 + int tag=0;
  314 + for(int i=0;i<cLists.size();i++){
  315 + CartCookbookDetail head=new CartCookbookDetail();
  316 + head.setTitle(true);
  317 + head.setClass_name(cLists.get(i).getClass_name());
  318 + head.setTitleName(cLists.get(i).getClass_name()+"("+cLists.get(i).getList().size()+")");
  319 + head.setTag(String.valueOf(tag));
  320 + head.setSize(cLists.get(i).getList().size());
  321 + observableList.add(new CartItemViewModel(context,head,orderid,fromSource,isWaitingSure));
  322 + int titleIndex=tag;
  323 + for(int j=0;j<cLists.get(i).getList().size();j++){
  324 + tag++;
  325 + CartCookbookDetail content=cLists.get(i).getList().get(j);
  326 + content.setTitleName(cLists.get(i).getClass_name()+"("+cLists.get(i).getList().size()+")");
  327 + content.setTag(String.valueOf(titleIndex));
  328 + observableList.add(new CartItemViewModel(context,content,orderid,fromSource,isWaitingSure));
  329 + }
  330 + tag++;
  331 + }
  332 + if(isSetMealFee.equals("1")){
  333 + CartCookbookDetail head=new CartCookbookDetail();
  334 + head.setTitle(true);
  335 + head.setClass_name("其它");
  336 + head.setTitleName("其它");
  337 + observableList.add(new CartItemViewModel(context,head,orderid,fromSource,isWaitingSure));
  338 + CartCookbookDetail content=new CartCookbookDetail();
  339 + content.setTitleName("其它");
  340 + content.setName("餐位费");
  341 + content.setPrice(meelFee);
  342 + content.setUnit("位");
  343 + content.setCount(orderEntity.getPnum());
  344 + observableList.add(new CartItemViewModel(context,content,orderid,fromSource,isWaitingSure));
  345 + }
  346 + }
  347 +
  348 + //修改人数
  349 + public BindingCommand textChangeCommand=new BindingCommand(new BindingConsumer<String>() {
  350 + @Override
  351 + public void call(String s) {
  352 + if(!TextUtils.isEmpty(s)){
  353 + int pnum=Integer.parseInt(s);
  354 + if(isSetMealFee!=null&&isSetMealFee.equals("1")){
  355 + ortherMoney=Float.parseFloat(meelFee)* pnum;
  356 + String titleText=title.get().toString();
  357 + KLog.d("titleText:"+titleText);
  358 + String all= new DecimalFormat("##0.00").format(countPrice+ortherMoney);
  359 + title.set(titleText.substring(0,titleText.indexOf("¥")+1)+all);
  360 + KLog.d(countPrice);
  361 + KLog.d(ortherMoney);
  362 + KLog.d("title:"+(titleText.substring(0,titleText.indexOf("¥")+1)));
  363 + RxBus.getDefault().post(pnum);
  364 + }
  365 + setOrderById(pnum);
  366 + }
  367 + }
  368 + });
  369 +
  370 + //继续点菜
  371 + public BindingCommand onContinueClickCommand=new BindingCommand(new BindingAction() {
  372 + @Override
  373 + public void call() {
  374 + Intent intent=new Intent(context,CookBookMainActivity.class);
  375 + intent.putExtra("orderid",orderid);
  376 + intent.putExtra("isFast",isFast);
  377 + intent.putExtra("fromSource",fromSource);
  378 + intent.putExtra("messageid",messageid);
  379 + intent.putExtra("isWaitingSure",isWaitingSure);
  380 + context.startActivity(intent);
  381 + }
  382 + });
  383 +
  384 + //点击确认下单按钮
  385 + public BindingCommand onSureClickCommand=new BindingCommand(new BindingAction() {
  386 + @Override
  387 + public void call() {
  388 + setClearNum();
  389 + }
  390 + });
  391 +
  392 +
  393 + //修改订单人数备注
  394 + private void setOrderById(int pnum){
  395 + Map<String,String> params=new HashMap<>();
  396 + params.put("orderid",orderid);
  397 + params.put("pnum",pnum+"");
  398 + RetrofitClient.getInstance().create(CartApiService.class)
  399 + .setOrderById(params)
  400 + .compose(RxUtils.schedulersTransformer())
  401 + .compose(RxUtils.exceptionTransformer())
  402 + .doOnSubscribe(new Consumer<Disposable>() {
  403 + @Override
  404 + public void accept(Disposable disposable) throws Exception {
  405 + }
  406 + })
  407 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  408 + @Override
  409 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  410 +
  411 + if(listBaseResponse.getRet()==200){
  412 +
  413 + }else{
  414 + ToastUtils.showShort(listBaseResponse.getMsg());
  415 + }
  416 + }
  417 + }, new Consumer<ResponseThrowable>() {
  418 + @Override
  419 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  420 + responseThrowable.printStackTrace();
  421 + ToastUtils.showShort(responseThrowable.msg);
  422 + }
  423 + });
  424 + }
  425 +
  426 + //下单时检测菜品是否充足
  427 + private void setClearNum(){
  428 + if(TextUtils.isEmpty(pnum.get())){
  429 + ToastUtils.showShort("请输入用餐人数");
  430 + return;
  431 + }
  432 + Map<String,String> params=new HashMap<>();
  433 + params.put("orderid",orderEntity.getId());
  434 + if(TextUtils.isEmpty(fromSource)){
  435 + params.put("type","1");//下单1、加菜2
  436 + }else{
  437 + params.put("type","2");//下单1、加菜2
  438 + }
  439 +
  440 + params.put("identity","2");//1 顾客 2 服务员
  441 + RetrofitClient.getInstance().create(CartApiService.class)
  442 + .setClearNum(params)
  443 + .compose(RxUtils.schedulersTransformer())
  444 + .compose(RxUtils.exceptionTransformer())
  445 + .doOnSubscribe(new Consumer<Disposable>() {
  446 + @Override
  447 + public void accept(Disposable disposable) throws Exception {
  448 + showDialog();
  449 + }
  450 + })
  451 + .subscribe(new Consumer<BaseResponse<List<ClearOutter>>>() {
  452 + @Override
  453 + public void accept(BaseResponse<List<ClearOutter>> listBaseResponse) throws Exception {
  454 + if(listBaseResponse.getRet()==200){
  455 + if(listBaseResponse.getData().size()==0){//没有仓储不足菜品直接下单
  456 + placeOrder();
  457 + }else{
  458 + dismissDialog();
  459 + ClearDialogFragment dialog=new ClearDialogFragment();
  460 + Bundle bundle=new Bundle();
  461 + bundle.putParcelable("clearOuter",listBaseResponse.getData().get(0));
  462 + bundle.putString("orderid",orderid);
  463 + bundle.putString("fromSource",fromSource);
  464 + bundle.putBoolean("isFast",isFast);
  465 + bundle.putString("messageid",messageid);
  466 + dialog.setArguments(bundle);
  467 + dialog.show(((CartActivity)context).getSupportFragmentManager(),"clearFragment");
  468 + }
  469 + }else{
  470 + dismissDialog();
  471 + ToastUtils.showShort(listBaseResponse.getMsg());
  472 + }
  473 + }
  474 + }, new Consumer<ResponseThrowable>() {
  475 + @Override
  476 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  477 + dismissDialog();
  478 + responseThrowable.printStackTrace();
  479 + ToastUtils.showShort(responseThrowable.msg);
  480 + }
  481 + });
  482 + }
  483 +
  484 + //下单接口
  485 + private void placeOrder(){
  486 + Map<String,String> params=new HashMap<>();
  487 + params.put("sellerid",orderEntity.getSellerid());
  488 + params.put("orderid",orderEntity.getId());
  489 + if(TextUtils.isEmpty(fromSource)){
  490 + params.put("type","1");//下单1、加菜2
  491 + }else{
  492 + params.put("type","2");//下单1、加菜2
  493 + }
  494 + params.put("identity","2");//1 顾客 2 服务员
  495 + RetrofitClient.getInstance().create(CartApiService.class)
  496 + .placeOrder(params)
  497 + .compose(RxUtils.schedulersTransformer())
  498 + .compose(RxUtils.exceptionTransformer())
  499 + .doOnSubscribe(new Consumer<Disposable>() {
  500 + @Override
  501 + public void accept(Disposable disposable) throws Exception {
  502 +
  503 + }
  504 + })
  505 + .subscribe(new Consumer<BaseResponse<List<String>>>() {
  506 + @Override
  507 + public void accept(BaseResponse<List<String>> listBaseResponse) throws Exception {
  508 + dismissDialog();
  509 + if(listBaseResponse.getRet()==200){
  510 + if(!TextUtils.isEmpty(messageid)){
  511 + getAppHandle(messageid);
  512 + }
  513 + final RightDialog dialog=new RightDialog();
  514 + Bundle bundle=new Bundle();
  515 + bundle.putString("msg","下单成功");
  516 + dialog.setArguments(bundle);
  517 + new Handler().postDelayed(new Runnable() {
  518 + @Override
  519 + public void run() {
  520 + dialog.dismiss();
  521 + if(isFast){//快速点餐直接跳到订单详情
  522 + Intent intent=new Intent(context, OrderActivity.class);
  523 + intent.putExtra("orderid",orderid);
  524 + context.startActivity(intent);
  525 + }else{
  526 + startActivity(TangShiActivity.class);
  527 + }
  528 + }
  529 + },1000);
  530 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"rightDialog");
  531 + }else{
  532 + ToastUtils.showShort(listBaseResponse.getMsg());
  533 + }
  534 + }
  535 + }, new Consumer<ResponseThrowable>() {
  536 + @Override
  537 + public void accept(ResponseThrowable responseThrowable) throws Exception {
  538 + dismissDialog();
  539 + responseThrowable.printStackTrace();
  540 + ToastUtils.showShort(responseThrowable.msg);
  541 + }
  542 + });
  543 + }
  544 +
  545 + //告诉后台前端消息已处理
  546 + private void getAppHandle(String messageid){
  547 + Map<String,String> params=new HashMap<>();
  548 + params.put("message_id",messageid);
  549 + RetrofitClient.getInstance().create(TangshiApiService.class)
  550 + .getAppHandle(params)
  551 + .compose(RxUtils.schedulersTransformer())
  552 + .compose(RxUtils.exceptionTransformer())
  553 + .doOnSubscribe(new Consumer<Disposable>() {
  554 + @Override
  555 + public void accept(Disposable disposable) throws Exception {
  556 +
  557 + }
  558 + })
  559 + .subscribe(new Consumer<BaseResponse<String>>() {
  560 + @Override
  561 + public void accept(BaseResponse<String> stringBaseResponse) throws Exception {
  562 + if(stringBaseResponse.getRet()==200){}
  563 + }
  564 + }, new Consumer<Throwable>() {
  565 + @Override
  566 + public void accept(Throwable throwable) throws Exception {
  567 +
  568 + }
  569 + });
  570 + }
  571 +}
  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 +import android.support.v7.widget.RecyclerView;
  6 +
  7 +import com.jcodecraeer.xrecyclerview.XRecyclerView;
  8 +import com.naji.xiaotao.widget.LayoutManagers;
  9 +
  10 +import me.goldze.mvvmhabit.binding.command.BindingCommand;
  11 +
  12 +public class ViewAdapter {
  13 +
  14 + @BindingAdapter(value = {"onRefreshCommand","onLoadMoreCommand"},requireAll = false)
  15 + public static void onRefreshCommand(XRecyclerView xRecyclerView, final BindingCommand onRefreshCommand, final BindingCommand onLoadMoreCommand){
  16 + xRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
  17 + @Override
  18 + public void onRefresh() {
  19 + if(onRefreshCommand!=null){
  20 + onRefreshCommand.execute();
  21 + }
  22 + }
  23 +
  24 + @Override
  25 + public void onLoadMore() {
  26 + if(onLoadMoreCommand!=null){
  27 + onLoadMoreCommand.execute();
  28 + }
  29 + }
  30 + });
  31 + }
  32 +
  33 + @BindingAdapter("layoutManager")
  34 + public static void setLayoutManager(RecyclerView recyclerView, LayoutManagers.LayoutManagerFactory layoutManagerFactory) {
  35 + recyclerView.setLayoutManager(layoutManagerFactory.create(recyclerView));
  36 + }
  37 +
  38 + @BindingAdapter(value = {"OnTabSelectCommand"},requireAll = false)
  39 + public static void onTabSelectCommand(TabLayout tabLayout,final BindingCommand<Integer> onTabSelectCommand){
  40 + tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
  41 + @Override
  42 + public void onTabSelected(TabLayout.Tab tab) {
  43 + onTabSelectCommand.execute(tab.getPosition());
  44 + }
  45 +
  46 + @Override
  47 + public void onTabUnselected(TabLayout.Tab tab) {
  48 +
  49 + }
  50 +
  51 + @Override
  52 + public void onTabReselected(TabLayout.Tab tab) {
  53 +
  54 + }
  55 + });
  56 + }
  57 +}
  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 + private boolean showIcon=true;
  19 +
  20 + @Override
  21 + public void onCreate(@Nullable Bundle savedInstanceState) {
  22 + super.onCreate(savedInstanceState);
  23 + showIcon=getArguments().getBoolean("showIcon",true);
  24 + }
  25 +
  26 + @Nullable
  27 + @Override
  28 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
  29 + getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
  30 + getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  31 + getDialog().setCanceledOnTouchOutside(false);
  32 + View view=inflater.inflate(R.layout.dialog_right,container);
  33 + ((TextView)view.findViewById(R.id.message)).setText(getArguments().getString("msg"));
  34 + if(showIcon){
  35 + view.findViewById(R.id.icon).setVisibility(View.VISIBLE);
  36 + }else{
  37 + view.findViewById(R.id.icon).setVisibility(View.GONE);
  38 + }
  39 + return view;
  40 + }
  41 +}
  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 + private boolean isWaitingSure;
  49 +
  50 + public ClassifyDetailAdapter(Context context, List<CookbookDetailEntity> list, String orderid,String fromSource,boolean isWaitingSure,RvListener listener) {
  51 + super(context, list, listener);
  52 + this.context=context;
  53 + this.orderid=orderid;
  54 + this.fromSource=fromSource;
  55 + this.isWaitingSure=isWaitingSure;
  56 + }
  57 +
  58 +
  59 + @Override
  60 + protected int getLayoutId(int viewType) {
  61 + return viewType == 0 ? R.layout.cookbook_item_title : R.layout.cookbook_item__detail;
  62 + }
  63 +
  64 + @Override
  65 + public int getItemViewType(int position) {
  66 + return list.get(position).isTitle() ? 0 : 1;
  67 + }
  68 +
  69 + @Override
  70 + protected RvHolder getHolder(View view, int viewType) {
  71 + return new ClassifyHolder(view, viewType, listener);
  72 + }
  73 +
  74 + public class ClassifyHolder extends RvHolder<CookbookDetailEntity> {
  75 + TextView tvTitle;//标题栏标题
  76 + TextView tvCook;//菜品名称
  77 + ImageView noMoreImg;//卖光了
  78 + TextView tvYidian;//点过标志
  79 + LinearLayout tagLayout;//标签容器
  80 + TextView tvPrice;//价格
  81 + TextView lastNum;//剩余菜品数量
  82 + ImageView jianImg;//减图标
  83 + TextView havingNum;//已点数量
  84 + ImageView addImg;//加图标
  85 + NiceImageView cookImg;//菜品图标
  86 +
  87 + public ClassifyHolder(View itemView, int type, RvListener listener) {
  88 + super(itemView, type, listener);
  89 + switch (type) {
  90 + case 0:
  91 + tvTitle = (TextView) itemView.findViewById(R.id.tv_title);
  92 + break;
  93 + case 1:
  94 + tvCook= (TextView) itemView.findViewById(R.id.tv_cook);
  95 + noMoreImg=itemView.findViewById(R.id.nomore);
  96 + tvYidian=itemView.findViewById(R.id.yidian);
  97 + tagLayout=itemView.findViewById(R.id.tag_layout);
  98 + tvPrice=itemView.findViewById(R.id.price);
  99 + lastNum=itemView.findViewById(R.id.lastnum);
  100 + jianImg=itemView.findViewById(R.id.jianImg);
  101 + havingNum=itemView.findViewById(R.id.havingnum);
  102 + addImg=itemView.findViewById(R.id.addImg);
  103 + cookImg=itemView.findViewById(R.id.cook_img);
  104 + break;
  105 + }
  106 +
  107 + }
  108 +
  109 + @Override
  110 + public void bindHolder(final CookbookDetailEntity sortBean, final int position) {
  111 + int itemViewType = ClassifyDetailAdapter.this.getItemViewType(position);
  112 + switch (itemViewType) {
  113 + case 0:
  114 + tvTitle.setText(sortBean.getTitleName());
  115 + break;
  116 + case 1:
  117 + tvCook.setText(sortBean.getName());
  118 + tvPrice.setText(sortBean.getPrice()+"元/"+sortBean.getUnit());
  119 + havingNum.setText(sortBean.getNum()+"");
  120 + if(!TextUtils.isEmpty(sortBean.getClear_num())&&Integer.parseInt(sortBean.getClear_num())<=0){
  121 + lastNum.setVisibility(View.GONE);
  122 + noMoreImg.setVisibility(View.VISIBLE);
  123 + addImg.setVisibility(View.GONE);
  124 + }else{
  125 + if(!TextUtils.isEmpty(sortBean.getClear_num())&&Integer.parseInt(sortBean.getClear_num())<=10){
  126 + lastNum.setVisibility(View.VISIBLE);
  127 + lastNum.setText("剩余"+sortBean.getClear_num()+"份");
  128 + }else{
  129 + lastNum.setVisibility(View.GONE);
  130 + lastNum.setText("剩余"+sortBean.getClear_num()+"份");
  131 + }
  132 + noMoreImg.setVisibility(View.INVISIBLE);
  133 + addImg.setVisibility(View.VISIBLE);
  134 + }
  135 + if(sortBean.getNum()>0){
  136 + jianImg.setVisibility(View.VISIBLE);
  137 + havingNum.setVisibility(View.VISIBLE);
  138 + }else{
  139 + jianImg.setVisibility(View.INVISIBLE);
  140 + havingNum.setVisibility(View.INVISIBLE);
  141 + }
  142 + if(!TextUtils.isEmpty(sortBean.getImage())){
  143 + //使用Glide框架加载图片
  144 + Glide.with(cookImg.getContext())
  145 + .load(sortBean.getImage())
  146 + .apply(new RequestOptions().placeholder(null))
  147 + .into(cookImg);
  148 + cookImg.setVisibility(View.VISIBLE);
  149 + }else{
  150 + cookImg.setVisibility(View.GONE);
  151 + }
  152 + tagLayout.removeAllViews();
  153 + if(sortBean.getLabelList()!=null&&sortBean.getLabelList().size()>0){
  154 + LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT);
  155 + params.rightMargin= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,10,mContext.getResources().getDisplayMetrics());
  156 + for(int i=0;i<sortBean.getLabelList().size();i++){
  157 + ImageView imageView=new ImageView(mContext);
  158 + Glide.with(imageView.getContext())
  159 + .load(sortBean.getLabelList().get(i))
  160 + .apply(new RequestOptions().placeholder(null))
  161 + .into(imageView);
  162 + tagLayout.addView(imageView,params);
  163 + }
  164 + }
  165 + addImg.setOnClickListener(new View.OnClickListener() {
  166 + @Override
  167 + public void onClick(View view) {
  168 + if(!TextUtils.isEmpty(list.get(position).getClear_num())&&list.get(position).getNum()==Integer.parseInt(list.get(position).getClear_num())){
  169 + ToastUtils.showShort("菜品沽清不足");
  170 + return;
  171 + }
  172 + if(sortBean.getPractice().size()>0||sortBean.getSpec().size()>0){//有菜品规格或者做法
  173 + SelectFragmentDialog dialog=new SelectFragmentDialog();
  174 + dialog.setOnSureClickListener(new SelectFragmentDialog.onSureClickListener() {
  175 + @Override
  176 + public void onSureClick(String specid, String practiceid,String spec,String practice,String price) {
  177 + addCookToCart(position,specid,practiceid,spec,practice,price,jianImg,havingNum);
  178 + }
  179 + });
  180 + Bundle bundle=new Bundle();
  181 + bundle.putSerializable("cook",list.get(position));
  182 + dialog.setArguments(bundle);
  183 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"selectFragmentDialog");
  184 + return;
  185 + }
  186 + addCookToCart(position,"","","","",list.get(position).getPrice(),jianImg,havingNum);
  187 +
  188 + }
  189 + });
  190 + jianImg.setOnClickListener(new View.OnClickListener() {
  191 + @Override
  192 + public void onClick(View view) {
  193 + if(sortBean.getPractice().size()>0||sortBean.getSpec().size()>0){//有菜品规格或做法
  194 + //获取一点菜品规则做法列表
  195 + Map<String,String> params=new HashMap<>();
  196 + params.put("sellerid",SPUtils.getInstance("user_info").getString("sellerid"));
  197 + params.put("orderid",orderid);
  198 + params.put("cookbookid",sortBean.getId());
  199 + RetrofitClient.getInstance().create(CookbookApiService.class)
  200 + .getCookbookSelBySpecsId(params)
  201 + .compose(RxUtils.schedulersTransformer())
  202 + .compose(RxUtils.exceptionTransformer())
  203 + .doOnSubscribe(new Consumer<Disposable>() {
  204 + @Override
  205 + public void accept(Disposable disposable) throws Exception {
  206 +
  207 + }
  208 + })
  209 + .subscribe(new Consumer<BaseResponse<List<List<ReduceBean>>>>() {
  210 + @Override
  211 + public void accept(BaseResponse<List<List<ReduceBean>>> listBaseResponse) throws Exception {
  212 + if(listBaseResponse.getRet()==200){
  213 + final ReduceFragmentDialog dialog=new ReduceFragmentDialog();
  214 + dialog.setListener(new ReduceFragmentDialog.ReduceListener() {
  215 + @Override
  216 + public void onAddSuccess(int position,ReduceBean bean) {
  217 + list.get(position).setNum(list.get(position).getNum()+1);
  218 + havingNum.setText(list.get(position).getNum()+"");
  219 + }
  220 +
  221 + @Override
  222 + public void onReduceSuccess(int position,ReduceBean bean) {
  223 + list.get(position).setNum(list.get(position).getNum()-1);
  224 + havingNum.setText(list.get(position).getNum()+"");
  225 + if(list.get(position).getNum()==0){
  226 + jianImg.setVisibility(View.INVISIBLE);
  227 + havingNum.setVisibility(View.INVISIBLE);
  228 + dialog.dismiss();
  229 + }
  230 + }
  231 + });
  232 + Bundle bundle=new Bundle();
  233 + bundle.putInt("position",position);
  234 + bundle.putString("cookname",sortBean.getName());
  235 + bundle.putString("fromSource",fromSource);
  236 + bundle.putString("clear_num",sortBean.getClear_num());
  237 + bundle.putParcelableArrayList("list", (ArrayList<? extends Parcelable>) listBaseResponse.getData().get(0));
  238 + dialog.setArguments(bundle);
  239 + dialog.show(((AppCompatActivity)context).getSupportFragmentManager(),"selectFragmentDialog");
  240 + }else{
  241 + ToastUtils.showShort(listBaseResponse.getMsg());
  242 + }
  243 + }
  244 + }, new Consumer<ResponseThrowable>() {
  245 + @Override
  246 + public void accept(ResponseThrowable throwable) throws Exception {
  247 + throwable.printStackTrace();
  248 + ToastUtils.showShort(throwable.msg);
  249 + }
  250 + });
  251 + return;
  252 + }
  253 + reduceCookFromCart(position,"","",jianImg,havingNum);
  254 + }
  255 + });
  256 + break;
  257 + }
  258 + }
  259 + }
  260 +
  261 + //添加菜品到购物车
  262 + private void addCookToCart(final int position, final String specid, final String practiceid, final String spec, final String practice, final String price,final ImageView reduceImg, final TextView havingNum){
  263 + Map<String,String> params=new HashMap<>();
  264 + params.put("orderid",orderid);
  265 + params.put("openid", SPUtils.getInstance("user_info").getString("openid"));
  266 + params.put("cookbookid",list.get(position).getId());
  267 + params.put("identity","2");
  268 + params.put("price",price);
  269 + if(!TextUtils.isEmpty(specid)){
  270 + params.put("specid",specid);
  271 + }
  272 + if(!TextUtils.isEmpty(practiceid)){
  273 + params.put("practiceid",practiceid);
  274 + }
  275 + if(!TextUtils.isEmpty(fromSource)||isWaitingSure){
  276 + params.put("fromSoucre","1");
  277 + }
  278 + RetrofitClient.getInstance().create(CookbookApiService.class)
  279 + .addCookToCart(params)
  280 + .compose(RxUtils.schedulersTransformer())
  281 + .compose(RxUtils.exceptionTransformer())
  282 + .doOnSubscribe(new Consumer<Disposable>() {
  283 + @Override
  284 + public void accept(Disposable disposable) throws Exception {
  285 +
  286 + }
  287 + })
  288 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  289 + @Override
  290 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  291 + if(baseResponse.getRet()==200){
  292 + list.get(position).setNum(list.get(position).getNum()+1);
  293 + havingNum.setText(list.get(position).getNum()+"");
  294 + reduceImg.setVisibility(View.VISIBLE);
  295 + havingNum.setVisibility(View.VISIBLE);
  296 + //通知CookbookMainActivity改变购物车数量
  297 + RxBus.getDefault().post(1);
  298 + }else{
  299 + ToastUtils.showShort(baseResponse.getMsg());
  300 + }
  301 + }
  302 + }, new Consumer<ResponseThrowable>() {
  303 + @Override
  304 + public void accept(ResponseThrowable throwable) throws Exception {
  305 + ToastUtils.showShort(throwable.msg);
  306 + throwable.printStackTrace();
  307 + }
  308 + });
  309 + }
  310 + //删减菜品从购物车
  311 + private void reduceCookFromCart(final int position,final String specid,final String practiceid,final ImageView reduceImg, final TextView havingNum){
  312 + Map<String,String> params=new HashMap<>();
  313 + params.put("orderid",orderid);
  314 + params.put("cookbookid",list.get(position).getId());
  315 + params.put("identity","2");
  316 + if(!TextUtils.isEmpty(specid)){
  317 + params.put("specid",specid);
  318 + }
  319 + if(!TextUtils.isEmpty(practiceid)){
  320 + params.put("practiceid",practiceid);
  321 + }
  322 + if(!TextUtils.isEmpty(fromSource)||isWaitingSure){
  323 + params.put("fromSoucre","1");
  324 + }
  325 + RetrofitClient.getInstance().create(CookbookApiService.class)
  326 + .reduceCookFromCart(params)
  327 + .compose(RxUtils.schedulersTransformer())
  328 + .compose(RxUtils.exceptionTransformer())
  329 + .doOnSubscribe(new Consumer<Disposable>() {
  330 + @Override
  331 + public void accept(Disposable disposable) throws Exception {
  332 +
  333 + }
  334 + })
  335 + .subscribe(new Consumer<BaseResponse<List<ResultEntity>>>() {
  336 + @Override
  337 + public void accept(BaseResponse<List<ResultEntity>> baseResponse) throws Exception {
  338 + if(baseResponse.getRet()==200){
  339 + list.get(position).setNum(list.get(position).getNum()-1);
  340 + havingNum.setText(list.get(position).getNum()+"");
  341 + if(list.get(position).getNum()<=0){
  342 + reduceImg.setVisibility(View.INVISIBLE);
  343 + havingNum.setVisibility(View.INVISIBLE);
  344 + }
  345 + //通知CookbookMainActivity改变购物车数量
  346 + RxBus.getDefault().post(-1);
  347 + }else{
  348 + ToastUtils.showShort(baseResponse.getMsg());
  349 + }
  350 + }
  351 + }, new Consumer<ResponseThrowable>() {
  352 + @Override
  353 + public void accept(ResponseThrowable throwable) throws Exception {
  354 + ToastUtils.showShort(throwable.msg);
  355 + throwable.printStackTrace();
  356 + }
  357 + });
  358 + }
  359 +
  360 +}
  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 +import android.content.Context;
  4 +import android.view.View;
  5 +import android.widget.TextView;
  6 +
  7 +import com.naji.xiaotao.R;
  8 +import com.naji.xiaotao.cookbook.bean.CookbookPractice;
  9 +import com.naji.xiaotao.cookbook.bean.ReduceBean;
  10 +import com.naji.xiaotao.cookbook.listener.RvListener;
  11 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  12 +
  13 +import java.util.List;
  14 +
  15 +public class SelectPracticeAdapter extends RvAdapter<CookbookPractice>{
  16 +
  17 + public SelectPracticeAdapter(Context context, List<CookbookPractice> list, RvListener listener) {
  18 + super(context, list, listener);
  19 + }
  20 +
  21 + @Override
  22 + protected int getLayoutId(int viewType) {
  23 + return R.layout.textview;
  24 + }
  25 +
  26 + @Override
  27 + protected RvHolder getHolder(View view, int viewType) {
  28 + return new SelectPractiveViewHolder(view,viewType,listener);
  29 + }
  30 +
  31 +
  32 + public class SelectPractiveViewHolder extends RvHolder<CookbookPractice>{
  33 +
  34 + private TextView textView;
  35 +
  36 + public SelectPractiveViewHolder(View itemView, int type, RvListener listener) {
  37 + super(itemView, type, listener);
  38 + textView=itemView.findViewById(R.id.textview);
  39 + }
  40 +
  41 +
  42 +
  43 + @Override
  44 + public void bindHolder(final CookbookPractice cookbookPractice, int position) {
  45 + textView.setText(cookbookPractice.getName());
  46 + if(cookbookPractice.isSelected()){
  47 + textView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_yidian));
  48 + textView.setTextColor(mContext.getResources().getColor(R.color.text3));
  49 + }else{
  50 + textView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_unselected));
  51 + textView.setTextColor(mContext.getResources().getColor(R.color.text1));
  52 + }
  53 + }
  54 + }
  55 +}
  1 +package com.naji.xiaotao.cookbook.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.View;
  5 +import android.widget.TextView;
  6 +
  7 +import com.naji.xiaotao.R;
  8 +import com.naji.xiaotao.cookbook.bean.CookbookPractice;
  9 +import com.naji.xiaotao.cookbook.bean.CookbookSize;
  10 +import com.naji.xiaotao.cookbook.listener.RvListener;
  11 +import com.naji.xiaotao.cookbook.viewholder.RvHolder;
  12 +
  13 +import java.util.List;
  14 +
  15 +public class SelectSizeAdapter extends RvAdapter<CookbookSize>{
  16 +
  17 + public SelectSizeAdapter(Context context, List<CookbookSize> list, RvListener listener) {
  18 + super(context, list, listener);
  19 + }
  20 +
  21 + @Override
  22 + protected int getLayoutId(int viewType) {
  23 + return R.layout.textview;
  24 + }
  25 +
  26 + @Override
  27 + protected RvHolder getHolder(View view, int viewType) {
  28 + return new SelectSizeViewHolder(view,viewType,listener);
  29 + }
  30 +
  31 +
  32 + public class SelectSizeViewHolder extends RvHolder<CookbookSize>{
  33 +
  34 + private TextView textView;
  35 +
  36 + public SelectSizeViewHolder(View itemView, int type, RvListener listener) {
  37 + super(itemView, type, listener);
  38 + textView=itemView.findViewById(R.id.textview);
  39 + }
  40 +
  41 +
  42 + @Override
  43 + public void bindHolder(CookbookSize cookbookSize, int position) {
  44 + textView.setText(cookbookSize.getSpecs());
  45 + if(cookbookSize.isSelected()){
  46 + textView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_yidian));
  47 + textView.setTextColor(mContext.getResources().getColor(R.color.text3));
  48 + }else{
  49 + textView.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_unselected));
  50 + textView.setTextColor(mContext.getResources().getColor(R.color.text1));
  51 + }
  52 + }
  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, Parcelable {
  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 + private boolean selected;//是否选中
  18 +
  19 + public String getId() {
  20 + return id;
  21 + }
  22 +
  23 + public void setId(String id) {
  24 + this.id = id;
  25 + }
  26 +
  27 + public String getCid() {
  28 + return cid;
  29 + }
  30 +
  31 + public void setCid(String cid) {
  32 + this.cid = cid;
  33 + }
  34 +
  35 + public String getPractice() {
  36 + return practice;
  37 + }
  38 +
  39 + public void setPractice(String practice) {
  40 + this.practice = practice;
  41 + }
  42 +
  43 + public String getName() {
  44 + return name;
  45 + }
  46 +
  47 + public void setName(String name) {
  48 + this.name = name;
  49 + }
  50 +
  51 + public String getPrice() {
  52 + return price;
  53 + }
  54 +
  55 + public void setPrice(String price) {
  56 + this.price = price;
  57 + }
  58 +
  59 + public String getMember_price() {
  60 + return member_price;
  61 + }
  62 +
  63 + public void setMember_price(String member_price) {
  64 + this.member_price = member_price;
  65 + }
  66 +
  67 + public boolean isSelected() {
  68 + return selected;
  69 + }
  70 +
  71 + public void setSelected(boolean selected) {
  72 + this.selected = selected;
  73 + }
  74 +
  75 + @Override
  76 + public int describeContents() {
  77 + return 0;
  78 + }
  79 +
  80 + @Override
  81 + public void writeToParcel(Parcel dest, int flags) {
  82 + dest.writeString(this.id);
  83 + dest.writeString(this.cid);
  84 + dest.writeString(this.practice);
  85 + dest.writeString(this.name);
  86 + dest.writeString(this.price);
  87 + dest.writeString(this.member_price);
  88 + dest.writeByte(this.selected ? (byte) 1 : (byte) 0);
  89 + }
  90 +
  91 + public CookbookPractice() {
  92 + }
  93 +
  94 + protected CookbookPractice(Parcel in) {
  95 + this.id = in.readString();
  96 + this.cid = in.readString();
  97 + this.practice = in.readString();
  98 + this.name = in.readString();
  99 + this.price = in.readString();
  100 + this.member_price = in.readString();
  101 + this.selected = in.readByte() != 0;
  102 + }
  103 +
  104 + public static final Parcelable.Creator<CookbookPractice> CREATOR = new Parcelable.Creator<CookbookPractice>() {
  105 + @Override
  106 + public CookbookPractice createFromParcel(Parcel source) {
  107 + return new CookbookPractice(source);
  108 + }
  109 +
  110 + @Override
  111 + public CookbookPractice[] newArray(int size) {
  112 + return new CookbookPractice[size];
  113 + }
  114 + };
  115 +}