@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
@ -0,0 +1 @@
|
||||
shopfour
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
/build
|
@ -0,0 +1,49 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.example.shopfour'
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.shopfour"
|
||||
minSdk 31
|
||||
targetSdk 32
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
dataBinding{
|
||||
enabled=true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.navigation:navigation-runtime:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-ui:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.4.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
@ -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,26 @@
|
||||
package com.example.shopfour;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.shopfour", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Shopfour"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
<service android:name=".MyService" />
|
||||
|
||||
<activity android:name=".RegisteredActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,54 @@
|
||||
package com.example.shopfour;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.example.shopfour.application.Goods;
|
||||
import com.example.shopfour.databinding.DialogGoodsBinding;
|
||||
|
||||
public class GoodsDialog extends Dialog implements View.OnClickListener {
|
||||
|
||||
private Goods goods;
|
||||
private Context context;
|
||||
private DialogGoodsBinding binding;
|
||||
|
||||
public GoodsDialog(@NonNull Context context, Goods goods) {
|
||||
super(context);
|
||||
this.goods = goods;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = DialogGoodsBinding.inflate(LayoutInflater.from(context));
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
// binding.imageViewPreviewDialog
|
||||
if (goods.getBitmaps().size() > 0){
|
||||
binding.imageViewPreviewDialog.setImageBitmap(goods.getBitmaps().get(0));
|
||||
}
|
||||
binding.getRoot().setOnClickListener(this);
|
||||
|
||||
|
||||
binding.textViewGoodsDescribeDialog.setText(goods.getDescribe());
|
||||
|
||||
binding.textViewGoodsNameDialog.setText(goods.getGoodsName());
|
||||
|
||||
binding.textViewGoodsTagsDialog.setText(goods.getTags().toString());
|
||||
|
||||
binding.textViewGoodsPriceDialog.setText(Goods.toPriceString(goods.getPrice()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
hide();
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.example.shopfour;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
import com.example.shopfour.application.Goods;
|
||||
import com.example.shopfour.application.Person;
|
||||
import com.example.shopfour.databinding.ActivityMainBinding;
|
||||
import com.example.shopfour.ui.goods.GoodsFragment;
|
||||
import com.example.shopfour.ui.person.PersonFragment;
|
||||
import com.example.shopfour.ui.person.PersonViewModel;
|
||||
import com.example.shopfour.ui.shopping.ShoppingFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActionBar actionBar=getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.hide();
|
||||
}
|
||||
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
BottomNavigationView navView = findViewById(R.id.nav_view);
|
||||
// Passing each menu ID as a set of Ids because each
|
||||
// menu should be considered as top level destinations.
|
||||
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
||||
R.id.navigation_goods, R.id.navigation_shopping, R.id.navigation_person)
|
||||
.build();
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
NavigationUI.setupWithNavController(binding.navView, navController);
|
||||
// 创建 Intent 对象,用于启动 Service
|
||||
// Intent serviceIntent = new Intent(this, MyService.class);
|
||||
|
||||
// 启动 Service
|
||||
// startService(serviceIntent);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.example.shopfour;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class MyService extends Service {
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
// 实现此方法以提供绑定服务的实现
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// 在此处执行服务工作
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
// 在此处进行资源清理
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.example.shopfour;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.shopfour.application.Database;
|
||||
import com.example.shopfour.application.MySQLiteHelper;
|
||||
import com.example.shopfour.application.Person;
|
||||
import com.example.shopfour.databinding.ActivityMainBinding;
|
||||
import com.example.shopfour.databinding.RegisteredLayoutBinding;
|
||||
|
||||
public class RegisteredActivity extends AppCompatActivity {
|
||||
private RegisteredLayoutBinding registeredLayoutBinding;
|
||||
public static int RESULTCODE_NEWPERSON = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
registeredLayoutBinding = RegisteredLayoutBinding.inflate(getLayoutInflater());
|
||||
setContentView(registeredLayoutBinding.getRoot());
|
||||
|
||||
registeredLayoutBinding.buttonCancelR.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
RegisteredActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
registeredLayoutBinding.buttonRegistered.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String userName = registeredLayoutBinding.editTextUsernameR.getText().toString().trim();
|
||||
String password = registeredLayoutBinding.editTextPasswordR.getText().toString().trim();
|
||||
String password2 = registeredLayoutBinding.editTextPasswordR2.getText().toString().trim();
|
||||
|
||||
if (!password.equals(password2)){
|
||||
Toast.makeText(RegisteredActivity.this,"两次密码输入不一致!",Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Database database = new Database(new MySQLiteHelper(RegisteredActivity.this));
|
||||
Person person = database.findPersonFromSQLite(null,userName,password);
|
||||
if (person != null){
|
||||
Toast.makeText(RegisteredActivity.this,"该账号已经注册过了!",Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
userName = registeredLayoutBinding.editTextUsernameR.getText().toString().trim();
|
||||
password = registeredLayoutBinding.editTextPasswordR.getText().toString().trim();
|
||||
|
||||
person = new Person(userName,password);
|
||||
person.setNum(database.getPersonMaxNumFromSQLite()+1);
|
||||
person.setId(String.valueOf(person.getNum()));
|
||||
person.setMoney(0);
|
||||
|
||||
database.insertPersonToSQLite(person);
|
||||
Toast.makeText(RegisteredActivity.this,"注册成功!",Toast.LENGTH_SHORT).show();
|
||||
Intent intentRegisterSuccess = new Intent();
|
||||
intentRegisterSuccess.putExtra("newPerson",person);
|
||||
setResult(RESULTCODE_NEWPERSON,intentRegisterSuccess);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.example.shopfour.application;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.shopfour.GoodsDialog;
|
||||
import com.example.shopfour.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BuyingListAdapter extends BaseAdapter {
|
||||
private ArrayList<Goods> list_goods ;
|
||||
private final Context context;
|
||||
|
||||
public BuyingListAdapter(ArrayList<Goods> list,Context context){
|
||||
this.list_goods = list;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setListGoods(ArrayList<Goods> list){
|
||||
this.list_goods = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list_goods.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list_goods.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@SuppressLint("ViewHolder")
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
@SuppressLint("ViewHolder") View item_view;
|
||||
item_view = View.inflate(this.context, R.layout.list_item_buying,null);
|
||||
|
||||
ImageView imageViewPreviewBuying = item_view.findViewById(R.id.imageViewPreviewBuying);
|
||||
TextView textViewGoodsNameBuying = item_view.findViewById(R.id.textViewGoodsNameBuying);
|
||||
TextView textViewGoodsPriceBuying = item_view.findViewById(R.id.textViewGoodsPriceBuying);
|
||||
|
||||
item_view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
String t="-"+Goods.toPriceString(list_goods.get(i).getPrice());
|
||||
textViewGoodsPriceBuying.setText(t);
|
||||
|
||||
textViewGoodsNameBuying.setText(list_goods.get(i).getGoodsName());
|
||||
|
||||
if (list_goods.get(i).getBitmaps().size() > 0){
|
||||
imageViewPreviewBuying.setImageBitmap(list_goods.get(i).getBitmaps().get(0));
|
||||
}
|
||||
|
||||
|
||||
return item_view;
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package com.example.shopfour.application;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Database {
|
||||
private MySQLiteHelper mySQLiteHelper;
|
||||
private SQLiteDatabase database;
|
||||
|
||||
public Database(MySQLiteHelper mySQLiteHelper){
|
||||
this.mySQLiteHelper = mySQLiteHelper;
|
||||
}
|
||||
|
||||
public void insertPersonToSQLite(Person person){
|
||||
database = mySQLiteHelper.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("id",person.getId());
|
||||
values.put("num",person.getNum());
|
||||
values.put("username",person.getUsername());
|
||||
values.put("password",person.getPassword());
|
||||
values.put("money",person.getMoney());
|
||||
long id = database.insert("person",null,values);
|
||||
database.close();
|
||||
}
|
||||
|
||||
public int getPersonMaxNumFromSQLite(){
|
||||
database = mySQLiteHelper.getWritableDatabase();
|
||||
int result;
|
||||
Cursor cursor = database.rawQuery("SELECT MAX(num) FROM person",null);
|
||||
if(cursor.getCount() ==0){
|
||||
return 0;
|
||||
} else {
|
||||
cursor.moveToFirst();
|
||||
result = cursor.getInt(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int updatePersonToSQLite(Person person){
|
||||
database = mySQLiteHelper.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("num",person.getNum());
|
||||
values.put("username",person.getUsername());
|
||||
values.put("password",person.getPassword());
|
||||
values.put("money",person.getMoney());
|
||||
int number = database.update("person",values,"id=?",new String[]{person.getId()});
|
||||
database.close();
|
||||
return number;
|
||||
}
|
||||
|
||||
public int deletePersonToSQLite(Person person){
|
||||
database = mySQLiteHelper.getWritableDatabase();
|
||||
int number = database.delete("person","id =?",new String[]{person.getId()});
|
||||
database.close();
|
||||
return number;
|
||||
}
|
||||
|
||||
//此方法用来查询数据库中是否存在person
|
||||
|
||||
public Person findPersonFromSQLite(String id,String username,String password){
|
||||
database = mySQLiteHelper.getReadableDatabase();
|
||||
Person person = new Person(username,null);
|
||||
Cursor cursor ;
|
||||
if(id != null && (!id.isEmpty())){
|
||||
cursor = database.query("person",null,"id=?",new String[]{id},null,null,null);
|
||||
if (cursor.getCount() ==0){
|
||||
database.close();
|
||||
return null;
|
||||
}
|
||||
cursor.moveToFirst();
|
||||
person.setId(cursor.getString(0));
|
||||
person.setNum(cursor.getInt(1));
|
||||
person.setUsername(cursor.getString(2));
|
||||
person.setPassword(cursor.getString(3));
|
||||
person.setMoney(cursor.getInt(4));
|
||||
cursor.close();
|
||||
database.close();
|
||||
return person;
|
||||
|
||||
} else if(username != null && (!username.isEmpty())){
|
||||
cursor = database.query("person",null,"username=?",new String[]{username},null,null,null);
|
||||
if (cursor.getCount() ==0){
|
||||
database.close();
|
||||
return null;
|
||||
} else if(cursor.getCount() ==1){
|
||||
cursor.moveToFirst();
|
||||
if (password != null){
|
||||
if (password.equals(cursor.getString(3))){
|
||||
person.setId(cursor.getString(0));
|
||||
person.setNum(cursor.getInt(1));
|
||||
person.setUsername(cursor.getString(2));
|
||||
person.setPassword(cursor.getString(3));
|
||||
person.setMoney(cursor.getInt(4));
|
||||
} else { //如果密码不相等
|
||||
person = null;
|
||||
}
|
||||
} else {
|
||||
person.setId(cursor.getString(0));
|
||||
person.setNum(cursor.getInt(1));
|
||||
person.setUsername(cursor.getString(2));
|
||||
person.setPassword(cursor.getString(3));
|
||||
person.setMoney(cursor.getInt(4));
|
||||
}
|
||||
cursor.close();
|
||||
database.close();
|
||||
return person;
|
||||
} else {
|
||||
cursor.moveToFirst();
|
||||
if (cursor.getString(3).equals(password)){
|
||||
person.setId(cursor.getString(0));
|
||||
person.setNum(cursor.getInt(1));
|
||||
person.setUsername(cursor.getString(2));
|
||||
person.setPassword(cursor.getString(3));
|
||||
person.setMoney(cursor.getInt(4));
|
||||
} else {
|
||||
boolean isExist = false;
|
||||
while(cursor.moveToNext()){
|
||||
if (cursor.getString(3).equals(password)){
|
||||
cursor.moveToFirst();
|
||||
person.setId(cursor.getString(0));
|
||||
person.setNum(cursor.getInt(1));
|
||||
person.setUsername(cursor.getString(2));
|
||||
person.setPassword(cursor.getString(3));
|
||||
person.setMoney(cursor.getInt(4));
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isExist) {
|
||||
person = null;
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
database.close();
|
||||
return person;
|
||||
}
|
||||
|
||||
}else {
|
||||
database.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void insertGoodsToSQLite(Person person,Goods goods,long time){
|
||||
database = mySQLiteHelper.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("id",person.getId());
|
||||
values.put("goodsName",goods.getGoodsName());
|
||||
values.put("time",time);
|
||||
long id = database.insert("shopping",null,values);
|
||||
database.close();
|
||||
}
|
||||
|
||||
public int deleteGoodsToSQLite(Person person,Goods goods){
|
||||
database = mySQLiteHelper.getWritableDatabase();
|
||||
int number = database.delete("shopping","id =? and goodsName =?",new String[]{person.getId(),goods.getGoodsName()});
|
||||
database.close();
|
||||
return number;
|
||||
}
|
||||
|
||||
public ArrayList<String> findGoodsListFromSQLite(Person person){
|
||||
database = mySQLiteHelper.getReadableDatabase();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
Cursor cursor = database.query("shopping",null,"id=?",new String[]{person.getId()},null,null,null);
|
||||
if (cursor.getCount() == 0){
|
||||
cursor.close();
|
||||
database.close();
|
||||
return list;
|
||||
} else {
|
||||
cursor.moveToFirst();
|
||||
list.add(new String(cursor.getString(1)));
|
||||
while (cursor.moveToNext()){
|
||||
list.add(new String(cursor.getString(1)));
|
||||
}
|
||||
cursor.close();
|
||||
database.close();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.example.shopfour.application;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
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 android.widget.Toast;
|
||||
|
||||
import com.example.shopfour.GoodsDialog;
|
||||
import com.example.shopfour.R;
|
||||
import com.example.shopfour.ui.person.PersonFragment;
|
||||
import com.example.shopfour.ui.shopping.ShoppingFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class GoodsListAdapter extends BaseAdapter{
|
||||
private ArrayList<Goods> list_goods;
|
||||
private final Context context;
|
||||
private boolean delay = false;
|
||||
|
||||
// private final ListItemGoodsBinding listItemGoodsBinding;
|
||||
|
||||
public GoodsListAdapter(ArrayList<Goods> list, Context context){
|
||||
this.list_goods = list;
|
||||
this.context = context;
|
||||
// listItemGoodsBinding =ListItemGoodsBinding.inflate(LayoutInflater.from(context));
|
||||
}
|
||||
|
||||
public void setListGoods(ArrayList<Goods> list){
|
||||
this.list_goods = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list_goods.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list_goods.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@SuppressLint("ViewHolder")
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
@SuppressLint("ViewHolder") View item_view;
|
||||
item_view = View.inflate(this.context, R.layout.list_item_goods,null);
|
||||
// View item_view = listItemGoodsBinding.getRoot();
|
||||
|
||||
ImageView imageViewPreview = item_view.findViewById(R.id.imageViewPreview);
|
||||
TextView textViewGoodsName = item_view.findViewById(R.id.textViewGoodsName);
|
||||
TextView textViewGoodsTags = item_view.findViewById(R.id.textViewGoodsTags);
|
||||
TextView textViewPrice = item_view.findViewById(R.id.textViewPrice);
|
||||
ImageButton imageButtonAdd = item_view.findViewById(R.id.imageButtonAdd);
|
||||
|
||||
imageViewPreview.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(GoodsListAdapter.this.context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
textViewGoodsName.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(GoodsListAdapter.this.context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
textViewGoodsTags.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(GoodsListAdapter.this.context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
textViewPrice.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(GoodsListAdapter.this.context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (list_goods.get(i).getBitmaps().size() > 0){
|
||||
imageViewPreview.setImageBitmap(list_goods.get(i).getBitmaps().get(0));
|
||||
}
|
||||
textViewGoodsName.setText(list_goods.get(i).getGoodsName());
|
||||
textViewGoodsTags.setText(list_goods.get(i).getTags().toString());
|
||||
|
||||
textViewPrice.setText(Goods.toPriceString(list_goods.get(i).getPrice()));
|
||||
|
||||
|
||||
imageButtonAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
|
||||
if(!PersonFragment.ISLOGIN){
|
||||
Toast.makeText(context,"请先登录",Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
if (!delay){
|
||||
ShoppingFragment.shoppingList.add(Goods.GOODSLIST.get(i));
|
||||
Toast.makeText(context,"添加成功",Toast.LENGTH_SHORT).show();
|
||||
delay = true;
|
||||
imageButtonAdd.setImageResource(R.drawable.ok);
|
||||
|
||||
@SuppressLint("HandlerLeak") Handler mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
delay=false;
|
||||
imageButtonAdd.setImageResource(R.drawable.shopping_add);
|
||||
}
|
||||
};
|
||||
TimerTask task = new TimerTask(){
|
||||
public void run() {
|
||||
Message message = new Message();
|
||||
mHandler.sendMessage(message);
|
||||
}
|
||||
};
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(task, 1000);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
return item_view;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.example.shopfour.application;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class MySQLiteHelper extends SQLiteOpenHelper {
|
||||
public MySQLiteHelper(@Nullable Context context) {
|
||||
super(context,"shopfour.db", null, 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||
sqLiteDatabase.execSQL("create table person(id varchar(10) primary key,num integer,username varchar(30),password varchar(30),money integer)");
|
||||
sqLiteDatabase.execSQL("create table shopping(id varchar(10),goodsName varchar(30),time bigint)");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.example.shopfour.application;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Person implements Serializable {
|
||||
private String id;
|
||||
private int num;
|
||||
private String username;
|
||||
private String password;
|
||||
private int money =0 ;
|
||||
|
||||
public Person(String name, String password){
|
||||
this.username = name;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public int getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(int money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
String t;
|
||||
t ="{id:%s,num:%s,username:%s,password:%s,money:%s}";
|
||||
t =String.format(t,this.id,this.num,this.username,this.password,this.money);
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.example.shopfour.application;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.shopfour.GoodsDialog;
|
||||
import com.example.shopfour.R;
|
||||
import com.example.shopfour.databinding.FragmentShoppingBinding;
|
||||
import com.example.shopfour.databinding.ListItemGoodsBinding;
|
||||
import com.example.shopfour.databinding.ListItemShoppingBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShoppingListAdapter extends BaseAdapter {
|
||||
|
||||
private ArrayList<Goods> list_goods ;
|
||||
private static ArrayList<Integer> list_select = new ArrayList<>();
|
||||
private int allPrice = 0;
|
||||
private final Context context;
|
||||
private FragmentShoppingBinding binding;
|
||||
|
||||
public ShoppingListAdapter(ArrayList<Goods> list, Context context, FragmentShoppingBinding binding){
|
||||
this.list_goods = list;
|
||||
this.context = context;
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public void setListGoods(ArrayList<Goods> list){
|
||||
this.list_goods = list;
|
||||
}
|
||||
|
||||
public void setSelectList(ArrayList<Integer> list){
|
||||
this.list_select = list;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getSelectList(){
|
||||
return this.list_select;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list_goods.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list_goods.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@SuppressLint("ViewHolder")
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
@SuppressLint("ViewHolder") View item_view;
|
||||
item_view = View.inflate(this.context, R.layout.list_item_shopping,null);
|
||||
|
||||
CheckBox checkBoxSelect = item_view.findViewById(R.id.checkBoxSelect);
|
||||
ImageView imageViewPreviewShopping = item_view.findViewById(R.id.imageViewPreviewShopping);
|
||||
TextView textViewGoodsNameShopping = item_view.findViewById(R.id.textViewGoodsNameShopping);
|
||||
TextView textViewGoodsPriceShopping = item_view.findViewById(R.id.textViewGoodsPriceShopping);
|
||||
|
||||
|
||||
if (list_select.contains(i)){
|
||||
checkBoxSelect.setChecked(true);
|
||||
}
|
||||
|
||||
checkBoxSelect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (checkBoxSelect.isChecked()){
|
||||
list_select.add(i);
|
||||
} else {
|
||||
list_select.remove(Integer.valueOf(i));
|
||||
}
|
||||
|
||||
allPrice = 0;
|
||||
|
||||
for (int i=0;i<list_goods.size();i++){
|
||||
if (list_select.contains(i)){
|
||||
allPrice+=list_goods.get(i).getPrice();
|
||||
}
|
||||
}
|
||||
|
||||
binding.shoppingBottom.textViewAllPrice.setText(Goods.toPriceString(allPrice));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (list_goods.get(i).getBitmaps().size() > 0){
|
||||
imageViewPreviewShopping.setImageBitmap(list_goods.get(i).getBitmaps().get(0));
|
||||
}
|
||||
imageViewPreviewShopping.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
textViewGoodsNameShopping.setText(list_goods.get(i).getGoodsName());
|
||||
textViewGoodsNameShopping.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
textViewGoodsPriceShopping.setText(Goods.toPriceString(list_goods.get(i).getPrice()));
|
||||
textViewGoodsPriceShopping.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GoodsDialog dialog = new GoodsDialog(context,list_goods.get(i));
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
return item_view;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.example.shopfour.ui.goods;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.example.shopfour.R;
|
||||
import com.example.shopfour.application.Goods;
|
||||
import com.example.shopfour.application.GoodsListAdapter;
|
||||
import com.example.shopfour.databinding.FragmentGoodsBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class GoodsFragment extends Fragment {
|
||||
|
||||
private GoodsViewModel goodsViewModel;
|
||||
private FragmentGoodsBinding binding;
|
||||
private ArrayList<Goods> list;
|
||||
private ArrayList<Goods> resultList;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
goodsViewModel =
|
||||
new ViewModelProvider(this).get(GoodsViewModel.class);
|
||||
|
||||
binding = FragmentGoodsBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
list = new ArrayList<>();
|
||||
resultList = new ArrayList<>();
|
||||
|
||||
initListView();
|
||||
initGoodsFragment();
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
|
||||
private void initGoodsFragment(){
|
||||
binding.topBar.imageButtonPhoto.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Navigation.findNavController(GoodsFragment.this.getView()).navigate(R.id.navigation_person);
|
||||
}
|
||||
});
|
||||
binding.topBar.imageButtonShopping.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Navigation.findNavController(GoodsFragment.this.getView()).navigate(R.id.navigation_shopping);
|
||||
}
|
||||
});
|
||||
|
||||
binding.topBar.editTextSearch.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String search = s.toString().trim();
|
||||
if(search.isEmpty()){
|
||||
goodsViewModel.setListGoods(list);
|
||||
} else {
|
||||
resultList.clear();
|
||||
for (Goods t:list) {
|
||||
if(t.getGoodsName().contains(search)){
|
||||
resultList.add(t);
|
||||
} else if (t.getTags().toString().contains(search)){
|
||||
resultList.add(t);
|
||||
} else if (t.getDescribe().contains(search)){
|
||||
resultList.add(t);
|
||||
}
|
||||
}
|
||||
goodsViewModel.setListGoods(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initListView(){
|
||||
if (Goods.GOODSLIST.size() == 0){
|
||||
Goods.getDefaultGoodsList(getContext());
|
||||
}
|
||||
list = new ArrayList<>(Goods.GOODSLIST);
|
||||
|
||||
goodsViewModel.setListGoods(list);
|
||||
GoodsListAdapter goodsListAdapter = new GoodsListAdapter(list,this.getContext());
|
||||
binding.listViewGoods.setAdapter(goodsListAdapter);
|
||||
|
||||
goodsViewModel.getListGoods().observe(getViewLifecycleOwner(), new Observer<ArrayList<Goods>>() {
|
||||
@Override
|
||||
public void onChanged(ArrayList<Goods> list) {
|
||||
goodsListAdapter.setListGoods(list);
|
||||
binding.listViewGoods.setAdapter(goodsListAdapter);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.example.shopfour.ui.goods;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.shopfour.application.Goods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GoodsViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<ArrayList<Goods>> list_goods;
|
||||
|
||||
public GoodsViewModel() {
|
||||
list_goods = new MutableLiveData<>();
|
||||
}
|
||||
|
||||
public LiveData<ArrayList<Goods>> getListGoods() {
|
||||
return list_goods;
|
||||
}
|
||||
|
||||
public void setListGoods(ArrayList<Goods> list){
|
||||
this.list_goods.setValue(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,268 @@
|
||||
package com.example.shopfour.ui.person;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.shopfour.RegisteredActivity;
|
||||
import com.example.shopfour.application.BuyingListAdapter;
|
||||
import com.example.shopfour.application.Database;
|
||||
import com.example.shopfour.application.Goods;
|
||||
import com.example.shopfour.application.MySQLiteHelper;
|
||||
import com.example.shopfour.application.Person;
|
||||
import com.example.shopfour.databinding.FragmentPersonBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PersonFragment extends Fragment {
|
||||
|
||||
private PersonViewModel personViewModel;
|
||||
private FragmentPersonBinding binding;
|
||||
public static boolean ISLOGIN = false;
|
||||
public static int REQUESTCODE_NEWPERSON = 1;
|
||||
public static Person person;
|
||||
private ArrayList<Goods> goodsArrayList = new ArrayList<>();
|
||||
private BuyingListAdapter buyingListAdapter;
|
||||
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
personViewModel =
|
||||
new ViewModelProvider(this).get(PersonViewModel.class);
|
||||
|
||||
binding = FragmentPersonBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
|
||||
if (!ISLOGIN){
|
||||
binding.linearLayoutLogin.setVisibility(View.VISIBLE);
|
||||
binding.linearLayoutLoginSuccess.setVisibility(View.GONE);
|
||||
} else
|
||||
{
|
||||
binding.linearLayoutLogin.setVisibility(View.GONE);
|
||||
binding.linearLayoutLoginSuccess.setVisibility(View.VISIBLE);
|
||||
|
||||
goodsArrayList.clear();
|
||||
Database database = new Database(new MySQLiteHelper(getContext()));
|
||||
ArrayList<String> goodsNameList = database.findGoodsListFromSQLite(person);
|
||||
for (String t:goodsNameList
|
||||
) {
|
||||
for (Goods goods:Goods.GOODSLIST
|
||||
) {
|
||||
if (t.equals(goods.getGoodsName())){
|
||||
goodsArrayList.add(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
personViewModel.getPerson().observe(getViewLifecycleOwner(), new Observer<Person>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable Person person) {
|
||||
if (person != null){
|
||||
PersonFragment.person = person;
|
||||
|
||||
binding.includeLogin.editTextUsername.setText(person.getUsername());
|
||||
binding.includeLogin.editTextPassword.setText(person.getPassword());
|
||||
|
||||
binding.includeLoginSuccess.textViewPersonName.setText(person.getUsername());
|
||||
|
||||
//购物清单也要跟着变
|
||||
Database database = new Database(new MySQLiteHelper(getContext()));
|
||||
ArrayList<String> goodsNameList = database.findGoodsListFromSQLite(person);
|
||||
ArrayList<Goods> goodsArrayList = new ArrayList<>();
|
||||
for (String t:goodsNameList
|
||||
) {
|
||||
for (Goods goods:Goods.GOODSLIST
|
||||
) {
|
||||
if (t.equals(goods.getGoodsName())){
|
||||
goodsArrayList.add(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
personViewModel.setBuyingList(goodsArrayList);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
personViewModel.setBuyingList(goodsArrayList);
|
||||
buyingListAdapter = new BuyingListAdapter(goodsArrayList,getContext());
|
||||
binding.includeLoginSuccess.buyingListView.setAdapter(buyingListAdapter);
|
||||
|
||||
personViewModel.getBuyingList().observe(getViewLifecycleOwner(), new Observer<ArrayList<Goods>>(){
|
||||
@Override
|
||||
public void onChanged(ArrayList<Goods> list) {
|
||||
buyingListAdapter.setListGoods(list);
|
||||
binding.includeLoginSuccess.buyingListView.setAdapter(buyingListAdapter);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
initLayoutLogin();
|
||||
initLayoutLoginSuccess();
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
// String result = (personViewModel.getPerson().getValue() == null)?"null":personViewModel.getPerson().getValue().toString();
|
||||
// Log.i("TAG", "onDestroyView: "+result);
|
||||
}
|
||||
|
||||
|
||||
public void initLayoutLogin(){
|
||||
if (personViewModel.getPerson().getValue() != null){
|
||||
binding.includeLogin.editTextUsername.setText(personViewModel.getPerson().getValue().getUsername());
|
||||
}
|
||||
|
||||
binding.includeLogin.buttonRegistered.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intentStartRegistered = new Intent(getActivity(), RegisteredActivity.class);
|
||||
startActivityForResult(intentStartRegistered,REQUESTCODE_NEWPERSON);
|
||||
}
|
||||
});
|
||||
binding.includeLogin.buttonLogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String userName = binding.includeLogin.editTextUsername.getText().toString().trim();
|
||||
String password = binding.includeLogin.editTextPassword.getText().toString().trim();
|
||||
|
||||
if (userName.isEmpty()){
|
||||
Toast.makeText(getContext(), "请输入用户名", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.isEmpty()){
|
||||
Toast.makeText(getContext(), "请输入密码", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Database database = new Database(new MySQLiteHelper(getContext()));
|
||||
Person person = database.findPersonFromSQLite(null,userName,password);
|
||||
if (person == null){
|
||||
Toast.makeText(getContext(), "用户名或密码错误,请核对后重新输入", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
personViewModel.setPerson(person);
|
||||
binding.includeLoginSuccess.textViewPersonName.setText(personViewModel.getPerson().getValue().getUsername());
|
||||
StringBuffer sb = new StringBuffer(String.valueOf(personViewModel.getPerson().getValue().getMoney()));
|
||||
//小于2位数
|
||||
if (sb.length()<=2)
|
||||
{
|
||||
if (sb.length() == 0){
|
||||
sb.insert(0,"0.00");
|
||||
} else if(sb.length() == 1){
|
||||
sb.insert(0,"0.0");
|
||||
} else if(sb.length() == 2){
|
||||
sb.insert(0,"0.");
|
||||
}
|
||||
} else {
|
||||
sb.insert(sb.length()-2,'.');
|
||||
}
|
||||
binding.includeLoginSuccess.textViewPersonMoney.setText(sb.toString());
|
||||
ISLOGIN = true;
|
||||
binding.linearLayoutLogin.setVisibility(View.GONE);
|
||||
binding.linearLayoutLoginSuccess.setVisibility(View.VISIBLE);
|
||||
|
||||
goodsArrayList.clear();
|
||||
ArrayList<String> goodsNameList = database.findGoodsListFromSQLite(person);
|
||||
for (String t:goodsNameList
|
||||
) {
|
||||
for (Goods goods:Goods.GOODSLIST
|
||||
) {
|
||||
if (t.equals(goods.getGoodsName())){
|
||||
goodsArrayList.add(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
personViewModel.setBuyingList(goodsArrayList);
|
||||
Log.i("TAG", "onClick: "+person.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void initLayoutLoginSuccess(){
|
||||
if (personViewModel.getPerson().getValue() != null){
|
||||
binding.includeLoginSuccess.textViewPersonName.setText(personViewModel.getPerson().getValue().getUsername());
|
||||
|
||||
StringBuffer sb = new StringBuffer(String.valueOf(personViewModel.getPerson().getValue().getMoney()));
|
||||
//小于2位数
|
||||
if (sb.length()<=2)
|
||||
{
|
||||
if (sb.length() == 0){
|
||||
sb.insert(0,"0.00");
|
||||
} else if(sb.length() == 1){
|
||||
sb.insert(0,"0.0");
|
||||
} else if(sb.length() == 2){
|
||||
sb.insert(0,"0.");
|
||||
}
|
||||
} else {
|
||||
sb.insert(sb.length()-2,'.');
|
||||
}
|
||||
binding.includeLoginSuccess.textViewPersonMoney.setText(sb.toString());
|
||||
}
|
||||
|
||||
binding.includeLoginSuccess.buttonEsc.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
binding.linearLayoutLoginSuccess.setVisibility(View.GONE);
|
||||
binding.linearLayoutLogin.setVisibility(View.VISIBLE);
|
||||
|
||||
if (personViewModel.getPerson().getValue()!= null){
|
||||
binding.includeLogin.editTextUsername.setText(personViewModel.getPerson().getValue().getUsername());
|
||||
binding.includeLogin.editTextPassword.setText(personViewModel.getPerson().getValue().getPassword());
|
||||
}
|
||||
|
||||
ISLOGIN = false;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
binding.includeLoginSuccess.buttonCharge.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getContext(),"充值成功",Toast.LENGTH_SHORT).show();
|
||||
Person person = personViewModel.getPerson().getValue();
|
||||
person.setMoney(person.getMoney()+10000);
|
||||
Database database = new Database(new MySQLiteHelper(getContext()));
|
||||
database.updatePersonToSQLite(person);
|
||||
personViewModel.setPerson(person);
|
||||
|
||||
binding.includeLoginSuccess.textViewPersonMoney.setText(Goods.toPriceString(personViewModel.getPerson().getValue().getMoney()));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PersonFragment.REQUESTCODE_NEWPERSON){
|
||||
if (resultCode == RegisteredActivity.RESULTCODE_NEWPERSON){
|
||||
Person person =(Person) data.getSerializableExtra("newPerson");
|
||||
// Navigation.findNavController(MainActivity.this.binding.getRoot()).navigate(R.id.navigation_person);
|
||||
personViewModel = new ViewModelProvider(this).get(PersonViewModel.class);
|
||||
personViewModel.setPerson(person);
|
||||
// Log.i("MainActivity", "onActivityResult: "+personViewModel.getPerson().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.example.shopfour.ui.person;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.shopfour.application.Database;
|
||||
import com.example.shopfour.application.Goods;
|
||||
import com.example.shopfour.application.Person;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PersonViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<Person> personMutableLiveData;
|
||||
private MutableLiveData<ArrayList<Goods>> buyingListMutableLiveData;
|
||||
|
||||
public PersonViewModel() {
|
||||
personMutableLiveData = new MutableLiveData<>();
|
||||
buyingListMutableLiveData = new MutableLiveData<>();
|
||||
buyingListMutableLiveData.setValue(new ArrayList<>());
|
||||
personMutableLiveData.setValue(PersonFragment.person); //从MainActivity中恢复数据
|
||||
}
|
||||
|
||||
public void setPerson(Person person){
|
||||
personMutableLiveData.setValue(person);
|
||||
PersonFragment.person = person; //防止Fragment销毁的时候数据也被清空
|
||||
|
||||
}
|
||||
|
||||
public LiveData<Person> getPerson() {
|
||||
return personMutableLiveData;
|
||||
}
|
||||
|
||||
public void setBuyingList(ArrayList<Goods> list){
|
||||
buyingListMutableLiveData.setValue(list);
|
||||
}
|
||||
|
||||
public LiveData<ArrayList<Goods>> getBuyingList() {
|
||||
return buyingListMutableLiveData;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.example.shopfour.ui.shopping;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.shopfour.application.Goods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShoppingViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<ArrayList<Goods>> shoppingList;
|
||||
|
||||
public ShoppingViewModel() {
|
||||
shoppingList = new MutableLiveData<>();
|
||||
}
|
||||
|
||||
public void setShoppingList(ArrayList<Goods> list){
|
||||
this.shoppingList.setValue(list);
|
||||
ShoppingFragment.shoppingList = list;
|
||||
}
|
||||
|
||||
public LiveData<ArrayList<Goods>> getShoppingList() {
|
||||
return shoppingList;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 84 KiB |
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:color="@color/color_focused" android:state_checked="true" />
|
||||
<item android:color="@color/color_un_focused" android:state_checked="false" />
|
||||
</selector>
|
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
@ -0,0 +1,30 @@
|
||||
<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:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
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="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 3.4 KiB |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<corners android:radius="10dp" />
|
||||
<stroke android:color="#000000" android:width="2dp" />
|
||||
</shape>
|
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!--底层使用蓝色填充色-->
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#FFFFFF"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<!--上面一层距离底层的顶部1dp,距离底部1dp,类似marginTop,填充色为白色,这样就形成了一个带有蓝色顶部边线和底部边线的白色背景的图-->
|
||||
<item android:bottom="3dp" android:top="3dp">
|
||||
<shape>
|
||||
<solid android:color="#FFFFFFFF"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
After Width: | Height: | Size: 245 KiB |
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#00000000" />
|
||||
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/white" />
|
||||
|
||||
<corners android:radius="16dp" />
|
||||
|
||||
</shape>
|
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 693 B |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 482 B |
After Width: | Height: | Size: 534 B |
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_iphone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="iPhone"
|
||||
android:textColor="#000000"
|
||||
android:background="@drawable/bg_button_transparent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_nio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="NIO"
|
||||
android:textColor="#000000"
|
||||
android:background="@drawable/bg_button_transparent"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_food"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="Food"
|
||||
android:textColor="#000000"
|
||||
android:background="@drawable/bg_button_transparent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,36 @@
|
||||
<?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:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:menu="@menu/bottom_nav_menu"
|
||||
app:itemIconTint="@drawable/bottom_navigation_item_selector"
|
||||
app:itemTextColor="@drawable/bottom_navigation_item_selector" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment_activity_main"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="55dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toTopOf="@id/nav_view"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewPreviewDialog"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="5dp"
|
||||
app:srcCompat="@drawable/default_goods"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsNameDialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="20sp"
|
||||
android:layout_margin="5dp"
|
||||
android:gravity="center"
|
||||
android:text="钢化膜" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsTagsDialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="5dp"
|
||||
android:textColor="#B0C4DE"
|
||||
android:textSize="10sp"
|
||||
android:gravity="center"
|
||||
android:text="TextView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsDescribeDialog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="5dp"
|
||||
android:textSize="10sp"
|
||||
android:textColor="#708090"
|
||||
android:gravity="center_vertical"
|
||||
android:text="TextView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsPriceDialog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_weight="2"
|
||||
android:layout_margin="5dp"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/black"
|
||||
android:text="TextView" />
|
||||
</LinearLayout>
|
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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=".ui.goods.GoodsFragment"
|
||||
android:id="@+id/fragment_goods"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:orientation="vertical" >
|
||||
<include
|
||||
android:id="@+id/top_bar"
|
||||
layout="@layout/top_bar"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="130dp"
|
||||
android:orientation="vertical" >
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/advertising">
|
||||
|
||||
</ImageView>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.3"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:text="Apple官方旗舰店 >" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:text="steelo的小吃店 >" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="18sp"
|
||||
android:text="蔚来汽车用品店:"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listViewGoods"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:divider="#00000000"
|
||||
android:dividerHeight="5dp"
|
||||
android:transcriptMode="alwaysScroll"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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:id="@+id/fragment_person"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.shopping.ShoppingFragment" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayoutLogin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible">
|
||||
<include
|
||||
android:id="@+id/includeLogin"
|
||||
layout="@layout/login_layout" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayoutLoginSuccess"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible" >
|
||||
<include
|
||||
android:id="@+id/includeLoginSuccess"
|
||||
layout="@layout/login_success_layout" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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:id="@+id/fragment_shopping"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.person.PersonFragment">
|
||||
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listViewShopping"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_margin="5dp"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<include
|
||||
android:id="@+id/shoppingBottom"
|
||||
layout="@layout/shopping_bottom"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewPreviewBuying"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_weight="2"
|
||||
app:srcCompat="@drawable/default_goods"
|
||||
android:background="@color/white"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsNameBuying"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="10"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textStyle="bold"
|
||||
android:text="TextView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsPriceBuying"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="5"
|
||||
android:layout_marginStart="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/purple_700"
|
||||
android:text="TextView" />
|
||||
</LinearLayout>
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewPreview"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/default_goods"
|
||||
android:background="@color/white"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3"
|
||||
android:layout_margin="5dp"
|
||||
android:textSize="20sp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="蔚来屏幕钢化膜"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsTags"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@drawable/text_view_tags"
|
||||
android:textSize="10sp"
|
||||
android:text="钢化膜 水凝膜 钥匙套 方向盘套" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPrice"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="3"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/purple_700"
|
||||
android:text="100.00" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButtonAdd"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/tianjia1"
|
||||
android:background="@color/white"
|
||||
android:layout_gravity="top"
|
||||
android:scaleType="fitEnd"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkBoxSelect"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewPreviewShopping"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_weight="2"
|
||||
app:srcCompat="@drawable/default_goods"
|
||||
android:background="@color/white"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsNameShopping"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_weight="10"
|
||||
android:layout_marginStart="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewGoodsPriceShopping"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_weight="3"
|
||||
android:layout_marginStart="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/purple_700"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewPersonPhoto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="150dp"
|
||||
app:srcCompat="@drawable/login" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewUsername"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="20dp"
|
||||
android:gravity="center"
|
||||
android:ems="5"
|
||||
android:text="用户名:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextUsername"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:hint="请输入用户名"
|
||||
android:inputType="textPersonName" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="20dp"
|
||||
android:ems="5"
|
||||
android:gravity="center"
|
||||
android:text="密码:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextPassword"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:hint="请输入密码"
|
||||
android:inputType="textWebPassword"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonRegistered"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="注册" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonLogin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="登录" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageViewPersonPhoto"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/steelo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPersonName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="4"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center_vertical"
|
||||
android:text="default" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPersonMoney"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textSize="15sp"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonCharge"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="5dp"
|
||||
android:text="余额" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonEsc"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="2"
|
||||
android:text="退出" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/information"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/imformation" />
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:text="我的地址" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:text="可乐" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:text="浙江省" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:text="快递方式" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="15sp"
|
||||
android:text="顺丰快递" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:text="我的订单" />
|
||||
<ListView
|
||||
android:id="@+id/buyingListView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="10"/>
|
||||
</LinearLayout>
|
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="25sp"
|
||||
android:layout_marginTop="150dp"
|
||||
android:text="注册新用户" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewUsernameR"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="20dp"
|
||||
android:gravity="center"
|
||||
android:ems="5"
|
||||
android:text="用户名:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextUsernameR"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:hint="请输入用户名"
|
||||
android:inputType="textPersonName" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPasswordR"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="20dp"
|
||||
android:ems="5"
|
||||
android:gravity="center"
|
||||
android:text="密码:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextPasswordR"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:hint="请输入密码"
|
||||
android:inputType="textWebPassword"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPasswordR2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="20dp"
|
||||
android:ems="5"
|
||||
android:gravity="center"
|
||||
android:text="确认密码:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextPasswordR2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:hint="请再次确认密码"
|
||||
android:inputType="textWebPassword"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonCancelR"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:textColor="@color/white"
|
||||
android:text="取消" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonRegistered"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="注册" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkBoxAll"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:textSize="10sp"
|
||||
android:textStyle="bold"
|
||||
android:text="全选" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewAllPrice"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:textColor="@color/white"
|
||||
android:gravity="center"
|
||||
android:text="0.00" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonDelete"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10sp"
|
||||
android:text="删除" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonBuy"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:textSize="10sp"
|
||||
android:text="去支付" />
|
||||
</LinearLayout>
|
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButtonPhoto"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="5dp"
|
||||
app:srcCompat="@drawable/steelo"
|
||||
android:background="@color/white"
|
||||
android:scaleType="fitStart" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextSearch"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="4"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:paddingStart="10dp"
|
||||
android:background="@drawable/sharp_edit"
|
||||
android:hint="搜一搜看吧"
|
||||
android:inputType="textPersonName"
|
||||
android:text="" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButtonShopping"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="end"
|
||||
android:layout_margin="5dp"
|
||||
app:srcCompat="@drawable/shoppingcart"
|
||||
android:background="@color/white"
|
||||
android:scaleType="fitEnd" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_goods"
|
||||
android:icon="@drawable/goods"
|
||||
android:title="@string/title_goods" />
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_shopping"
|
||||
android:icon="@drawable/shopping"
|
||||
android:title="@string/title_shopping" />
|
||||
|
||||
<item
|
||||
android:id="@+id/navigation_person"
|
||||
android:icon="@drawable/person"
|
||||
android:title="@string/title_person" />
|
||||
|
||||
</menu>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation 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:id="@+id/mobile_navigation"
|
||||
app:startDestination="@+id/navigation_goods">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_goods"
|
||||
android:name="com.example.shopfour.ui.goods.GoodsFragment"
|
||||
android:label="@string/title_goods"
|
||||
tools:layout="@layout/fragment_goods" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_shopping"
|
||||
android:name="com.example.shopfour.ui.shopping.ShoppingFragment"
|
||||
android:label="@string/title_shopping"
|
||||
tools:layout="@layout/fragment_shopping" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_person"
|
||||
android:name="com.example.shopfour.ui.person.PersonFragment"
|
||||
android:label="@string/title_person"
|
||||
tools:layout="@layout/fragment_person" />
|
||||
</navigation>
|
@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Shopfour" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="selector_color">#FFBB86FC</color>
|
||||
<color name="title_color">#FFBB86FC</color>
|
||||
<color name="color_focused">#4169E1</color>
|
||||
<color name="color_un_focused">#000000</color>
|
||||
<color name="red">#FFFF0000</color>
|
||||
</resources>
|
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
<string name="app_name">shopfour</string>
|
||||
|
||||
<string name="title_goods">商品</string>
|
||||
<string name="title_shopping">购物车</string>
|
||||
<string name="title_person">个人中心</string>
|
||||
<string name="searchHint">请输入商品名称</string>
|
||||
</resources>
|
@ -0,0 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Shopfour" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
@ -0,0 +1,17 @@
|
||||
package com.example.shopfour;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
buildscript {
|
||||
ext {
|
||||
agp_version = '8.2.2'
|
||||
}
|
||||
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '8.2.2' apply false
|
||||
id 'com.android.library' version '7.3.0' apply false
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|