@ -0,0 +1,2 @@
|
||||
#Fri Oct 21 23:04:16 GMT+08:00 2022
|
||||
gradle.version=6.4.1
|
@ -0,0 +1 @@
|
||||
/build
|
@ -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'
|
||||
}
|
@ -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
|
@ -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":{}}]
|
@ -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 <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());
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?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="潮汕牛肉"></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>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<litepal>
|
||||
<!--注释快捷键 ctrl shift /-->
|
||||
<!--dbname 标签用来指定数据库的名称-->
|
||||
<dbname value="order" />
|
||||
<!--version 标签是指定数据库版本,更新表的时候需要增大该值-->
|
||||
<version value="8" />
|
||||
<!--list 标签是用来指定映射模型,即实体类的路径用 mapping标签放进来-->
|
||||
<list>
|
||||
<mapping class="com.sbw.atrue.Order.Entity.ProductOrder">
|
||||
</mapping>
|
||||
<mapping class="com.sbw.atrue.Order.Entity.Order">
|
||||
</mapping>
|
||||
</list>
|
||||
</litepal>
|
@ -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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
...
|
||||
}*/
|
@ -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 <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) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
//健康结算界面
|
||||
public class NutritionActivity {
|
||||
|
||||
}
|
@ -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<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); //两次密码输入不一致提示消失
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <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) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -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 <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;
|
||||
}
|
||||
}
|
@ -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<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;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.sbw.atrue.Order.Util;
|
||||
|
||||
|
||||
public class HttpUtil {
|
||||
|
||||
public static final String HOST = "http://coding-space.cn:9030/";
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.sbw.atrue.Order.Util;
|
||||
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
public interface MyListener<T> {
|
||||
void onSuccess(T data) throws JSONException;
|
||||
}
|
@ -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<Product> productsData; //商品内容数据源
|
||||
private ArrayList<Product> selectedProducts = new ArrayList<Product>(); //被选择的的商品数据
|
||||
private int totalSelectedCount = 0; //当前选择商品总数
|
||||
private int totalPrice = 0; //当前选择商品总价
|
||||
|
||||
public ProductListAdapter(Context context, List<Product> 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<Product> 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; //减去商品按钮
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 46 KiB |
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!--圆角-->
|
||||
<corners android:radius="30dp"/>
|
||||
<!--中间颜色-->
|
||||
<solid android:color="@android:color/white"/>
|
||||
<!--边框/颜色-->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#ed7b7b"/>
|
||||
</shape>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!--圆角-->
|
||||
<corners android:radius="30dp"/>
|
||||
<!--中间颜色-->
|
||||
<solid android:color="@android:color/white"/>
|
||||
<!--边框/颜色-->
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="#82b2ff"/>
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#82b2ff" />
|
||||
<corners android:radius="25dp" />
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#aee4da" />
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#33b34f" />
|
||||
<corners android:radius="20dp" />
|
||||
<padding
|
||||
android:right="6dp" />
|
||||
</shape>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#f9e939" />
|
||||
</shape>
|
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_window_focused="false"
|
||||
android:drawable="@drawable/bg_edittext_normal" />
|
||||
<item android:state_focused="true"
|
||||
android:drawable="@drawable/bg_edittext_focused" />
|
||||
</selector>
|
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 265 B |