After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 304 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 22 KiB |
@ -1,56 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--基本结构-->
|
||||
<!--
|
||||
<manifest>
|
||||
<application
|
||||
android:name="com.example.MyApplication"
|
||||
...
|
||||
>
|
||||
...
|
||||
</application>
|
||||
</manifest>
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sbw.atrue.Order">
|
||||
<!--获取联网许可-->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<application
|
||||
android:name=".Activity.MyApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/fengmian"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<!-- 将登录活动设置为程序的主活动和启动项 -->
|
||||
<activity
|
||||
android:name=".Activity.LoginActivity"
|
||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- 定义了使用ToolBar控件的布局的标题为food -->
|
||||
<activity
|
||||
android:name=".Activity.OrderActivity"
|
||||
android:label="航吃Hang吃"></activity>
|
||||
<activity
|
||||
android:name=".Activity.FoodActivity"
|
||||
android:theme="@style/foodActivityTheme"></activity>
|
||||
|
||||
<!--声明其他各项活动-->
|
||||
<activity android:name=".Activity.RegisterActivity" />
|
||||
<activity android:name=".Activity.ShoppingActivity" />
|
||||
<activity android:name=".Activity.InputActivity" />
|
||||
<activity android:name=".Activity.SuccessActivity" />
|
||||
<activity android:name=".Activity.ReadOrderActivity" />
|
||||
<activity android:name=".Activity.MyMoneyActivity" />
|
||||
<activity android:name=".Activity.SettingActivity" />
|
||||
<activity android:name=".Activity.horizonta_main"/>
|
||||
|
||||
</application>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sbw.atrue.Order">
|
||||
<!-- 获取联网许可 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<application
|
||||
android:name=".Activity.MyApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/fengmian"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="com.sbw.atrue.Order.Activity.MainActivity"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<!-- 将登录活动设置为程序的主活动和启动项 -->
|
||||
<activity
|
||||
android:name=".Activity.LoginActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity> <!-- 定义了使用ToolBar控件的布局的标题为food -->
|
||||
<activity
|
||||
android:name=".Activity.OrderActivity"
|
||||
android:label="航吃Hang吃" />
|
||||
<activity
|
||||
android:name=".Activity.FoodActivity"
|
||||
android:theme="@style/foodActivityTheme" /> <!-- 声明其他各项活动 -->
|
||||
<activity android:name=".Activity.RegisterActivity" />
|
||||
<activity android:name=".Activity.ShoppingActivity" />
|
||||
<activity android:name=".Activity.InputActivity" />
|
||||
<activity android:name=".Activity.SuccessActivity" />
|
||||
<activity android:name=".Activity.ReadOrderActivity" />
|
||||
<activity android:name=".Activity.MyMoneyActivity" />
|
||||
<activity android:name=".Activity.SettingActivity" />
|
||||
<activity android:name=".Activity.horizonta_main" />
|
||||
<activity android:name=".Activity.CommentActivity" />
|
||||
<activity android:name=".Activity.TurnActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,16 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.sbw.atrue.Order.R;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main2);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
//import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.sbw.atrue.Order.R;
|
||||
import com.sbw.atrue.Order.Util.LuckyView;
|
||||
//import com.showly.luckyactivity.view.LuckyView;
|
||||
|
||||
public class TurnActivity extends AppCompatActivity {
|
||||
|
||||
private LuckyView luckyView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_turnable);
|
||||
|
||||
initView();
|
||||
initData();
|
||||
initListener();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
luckyView = findViewById(R.id.lucky_view);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
luckyView.setLuckAnimationEndListener(new LuckyView.OnLuckAnimationEndListener() {
|
||||
@Override
|
||||
public void onLuckAnimationEnd(int pos, String msg) {
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.sbw.atrue.Order.Entity;
|
||||
|
||||
|
||||
public class Comment {
|
||||
|
||||
String name; //评论者
|
||||
String content; //评论内容
|
||||
|
||||
public Comment(){
|
||||
|
||||
}
|
||||
|
||||
public Comment(String name, String content){
|
||||
this.name = name;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.sbw.atrue.Order.Entity;
|
||||
|
||||
import org.litepal.LitePalApplication;
|
||||
|
||||
public class Custom extends LitePalApplication {
|
||||
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
public class LoginServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
// 设置响应内容类型
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
|
||||
//获得请求中传来的用户名和密码
|
||||
String account = request.getParameter("account").trim();
|
||||
String password = request.getParameter("password").trim();
|
||||
|
||||
//密码验证结果
|
||||
Boolean verifyResult = verifyLogin(account, password);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
if (verifyResult) {
|
||||
params.put("Result", "success");
|
||||
} else {
|
||||
params.put("Result", "failed");
|
||||
}
|
||||
|
||||
jsonObject.put("params", params);
|
||||
out.write(jsonObject.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
//验证用户名密码是否正确
|
||||
private Boolean verifyLogin(String userName, String password) {
|
||||
User user = UserDAO.queryUser(userName);
|
||||
//账户密码验证
|
||||
return null != user && password.equals(user.getPassword());
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class RegisterServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// 设置响应内容类型
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
//获得请求中传来的用户名和密码
|
||||
String account = request.getParameter("account").trim();
|
||||
String password = request.getParameter("password").trim();
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if(isExist(account)){
|
||||
params.put("Result", "账号已存在");
|
||||
}else{
|
||||
UserDAO.Register(account, password);
|
||||
params.put("Result", "注册成功");
|
||||
}
|
||||
jsonObject.put("结果", params);
|
||||
out.write(jsonObject.toString());
|
||||
}
|
||||
}
|
||||
//判断用户是否存在
|
||||
private Boolean isExist(String account) {
|
||||
User user = UserDAO.queryUser(account);
|
||||
if(user.getAccount().isEmpty()){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
private int socket_port=9999;
|
||||
private boolean ifListen =true;
|
||||
/**
|
||||
* 开始监听
|
||||
*/
|
||||
private Thread socketThread = new Thread() {
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
if (serverSocket == null && ifListen) {
|
||||
serverSocket = new ServerSocket(socket_port);
|
||||
// serverSocket.setSoTimeout(60*1000);
|
||||
} else if (serverSocket != null) {
|
||||
socket = serverSocket.accept();
|
||||
if (socket != null) {
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(socket
|
||||
.getInputStream()));
|
||||
try {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = in.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
byte[] data = outStream.toByteArray();
|
||||
dataString = new String(data, "utf-8");
|
||||
AppLog.Log(dataString);
|
||||
} catch (Exception e) {
|
||||
AppLog.Log(AppLog.LogType.ERROR, "DataService read: " + e);
|
||||
destorySocket();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
AppLog.Log(AppLog.LogType.ERROR, "DataService accept: " + e1);
|
||||
destorySocket(); }
|
||||
try {
|
||||
Thread.sleep(Config.KEEP_ALIVE_RESPONSE_TIMEOUT);
|
||||
} catch (InterruptedException e) {
|
||||
AppLog.Log(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void startListen() {
|
||||
ifListen = true;
|
||||
if (!ifSocketThreadStart) {
|
||||
ifSocketThreadStart = true;
|
||||
socketThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopListen() {
|
||||
ifListen = false;
|
||||
destorySocket();
|
||||
}
|
||||
|
||||
private void destorySocket() {
|
||||
AppLog.Log("destorySocket");
|
||||
try {
|
||||
if (serverSocket != null && !serverSocket.isClosed()) {
|
||||
serverSocket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
AppLog.Log(e.toString());
|
||||
} finally {
|
||||
serverSocket = null;
|
||||
}
|
||||
try {
|
||||
if (socket != null && !socket.isClosed()) {
|
||||
socket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
AppLog.Log(e.toString());
|
||||
} finally {
|
||||
socket = null;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 966 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 351 B |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 82 KiB |
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/grey">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/comment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="50dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/rl_enroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@drawable/comment"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:src="@drawable/chat"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_comment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="@color/white"
|
||||
android:visibility="gone"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/grey" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hide_down"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hide_down"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/txtgrey"
|
||||
android:drawableBottom="@drawable/hide_dowm"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/grey"
|
||||
android:layout_toRightOf="@id/hide_down"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
<EditText
|
||||
android:id="@+id/comment_content"
|
||||
android:hint="@string/comment_content"
|
||||
android:textSize="15sp"
|
||||
android:singleLine="true"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@null"
|
||||
android:layout_toRightOf="@id/hide_down"
|
||||
android:layout_marginLeft="20dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/comment_send"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_margin="5dp"
|
||||
android:text="@string/send"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/white"
|
||||
android:background="@color/mainColor"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="15dp"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Activity.MainActivity">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#fff"
|
||||
tools:context="com.sbw.atrue.Order.Activity.TurnActivity">
|
||||
|
||||
<com.sbw.atrue.Order.Util.LuckyView
|
||||
android:id="@+id/lucky_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="50dp"
|
||||
tools:ignore="MissingClass" />
|
||||
</RelativeLayout>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/mainColor"
|
||||
android:textSize="15sp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="3dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="15sp" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</menu>
|
@ -1,4 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">航吃Hang吃</string>
|
||||
<string name="随即转盘">吃货大赏</string>
|
||||
<string name="hide_down">隐藏</string>
|
||||
<string name="comment_content">输入评论内容</string>
|
||||
<string name="send">发送</string>
|
||||
</resources>
|
||||
|
@ -1,11 +0,0 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches/build_file_checksums.ser
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WizardSettings">
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorWizard">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorAssetStep">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipartAsset">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="jar:file:/D:/Program%20Files%20(x86)/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/communication/ic_message_black_24dp.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="outputName" value="ic_message_black_24dp" />
|
||||
<entry key="sourceFile" value="C:\Users\ACER" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -1,116 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<compositeConfiguration>
|
||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
||||
</compositeConfiguration>
|
||||
<option name="delegatedBuild" value="false" />
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
@ -1 +0,0 @@
|
||||
/build
|
@ -1,38 +0,0 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "com.sbw.atrue.Order"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
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(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||
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 'com.yanzhenjie.nohttp:nohttp:1.1.4'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation files('libs/mysql-connector-java-5.1.38.jar')
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
# 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
|
@ -1 +0,0 @@
|
||||
[{"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":{}}]
|
@ -1,26 +0,0 @@
|
||||
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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@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());
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.sbw.atrue.Order">
|
||||
|
||||
<application
|
||||
android:name=".Activity.MyApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/fengmian"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<!-- 将登录活动设置为程序的主活动和启动项 -->
|
||||
<activity
|
||||
android:name=".Activity.LoginActivity"
|
||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- 定义了使用ToolBar控件的布局的标题为food -->
|
||||
<activity
|
||||
android:name=".Activity.OrderActivity"
|
||||
android:label="潮汕牛肉"></activity>
|
||||
<activity
|
||||
android:name=".Activity.FoodActivity"
|
||||
android:theme="@style/foodActivityTheme"></activity>
|
||||
|
||||
<!--声明其他各项活动-->
|
||||
<activity android:name=".Activity.RegisterActivity" />
|
||||
<activity android:name=".Activity.ShoppingActivity" />
|
||||
<activity android:name=".Activity.InputActivity" />
|
||||
<activity android:name=".Activity.SuccessActivity" />
|
||||
<activity android:name=".Activity.ReadOrderActivity" />
|
||||
<activity android:name=".Activity.MyMoneyActivity" />
|
||||
<activity android:name=".Activity.SettingActivity" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<litepal>
|
||||
<dbname value="order" ></dbname>
|
||||
<version value="8" ></version>
|
||||
<list>
|
||||
<mapping class="com.sbw.atrue.Order.Entity.ProductOrder"></mapping>
|
||||
<mapping class="com.sbw.atrue.Order.Entity.Order"></mapping>
|
||||
</list>
|
||||
</litepal>
|
@ -1,62 +0,0 @@
|
||||
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.41.175";
|
||||
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 = "lyx123";
|
||||
|
||||
// 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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
|
||||
|
||||
import com.yanzhenjie.nohttp.InitializationConfig;
|
||||
import com.yanzhenjie.nohttp.NoHttp;
|
||||
|
||||
import org.litepal.LitePalApplication;
|
||||
|
||||
public class MyApplication extends LitePalApplication {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
InitializationConfig config = InitializationConfig.newBuilder(this)
|
||||
.connectionTimeout(30 * 1000)
|
||||
.readTimeout(30 * 1000)
|
||||
.retry(10)
|
||||
.build();
|
||||
NoHttp.initialize(config);
|
||||
Connection.mymysql();
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
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 <br>
|
||||
* Description: <br>
|
||||
* Author: 沈滨伟-13042299081 <br>
|
||||
* 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<JSONObject> request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
|
||||
//3.利用队列去添加消息请求
|
||||
//使用request对象添加上传的对象添加键与值,post方式添加上传的数据
|
||||
request.add("userId", ShareUtils.getInt(getApplicationContext(), "user_id", 0));
|
||||
|
||||
queue.add(1, request, new OnResponseListener<JSONObject>() {
|
||||
@Override
|
||||
public void onStart(int what) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSucceed(int what, Response<JSONObject> 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<JSONObject> response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(int what) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
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<JSONObject> request = NoHttp.createJsonObjectRequest(postUrl, RequestMethod.POST);
|
||||
//3.利用队列去添加消息请求
|
||||
//使用request对象添加上传的对象添加键与值,post方式添加上传的数据
|
||||
request.add("username", username);
|
||||
request.add("password", password);
|
||||
|
||||
queue.add(1, request, new OnResponseListener<JSONObject>() {
|
||||
@Override
|
||||
public void onStart(int what) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSucceed(int what, Response<JSONObject> 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<JSONObject> 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); //两次密码输入不一致提示消失
|
||||
}
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
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 <br>
|
||||
* Description: <br>
|
||||
* Author: 沈滨伟-13042299081 <br>
|
||||
* 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<JSONObject> 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<JSONObject>() {
|
||||
@Override
|
||||
public void onStart(int what) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSucceed(int what, Response<JSONObject> 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<JSONObject> response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(int what) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.sbw.atrue.Order.Entity;
|
||||
|
||||
import org.litepal.crud.DataSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* FileName: Order <br>
|
||||
* Description: 订单类 <br>
|
||||
* Author: 沈滨伟-13042299081 <br>
|
||||
* Date: 2019/4/8 15:25
|
||||
*/
|
||||
public class Order extends DataSupport {
|
||||
private int id; //订单ID
|
||||
private List<ProductOrder> 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<ProductOrder> 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<ProductOrder> 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;
|
||||
}
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
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 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<Product> CREATOR = new Creator<Product>() {
|
||||
@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;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.sbw.atrue.Order.Entity;
|
||||
|
||||
import org.litepal.crud.DataSupport;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* FileName: ProductOrder <br>
|
||||
* Description: 订单中的菜品信息类 <br>
|
||||
* Author: 沈滨伟-13042299081 <br>
|
||||
* Date: 2019/4/9 14:54
|
||||
*/
|
||||
public class ProductOrder extends DataSupport{
|
||||
private int id; //订单ID
|
||||
private List<Order> orders; //与Order表建立多对多关联关系
|
||||
private String foodName;//菜名
|
||||
private int num;//购买数量
|
||||
private double price;//单项菜品总价
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Order> 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<Order> 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;
|
||||
}
|
||||
}
|