diff --git a/src/.gradle/5.6.4/fileChanges/last-build.bin b/src/.gradle/5.6.4/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/src/.gradle/5.6.4/fileChanges/last-build.bin differ
diff --git a/src/.gradle/5.6.4/fileHashes/fileHashes.bin b/src/.gradle/5.6.4/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..5ac2f71
Binary files /dev/null and b/src/.gradle/5.6.4/fileHashes/fileHashes.bin differ
diff --git a/src/.gradle/5.6.4/fileHashes/fileHashes.lock b/src/.gradle/5.6.4/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..4c4c9e9
Binary files /dev/null and b/src/.gradle/5.6.4/fileHashes/fileHashes.lock differ
diff --git a/src/.gradle/5.6.4/gc.properties b/src/.gradle/5.6.4/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/.gradle/6.4.1/executionHistory/executionHistory.bin b/src/.gradle/6.4.1/executionHistory/executionHistory.bin
new file mode 100644
index 0000000..a0fc6c8
Binary files /dev/null and b/src/.gradle/6.4.1/executionHistory/executionHistory.bin differ
diff --git a/src/.gradle/6.4.1/executionHistory/executionHistory.lock b/src/.gradle/6.4.1/executionHistory/executionHistory.lock
new file mode 100644
index 0000000..474b06f
Binary files /dev/null and b/src/.gradle/6.4.1/executionHistory/executionHistory.lock differ
diff --git a/src/.gradle/6.4.1/fileChanges/last-build.bin b/src/.gradle/6.4.1/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/src/.gradle/6.4.1/fileChanges/last-build.bin differ
diff --git a/src/.gradle/6.4.1/fileContent/fileContent.lock b/src/.gradle/6.4.1/fileContent/fileContent.lock
new file mode 100644
index 0000000..a19b64c
Binary files /dev/null and b/src/.gradle/6.4.1/fileContent/fileContent.lock differ
diff --git a/src/.gradle/6.4.1/fileHashes/fileHashes.bin b/src/.gradle/6.4.1/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..b256875
Binary files /dev/null and b/src/.gradle/6.4.1/fileHashes/fileHashes.bin differ
diff --git a/src/.gradle/6.4.1/fileHashes/fileHashes.lock b/src/.gradle/6.4.1/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..e681b38
Binary files /dev/null and b/src/.gradle/6.4.1/fileHashes/fileHashes.lock differ
diff --git a/src/.gradle/6.4.1/fileHashes/resourceHashesCache.bin b/src/.gradle/6.4.1/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..f625d62
Binary files /dev/null and b/src/.gradle/6.4.1/fileHashes/resourceHashesCache.bin differ
diff --git a/src/.gradle/6.4.1/gc.properties b/src/.gradle/6.4.1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/.gradle/6.4.1/javaCompile/classAnalysis.bin b/src/.gradle/6.4.1/javaCompile/classAnalysis.bin
new file mode 100644
index 0000000..2874f4b
Binary files /dev/null and b/src/.gradle/6.4.1/javaCompile/classAnalysis.bin differ
diff --git a/src/.gradle/6.4.1/javaCompile/jarAnalysis.bin b/src/.gradle/6.4.1/javaCompile/jarAnalysis.bin
new file mode 100644
index 0000000..391114e
Binary files /dev/null and b/src/.gradle/6.4.1/javaCompile/jarAnalysis.bin differ
diff --git a/src/.gradle/6.4.1/javaCompile/javaCompile.lock b/src/.gradle/6.4.1/javaCompile/javaCompile.lock
new file mode 100644
index 0000000..a5eab79
Binary files /dev/null and b/src/.gradle/6.4.1/javaCompile/javaCompile.lock differ
diff --git a/src/.gradle/6.4.1/javaCompile/taskHistory.bin b/src/.gradle/6.4.1/javaCompile/taskHistory.bin
new file mode 100644
index 0000000..373e27c
Binary files /dev/null and b/src/.gradle/6.4.1/javaCompile/taskHistory.bin differ
diff --git a/src/.gradle/6.7.1/executionHistory/executionHistory.bin b/src/.gradle/6.7.1/executionHistory/executionHistory.bin
new file mode 100644
index 0000000..ea2c243
Binary files /dev/null and b/src/.gradle/6.7.1/executionHistory/executionHistory.bin differ
diff --git a/src/.gradle/6.7.1/executionHistory/executionHistory.lock b/src/.gradle/6.7.1/executionHistory/executionHistory.lock
new file mode 100644
index 0000000..8f48f83
Binary files /dev/null and b/src/.gradle/6.7.1/executionHistory/executionHistory.lock differ
diff --git a/src/.gradle/6.7.1/fileChanges/last-build.bin b/src/.gradle/6.7.1/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/src/.gradle/6.7.1/fileChanges/last-build.bin differ
diff --git a/src/.gradle/6.7.1/fileHashes/fileHashes.bin b/src/.gradle/6.7.1/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..f54b394
Binary files /dev/null and b/src/.gradle/6.7.1/fileHashes/fileHashes.bin differ
diff --git a/src/.gradle/6.7.1/fileHashes/fileHashes.lock b/src/.gradle/6.7.1/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..f75aa57
Binary files /dev/null and b/src/.gradle/6.7.1/fileHashes/fileHashes.lock differ
diff --git a/src/.gradle/6.7.1/fileHashes/resourceHashesCache.bin b/src/.gradle/6.7.1/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..1462c40
Binary files /dev/null and b/src/.gradle/6.7.1/fileHashes/resourceHashesCache.bin differ
diff --git a/src/.gradle/6.7.1/gc.properties b/src/.gradle/6.7.1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/.gradle/6.7.1/javaCompile/classAnalysis.bin b/src/.gradle/6.7.1/javaCompile/classAnalysis.bin
new file mode 100644
index 0000000..ddba9bd
Binary files /dev/null and b/src/.gradle/6.7.1/javaCompile/classAnalysis.bin differ
diff --git a/src/.gradle/6.7.1/javaCompile/jarAnalysis.bin b/src/.gradle/6.7.1/javaCompile/jarAnalysis.bin
new file mode 100644
index 0000000..41b4e58
Binary files /dev/null and b/src/.gradle/6.7.1/javaCompile/jarAnalysis.bin differ
diff --git a/src/.gradle/6.7.1/javaCompile/javaCompile.lock b/src/.gradle/6.7.1/javaCompile/javaCompile.lock
new file mode 100644
index 0000000..4fd4f78
Binary files /dev/null and b/src/.gradle/6.7.1/javaCompile/javaCompile.lock differ
diff --git a/src/.gradle/6.7.1/javaCompile/taskHistory.bin b/src/.gradle/6.7.1/javaCompile/taskHistory.bin
new file mode 100644
index 0000000..a01e3b1
Binary files /dev/null and b/src/.gradle/6.7.1/javaCompile/taskHistory.bin differ
diff --git a/src/.gradle/7.0.2/dependencies-accessors/dependencies-accessors.lock b/src/.gradle/7.0.2/dependencies-accessors/dependencies-accessors.lock
new file mode 100644
index 0000000..8f1736c
Binary files /dev/null and b/src/.gradle/7.0.2/dependencies-accessors/dependencies-accessors.lock differ
diff --git a/src/.gradle/7.0.2/dependencies-accessors/gc.properties b/src/.gradle/7.0.2/dependencies-accessors/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/.gradle/7.0.2/executionHistory/executionHistory.bin b/src/.gradle/7.0.2/executionHistory/executionHistory.bin
new file mode 100644
index 0000000..d2423c0
Binary files /dev/null and b/src/.gradle/7.0.2/executionHistory/executionHistory.bin differ
diff --git a/src/.gradle/7.0.2/executionHistory/executionHistory.lock b/src/.gradle/7.0.2/executionHistory/executionHistory.lock
new file mode 100644
index 0000000..87349eb
Binary files /dev/null and b/src/.gradle/7.0.2/executionHistory/executionHistory.lock differ
diff --git a/src/.gradle/7.0.2/fileChanges/last-build.bin b/src/.gradle/7.0.2/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/src/.gradle/7.0.2/fileChanges/last-build.bin differ
diff --git a/src/.gradle/7.0.2/fileHashes/fileHashes.bin b/src/.gradle/7.0.2/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..6698e24
Binary files /dev/null and b/src/.gradle/7.0.2/fileHashes/fileHashes.bin differ
diff --git a/src/.gradle/7.0.2/fileHashes/fileHashes.lock b/src/.gradle/7.0.2/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..740d3cb
Binary files /dev/null and b/src/.gradle/7.0.2/fileHashes/fileHashes.lock differ
diff --git a/src/.gradle/7.0.2/fileHashes/resourceHashesCache.bin b/src/.gradle/7.0.2/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..b7e2e19
Binary files /dev/null and b/src/.gradle/7.0.2/fileHashes/resourceHashesCache.bin differ
diff --git a/src/.gradle/7.0.2/gc.properties b/src/.gradle/7.0.2/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/.gradle/7.0.2/javaCompile/classAnalysis.bin b/src/.gradle/7.0.2/javaCompile/classAnalysis.bin
new file mode 100644
index 0000000..be104bf
Binary files /dev/null and b/src/.gradle/7.0.2/javaCompile/classAnalysis.bin differ
diff --git a/src/.gradle/7.0.2/javaCompile/jarAnalysis.bin b/src/.gradle/7.0.2/javaCompile/jarAnalysis.bin
new file mode 100644
index 0000000..68e92e4
Binary files /dev/null and b/src/.gradle/7.0.2/javaCompile/jarAnalysis.bin differ
diff --git a/src/.gradle/7.0.2/javaCompile/javaCompile.lock b/src/.gradle/7.0.2/javaCompile/javaCompile.lock
new file mode 100644
index 0000000..d516ace
Binary files /dev/null and b/src/.gradle/7.0.2/javaCompile/javaCompile.lock differ
diff --git a/src/.gradle/7.0.2/javaCompile/taskHistory.bin b/src/.gradle/7.0.2/javaCompile/taskHistory.bin
new file mode 100644
index 0000000..f2754cd
Binary files /dev/null and b/src/.gradle/7.0.2/javaCompile/taskHistory.bin differ
diff --git a/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock
new file mode 100644
index 0000000..fe6ebbc
Binary files /dev/null and b/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/src/.gradle/buildOutputCleanup/cache.properties b/src/.gradle/buildOutputCleanup/cache.properties
new file mode 100644
index 0000000..e4eca38
--- /dev/null
+++ b/src/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
+#Fri Oct 21 23:04:16 GMT+08:00 2022
+gradle.version=6.4.1
diff --git a/src/.gradle/buildOutputCleanup/outputFiles.bin b/src/.gradle/buildOutputCleanup/outputFiles.bin
new file mode 100644
index 0000000..8e33fc8
Binary files /dev/null and b/src/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/src/.gradle/checksums/checksums.lock b/src/.gradle/checksums/checksums.lock
new file mode 100644
index 0000000..13b7f20
Binary files /dev/null and b/src/.gradle/checksums/checksums.lock differ
diff --git a/src/.gradle/checksums/md5-checksums.bin b/src/.gradle/checksums/md5-checksums.bin
new file mode 100644
index 0000000..b818f42
Binary files /dev/null and b/src/.gradle/checksums/md5-checksums.bin differ
diff --git a/src/.gradle/checksums/sha1-checksums.bin b/src/.gradle/checksums/sha1-checksums.bin
new file mode 100644
index 0000000..77858d8
Binary files /dev/null and b/src/.gradle/checksums/sha1-checksums.bin differ
diff --git a/src/.gradle/configuration-cache/gc.properties b/src/.gradle/configuration-cache/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/.gradle/vcs-1/gc.properties b/src/.gradle/vcs-1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 0000000..1c3b282
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,17 @@
+### 简介
+
+
+- 2018年天津市大学生创新训练项目—“基于Android的无线点餐系统的设计与研究”。本课题旨在研究并设计一基于Android的无线点餐系统,系统能实现顾客就餐全过程的自动化管理。
+- 对于系统功能设计:主要包括功能框架和设计模块,其中功能框架主要包括登录模块、点餐模块、结账模块和餐台管理;功能模块设计分为服务器和客户端,具体包括登录功能、用户管理、菜谱管理、系统管理。各模块之间互相依赖,形成一个完整的无线点餐系统手机(平板)客户端与服务器的交互设计系统。
+
+### 研究内容
+
+- A、确立物理架构:Android系统客户端通过无线网络访问后台Web服务器,如果需要数据访问,则访问后台数据库服务器;
+- B、确立技术选型:Android客户端选用JAVA技术,网络通信选用Apache Http协议,而中间Web服务器采用Servlet响应可客户请求。后台数据库使用JDBC来访问数据库,Android客户端部分数据的存储则采用SQLite数据库;
+- C、进行系统规划和需求分析,通过数据流程图、实体属性图分析数据间的关系,设计并创建一个合理可靠的数据库;
+- D、实现客户端功能设计,基于Android开发平台,前端客户端功能模块大概分为锁定桌号、桌号查询、菜品查询、加菜功能、退菜功能、结算功能;
+- E、实现服务器端功能设计,后端服务器功能模块大概分为用户评价管理、桌号管理、菜品管理、订单管理、信息管理;
+- F、后端服务器采用Tomcat服务器,利用JDBC访问后台数据库,Servlet响应HttpRequest请求,并返回响应结果,在此过程中采用MVC+DAO的设计模式及分层的开发思想。
+
+### 系统页面
+
diff --git a/src/app/.gitignore b/src/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/src/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/src/app/build.gradle b/src/app/build.gradle
new file mode 100644
index 0000000..431696c
--- /dev/null
+++ b/src/app/build.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 33
+ defaultConfig {
+ applicationId "com.sbw.atrue.Order"
+ minSdkVersion 16
+ targetSdkVersion 33
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
+ implementation files('libs\\mysql-connector-java-5.1.38.jar')
+ implementation files('libs\\mysql-connector-java-5.1.38.jar')
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.3.0-beta01'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-beta01'
+ implementation 'com.google.android.material:material:1.2.0-alpha06'
+ implementation 'de.hdodenhof:circleimageview:2.1.0'
+ implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
+ implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
+ implementation 'androidx.cardview:cardview:1.0.0'
+ implementation 'com.github.bumptech.glide:glide:4.11.0'
+ implementation 'org.litepal.android:core:1.3.2'
+ /*implementation 'org.litepal.guolindev:core:3.2.3'*/
+ implementation 'com.yanzhenjie.nohttp:nohttp:1.1.4'
+ implementation 'com.google.code.gson:gson:2.8.6'
+}
diff --git a/src/app/libs/mysql-connector-java-5.1.38.jar b/src/app/libs/mysql-connector-java-5.1.38.jar
new file mode 100644
index 0000000..be09493
Binary files /dev/null and b/src/app/libs/mysql-connector-java-5.1.38.jar differ
diff --git a/src/app/proguard-rules.pro b/src/app/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/src/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/src/app/release/app-release.apk b/src/app/release/app-release.apk
new file mode 100644
index 0000000..e7ff92e
Binary files /dev/null and b/src/app/release/app-release.apk differ
diff --git a/src/app/release/output.json b/src/app/release/output.json
new file mode 100644
index 0000000..9f0c959
--- /dev/null
+++ b/src/app/release/output.json
@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/src/app/src/androidTest/java/com/sbw/atrue/Order/ExampleInstrumentedTest.java b/src/app/src/androidTest/java/com/sbw/atrue/Order/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..b287abd
--- /dev/null
+++ b/src/app/src/androidTest/java/com/sbw/atrue/Order/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.sbw.atrue.Order;
+
+import android.content.Context;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {//做测试的
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.sbw.atrue.toolbartest", appContext.getPackageName());
+ }
+}
diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..c396b33
--- /dev/null
+++ b/src/app/src/main/AndroidManifest.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/assets/litepal.xml b/src/app/src/main/assets/litepal.xml
new file mode 100644
index 0000000..5edebfc
--- /dev/null
+++ b/src/app/src/main/assets/litepal.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/Connection.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/Connection.java
new file mode 100644
index 0000000..3183ffa
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/Connection.java
@@ -0,0 +1,61 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.util.Log;
+
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class Connection {
+ private static final String TAG = "mysql11111";
+ java.sql.Connection conn=null;
+ public static void mymysql(){
+ final Thread thread =new Thread(new Runnable() {
+ @Override
+ public void run() {
+
+ while (!Thread.interrupted()) {
+ try {
+ Thread.sleep(100); // 每隔0.1秒尝试连接
+ } catch (InterruptedException e) {
+ Log.e(TAG, e.toString());
+ }
+
+// 1.加载JDBC驱动
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ Log.v(TAG, "加载JDBC驱动成功");
+ } catch (ClassNotFoundException e) {
+ Log.e(TAG, "加载JDBC驱动失败");
+ return;
+ }
+
+ // 2.设置好IP/端口/数据库名/用户名/密码等必要的连接信息
+ String ip = "10.11.169.231";
+ int port = 3306;
+ String dbName = "mysql";
+ String url = "jdbc:mysql://" + ip + ":" + port
+ + "/" + dbName+"?useUnicode=true&characterEncoding=utf-8&useSSL=false";
+ // 构建连接mysql的字符串
+ String user = "root";
+ String password = "123456";
+
+ // 3.连接JDBC
+ try {
+ java.sql.Connection conn = DriverManager.getConnection(url, user, password);
+ Log.d(TAG, "数据库连接成功");
+ conn.close();
+ return;
+ }
+ catch (SQLException e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
+ }
+ });
+ thread.start();
+
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/FoodActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/FoodActivity.java
new file mode 100644
index 0000000..459f384
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/FoodActivity.java
@@ -0,0 +1,67 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.content.Intent;
+import com.google.android.material.appbar.CollapsingToolbarLayout;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import android.os.Bundle;
+import androidx.appcompat.widget.Toolbar;
+import android.view.MenuItem;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+import com.sbw.atrue.Order.Entity.Food;
+import com.sbw.atrue.Order.R;
+
+/**
+ * ClassName: FoodActivity
+ * description: 用于加载展示菜品的详细信息的活动
+ * author: 沈滨伟-13042299081
+ * Date: 2019/2/18 20:59
+ */
+public class FoodActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_food); // 这里连到界面
+ //获取各布局控件的实例
+ CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
+ ImageView foodImageView = (ImageView) findViewById(R.id.food_image_view);
+ TextView foodContentText = (TextView) findViewById(R.id.food_content_text);
+
+ //从上一级活动获取用户点击的菜品的对象
+ Intent intent = getIntent();
+ Food food=(Food)intent.getSerializableExtra("Food_Choose");
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ //显示标题栏最左侧的系统默认自带的返回导航键,用于返回上一级活动
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
+ //设置菜品的名称、图片
+ collapsingToolbar.setTitle(food.getName());
+ Glide.with(this).load(food.getImageId()).into(foodImageView);
+ //设置菜品详情介绍
+ foodContentText.setText(food.getDescription());
+ }
+
+ /**
+ * 设置当前布局里的菜单子布局的控件监听事件,此处实现返回导航键的注销本活动功能
+ * @param item
+ * @return
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ //R.id.home是系统默认的ActionBar标题栏最左侧按键HomeAsUp键的Id
+ case android.R.id.home:
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/InputActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/InputActivity.java
new file mode 100644
index 0000000..7f75e49
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/InputActivity.java
@@ -0,0 +1,159 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gson.Gson;
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Entity.Product;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.MyListener;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+//订单确认
+public class InputActivity extends Activity {
+ private EditText etname; //姓名输入框
+ private EditText etPhone; //手机号输入框
+ private EditText ettable; //桌号输入框
+ private Button btnInputCompleted; //输入完成按钮
+ private ArrayList selectedProducts = new ArrayList(); //被选择的的商品数据
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_input);
+ initViews(); //初始化页面控件
+ initEvents(); //初始化控件事件
+ }
+
+ //初始化控件事件
+ private void initEvents() {
+ Intent otherIntent = getIntent(); //获取信息输入界面传来的意图
+ selectedProducts = otherIntent.getParcelableArrayListExtra("selectedProducts"); //从意图中获取被选择的的商品数据
+ etPhone.setSelection(etPhone.getText().length()); //将光标移动到电话输入框最后面
+ etname.setText(ShareUtils.getString(InputActivity.this, "user_true_name", ""));//从本地读取客户姓名
+ etPhone.setText(ShareUtils.getString(InputActivity.this, "user_true_phone", ""));//从本地读取客户电话
+ //给输入完成按钮设置点击事件
+ btnInputCompleted.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final String address = ettable.getText().toString(); //获取输入框中的桌号
+ final String name = etname.getText().toString(); //获取输入框中的客户姓名
+ final String phone = etPhone.getText().toString(); //获取输入框中的手机号
+ if (!TextUtils.isEmpty(phone)
+ && !TextUtils.isEmpty(address)
+ && phone.length() >= 7) { //手机号和地址不为空且手机号大于等于7位
+
+
+ addOrder(selectedProducts, name, phone, address, new MyListener() {
+ @Override
+ public void onSuccess(String data) {
+ Intent intent = new Intent(getApplicationContext(), SuccessActivity.class); //新建意图
+ intent.putParcelableArrayListExtra("selectedProducts", selectedProducts); //给意图添加被选择的的商品数据
+ intent.putExtra("name", name); //给意图设置客户姓名
+ intent.putExtra("phone", phone); //给意图设置联系电话
+ intent.putExtra("orderId", data); //给意图设置用餐桌号
+ intent.putExtra("table", address); //给意图设置用餐桌号
+ startActivity(intent); //跳转到购买成功页面
+ ShoppingActivity.mInstance.finish(); //结束购物界面
+ InputActivity.this.finish(); //结束信息输入界面
+ }
+ });
+
+ } else { //输入手机号或地址不正确
+ //Toast.makeText(InputActivity.this, "手机号或地址输入不正确,手机号至少7位", Toast.LENGTH_SHORT).show();
+ showDialog("手机号或地址输入不正确,手机号至少7位!");
+ }
+ }
+ });
+ }
+
+ private void addOrder(List productList, String name, String phone, String address, final MyListener literer) {
+ String postUrl = HttpUtil.HOST + "api/order/addOrder";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("userId", ShareUtils.getInt(getApplicationContext(), "user_id", 0));
+ request.add("name", name);
+ request.add("phone", phone);
+ request.add("tableId", address);
+ request.add("productList", new Gson().toJson(productList));
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ literer.onSuccess(res.getString("data"));
+ } else {
+ showDialog(res.getString("msg"));
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+ }
+
+ //初始化页面控件
+ private void initViews() {
+ etname = (EditText) findViewById(R.id.et_name);
+ etPhone = (EditText) findViewById(R.id.et_phone);
+ ettable = (EditText) findViewById(R.id.et_table);
+ btnInputCompleted = (Button) findViewById(R.id.btn_input_completed);
+ }
+
+ /**
+ * 为了方便,定义一个弹框控件的函数
+ *
+ * @param msg 要显示的提示信息
+ */
+ private void showDialog(String msg) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(msg)
+ .setCancelable(false)
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/LoginActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/LoginActivity.java
new file mode 100644
index 0000000..94031d1
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/LoginActivity.java
@@ -0,0 +1,169 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Map;
+
+/**
+ * ClassName: LoginActivity
+ * description: 系统登录活动
+ * author: 沈滨伟-13042299081
+ * Date: 2019/2/18 14:54
+ */
+public class LoginActivity extends AppCompatActivity {
+ private EditText accountEdit;
+ private EditText passwordEdit;
+ private Button btnlogin;
+ private Button btnRegister;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_login);
+ initViews(); //初始化页面控件
+ initEvents(); //初始化控件事件
+ }
+
+ //初始化页面控件
+ private void initViews() {
+ accountEdit = (EditText) findViewById(R.id.account);
+ passwordEdit = (EditText) findViewById(R.id.password);
+ btnlogin = (Button) findViewById(R.id.login);
+ btnRegister = (Button) findViewById(R.id.register);
+ }
+
+ //初始化控件事件
+ private void initEvents() {
+ //给登录按钮设置点击事件
+ btnlogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String account = accountEdit.getText().toString();
+ String password = passwordEdit.getText().toString();
+ //判断用户名和密码是否正确
+ if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(password)) { //用户名和密码都不为空
+ //尝试登陆
+ tryToLogin(account, password);
+ } else {
+ showDialog("用户名或密码不能为空!");
+ }
+
+ }
+ });
+
+ //给注册按钮设置点击事件
+ btnRegister.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //跳转到注册界面
+ startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
+ LoginActivity.this.finish(); //结束当前界面
+ }
+ });
+ }
+
+ /**
+ * 进行登录请求的数据库查询
+ *
+ * @param username 用户名
+ * @param password 密码
+ */
+ private void tryToLogin(String username, String password) {
+ String postUrl = HttpUtil.HOST + "api/user/login";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("username", username);
+ request.add("password", password);
+
+ //直接连本地数据库呢?直接从本地数据库获取信息
+
+ /**/queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ JSONObject data = res.getJSONObject("data");
+ //给用户的钱包余额设定金额
+ ShareUtils.putInt(getApplicationContext(), "money", data.getInt("money"));
+ ShareUtils.putInt(getApplicationContext(), "user_id", data.getInt("id"));
+ ShareUtils.putString(getApplicationContext(), "user_true_name", data.getString("nickname"));
+ ShareUtils.putString(getApplicationContext(), "user_true_phone", data.getString("phone"));
+ ShareUtils.putString(getApplicationContext(), "user_true_mail", data.getString("email"));
+ //登录成功,跳转到菜单展示的主页面
+ Intent intent = new Intent(LoginActivity.this, OrderActivity.class);
+ startActivity(intent);
+ finish();
+ } else {
+ showDialog(res.getString("msg"));
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ //登录成功,跳转到菜单展示的主页面
+ Intent intent = new Intent(LoginActivity.this, OrderActivity.class);
+ startActivity(intent);
+ }
+
+ @Override
+ public void onFinish(int what) {
+ //登录成功,跳转到菜单展示的主页面
+ Intent intent = new Intent(LoginActivity.this, OrderActivity.class);
+ startActivity(intent);
+ }
+ });
+ }
+
+ /**
+ * 为了方便,定义一个弹框控件的函数
+ *
+ * @param msg 要显示的提示信息
+ */
+ private void showDialog(String msg) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(msg)
+ .setCancelable(false)
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/MyApplication.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/MyApplication.java
new file mode 100644
index 0000000..3df505c
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/MyApplication.java
@@ -0,0 +1,29 @@
+package com.sbw.atrue.Order.Activity;
+import com.yanzhenjie.nohttp.InitializationConfig;
+import com.yanzhenjie.nohttp.NoHttp;
+
+import org.litepal.LitePalApplication;
+import org.litepal.util.Const;
+
+public class MyApplication extends LitePalApplication {
+ @Override
+ public void onCreate() {//可理解为我们之前的主函数
+ super.onCreate();
+ Connection.mymysql();
+ InitializationConfig config = InitializationConfig.newBuilder(this)
+ .connectionTimeout(30 * 1000)
+ .readTimeout(30 * 1000)
+ .retry(10)
+ .build();
+ NoHttp.initialize(config);
+ }
+}
+/*public class MyApplication extends Application {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ LitePal.initialize(this);
+ }
+ ...
+}*/
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/MyMoneyActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/MyMoneyActivity.java
new file mode 100644
index 0000000..d025961
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/MyMoneyActivity.java
@@ -0,0 +1,102 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * FileName: MyMoneyActivity
+ * Description:
+ * Author: 沈滨伟-13042299081
+ * Date: 2019/4/12 16:51
+ */
+public class MyMoneyActivity extends Activity {
+ //账户余额显示文字控件
+ private TextView myMoney;
+ private Button btnSure;
+ private Button btnsaveMoney;
+ private int nowMoney;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.my_money);
+ myMoney = (TextView) findViewById(R.id.my_money);
+ btnSure = (Button) findViewById(R.id.btn_Sure);
+ btnsaveMoney = (Button) findViewById(R.id.btn_SaveMoney);
+ //读取本地文件中的账户余额
+ nowMoney = ShareUtils.getInt(MyMoneyActivity.this, "money", 1);
+ myMoney.setText(String.valueOf(nowMoney));
+
+ //给确定按钮设置点击事件
+ btnSure.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //结束当前界面,将自动返回系统上一级未被销毁的活动!比如结账活动或者主页面活动
+ MyMoneyActivity.this.finish();
+ }
+ });
+
+ //给充值按钮设置点击事件
+ btnsaveMoney.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String postUrl = HttpUtil.HOST + "api/user/addMoney";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("userId", ShareUtils.getInt(getApplicationContext(), "user_id", 0));
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ int data = res.getInt("data");
+ ShareUtils.putInt(MyMoneyActivity.this, "money", data);
+ myMoney.setText(String.valueOf(data));
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+
+ }
+ });
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/NutritionActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/NutritionActivity.java
new file mode 100644
index 0000000..a7afa62
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/NutritionActivity.java
@@ -0,0 +1,5 @@
+package com.sbw.atrue.Order.Activity;
+//健康结算界面
+public class NutritionActivity {
+
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/OrderActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/OrderActivity.java
new file mode 100644
index 0000000..a114060
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/OrderActivity.java
@@ -0,0 +1,398 @@
+package com.sbw.atrue.Order.Activity;
+
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.navigation.NavigationView;
+
+import androidx.core.view.GravityCompat;
+import androidx.drawerlayout.widget.DrawerLayout;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.appcompat.widget.Toolbar;
+
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.sbw.atrue.Order.Entity.Food;
+import com.sbw.atrue.Order.Entity.Product;
+import com.sbw.atrue.Order.Util.FoodAdapter;
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Util.FoodFctory;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.MyListener;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ClassName: OrderActivity
+ * description: 用于展示菜单的活动
+ * author: 沈滨伟-13042299081
+ * Date: 2019/2/18 21:03
+ */
+public class OrderActivity extends AppCompatActivity {
+ //从生产类中加载系统存储的菜单列表
+// private Food[] foods = FoodFctory.Beef;
+ private List foodList = new ArrayList<>();
+ private DrawerLayout mDrawerLayout;
+ private FoodAdapter adapter;
+ private SwipeRefreshLayout swipeRefresh;
+ private int first = 0;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_order);
+ //导入Toolbar的自定义布局形式
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ //导入滑动菜单
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ NavigationView navView = (NavigationView) findViewById(R.id.nav_view);
+ //获得ActionBar的实例,虽然此ActionBar具体实现是由ToolBar来完成的
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ //将ActionBar的导航按钮HomeAsUp显示出来(Toolbar标题栏最左侧的按钮图标默认为箭头,含义为返回上一级活动)
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ //更改导航按钮HomeAsUp的默认图标(箭头改为导航键)
+ //actionBar.setHomeAsUpIndicator(R.drawable.ic_comment);
+ }
+ //设置滑动菜单的按钮点击事件
+ navView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
+ @Override
+ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
+ //点击任意菜单选项,则将滑动菜单关闭
+ // mDrawerLayout.closeDrawers();
+ menuItem.setChecked(true);
+ switch (menuItem.getItemId()) {
+ case R.id.nav_Order:
+ //跳转到订单界面
+ orderDetail(new MyListener() {
+ @Override
+ public void onSuccess(JSONArray array) throws JSONException {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < array.length(); i++) {
+ sb.append(getDataString(array.getJSONObject(i)));
+ }
+ Log.e("demo", "onSuccess: "+sb.toString() );
+ Intent intent = new Intent(OrderActivity.this, ReadOrderActivity.class);
+ intent.putExtra("content", sb.toString());
+ startActivity(intent);
+ }
+ });
+
+ break;
+ case R.id.nav_money:
+ //跳转到钱包界面
+ startActivity(new Intent(OrderActivity.this, MyMoneyActivity.class));
+ break;
+ case R.id.nav_setting:
+ //跳转到钱包界面
+ startActivity(new Intent(OrderActivity.this, SettingActivity.class));
+ break;
+ case R.id.nav_logout:
+ //跳转到登陆界面
+ startActivity(new Intent(OrderActivity.this, LoginActivity.class));
+ //结束当前界面
+ OrderActivity.this.finish();
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+ });
+ //悬浮按键的设置
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //跳转到登陆界面
+ startActivity(new Intent(OrderActivity.this, ShoppingActivity.class));
+ }
+ });
+ //显示菜单的控件逻辑
+ initFruits();
+ RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
+ GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
+ recyclerView.setLayoutManager(layoutManager);
+ adapter = new FoodAdapter(foodList);
+ recyclerView.setAdapter(adapter);
+ //刷新菜单的控件逻辑
+ swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
+ swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
+ swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ refreshfoods();
+ }
+ });
+ }
+
+ /**
+ * 初始化页面数据
+ */
+ private void initDatas(String demo) {
+
+
+ }
+
+ private String getDataString(JSONObject data) throws JSONException {
+ double totalPrice = 0; //购买商品总价
+
+ ArrayList selectedProducts = new ArrayList<>();
+ JSONArray array = data.getJSONArray("selectedProducts");
+ for (int i = 0; i < array.length(); i++) {
+ JSONObject jsonObject = array.getJSONObject(i);
+ int id = 0;
+ String name = jsonObject.getString("foodName");
+ double price = jsonObject.getDouble("price");
+// JSONObject product=jsonObject.getJSONObject("product");
+
+// String picture = product.getString("picture");
+
+
+ int sale = 1;
+ String shopName = "";
+ String detail = "";
+ boolean isShowSubBtn = true;
+ Product product = new Product(id, name, price, "", sale, shopName, detail, isShowSubBtn);
+ product.setSelctCount(jsonObject.getInt("num"));
+ selectedProducts.add(product);
+ }
+
+ String name = data.getString("userName");
+ String phone = data.getString("phone"); //从意图获取手机号
+ String tableId = data.getString("tableId"); //从意图获取用餐桌号
+ StringBuilder orderResult = new StringBuilder(); //新建订单结果信息
+ orderResult.append("\t\t\t\t\t\t\t订单信息如下\n\n");//添加文本内容
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ for (int i = 0; i < selectedProducts.size(); i++) { //遍历商品列表并往文本写入商品信息
+ Product product = selectedProducts.get(i);
+ if (product.getName().length() == 2) {
+ orderResult.append(product.getName() + "\t\t\t\t\t\t\t " + product.getSelectedCount() + " \t\t\t\t\t" + product.getPrice() * product.getSelectedCount() + "\n");
+ } else {
+ orderResult.append(product.getName() + "\t\t\t\t\t" + product.getSelectedCount() + "\t\t\t\t\t" + product.getPrice() * product.getSelectedCount() + "\n");
+ }
+ totalPrice += product.getPrice() * product.getSelectedCount(); //设置商品总价
+ }
+
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + totalPrice + "元\n\n");
+ orderResult.append("\t\t\t\t\t\t\t您的信息如下\n");
+ orderResult.append("*************************\n");
+ orderResult.append("姓名:" + name + "\n");
+ orderResult.append("电话:" + phone + "\n");
+ orderResult.append("桌号:" + tableId + "\n");
+ //获取当前系统时间(记录下单时间)
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
+ Date date = new Date(System.currentTimeMillis());
+ String nowTime = simpleDateFormat.format(date);
+ orderResult.append("时间:" + nowTime + "\n");
+ //将订单结果信息设置到订单信息显示文字控件
+ return orderResult.toString();
+ }
+
+ private void orderDetail(final MyListener literer) {
+ String postUrl = HttpUtil.HOST + "api/order/list";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("userId", ShareUtils.getInt(getApplicationContext(), "user_id", 0));
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ literer.onSuccess(res.getJSONArray("data"));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+ }
+
+ /**
+ * 刷新菜单
+ */
+ private void refreshfoods() {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ //为了避免程序刷新太快,先让线程睡眠2秒
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ //从子线程切回到主线程,从而可以更改UI
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ //向菜单中增加新菜
+ if (first == 0) {
+ Food WanZi = new Food("牛肉丸", "R.drawable.wanzi", "牛肉丸是潮汕美食啊!!!");
+ foodList.add(WanZi);
+ first = 1;
+ }
+ //通知适配器数据发生了变化,用于RecycleView自动更新显示项
+ adapter.notifyDataSetChanged();
+ //刷新结束,将刷新进度条隐藏
+ swipeRefresh.setRefreshing(false);
+ //显示更新结果的弹框通知,告知用户更新情况
+ AlertDialog.Builder builder = new AlertDialog.Builder(OrderActivity.this);
+ builder.setMessage("菜单更新成功啦~")
+ .setCancelable(false)
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+ });
+ }
+ }).start();
+ }
+
+ /**
+ * 将Food数组转换为数组列表
+ */
+ private void initFruits() {
+ foodList.clear();
+ String postUrl = HttpUtil.HOST + "api/food/list";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ JSONArray array = res.getJSONArray("data");
+ for (int i = 0; i < array.length(); i++) {
+ JSONObject data = array.getJSONObject(i);
+
+ Food food = new Food(data.getString("name"), data.getString("imageId"), data.getString("description"));
+ foodList.add(food);
+ }
+ adapter.notifyDataSetChanged();
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+ }
+
+ /**
+ * 加载toolbar.xml菜单文件
+ *
+ * @param menu
+ * @return
+ */
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.toolbar, menu);
+ return true;
+ }
+
+ /**
+ * Toolbat导航栏按键的响应事件
+ *
+ * @param item
+ * @return
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ //android.R.id.home是标题栏最左侧按键HomeAsUp的Id
+ case android.R.id.home:
+ //将滑动菜单展示出来,GravityCompat.START参数与XML文件定义的保持一致
+ mDrawerLayout.openDrawer(GravityCompat.START);
+ break;
+ case R.id.backup:
+ Toast.makeText(this, "You click Backup", Toast.LENGTH_SHORT).show();
+ break;
+ case R.id.delete:
+ Toast.makeText(this, "You click Delete", Toast.LENGTH_SHORT).show();
+ break;
+ case R.id.setting:
+ Toast.makeText(this, "You click Setting", Toast.LENGTH_SHORT).show();
+ break;
+ default:
+ }
+ return true;
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/ReadOrderActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/ReadOrderActivity.java
new file mode 100644
index 0000000..878a43f
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/ReadOrderActivity.java
@@ -0,0 +1,137 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+import com.sbw.atrue.Order.Entity.Order;
+import com.sbw.atrue.Order.Entity.Product;
+import com.sbw.atrue.Order.Entity.ProductOrder;
+import com.sbw.atrue.Order.R;
+
+import org.litepal.crud.DataSupport;
+
+import java.util.List;
+
+/**
+ * FileName: ReadOrderActivity
+ * Description: 查看历史订单信息
+ * Author: 沈滨伟-13042299081
+ * Date: 2019/4/9 10:52
+ */
+public class ReadOrderActivity extends Activity {
+
+ private TextView tvResult; //订单信息显示文字控件
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_readorder);
+ tvResult = (TextView) findViewById(R.id.tv_result);
+ //从数据库中读取订单信息
+ //readFromSqlite();
+ //暴力输出订单信息
+ readBaoLi();
+ }
+
+ /**
+ * 基于LitePal框架,从SQlite数据库中读取客户的订单信息并输出
+ */
+ private void readFromSqlite(){
+ //从SQLite数据库读取历史订单列表
+ List orders=DataSupport.findAll(Order.class);
+ //遍历订单列表并输出订单信息
+ for(Order order:orders){
+ StringBuilder orderResult = new StringBuilder(); //新建订单结果信息
+ orderResult.append("\t\t\t\t\t\t\t订单信息如下\n");//添加文本内容
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ double totalPrice = 0; //购买商品总价
+ for (int i = 0; i < order.getSelectedProducts().size(); i++) { //遍历商品列表并往文本写入商品信息
+ ProductOrder product = order.getSelectedProducts().get(i);
+ if(product.getFoodName().length()==2){
+ orderResult.append(product.getFoodName() + "\t\t\t\t\t\t\t " + product.getNum() + " \t\t\t\t\t" + product.getPrice() + "\n");
+ }else{
+ orderResult.append(product.getFoodName() + "\t\t\t\t\t" + product.getNum() + "\t\t\t\t\t" + product.getPrice()+ "\n");
+ }
+ totalPrice += product.getPrice(); //设置商品总价
+ }
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + totalPrice + "元\n\n");
+ orderResult.append("\t\t\t\t\t\t\t您的信息如下\n");
+ orderResult.append("*************************\n");
+ orderResult.append("姓名:" + order.getUserName() + "\n");
+ orderResult.append("电话:" + order.getPhone() + "\n");
+ orderResult.append("桌号:" + order.getTableId()+ "\n");
+ orderResult.append("时间:"+ order.getTime()+ "\n");
+ //将订单结果信息设置到订单信息显示文字控件
+ tvResult.setText(orderResult);
+ }
+ }
+
+ /**
+ * 暴力输出订单信息,不基于数据库
+ */
+ private void readBaoLi(){
+ StringBuilder orderResult = new StringBuilder(); //新建订单结果信息
+ orderResult.append("\t\t\t\t\t\t\t订单1\n");//添加文本内容
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ orderResult.append("牛肉丸"+ "\t\t\t\t\t" + 2 + " \t\t\t\t\t" + 76 + "\n");
+ orderResult.append("嫩肉"+ "\t\t\t\t\t\t\t " + 2 + " \t\t\t\t\t" + 76 + "\n");
+ orderResult.append("五花趾"+ "\t\t\t\t\t" + 1 + " \t\t\t\t\t" + 38 + "\n");
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + 152 + "元\n");
+ orderResult.append("姓名:" + "沈滨伟" + "\n");
+ orderResult.append("电话:" + "13042299081" + "\n");
+ orderResult.append("桌号:" + "10"+ "\n");
+ orderResult.append("时间:"+ "2019年4月10日 15:11:35"+ "\n");
+
+ orderResult.append("\n\n");
+ orderResult.append("\t\t\t\t\t\t\t订单2\n");
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ orderResult.append("雪花"+ "\t\t\t\t\t\t\t " + 2 + " \t\t\t\t\t" + 100 + "\n");
+ orderResult.append("吊龙"+ "\t\t\t\t\t\t\t " + 1 + " \t\t\t\t\t" + 40 + "\n");
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + 140 + "元\n");
+ orderResult.append("姓名:" + "沈滨伟" + "\n");
+ orderResult.append("电话:" + "13042299081" + "\n");
+ orderResult.append("桌号:" + "10"+ "\n");
+ orderResult.append("时间:"+ "2019年4月11日 19:24:30"+ "\n");
+
+ orderResult.append("\n\n");
+ orderResult.append("\t\t\t\t\t\t\t订单3\n");
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ orderResult.append("胸口朥"+ "\t\t\t\t\t" + 2 + " \t\t\t\t\t" + 90 + "\n");
+ orderResult.append("嫩肉"+ "\t\t\t\t\t\t\t " + 2 + " \t\t\t\t\t" + 76 + "\n");
+ orderResult.append("五花趾"+ "\t\t\t\t\t" + 1 + " \t\t\t\t\t" + 38 + "\n");
+ orderResult.append("吊龙"+ "\t\t\t\t\t\t\t " + 2 + " \t\t\t\t\t" + 80 + "\n");
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + 284 + "元\n");
+ orderResult.append("姓名:" + "沈滨伟" + "\n");
+ orderResult.append("电话:" + "13042299081" + "\n");
+ orderResult.append("桌号:" + "10"+ "\n");
+ orderResult.append("时间:"+ "2019年4月12日 08:15:45"+ "\n");
+
+ orderResult.append("\n\n");
+ orderResult.append("\t\t\t\t\t\t\t订单4\n");
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ orderResult.append("三花趾"+ "\t\t\t\t\t" + 2 + " \t\t\t\t\t" + 72 + "\n");
+ orderResult.append("胸口朥"+ "\t\t\t\t\t" + 2 + " \t\t\t\t\t" + 90 + "\n");
+ orderResult.append("嫩肉"+ "\t\t\t\t\t\t\t " + 2 + " \t\t\t\t\t" + 76 + "\n");
+ orderResult.append("五花趾"+ "\t\t\t\t\t" + 1 + " \t\t\t\t\t" + 38 + "\n");
+ orderResult.append("嫩肉"+ "\t\t\t\t\t\t\t " + 3 + " \t\t\t\t\t" + 120 + "\n");
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + 399 + "元\n");
+ orderResult.append("姓名:" + "沈滨伟" + "\n");
+ orderResult.append("电话:" + "13042299081" + "\n");
+ orderResult.append("桌号:" + "10"+ "\n");
+ orderResult.append("时间:"+ "2019年4月15日 11:24:06"+ "\n");
+
+ //将订单结果信息设置到订单信息显示文字控件
+ tvResult.setText(getIntent().getStringExtra("content"));
+
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/RegisterActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/RegisterActivity.java
new file mode 100644
index 0000000..2b3df50
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/RegisterActivity.java
@@ -0,0 +1,186 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+public class RegisterActivity extends Activity {
+
+ private EditText etUsername; //用户名输入框
+ private EditText etPassword; //密码输入框
+ private EditText etPassAgain; //第二次密码输入框
+ private TextView tvNameWrong; //用户名错误提示文字
+ private TextView tvPssWrong; //密码错误提示文字
+ private TextView tvPssNotMatch; //密码错误提示文字
+ private Button btnRegister; //注册按钮
+ private Button btnLogin; //登录按钮
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_register);
+ initViews(); //初始化页面控件
+ initEvents(); //初始化控件事件
+ }
+
+ //初始化页面控件
+ private void initViews() {
+ etUsername = (EditText) findViewById(R.id.et_username);
+ etPassword = (EditText) findViewById(R.id.et_password);
+ etPassAgain = (EditText) findViewById(R.id.et_pass_again);
+ tvNameWrong = (TextView) findViewById(R.id.tv_name_wrong);
+ tvPssWrong = (TextView) findViewById(R.id.tv_pass_wrong);
+ tvPssNotMatch = (TextView) findViewById(R.id.tv_pass_not_match);
+ btnRegister = (Button) findViewById(R.id.btn_register);
+ btnLogin = (Button) findViewById(R.id.btn_login);
+ }
+
+ //初始化控件事件
+ private void initEvents() {
+ //给登陆按钮设置点击事件
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //跳转到登陆界面
+ startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
+ RegisterActivity.this.finish(); //结束当前界面
+ }
+ });
+
+ //给注册按钮设置点击事件
+ btnRegister.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //获取用户名输入框中的内容
+ String username = etUsername.getText().toString();
+ //获取密码输入框中的内容
+ String password = etPassword.getText().toString();
+ //获取再次输入密码输入框中的内容
+ String passAgain = etPassAgain.getText().toString();
+
+ //判断用户名和密码是否正确
+ if (!TextUtils.isEmpty(username)
+ && !TextUtils.isEmpty(password)
+ && !TextUtils.isEmpty(passAgain)
+ && password.equals(passAgain)) { //用户名和密码都不为空且两次密码相同
+
+ hideNameAndPassError(); //隐藏用户名和密码错误提示
+ tryToRegister(username, password); //尝试登陆
+
+ } else { //用户名或密码为空或两次密码不同
+ showNameOrPassError(username, password, passAgain); //显示用户名或密码错误文字提示
+ }
+ }
+ });
+ }
+
+ //隐藏用户名和密码错误提示
+ private void hideNameAndPassError() {
+ tvNameWrong.setVisibility(View.INVISIBLE); //隐藏用户名不能为空提示文字
+ tvPssWrong.setVisibility(View.INVISIBLE); //隐藏不能为空提示文字
+ tvPssNotMatch.setVisibility(View.INVISIBLE); //隐藏两次密码不一致提示文字
+ }
+
+ //尝试登陆
+ private void tryToRegister(final String username, final String password) {
+ String postUrl = HttpUtil.HOST + "api/user/register";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("username", username);
+ request.add("password", password);
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ JSONObject data = res.getJSONObject("data");
+ Toast.makeText(getApplicationContext(), "成功注册用户:" + username, Toast.LENGTH_SHORT).show();
+ //跳转到商品购买页面
+ startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
+ finish();
+ } else {
+ Toast.makeText(getApplicationContext(), "用户名已存在", Toast.LENGTH_SHORT).show();
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+
+ //获取数据库中该用户名对应的密码
+ String realPassword = ShareUtils.getString(this, username, "");
+ if ("".equals(realPassword)) { //数据库中没有该用户名的数据
+
+ } else { //该用户名已存在数据库中
+ //提示用户名已存在
+
+ }
+ }
+
+ /**
+ * 显示用户名或密码错误文字提示
+ *
+ * @param username 输入的用户名
+ * @param password 输入的密码
+ * @param passAgain 再次输入的密码
+ */
+ private void showNameOrPassError(String username, String password, String passAgain) {
+ if (TextUtils.isEmpty(username)) { //用户名为空
+ tvNameWrong.setVisibility(View.VISIBLE); //显示用户名错误提示文字
+ } else { //用户名不为空
+ tvNameWrong.setVisibility(View.INVISIBLE); //用户名错误提示文字消失
+ }
+
+ if (TextUtils.isEmpty(password)) { //密码为空
+ tvPssWrong.setVisibility(View.VISIBLE); //显示密码错误提示文字
+ } else { //密码不为空
+ tvPssWrong.setVisibility(View.INVISIBLE); //密码错误提示文字消失
+ }
+
+ if (!password.equals(passAgain)) { //两次输入的密码不同
+ tvPssNotMatch.setVisibility(View.VISIBLE); //显示两次密码输入不一致提示
+ } else { //两次输入的密码相同
+ tvPssNotMatch.setVisibility(View.INVISIBLE); //两次密码输入不一致提示消失
+ }
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/SettingActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/SettingActivity.java
new file mode 100644
index 0000000..94909e1
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/SettingActivity.java
@@ -0,0 +1,103 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * FileName: SettingActivity
+ * Description:
+ * Author: 沈滨伟-13042299081
+ * Date: 2019/4/12 20:55
+ */
+public class SettingActivity extends Activity {
+ private EditText etname; //姓名输入框
+ private EditText etPhone; //手机号输入框
+ private EditText etMail; //邮箱输入框
+ private Button btnInputCompleted; //输入完成按钮
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.person_setting);
+ etname = (EditText) findViewById(R.id.et_name);
+ etPhone = (EditText) findViewById(R.id.et_phone);
+ etMail = (EditText) findViewById(R.id.et_mail);
+ btnInputCompleted = (Button) findViewById(R.id.btn_input_completed);
+ //登录时默认自动在本地保存了一份客户信息,将其读取出来并显示
+ etname.setText(ShareUtils.getString(this, "user_true_name", ""));
+ etPhone.setText(ShareUtils.getString(this, "user_true_phone", ""));
+ etMail.setText(ShareUtils.getString(this, "user_true_mail", ""));
+ btnInputCompleted.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+
+ String postUrl = HttpUtil.HOST + "api/user/updateUser";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("id", ShareUtils.getInt(getApplicationContext(), "user_id", 0));
+ request.add("nickname", etname.getText().toString());
+ request.add("phone", etPhone.getText().toString());
+ request.add("email", etMail.getText().toString());
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ //保存用户新设置的客户个人信息
+ ShareUtils.putString(SettingActivity.this, "user_true_name", etname.getText().toString());
+ ShareUtils.putString(SettingActivity.this, "user_true_phone", etPhone.getText().toString());
+ ShareUtils.putString(SettingActivity.this, "user_true_mail", etMail.getText().toString());
+ //登录成功,跳转到菜单展示的主页面
+ Intent intent = new Intent(SettingActivity.this, OrderActivity.class);
+ startActivity(intent);
+ finish();
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+
+
+ }
+ });
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/ShoppingActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/ShoppingActivity.java
new file mode 100644
index 0000000..662234c
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/ShoppingActivity.java
@@ -0,0 +1,258 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import com.sbw.atrue.Order.Entity.Food;
+import com.sbw.atrue.Order.Entity.Product;
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Util.FoodFctory;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.ProductListAdapter;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class ShoppingActivity extends Activity {
+ public static ShoppingActivity mInstance = null; //当前对象的实例本身
+
+ private ListView lvProduct; //商品展示列表控件
+ private TextView tvSelected; //已选择商品数量提示文字
+ private TextView tvTotal; //已选择商品总价提示文字
+ private Button btnTakeOrder; //下单按钮
+ private Button btnSortByNew; //根据新品排序
+ private Button btnSortBySale; //根据销量排序
+ private Button btnSortByPrice; //根据价格排序
+ private Button btnSortByAll; //根据综合情况排序
+ private List productsData = new ArrayList(); //所有的商品数据
+ private ArrayList selectedProducts = new ArrayList(); //被选择的的商品数据
+ private ProductListAdapter productListAdapter; //商品列表适配器
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_shopping);
+ initViews(); //初始化页面控件
+ initDatas(); //初始化数据
+ initEvents(); //初始化控件事件
+ }
+
+ private void initDatas() {
+ productsData = new ArrayList<>();
+ String postUrl = HttpUtil.HOST + "api/food/productList";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ JSONArray array = res.getJSONArray("data");
+ for (int i = 0; i < array.length(); i++) {
+ JSONObject data = array.getJSONObject(i);
+
+ Product product = new Product(data.getInt("id"),
+ data.getString("name"),
+ data.getDouble("price"),
+ data.getString("picture"),
+ data.getInt("sale"),
+ data.getString("shopName"),
+ data.getString("detail"), true);
+ productsData.add(product);
+ }
+ productListAdapter.notifyDataSetChanged();
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+
+ }
+
+ //初始化页面控件
+ private void initViews() {
+ lvProduct = (ListView) findViewById(R.id.lv_product);
+ tvSelected = (TextView) findViewById(R.id.tv_selected);
+ tvTotal = (TextView) findViewById(R.id.tv_total);
+ btnTakeOrder = (Button) findViewById(R.id.btn_take_order);
+ btnSortByNew = (Button) findViewById(R.id.btn_sort_by_new);
+ btnSortByPrice = (Button) findViewById(R.id.btn_sort_by_price);
+ btnSortBySale = (Button) findViewById(R.id.btn_sort_by_sale);
+ btnSortByAll = (Button) findViewById(R.id.btn_sort_by_all);
+ }
+
+ //初始化控件事件
+ private void initEvents() {
+ mInstance = this; //设置实例等于当前对象本身
+ //将数据源放入适配器中
+ productListAdapter = new ProductListAdapter(this, productsData);
+ //给商品展示列表控件设置顶部分隔线
+ lvProduct.addHeaderView(new View(this));
+ //给商品展示列表控件设置适配器
+ lvProduct.setAdapter(productListAdapter);
+
+ //给下单按钮添加点击事件
+ btnTakeOrder.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (selectedProducts.size() != 0) { //已选择商品数据不为空
+ Intent intent = new Intent(getApplicationContext(), InputActivity.class); //新建意图
+ intent.putParcelableArrayListExtra("selectedProducts", selectedProducts); //设置已选择的商品数据
+ startActivity(intent); //启动信息输入界面
+ } else { //已选择商品数据为空
+ showDialog("购物车为空,请选择商品!");
+ }
+ }
+ });
+
+ //给按新品排序按钮设置点击事件
+ btnSortByNew.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) { //点击事件
+ Collections.sort(productsData, new Comparator() { //对商品数据进行排序
+ @Override
+ public int compare(Product product1, Product product2) { //比较商品
+ //如果本商品被选择次数大于第二个商品
+ if (product1.getSelectedCount() > product2.getSelectedCount()) {
+ return 1; //返回正数代表本商品大于第二个商品
+ }
+ return -1; //返回负数代表本商品小于第二个商品
+ }
+ });
+ productListAdapter.notifyDataSetChanged(); //通知系统数据改变
+ }
+ });
+
+ //给按销量排序按钮设置点击事件
+ btnSortBySale.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) { //点击事件
+ Collections.sort(productsData, new Comparator() { //对商品数据进行排序
+ @Override
+ public int compare(Product product1, Product product2) { //比较商品
+ //如果本商品的销量小于第二个商品
+ if (product1.getSale() < product2.getSale()) {
+ return 1; //返回正数代表本商品大于第二个商品
+ }
+ return -1; //返回负数代表本商品小于第二个商品
+ }
+ });
+ productListAdapter.notifyDataSetChanged(); //通知系统数据改变
+ }
+ });
+
+ //给按价格排序按钮设置点击事件
+ btnSortByPrice.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) { //点击事件
+ Collections.sort(productsData, new Comparator() { //对商品数据进行排序
+ @Override
+ public int compare(Product product1, Product product2) { //比较商品
+ //如果本商品的价格大于第二个商品
+ if (product1.getPrice() > product2.getPrice()) {
+ return 1; //返回正数代表本商品大于第二个商品
+ }
+ return -1; //返回负数代表本商品小于第二个商品
+ }
+ });
+ productListAdapter.notifyDataSetChanged(); //通知系统数据改变
+ }
+ });
+
+ //给按综合排序按钮设置点击事件
+ btnSortByAll.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) { //点击事件
+ Collections.sort(productsData, new Comparator() { //对商品数据进行排序
+ @Override
+ public int compare(Product product1, Product product2) { //比较商品
+ //如果本商品的价格大于第二个商品
+ if (product1.getId() > product2.getId()) {
+ return 1; //返回正数代表本商品大于第二个商品
+ }
+ return -1; //返回负数代表本商品小于第二个商品
+ }
+ });
+ productListAdapter.notifyDataSetChanged(); //通知系统数据改变
+ }
+ });
+ }
+
+ //设置被选择商品数量与价格
+ public void setSelectedCountAndPrice(int selectedCount, int totalPrice) {
+ tvSelected.setText(String.valueOf(selectedCount)); //在界面上设置已选择商品数量的信息
+ tvTotal.setText(String.valueOf(totalPrice)); //在界面上设置已选择商品总价的信息
+ if (selectedCount == 0 && totalPrice == 0) { //当被选择商品数量和总价都为0时
+ for (Product product : productsData) { //遍历商品列表
+ product.clearZero(); //将每一项商品的选择次数归零与不显示减去按钮
+ }
+ selectedProducts.clear(); //清空已选择商品列表
+ productListAdapter.notifyDataSetChanged(); //通知系统数据已改变
+ }
+ }
+
+ //设置被选择的商品数据
+ public void setSelectedProducts(ArrayList data) {
+ this.selectedProducts = data; //获取被选择商品数据
+ productListAdapter.setSelectedProducts(data); //设置被选择商品数据到商品适配器
+ }
+
+
+ /**
+ * 为了方便,定义一个弹框控件的函数
+ *
+ * @param msg 要显示的提示信息
+ */
+ private void showDialog(String msg) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(msg)
+ .setCancelable(false)
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Activity/SuccessActivity.java b/src/app/src/main/java/com/sbw/atrue/Order/Activity/SuccessActivity.java
new file mode 100644
index 0000000..498a1f6
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Activity/SuccessActivity.java
@@ -0,0 +1,459 @@
+package com.sbw.atrue.Order.Activity;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.google.gson.Gson;
+import com.sbw.atrue.Order.Entity.Order;
+import com.sbw.atrue.Order.Entity.ProductOrder;
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Entity.Product;
+import com.sbw.atrue.Order.Util.HttpUtil;
+import com.sbw.atrue.Order.Util.MyListener;
+import com.sbw.atrue.Order.Util.ShareUtils;
+import com.yanzhenjie.nohttp.NoHttp;
+import com.yanzhenjie.nohttp.RequestMethod;
+import com.yanzhenjie.nohttp.rest.JsonObjectRequest;
+import com.yanzhenjie.nohttp.rest.OnResponseListener;
+import com.yanzhenjie.nohttp.rest.Request;
+import com.yanzhenjie.nohttp.rest.RequestQueue;
+import com.yanzhenjie.nohttp.rest.Response;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.litepal.tablemanager.Connector;
+
+public class SuccessActivity extends Activity {
+ private static final String TAG = SuccessActivity.class.getName();
+ private TextView tvResult; //订单信息显示文字控件
+ private Button btnContinueBuy; //加菜按钮
+ private Button btnPay; //结账按钮
+ private ArrayList selectedProducts = new ArrayList(); //被选择的的商品数据
+ private String nowTime;//订单提交时间
+ private double totalPrice = 0; //购买商品总价
+ private boolean ispay = false; //判断订单是否已被支付
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_success);
+ initViews(); //初始化页面控件
+ initDatas(); //初始化页面数据
+ initEvents(); //初始化控件事件
+ }
+
+ //初始化页面控件
+ private void initViews() {
+ tvResult = (TextView) findViewById(R.id.tv_result);
+ btnContinueBuy = (Button) findViewById(R.id.btn_continue_buy);
+ btnPay = (Button) findViewById(R.id.btn_pay);
+ }
+
+ /**
+ * 初始化控件事件
+ */
+ private void initEvents() {
+ showDialog("您的订单提交成功!请您及时支付!");
+ //给加菜按钮设置点击事件
+ btnContinueBuy.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (ispay) {
+ //跳转到购物界面
+ startActivity(new Intent(getApplicationContext(), ShoppingActivity.class));
+ //结束当前界面
+ SuccessActivity.this.finish();
+ } else {
+ showDialog("您尚未支付当前订单!请结账后再加菜!");
+ }
+ }
+ });
+
+ //给结账按钮设置点击事件
+ btnPay.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //保存订单信息至SQLite数据库中,可惜Litepal框架使用失败。
+// transformData();
+ MyListener stringMyListener = new MyListener() {
+ @Override
+ public void onSuccess(JSONObject data) throws JSONException {
+ if (data.getInt("status") != 0) {
+ showDialog(data.getString("msg"));
+ } else {
+ int myMoney = ShareUtils.getInt(SuccessActivity.this, "money", 1);
+ if (totalPrice > myMoney) {
+ //当账户余额的钱不足以支付当前订单时
+ showDialogNoMoney();
+ } else {
+ myMoney -= totalPrice;
+ //更新账户余额
+ ShareUtils.putInt(SuccessActivity.this, "money", myMoney);
+ //将订单标记为“已结账”,并将结账按钮设置为不可见状态
+ ispay = true;
+ btnPay.setVisibility(View.INVISIBLE);
+ //结账成功后,客户选择返回主界面,还是继续加菜
+ showDialogFinish();
+ }
+ }
+ }
+ };
+ payOrder(getIntent().getStringExtra("orderId"), stringMyListener);
+
+ }
+ });
+ }
+
+ private void payOrder(String orderId, final MyListener listener) {
+ String postUrl = HttpUtil.HOST + "api/order/pay";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("orderId", orderId);
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ Log.w(TAG, "onSucceed: " + res.getString("data"));
+ listener.onSuccess(res);
+ } else {
+ showDialog(res.getString("msg"));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ showDialog(e.getMessage());
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+ }
+
+ /**
+ * 初始化页面数据
+ */
+ private void initDatas() {
+ Intent otherIntent = getIntent(); //获取信息输入界面传来的意图
+ selectedProducts = otherIntent.getParcelableArrayListExtra("selectedProducts"); //从意图中获取被选择的的商品数据
+ String name = otherIntent.getStringExtra("name"); //从意图获取客户姓名
+ String phone = otherIntent.getStringExtra("phone"); //从意图获取手机号
+ String tableId = otherIntent.getStringExtra("table"); //从意图获取用餐桌号
+ StringBuilder orderResult = new StringBuilder(); //新建订单结果信息
+ orderResult.append("\t\t\t\t\t\t\t订单信息如下\n");//添加文本内容
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ for (int i = 0; i < selectedProducts.size(); i++) { //遍历商品列表并往文本写入商品信息
+ Product product = selectedProducts.get(i);
+ if (product.getName().length() == 2) {
+ orderResult.append(product.getName() + "\t\t\t\t\t\t\t " + product.getSelectedCount() + " \t\t\t\t\t" + product.getPrice() * product.getSelectedCount() + "\n");
+ } else {
+ orderResult.append(product.getName() + "\t\t\t\t\t" + product.getSelectedCount() + "\t\t\t\t\t" + product.getPrice() * product.getSelectedCount() + "\n");
+ }
+ totalPrice += product.getPrice() * product.getSelectedCount(); //设置商品总价
+ }
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + totalPrice + "元\n\n");
+ orderResult.append("\t\t\t\t\t\t\t您的信息如下\n");
+ orderResult.append("*************************\n");
+ orderResult.append("姓名:" + name + "\n");
+ orderResult.append("电话:" + phone + "\n");
+ orderResult.append("桌号:" + tableId + "\n");
+ //获取当前系统时间(记录下单时间)
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
+ Date date = new Date(System.currentTimeMillis());
+ nowTime = simpleDateFormat.format(date);
+ orderResult.append("时间:" + nowTime + "\n");
+ //将订单结果信息设置到订单信息显示文字控件
+ tvResult.setText(orderResult);
+ }
+
+ /**
+ * 将该订单信息保存到数据库中,便于客户查询
+ */
+ private void transformData() {
+ Connector.getDatabase();//创建数据库
+ Intent otherIntent = getIntent(); //获取信息输入界面传来的意图
+ selectedProducts = otherIntent.getParcelableArrayListExtra("selectedProducts"); //从意图中获取被选择的的商品数据
+ String name = otherIntent.getStringExtra("name"); //从意图获取客户姓名
+ String phone = otherIntent.getStringExtra("phone"); //从意图获取手机号
+ String tableId = otherIntent.getStringExtra("table"); //从意图获取用餐桌号
+ List productOrders = new ArrayList<>();
+ ProductOrder productOrder = new ProductOrder();
+ for (int i = 0; i < selectedProducts.size(); i++) { //遍历商品列表并存入到productOrders列表中
+ Product product = selectedProducts.get(i);
+ productOrder.setFoodName(product.getName());
+ productOrder.setNum(product.getSelectedCount());
+ productOrder.setPrice(product.getPrice() * product.getSelectedCount());
+ productOrders.add(productOrder);
+ }
+ Order newOrder = new Order();
+ newOrder.setSelectedProducts(productOrders);
+ newOrder.setUserName(name);
+ newOrder.setPhone(phone);
+ newOrder.setTableId(tableId);
+ newOrder.setTime(nowTime);
+
+ String postUrl = HttpUtil.HOST + "api/user/login";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+
+ request.setDefineRequestBodyForJson(new Gson().toJson(newOrder));
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ JSONObject data = res.getJSONObject("data");
+ //给用户的钱包余额设定金额
+ ShareUtils.putInt(getApplicationContext(), "money", data.getInt("money"));
+ ShareUtils.putInt(getApplicationContext(), "user_id", data.getInt("id"));
+ ShareUtils.putString(getApplicationContext(), "user_true_name", data.getString("nickname"));
+ ShareUtils.putString(getApplicationContext(), "user_true_phone", data.getString("phone"));
+ ShareUtils.putString(getApplicationContext(), "user_true_mail", data.getString("email"));
+ //登录成功,跳转到菜单展示的主页面
+ Intent intent = new Intent(getApplicationContext(), OrderActivity.class);
+ startActivity(intent);
+ finish();
+ } else {
+ showDialog(res.getString("msg"));
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+
+ }
+
+
+ /**
+ * 为了方便,定义一个弹框控件的函数
+ *
+ * @param msg 要显示的提示信息
+ */
+ private void showDialog(String msg) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(msg)
+ .setCancelable(false)
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+
+ /**
+ * 当结账时钱不够的弹框提示
+ */
+ private void showDialogNoMoney() {
+ AlertDialog.Builder dialog = new AlertDialog.Builder(SuccessActivity.this);
+ dialog.setTitle("账户余额不足\n\n");
+ dialog.setMessage("请您到充值页面进行充值后再结账!");
+ dialog.setCancelable(false);
+ dialog.setPositiveButton("好的", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startActivity(new Intent(getApplicationContext(), MyMoneyActivity.class));
+ }
+ });
+ dialog.setNegativeButton("不吃了", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Toast.makeText(SuccessActivity.this, "您选择不吃了!", Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.show();
+ }
+
+ /**
+ * 成功结账后的弹框提示
+ */
+ private void showDialogFinish() {
+ AlertDialog.Builder dialog = new AlertDialog.Builder(SuccessActivity.this);
+ dialog.setTitle("订单支付成功!\n\n");
+ dialog.setMessage("您是否想继续加菜?");
+ dialog.setCancelable(false);
+ dialog.setPositiveButton("是的", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Toast.makeText(SuccessActivity.this, "请继续点餐~", Toast.LENGTH_SHORT).show();
+ }
+ });
+ dialog.setNegativeButton("不用了", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Toast.makeText(SuccessActivity.this, "感谢您的光临!祝您用餐愉快!", Toast.LENGTH_SHORT).show();
+ //跳转到购物界面
+ startActivity(new Intent(getApplicationContext(), OrderActivity.class));
+ SuccessActivity.this.finish(); //结束当前界面
+ }
+ });
+ dialog.show();
+ }
+
+
+ /**
+ * 初始化页面数据
+ */
+ private void initDatas(String demo) {
+
+ tvResult.setText("ss\n\n\ndsss");
+ orderDetail(getIntent().getStringExtra("orderId"), new MyListener() {
+ @Override
+ public void onSuccess(JSONObject data) throws JSONException {
+
+ selectedProducts = new ArrayList<>();
+ JSONArray array = data.getJSONArray("selectedProducts");
+ for (int i = 0; i < array.length(); i++) {
+ JSONObject jsonObject = array.getJSONObject(i);
+ int id = 0;
+ String name = jsonObject.getString("foodName");
+ double price = jsonObject.getDouble("price");
+ String picture = jsonObject.getJSONObject("product").getString("picture");
+ int sale = 1;
+ String shopName = "";
+ String detail = "";
+ boolean isShowSubBtn = true;
+ Product product = new Product(id, name, price, picture, sale, shopName, detail, isShowSubBtn);
+ product.setSelctCount(jsonObject.getInt("num"));
+ selectedProducts.add(product);
+ }
+ Log.w(TAG, "onSucceed: " + selectedProducts.size());
+
+ String name = data.getString("userName");
+ String phone = data.getString("phone"); //从意图获取手机号
+ String tableId = data.getString("tableId"); //从意图获取用餐桌号
+ StringBuilder orderResult = new StringBuilder(); //新建订单结果信息
+ orderResult.append("\t\t\t\t\t\t\t订单信息如下\n\n");//添加文本内容
+ orderResult.append("*************************\n");
+ orderResult.append("商品名\t\t\t数量\t\t\t\t价格\n");
+ for (int i = 0; i < SuccessActivity.this.selectedProducts.size(); i++) { //遍历商品列表并往文本写入商品信息
+ Product product = SuccessActivity.this.selectedProducts.get(i);
+ if (product.getName().length() == 2) {
+ orderResult.append(product.getName() + "\t\t\t\t\t\t\t " + product.getSelectedCount() + " \t\t\t\t\t" + product.getPrice() * product.getSelectedCount() + "\n");
+ } else {
+ orderResult.append(product.getName() + "\t\t\t\t\t" + product.getSelectedCount() + "\t\t\t\t\t" + product.getPrice() * product.getSelectedCount() + "\n");
+ }
+ totalPrice += product.getPrice() * product.getSelectedCount(); //设置商品总价
+ }
+ Log.w(TAG, "onSucceed: " + totalPrice);
+
+ orderResult.append("*************************");
+ orderResult.append("\n共计:" + totalPrice + "元\n\n");
+ orderResult.append("\t\t\t\t\t\t\t您的信息如下\n");
+ orderResult.append("*************************\n");
+ orderResult.append("姓名:" + name + "\n");
+ orderResult.append("电话:" + phone + "\n");
+ orderResult.append("桌号:" + tableId + "\n");
+ //获取当前系统时间(记录下单时间)
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
+ Date date = new Date(System.currentTimeMillis());
+ nowTime = simpleDateFormat.format(date);
+ orderResult.append("时间:" + nowTime + "\n");
+ //将订单结果信息设置到订单信息显示文字控件
+ Log.w(TAG, "onSucceed: " + orderResult);
+ tvResult.setText(orderResult);
+ Log.w(TAG, "onSucceed: " + orderResult);
+ initEvents(); //初始化控件事件
+ }
+ });
+
+ }
+
+ private void orderDetail(String orderId, final MyListener literer) {
+ String postUrl = HttpUtil.HOST + "api/order/orderDetail";
+ //1.创建一个队列
+ RequestQueue queue = NoHttp.newRequestQueue();
+ //2.创建消息请求 参数1:String字符串,传网址 参数2:请求方式
+ final Request request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
+ //3.利用队列去添加消息请求
+ //使用request对象添加上传的对象添加键与值,post方式添加上传的数据
+ request.add("userId", ShareUtils.getInt(getApplicationContext(), "user_id", 0));
+ request.add("orderId", orderId);
+
+ queue.add(1, request, new OnResponseListener() {
+ @Override
+ public void onStart(int what) {
+
+ }
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ JSONObject res = response.get();
+ try {
+ if (res.getInt("status") == 0) {
+ Log.w(TAG, "onSucceed: " + res.getJSONObject("data").toString());
+ literer.onSuccess(res.getJSONObject("data"));
+ } else {
+ showDialog(res.getString("msg"));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ showDialog(e.getMessage());
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ }
+
+ @Override
+ public void onFinish(int what) {
+
+ }
+ });
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Entity/Food.java b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Food.java
new file mode 100644
index 0000000..23d3607
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Food.java
@@ -0,0 +1,37 @@
+package com.sbw.atrue.Order.Entity;
+
+import java.io.Serializable;
+
+/**
+ * ClassName: Food
+ * description: 菜品的实体类。定义序列化是为了用于Intent直接传递对象
+ * author: 沈滨伟-13042299081
+ * Date: 2019/2/18 22:08
+ */
+public class Food implements Serializable {
+ //菜品名称
+ private String name;
+ /**
+ * 菜品图像的存储路径,如“R.drawable.mango”
+ */
+ private String imageId;
+ //菜品描述
+ private String description;
+
+ public Food(String name, String imageId,String description) {
+ this.name = name;
+ this.imageId = imageId;
+ this.description=description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getImageId() {
+ return imageId;
+ }
+
+ public String getDescription(){return description;}
+
+}
\ No newline at end of file
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Entity/Nutrition.java b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Nutrition.java
new file mode 100644
index 0000000..c33e080
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Nutrition.java
@@ -0,0 +1,41 @@
+package com.sbw.atrue.Order.Entity;
+
+import org.litepal.crud.DataSupport;
+
+import java.util.HashMap;
+//public类变量和方法可以跨包访问,在全局作用。
+//对实体类进行数据库操作之前,一定要先让我们数据库知道哪些是我们的实体类,可以对其进行操作,故而需要让我们的实体类先继承DataSupport这个类!!!
+public class Nutrition extends DataSupport {
+ private String name;//营养成分这里需要图片吗 感觉可以做个分类出来 某几类的某几个
+ /**
+ * 菜品图像的存储路径,如“R.drawable.mango” 这个就是在这个文件夹下的
+ */
+ //做个排序 健康小助手只展示排名前几的 其余的用其他来代替?
+ private String imageId;
+ public final static int Unit_g = 100;//每100g
+ public int Heat; // 单位为千卡
+ public double protein; // 单位为克
+ public double fat; // 单位为克
+ public double carbohydrates; // 单位为克
+ public double Dietaryfiber; // 单位为克
+ public double Na; // 单位为毫克
+ public double Ca; // 单位为毫克
+ public double Fe; // 单位为毫克
+ public double Mg; // 单位为毫克
+ public double Mn; // 单位为毫克
+ public double Zn; // 单位为毫克
+ public double Cu; // 单位为毫克
+ public double K; // 单位为毫克
+ public double P; // 单位为毫克
+
+ public double thiamine; // 硫胺素 单位为毫克
+ public double riboflavin; // 核黄素 单位为毫克
+ public double nicotinic_acid; // 烟酸 单位为毫克
+ public double cholesterol; // 胆固醇 单位为毫克
+ public double VC; // 维生素C 单位为毫克
+ public double VE; // 维生素E 单位为毫克
+ public double VA; // 维生素A 单位为微克
+ public double Se; // 单位为微克
+ public double Carotene; // 胡罗卜素 单位为微克
+ public double Retinol_equivalent; // 视黄醇当量 单位为微克
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Entity/Order.java b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Order.java
new file mode 100644
index 0000000..907fe9b
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Order.java
@@ -0,0 +1,87 @@
+package com.sbw.atrue.Order.Entity;
+
+import org.litepal.crud.DataSupport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FileName: Order
+ * Description: 订单类
+ * Author: 沈滨伟-13042299081
+ * Date: 2019/4/8 15:25
+ */
+public class Order extends DataSupport {
+ private int id; //订单ID
+ private List selectedProducts; //被选择的的商品数据
+ private double totalPrice;//该订单的总价
+ private String userName;//客户姓名
+ private String phone;//客户电话
+ private String tableId;//用餐桌号
+ private String time;//下单时间
+ private boolean ispay;//是否已结账
+
+ public int getId() {
+ return id;
+ }
+
+ public List getSelectedProducts() {
+ return selectedProducts;
+ }
+
+ public double getTotalPrice() {
+ return totalPrice;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public String getTableId() {
+ return tableId;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public boolean isIspay() {
+ return ispay;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public void setSelectedProducts(List selectedProducts) {
+ this.selectedProducts = selectedProducts;
+ }
+
+ public void setTotalPrice(double totalPrice) {
+ this.totalPrice = totalPrice;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public void setTableId(String tableId) {
+ this.tableId = tableId;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public void setIspay(boolean ispay) {
+ this.ispay = ispay;
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Entity/Product.java b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Product.java
new file mode 100644
index 0000000..3021b98
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Entity/Product.java
@@ -0,0 +1,155 @@
+package com.sbw.atrue.Order.Entity;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+//商品类
+public class Product implements Parcelable {
+ private int id; //商品表示符
+ private String name; //商品名
+ private double price; //价格
+ private String picture; //商品图片
+ private int sale; //月销量
+ private String shopName; //店铺名称
+
+ private int level; //评级
+
+ private String detail; //产品描述
+ private int selectedCount = 0; //已选择该商品的数量
+ private boolean isShowSubBtn; //是否显示减去按钮
+
+ public Product(int id, String name, double price, String picture, int sale, String shopName, String detail, boolean isShowSubBtn) {
+ this.id = id;
+ this.name = name;
+ this.price = price;
+ this.picture = picture;
+ this.sale = sale;
+ this.shopName = shopName;
+ this.detail = detail;
+ this.isShowSubBtn = isShowSubBtn;
+ }
+
+ //获取该商品被选中的次数
+ public int getSelectedCount() {
+ return selectedCount;
+ }
+
+ //将商品被选中次数清零与设置不显示减去按钮
+ public void clearZero() {
+ selectedCount = 0;
+ isShowSubBtn = false;
+ }
+
+ //增加该商品被选中的次数
+ public void addSelectedCount() {
+ selectedCount++;
+ }
+
+ //减少该商品被选中的次数
+ public void subSelectedCount() {
+ if (selectedCount > 0) {
+ selectedCount--;
+ }
+ }
+
+ //获取该商品的id
+ public int getId() {
+ return id;
+ }
+
+ //获取该商品的名字
+ public String getName() {
+ return name;
+ }
+
+ //获取该商品的价格
+ public double getPrice() {
+ return price;
+ }
+
+ //获取该商品的图片
+ public String getPicture() {
+ return picture;
+ }
+
+ //获取该商品的月销量
+ public int getSale() {
+ return sale;
+ }
+
+ //获取该商品的店铺名
+ public String getShopName() {
+ return shopName;
+ }
+
+ //获取该商品的详情
+ public String getDetail() {
+ return detail;
+ }
+
+ //获取是否显示减去按钮
+ public boolean getIsShowSubBtn() {
+ return isShowSubBtn;
+ }
+
+ //设置是否显示减去按钮
+ public void setIsShowSubBtn(boolean isShowSubBtn) {
+ this.isShowSubBtn = isShowSubBtn;
+ }
+
+ @Override
+ public String toString() {
+ return "Product[ name=" + name + ",price=" + price + ",picture=" + picture
+ + ",sale=" + sale + ",shopName=" + shopName + ",detail=" + detail + ",selectedCount=" + selectedCount + " ]";
+ }
+
+ //以下是实现Parcelable自动生成的内容
+ protected Product(Parcel in) {
+ id = in.readInt();
+ name = in.readString();
+ price = in.readDouble();
+ picture = in.readString();
+ sale = in.readInt();
+ shopName = in.readString();
+ detail = in.readString();
+ selectedCount = in.readInt();
+ isShowSubBtn = in.readByte() != 0;
+ }
+
+ public static final Creator CREATOR = new Creator() {
+ @Override
+ public Product createFromParcel(Parcel in) {
+ return new Product(in);
+ }
+
+ @Override
+ public Product[] newArray(int size) {
+ return new Product[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(id);
+ dest.writeString(name);
+ dest.writeDouble(price);
+ dest.writeString(picture);
+ dest.writeInt(sale);
+ dest.writeString(shopName);
+ dest.writeString(detail);
+ dest.writeInt(selectedCount);
+ dest.writeByte((byte) (isShowSubBtn ? 1 : 0));
+ }
+
+ public void setSelctCount(int num) {
+ selectedCount = num;
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Entity/ProductOrder.java b/src/app/src/main/java/com/sbw/atrue/Order/Entity/ProductOrder.java
new file mode 100644
index 0000000..7edb1fb
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Entity/ProductOrder.java
@@ -0,0 +1,58 @@
+package com.sbw.atrue.Order.Entity;
+
+import org.litepal.crud.DataSupport;
+import java.util.List;
+
+/**
+ * FileName: ProductOrder
+ * Description: 订单中的菜品信息类
+ * Author: 沈滨伟-13042299081
+ * Date: 2019/4/9 14:54
+ */
+public class ProductOrder extends DataSupport{
+ private int id; //订单ID
+ private List orders; //与Order表建立多对多关联关系
+ private String foodName;//菜名
+ private int num;//购买数量
+ private double price;//单项菜品总价
+
+ public int getId() {
+ return id;
+ }
+
+ public List getOrders() {
+ return orders;
+ }
+
+ public String getFoodName() {
+ return foodName;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public void setFoodName(String foodName) {
+ this.foodName = foodName;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Util/FoodAdapter.java b/src/app/src/main/java/com/sbw/atrue/Order/Util/FoodAdapter.java
new file mode 100644
index 0000000..fa952a0
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Util/FoodAdapter.java
@@ -0,0 +1,107 @@
+package com.sbw.atrue.Order.Util;
+
+import android.content.Context;
+import android.content.Intent;
+import androidx.cardview.widget.CardView;
+import androidx.recyclerview.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+import com.sbw.atrue.Order.Activity.FoodActivity;
+import com.sbw.atrue.Order.Entity.Food;
+import com.sbw.atrue.Order.R;
+
+import java.util.List;
+
+/**
+ * ClassName: FoodAdapter
+ * description: 菜品适配器,用于与RecycleView控件结合
+ * author: 沈滨伟-13042299081
+ * Date: 2019/2/18 21:03
+ */
+public class FoodAdapter extends RecyclerView.Adapter{
+
+ private static final String TAG = "FoodAdapter";
+ private Context mContext;
+ private List mfoodList;
+
+ /**
+ * foodAdapter的内部类,用于加载布局各控件的实例
+ */
+ static class ViewHolder extends RecyclerView.ViewHolder {
+ CardView cardView;
+ ImageView foodImage;
+ TextView foodName;
+ //构造函数
+ public ViewHolder(View view) {
+ super(view);
+ cardView = (CardView) view;
+ foodImage = (ImageView) view.findViewById(R.id.food_image);
+ foodName = (TextView) view.findViewById(R.id.food_name);
+ }
+ }
+
+ /**
+ * foodAdapter类的构造函数,接收并指定菜单列表
+ * @param foodList 菜单列表
+ */
+ public FoodAdapter(List foodList) {
+ mfoodList = foodList;
+ }
+
+ /**
+ * 用于创建ViewHolder实例,并设置菜品卡片的点击监听事件
+ * @param parent 父布局
+ * @param viewType
+ * @return ViewHolder实例,用于onBindViewHolder函数加载本地展示布局
+ */
+ @Override
+ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (mContext == null) {
+ mContext = parent.getContext();
+ }
+ //动态加载布局文件(菜品的简单展示布局,即图片+菜名),并并把加载出来的布局传入到构造函数中,从而创建ViewHolder实例
+ View view = LayoutInflater.from(mContext).inflate(R.layout.food_item, parent, false);
+ final ViewHolder holder = new ViewHolder(view);
+ //如果用户点击菜品卡片,则跳转到显示相应的菜品详情的活动中去
+ holder.cardView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int position = holder.getAdapterPosition();
+ Food food = mfoodList.get(position);
+ Intent intent = new Intent(mContext, FoodActivity.class);
+ //将用户点击的菜品的对象传递到下一个活动(菜品详情展示FoodActivity )
+ intent.putExtra("Food_Choose",food);
+ mContext.startActivity(intent);
+ }
+ });
+ return holder;
+ }
+
+ /**
+ * 用于对RecycleView子项的数据(图片+菜名)进行赋值,会在每个子项被滚动到屏幕内的时候自动执行
+ * @param holder 从onCreateViewHolder函数返回的值获取ViewHolder实例
+ * @param position
+ */
+ @Override
+ public void onBindViewHolder(ViewHolder holder, int position) {
+ Food food = mfoodList.get(position);
+ holder.foodName.setText(food.getName());
+ //使用Glide加载图片,不用担心像素太高导致内存溢出
+ Glide.with(mContext).load(food.getImageId()).into(holder.foodImage);
+ }
+
+ /**
+ * 返回菜品总数
+ * @return
+ */
+ @Override
+ public int getItemCount() {
+ return mfoodList.size();
+ }
+
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Util/FoodFctory.java b/src/app/src/main/java/com/sbw/atrue/Order/Util/FoodFctory.java
new file mode 100644
index 0000000..5ec6532
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Util/FoodFctory.java
@@ -0,0 +1,55 @@
+package com.sbw.atrue.Order.Util;
+
+import com.sbw.atrue.Order.Entity.Food;
+import com.sbw.atrue.Order.Entity.Product;
+import com.sbw.atrue.Order.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FileName: FoodFctory
+ * Description: 用于生成菜单的生产类
+ * Author: 沈滨伟-13042299081
+ * Date: 2019/2/18 22:21
+ */
+public class FoodFctory {
+
+// static public Food[] Beef={
+// //备注文字如果想要有换行效果的话,直接上\n即可
+// new Food("雪花",R.drawable.xuehua,"\t\t\t\t雪花是牛脖子上的凸起的一块肉,是牛运动最为频繁的一块活肉,也是牛身上最好吃的一块肉。一千斤的牛身上,可能也就只有一两斤的雪花牛肉。因为在脖子上,所以它还叫脖仁,脖仁肥瘦相间,拥有大理石般的纹路,涮4-6秒后入口,口感柔嫩多脂,十分鲜甜脆爽。"),
+// new Food("匙柄",R.drawable.chibing,"\t\t\t\t匙柄位于牛前腿上方部位,是牛肉中最好的部位之一,即牛夹层里脊肉内层。匙柄的脂肪含量少,切面呈树叶状,且纹理清晰,口感甜嫩无渣。"),
+// new Food("匙仁",R.drawable.chiren,"\t\t\t\t匙仁在西餐牛肉的分割部位叫做“眼肉”,该处肉质柔嫩且多汁(有雪花纹),滋味无穷。眼肉属于高档肉,经过精细切割后外观呈四方圆弧状,肉质红白镶嵌,有大理石花斑状纹理。由于臀部的运动较多,眼肉肉质细嫩,脂肪及水分含量较高,吃起来的口感比较香甜多汁、不干涩。"),
+// new Food("三花趾",R.drawable.sanhuazhi,"\t\t\t\t如果你在吃潮汕牛肉火锅的时候,雪花脖仁没有了怎么办,虽然有点遗憾,但还有很多部位一样美味,三花趾就是其中的一种。这块牛肉的位置在上肢,就是牛前腿的腱子肉,牛肉中有较粗的筋。"),
+// new Food("五花趾",R.drawable.wuhuazhi,"\t\t\t\t五花趾中的筋要比三花趾中的筋还要多一些,肉的纹理也要更加的清晰一些,在口感上也要更加的爽口,吃起来非常的脆。如果你喜欢吃脆弹一些的肉,那么潮汕牛肉火锅中的五花趾就是你的不二之选。"),
+// new Food("肥胼",R.drawable.feipin,"\t\t\t\t肥胼对应的部位是大家再熟悉不过的牛腩位置,并且是经过精修的牛腩,只留牛腩腹心及上面一层牛油,这样切开来之后每一片就有明显的两层,一层嫩肉再带着一层黄色的牛油。口感肥腻细嫩,对牛脂香味情有独钟的值得一试。"),
+// new Food("吊龙",R.drawable.diaolong,"\t\t\t\t吊龙的意思是牛脊,吊龙伴则是腰脊肉的两个侧边,而这里头还要再细分,吊龙伴中的两个小吊龙,即牛骨盆的夹缝中,两条长长的肉,样子有点像龙虾的两根大触须,潮汕人叫它“伴仔”或“龙虾须”,这几两重的肉须,便是吊龙伴中最为登峰造极的美味,其特点是鲜甜而弹牙。"),
+// new Food("嫩肉",R.drawable.nengrou,"\t\t\t\t嫩肉是在牛屁股上的肉,基本上没有油脂,全是精肉,在潮汕牛肉火锅中算是产量比较大的一种了。嫩肉在潮汕牛肉火锅中最大的特点就是甜度高一些。 烫煮时间:8秒 。"),
+// new Food("胸口朥",R.drawable.xiongkoulao,"\t\t\t\t胸口朥是牛前胸的脂肪部分,不是每一头牛都有这么一部分肉,只有大而肥的牛才能长出,十分稀有,只有在潮汕火锅才能看到它的身影。它看上去油得出奇,入口却是清甜间微微泛着牛油的香味,口感脆而爽口、带点韧劲,与“肥腻”两字完全不沾边。 烫煮时间:30秒-3分钟 。"),
+// };
+
+// static public List initDatas() {
+// List productsData = new ArrayList();
+// Product product = new Product(0, "雪花",50, R.drawable.xuehua, 220, "潮汕牛肉", "牛运动最为频繁的一块活肉!", false);
+// productsData.add(product);
+// product = new Product(1, "匙柄",40, R.drawable.chibing, 340,"潮汕牛肉", "纹理清晰~口感甜嫩无渣!", false);
+// productsData.add(product);
+// product = new Product(2,"匙仁",52, R.drawable.chiren, 572, "潮汕牛肉", "肉质柔嫩且多汁~滋味无穷!", false);
+// productsData.add(product);
+// product = new Product(3,"三花趾",38, R.drawable.sanhuazhi, 678, "潮汕牛肉", "牛前腿的腱子肉~", false);
+// productsData.add(product);
+// product = new Product(4, "五花趾",38, R.drawable.wuhuazhi, 441, "潮汕牛肉", "纹理清晰~肉质爽口!", false);
+// productsData.add(product);
+// product = new Product(5,"肥胼",42, R.drawable.feipin, 233, "潮汕牛肉", "口感肥腻细嫩,富有牛脂香味~", false);
+// productsData.add(product);
+// product = new Product(6, "吊龙",40, R.drawable.diaolong, 128, "潮汕牛肉", "鲜甜弹牙~登峰造极的美味!", false);
+// productsData.add(product);
+// product = new Product(7, "嫩肉",36, R.drawable.nengrou, 214, "潮汕牛肉", "精肉无油~味道甜美!", false);
+// productsData.add(product);
+// product = new Product(8, "胸口朥",45, R.drawable.xiongkoulao, 82, "潮汕牛肉", "清甜间+牛油的香味~脆而爽口!", false);
+// productsData.add(product);
+// product = new Product(9, "牛肉丸",38, R.drawable.wanzi, 520, "潮汕牛肉", "纯肉打造!!不可错过!", false);
+// productsData.add(product);
+// return productsData;
+// }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Util/HttpUtil.java b/src/app/src/main/java/com/sbw/atrue/Order/Util/HttpUtil.java
new file mode 100644
index 0000000..1cfcbb4
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Util/HttpUtil.java
@@ -0,0 +1,7 @@
+package com.sbw.atrue.Order.Util;
+
+
+public class HttpUtil {
+
+ public static final String HOST = "http://coding-space.cn:9030/";
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Util/MyListener.java b/src/app/src/main/java/com/sbw/atrue/Order/Util/MyListener.java
new file mode 100644
index 0000000..1b9357b
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Util/MyListener.java
@@ -0,0 +1,8 @@
+package com.sbw.atrue.Order.Util;
+
+
+import org.json.JSONException;
+
+public interface MyListener {
+ void onSuccess(T data) throws JSONException;
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Util/ProductListAdapter.java b/src/app/src/main/java/com/sbw/atrue/Order/Util/ProductListAdapter.java
new file mode 100644
index 0000000..d34f823
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Util/ProductListAdapter.java
@@ -0,0 +1,185 @@
+package com.sbw.atrue.Order.Util;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.bumptech.glide.Glide;
+import com.sbw.atrue.Order.Activity.ShoppingActivity;
+import com.sbw.atrue.Order.R;
+import com.sbw.atrue.Order.Entity.Product;
+
+
+//商品列表适配器
+public class ProductListAdapter extends BaseAdapter {
+ private Context mContext; //页面布局加载器
+ private List productsData; //商品内容数据源
+ private ArrayList selectedProducts = new ArrayList(); //被选择的的商品数据
+ private int totalSelectedCount = 0; //当前选择商品总数
+ private int totalPrice = 0; //当前选择商品总价
+
+ public ProductListAdapter(Context context, List data) {
+ mContext = context;
+ productsData = data;
+ }
+
+ //返回适配器内子项的数量
+ @Override
+ public int getCount() {
+ return productsData.size();
+ }
+
+ //返回适配器内的某个子项
+ @Override
+ public Object getItem(int position) {
+ return productsData.get(position);
+ }
+
+ //返回适配器内的某个子项的id号
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ //每个子view生成都会调用的界面生成方法
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder = null; //声明控件暂存器
+ if (convertView == null) { //如果内容界面为空
+ viewHolder = new ViewHolder(); //新建控件暂存器
+ //加载内容界面
+ convertView = LayoutInflater.from(mContext).inflate(R.layout.product_listview_item, null);
+ //绑定控件
+ viewHolder.picture = (ImageView) convertView.findViewById(R.id.iv_product_picture);
+ viewHolder.name = (TextView) convertView.findViewById(R.id.tv_product_name);
+ viewHolder.price = (TextView) convertView.findViewById(R.id.tv_product_pirce);
+ viewHolder.sale = (TextView) convertView.findViewById(R.id.tv_sale_count);
+ viewHolder.shopName = (TextView) convertView.findViewById(R.id.tv_product_shop_name);
+ viewHolder.detail = (TextView) convertView.findViewById(R.id.tv_product_detail);
+ viewHolder.selectedCount = (TextView) convertView.findViewById(R.id.tv_selected_count);
+ viewHolder.addProduct = (ImageButton) convertView.findViewById(R.id.btn_add_product);
+ viewHolder.subProduct = (ImageButton) convertView.findViewById(R.id.btn_sub_product);
+ //将控件暂存器放到内容界面中
+ convertView.setTag(viewHolder);
+ } else { //内容界面不为空
+ viewHolder = (ViewHolder) convertView.getTag(); //从内容界面提取出控件暂存器
+ }
+ Product product = productsData.get(position); //获取当前位置的商品
+ initListItem(viewHolder, product); //初始化列表界面内容
+ initButtonEvent(viewHolder, product); //初始化按钮的点击事件
+ return convertView; //返回主界面
+ }
+
+ /**
+ * 初始化列表界面内容
+ *
+ * @param viewHolder 控件暂存器
+ * @param product 当前位置的产品
+ */
+ private void initListItem(final ViewHolder viewHolder, final Product product) {
+// viewHolder.picture.setImageResource(product.getPicture()); //设置商品图片
+ Glide.with(mContext).load(product.getPicture()).into(viewHolder.picture);
+ viewHolder.name.setText(product.getName()); //设置商品名
+ viewHolder.price.setText(String.valueOf("¥" + product.getPrice())); //设置商品价格
+ viewHolder.sale.setText(String.valueOf("月售:" + product.getSale())); //设置商品月销售量
+ viewHolder.shopName.setText(product.getShopName()); //设置商家名称
+ viewHolder.detail.setText(product.getDetail()); //设置商品简介
+ }
+
+ /**
+ * 初始化按钮的点击事件
+ *
+ * @param viewHolder 控件暂存器
+ * @param product 当前位置的产品
+ */
+ private void initButtonEvent(final ViewHolder viewHolder, final Product product) {
+ //给添加商品按钮添加点击事件
+ viewHolder.addProduct.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ totalSelectedCount++; //被选择商品总数加1
+ totalPrice += product.getPrice(); //被选择商品总价加上该商品的价格
+ product.addSelectedCount(); //商品本身的数量加1
+ if (!selectedProducts.contains(product)) { //如果被选择商品列表还没有该商品
+ selectedProducts.add(product); //将该商品加到被选择列表中
+ }
+ product.setIsShowSubBtn(true); //设置商品对应的减去按钮消失
+ //在被选择商品数标签上设置被选择商品数
+ viewHolder.selectedCount.setText(String.valueOf(product.getSelectedCount()));
+ //将被选择的商品总数和总价设置回购物界面
+ ((ShoppingActivity) mContext).setSelectedCountAndPrice(totalSelectedCount, totalPrice);
+ //将被选择的商品列表设置回购物界面
+ ((ShoppingActivity) mContext).setSelectedProducts(selectedProducts);
+ }
+ });
+
+ //给减去商品按钮添加点击事件
+ viewHolder.subProduct.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (totalSelectedCount - 1 >= 0) { //当被选择总数减1不为0时
+ totalSelectedCount--; //被选择商品总数减1
+ totalPrice -= product.getPrice(); //被选择商品总价减去该商品的价格
+ product.subSelectedCount(); //商品本身的数量减1
+ if (product.getSelectedCount() == 0) { //如果被选择商品的数量为0
+
+ product.setIsShowSubBtn(false); //设置该商品对应的减去按钮消失
+ selectedProducts.remove(product); //从被选择商品列表中移除该商品
+ }
+ //在被选择商品数标签上设置被选择商品数
+ viewHolder.selectedCount.setText(String.valueOf(product.getSelectedCount()));
+ //将被选择的商品总数和总价设置回购物界面
+ ((ShoppingActivity) mContext).setSelectedCountAndPrice(totalSelectedCount, totalPrice);
+ //将被选择的商品列表设置回购物界面
+ ((ShoppingActivity) mContext).setSelectedProducts(selectedProducts);
+ }
+ }
+ });
+
+ //设置减去按钮的与被选择商品数量标签的可见性
+ setSubButtonAndSelectCount(viewHolder, product);
+ }
+
+ /**
+ * 设置减去按钮的与被选择商品数量标签的可见性
+ *
+ * @param viewHolder 控件暂存器
+ * @param product 当前位置的产品
+ */
+ private void setSubButtonAndSelectCount(final ViewHolder viewHolder, Product product) {
+ boolean show = product.getIsShowSubBtn(); //从Map中获取是否需要展示减去按钮
+ viewHolder.subProduct.setVisibility(show ? View.VISIBLE : View.INVISIBLE); //设置减去商品按钮是否可见
+ viewHolder.selectedCount.setVisibility(show ? View.VISIBLE : View.INVISIBLE); //设置被选择商品数标签是否可见
+ if (show) { //需要展示减去按钮
+ //在被选择商品数标签上设置被选择商品数
+ viewHolder.selectedCount.setText(String.valueOf(product.getSelectedCount()));
+ }
+ }
+
+ //设置全部商品数据
+ public void setSelectedProducts(ArrayList selectedProducts) {
+ this.selectedProducts = selectedProducts; //设置被选择的商品
+ notifyDataSetChanged(); //通知系统数据改变
+ }
+
+ //控件暂存器
+ static class ViewHolder {
+ ImageView picture; //商品图片
+ TextView name; //商品名
+ TextView price; //商品价格
+ TextView sale; //月销量
+ TextView shopName; //商店名
+ TextView detail; //商品细节
+ TextView selectedCount; //选择商品的数量
+ ImageButton addProduct; //添加商品按钮
+ ImageButton subProduct; //减去商品按钮
+ }
+}
diff --git a/src/app/src/main/java/com/sbw/atrue/Order/Util/ShareUtils.java b/src/app/src/main/java/com/sbw/atrue/Order/Util/ShareUtils.java
new file mode 100644
index 0000000..878964c
--- /dev/null
+++ b/src/app/src/main/java/com/sbw/atrue/Order/Util/ShareUtils.java
@@ -0,0 +1,50 @@
+package com.sbw.atrue.Order.Util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.view.View;
+
+/**
+ * SharedPreferences工具类
+ */
+public class ShareUtils {
+ public static final String NAME = "config";
+
+ /**
+ * 存入字符串
+ * @param mContext 上下文
+ * @param key 关键字
+ * @param value 传入的值
+ */
+ public static void putString(Context mContext, String key, String value) {
+ getSP(mContext).edit().putString(key, value).commit();
+ }
+
+ public static void putInt(Context mContext, String key, int value) {
+ getSP(mContext).edit().putInt(key,value).commit();
+ }
+
+
+ /**
+ * 获取字符串
+ * @param mContext 上下文
+ * @param key 关键字
+ * @param defValue 默认返回值
+ */
+ public static String getString(Context mContext, String key, String defValue) {
+ return getSP(mContext).getString(key, defValue);
+ }
+
+ public static int getInt(Context mContext, String key, int defValue) {
+ return getSP(mContext).getInt(key, defValue);
+ }
+
+ /**
+ * 返回一个根据上下文生成的SharedPreferences
+ * @param mContext 上下文
+ * @return 根据上下文生成的SharedPreferences
+ */
+ private static SharedPreferences getSP(Context mContext) {
+ return mContext.getSharedPreferences(NAME, Context.MODE_PRIVATE);
+ }
+}
diff --git a/src/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/src/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 0000000..1f6bb29
--- /dev/null
+++ b/src/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/drawable/background01.jpeg b/src/app/src/main/res/drawable/background01.jpeg
new file mode 100644
index 0000000..927c2e9
Binary files /dev/null and b/src/app/src/main/res/drawable/background01.jpeg differ
diff --git a/src/app/src/main/res/drawable/background02.jpg b/src/app/src/main/res/drawable/background02.jpg
new file mode 100644
index 0000000..4d1a6ca
Binary files /dev/null and b/src/app/src/main/res/drawable/background02.jpg differ
diff --git a/src/app/src/main/res/drawable/background03.jpg b/src/app/src/main/res/drawable/background03.jpg
new file mode 100644
index 0000000..0a2429a
Binary files /dev/null and b/src/app/src/main/res/drawable/background03.jpg differ
diff --git a/src/app/src/main/res/drawable/bg_edittext_focused.xml b/src/app/src/main/res/drawable/bg_edittext_focused.xml
new file mode 100644
index 0000000..d91cfe4
--- /dev/null
+++ b/src/app/src/main/res/drawable/bg_edittext_focused.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/bg_edittext_normal.xml b/src/app/src/main/res/drawable/bg_edittext_normal.xml
new file mode 100644
index 0000000..8d58da0
--- /dev/null
+++ b/src/app/src/main/res/drawable/bg_edittext_normal.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/btn_bg.xml b/src/app/src/main/res/drawable/btn_bg.xml
new file mode 100644
index 0000000..aa9c7e0
--- /dev/null
+++ b/src/app/src/main/res/drawable/btn_bg.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/btn_bg2.xml b/src/app/src/main/res/drawable/btn_bg2.xml
new file mode 100644
index 0000000..e8b3226
--- /dev/null
+++ b/src/app/src/main/res/drawable/btn_bg2.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/btn_bg3.xml b/src/app/src/main/res/drawable/btn_bg3.xml
new file mode 100644
index 0000000..5dee111
--- /dev/null
+++ b/src/app/src/main/res/drawable/btn_bg3.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/btn_bg4.xml b/src/app/src/main/res/drawable/btn_bg4.xml
new file mode 100644
index 0000000..0df6bf5
--- /dev/null
+++ b/src/app/src/main/res/drawable/btn_bg4.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/chibing.jpg b/src/app/src/main/res/drawable/chibing.jpg
new file mode 100644
index 0000000..bb3a1e8
Binary files /dev/null and b/src/app/src/main/res/drawable/chibing.jpg differ
diff --git a/src/app/src/main/res/drawable/chiren.jpg b/src/app/src/main/res/drawable/chiren.jpg
new file mode 100644
index 0000000..1e7484e
Binary files /dev/null and b/src/app/src/main/res/drawable/chiren.jpg differ
diff --git a/src/app/src/main/res/drawable/diaolong.jpg b/src/app/src/main/res/drawable/diaolong.jpg
new file mode 100644
index 0000000..db26386
Binary files /dev/null and b/src/app/src/main/res/drawable/diaolong.jpg differ
diff --git a/src/app/src/main/res/drawable/edittext_bg.xml b/src/app/src/main/res/drawable/edittext_bg.xml
new file mode 100644
index 0000000..ffc2655
--- /dev/null
+++ b/src/app/src/main/res/drawable/edittext_bg.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/drawable/feipin.jpg b/src/app/src/main/res/drawable/feipin.jpg
new file mode 100644
index 0000000..5a90c65
Binary files /dev/null and b/src/app/src/main/res/drawable/feipin.jpg differ
diff --git a/src/app/src/main/res/drawable/fengmian.jpg b/src/app/src/main/res/drawable/fengmian.jpg
new file mode 100644
index 0000000..f04c483
Binary files /dev/null and b/src/app/src/main/res/drawable/fengmian.jpg differ
diff --git a/src/app/src/main/res/drawable/ic_backup.png b/src/app/src/main/res/drawable/ic_backup.png
new file mode 100644
index 0000000..3ff57ad
Binary files /dev/null and b/src/app/src/main/res/drawable/ic_backup.png differ
diff --git a/src/app/src/main/res/drawable/ic_comment.png b/src/app/src/main/res/drawable/ic_comment.png
new file mode 100644
index 0000000..a3d45a5
Binary files /dev/null and b/src/app/src/main/res/drawable/ic_comment.png differ
diff --git a/src/app/src/main/res/drawable/ic_delete.png b/src/app/src/main/res/drawable/ic_delete.png
new file mode 100644
index 0000000..3fcdfdb
Binary files /dev/null and b/src/app/src/main/res/drawable/ic_delete.png differ
diff --git a/src/app/src/main/res/drawable/ic_done.png b/src/app/src/main/res/drawable/ic_done.png
new file mode 100644
index 0000000..0ebb555
Binary files /dev/null and b/src/app/src/main/res/drawable/ic_done.png differ
diff --git a/src/app/src/main/res/drawable/ic_launcher_background.xml b/src/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..0d025f9
--- /dev/null
+++ b/src/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/drawable/ic_menu.png b/src/app/src/main/res/drawable/ic_menu.png
new file mode 100644
index 0000000..238a905
Binary files /dev/null and b/src/app/src/main/res/drawable/ic_menu.png differ
diff --git a/src/app/src/main/res/drawable/ic_settings.png b/src/app/src/main/res/drawable/ic_settings.png
new file mode 100644
index 0000000..b3cc107
Binary files /dev/null and b/src/app/src/main/res/drawable/ic_settings.png differ
diff --git a/src/app/src/main/res/drawable/icon_plus.png b/src/app/src/main/res/drawable/icon_plus.png
new file mode 100644
index 0000000..845e429
Binary files /dev/null and b/src/app/src/main/res/drawable/icon_plus.png differ
diff --git a/src/app/src/main/res/drawable/icon_sub.png b/src/app/src/main/res/drawable/icon_sub.png
new file mode 100644
index 0000000..d0eac37
Binary files /dev/null and b/src/app/src/main/res/drawable/icon_sub.png differ
diff --git a/src/app/src/main/res/drawable/icon_up_and_down.png b/src/app/src/main/res/drawable/icon_up_and_down.png
new file mode 100644
index 0000000..ecf803c
Binary files /dev/null and b/src/app/src/main/res/drawable/icon_up_and_down.png differ
diff --git a/src/app/src/main/res/drawable/nav_task.png b/src/app/src/main/res/drawable/nav_task.png
new file mode 100644
index 0000000..3b6283f
Binary files /dev/null and b/src/app/src/main/res/drawable/nav_task.png differ
diff --git a/src/app/src/main/res/drawable/nengrou.jpg b/src/app/src/main/res/drawable/nengrou.jpg
new file mode 100644
index 0000000..a025f59
Binary files /dev/null and b/src/app/src/main/res/drawable/nengrou.jpg differ
diff --git a/src/app/src/main/res/drawable/pic_background_03.png b/src/app/src/main/res/drawable/pic_background_03.png
new file mode 100644
index 0000000..6fab475
Binary files /dev/null and b/src/app/src/main/res/drawable/pic_background_03.png differ
diff --git a/src/app/src/main/res/drawable/sanhuazhi.jpg b/src/app/src/main/res/drawable/sanhuazhi.jpg
new file mode 100644
index 0000000..6d95cce
Binary files /dev/null and b/src/app/src/main/res/drawable/sanhuazhi.jpg differ
diff --git a/src/app/src/main/res/drawable/sbw_image.jpg b/src/app/src/main/res/drawable/sbw_image.jpg
new file mode 100644
index 0000000..81bf718
Binary files /dev/null and b/src/app/src/main/res/drawable/sbw_image.jpg differ
diff --git a/src/app/src/main/res/drawable/shachajiang.jpg b/src/app/src/main/res/drawable/shachajiang.jpg
new file mode 100644
index 0000000..8f7aa17
Binary files /dev/null and b/src/app/src/main/res/drawable/shachajiang.jpg differ
diff --git a/src/app/src/main/res/drawable/shop.jpg b/src/app/src/main/res/drawable/shop.jpg
new file mode 100644
index 0000000..0428a22
Binary files /dev/null and b/src/app/src/main/res/drawable/shop.jpg differ
diff --git a/src/app/src/main/res/drawable/wanglaoji.jpg b/src/app/src/main/res/drawable/wanglaoji.jpg
new file mode 100644
index 0000000..bd7271e
Binary files /dev/null and b/src/app/src/main/res/drawable/wanglaoji.jpg differ
diff --git a/src/app/src/main/res/drawable/wanzi.jpg b/src/app/src/main/res/drawable/wanzi.jpg
new file mode 100644
index 0000000..8ad6974
Binary files /dev/null and b/src/app/src/main/res/drawable/wanzi.jpg differ
diff --git a/src/app/src/main/res/drawable/welcome.jpg b/src/app/src/main/res/drawable/welcome.jpg
new file mode 100644
index 0000000..e9ffe17
Binary files /dev/null and b/src/app/src/main/res/drawable/welcome.jpg differ
diff --git a/src/app/src/main/res/drawable/wuhuazhi.jpg b/src/app/src/main/res/drawable/wuhuazhi.jpg
new file mode 100644
index 0000000..cfa7614
Binary files /dev/null and b/src/app/src/main/res/drawable/wuhuazhi.jpg differ
diff --git a/src/app/src/main/res/drawable/xiongkoulao.jpg b/src/app/src/main/res/drawable/xiongkoulao.jpg
new file mode 100644
index 0000000..18cae89
Binary files /dev/null and b/src/app/src/main/res/drawable/xiongkoulao.jpg differ
diff --git a/src/app/src/main/res/drawable/xuehua.jpg b/src/app/src/main/res/drawable/xuehua.jpg
new file mode 100644
index 0000000..bc51be5
Binary files /dev/null and b/src/app/src/main/res/drawable/xuehua.jpg differ
diff --git a/src/app/src/main/res/layout/activity_food.xml b/src/app/src/main/res/layout/activity_food.xml
new file mode 100644
index 0000000..b27ec9c
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_food.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/activity_input.xml b/src/app/src/main/res/layout/activity_input.xml
new file mode 100644
index 0000000..6d6bfc5
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_input.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/activity_login.xml b/src/app/src/main/res/layout/activity_login.xml
new file mode 100644
index 0000000..b57d897
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_login.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/activity_order.xml b/src/app/src/main/res/layout/activity_order.xml
new file mode 100644
index 0000000..b10f69c
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_order.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/activity_readorder.xml b/src/app/src/main/res/layout/activity_readorder.xml
new file mode 100644
index 0000000..2238b2b
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_readorder.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/activity_register.xml b/src/app/src/main/res/layout/activity_register.xml
new file mode 100644
index 0000000..641790c
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_register.xml
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/activity_shopping.xml b/src/app/src/main/res/layout/activity_shopping.xml
new file mode 100644
index 0000000..b12ff0b
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_shopping.xml
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/activity_success.xml b/src/app/src/main/res/layout/activity_success.xml
new file mode 100644
index 0000000..4077194
--- /dev/null
+++ b/src/app/src/main/res/layout/activity_success.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/food_item.xml b/src/app/src/main/res/layout/food_item.xml
new file mode 100644
index 0000000..f7c7f35
--- /dev/null
+++ b/src/app/src/main/res/layout/food_item.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/my_money.xml b/src/app/src/main/res/layout/my_money.xml
new file mode 100644
index 0000000..d46fbfb
--- /dev/null
+++ b/src/app/src/main/res/layout/my_money.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/nav_header.xml b/src/app/src/main/res/layout/nav_header.xml
new file mode 100644
index 0000000..5045c0f
--- /dev/null
+++ b/src/app/src/main/res/layout/nav_header.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/person_setting.xml b/src/app/src/main/res/layout/person_setting.xml
new file mode 100644
index 0000000..5322d35
--- /dev/null
+++ b/src/app/src/main/res/layout/person_setting.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/res/layout/product_listview_item.xml b/src/app/src/main/res/layout/product_listview_item.xml
new file mode 100644
index 0000000..5f3d93a
--- /dev/null
+++ b/src/app/src/main/res/layout/product_listview_item.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/shop_car_listview_item.xml b/src/app/src/main/res/layout/shop_car_listview_item.xml
new file mode 100644
index 0000000..b64d9f2
--- /dev/null
+++ b/src/app/src/main/res/layout/shop_car_listview_item.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/shop_list_empty.xml b/src/app/src/main/res/layout/shop_list_empty.xml
new file mode 100644
index 0000000..61a2ad3
--- /dev/null
+++ b/src/app/src/main/res/layout/shop_list_empty.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/layout/shop_list_layout.xml b/src/app/src/main/res/layout/shop_list_layout.xml
new file mode 100644
index 0000000..da5c4c1
--- /dev/null
+++ b/src/app/src/main/res/layout/shop_list_layout.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/menu/nav_menu.xml b/src/app/src/main/res/menu/nav_menu.xml
new file mode 100644
index 0000000..4c3a9db
--- /dev/null
+++ b/src/app/src/main/res/menu/nav_menu.xml
@@ -0,0 +1,25 @@
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/menu/toolbar.xml b/src/app/src/main/res/menu/toolbar.xml
new file mode 100644
index 0000000..7b57da2
--- /dev/null
+++ b/src/app/src/main/res/menu/toolbar.xml
@@ -0,0 +1,24 @@
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/src/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/src/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/src/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/src/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/src/main/res/mipmap-hdpi/ic_launcher.png b/src/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..898f3ed
Binary files /dev/null and b/src/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/src/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/src/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..dffca36
Binary files /dev/null and b/src/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/src/app/src/main/res/mipmap-mdpi/ic_launcher.png b/src/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..64ba76f
Binary files /dev/null and b/src/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/src/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/src/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..dae5e08
Binary files /dev/null and b/src/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/src/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/src/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..e5ed465
Binary files /dev/null and b/src/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/src/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/src/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..14ed0af
Binary files /dev/null and b/src/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/src/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/src/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b0907ca
Binary files /dev/null and b/src/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/src/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/src/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..d8ae031
Binary files /dev/null and b/src/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/src/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/src/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..2c18de9
Binary files /dev/null and b/src/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/src/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/src/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..beed3cd
Binary files /dev/null and b/src/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/src/app/src/main/res/values/colors.xml b/src/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..7e4db61
--- /dev/null
+++ b/src/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #ff4054
+
diff --git a/src/app/src/main/res/values/dimens.xml b/src/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..47c8224
--- /dev/null
+++ b/src/app/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 16dp
+ 16dp
+
diff --git a/src/app/src/main/res/values/strings.xml b/src/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..a8275fe
--- /dev/null
+++ b/src/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ 潮汕牛肉
+
diff --git a/src/app/src/main/res/values/styles.xml b/src/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..dc83a43
--- /dev/null
+++ b/src/app/src/main/res/values/styles.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/src/app/src/test/java/com/sbw/atrue/Order/ExampleUnitTest.java b/src/app/src/test/java/com/sbw/atrue/Order/ExampleUnitTest.java
new file mode 100644
index 0000000..0d1e854
--- /dev/null
+++ b/src/app/src/test/java/com/sbw/atrue/Order/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.sbw.atrue.Order;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/src/build.gradle b/src/build.gradle
new file mode 100644
index 0000000..8e59b72
--- /dev/null
+++ b/src/build.gradle
@@ -0,0 +1,27 @@
+
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:4.0.2'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/src/gradle.properties b/src/gradle.properties
new file mode 100644
index 0000000..d546dea
--- /dev/null
+++ b/src/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+android.enableJetifier=true
+android.useAndroidX=true
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
+
diff --git a/src/gradle/wrapper/gradle-wrapper.jar b/src/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
Binary files /dev/null and b/src/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/src/gradle/wrapper/gradle-wrapper.properties b/src/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..0cad2dc
--- /dev/null
+++ b/src/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Oct 21 23:00:20 GMT+08:00 2022
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/src/gradlew b/src/gradlew
new file mode 100644
index 0000000..cccdd3d
--- /dev/null
+++ b/src/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/src/gradlew.bat b/src/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/src/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/local.properties b/src/local.properties
new file mode 100644
index 0000000..fce282a
--- /dev/null
+++ b/src/local.properties
@@ -0,0 +1,8 @@
+## This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Fri Oct 21 20:41:36 GMT+08:00 2022
+sdk.dir=D\:\\Android\\Sdk
diff --git a/src/settings.gradle b/src/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/src/settings.gradle
@@ -0,0 +1 @@
+include ':app'