@ -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,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="jbr-11" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DesignSurface">
|
||||||
|
<option name="filePathToZoomLevelMap">
|
||||||
|
<map>
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.25729166666666664" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/bottom_navigation_item_selector.xml" value="0.25729166666666664" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/ic_home_black_24dp.xml" value="0.25729166666666664" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/ic_launcher_background.xml" value="0.25729166666666664" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/ic_notifications_black_24dp.xml" value="0.25729166666666664" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/sharp_edit.xml" value="0.25729166666666664" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/sharp_edittext.xml" value="0.16770833333333332" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/drawable/text_view_tags.xml" value="0.13697916666666668" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/activity_main.xml" value="0.12083333333333333" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/bottom_navigation_item_selector.xml" value="0.2265625" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/dialog_goods.xml" value="0.1" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/fragment_dashboard.xml" value="0.24114583333333334" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/fragment_goods.xml" value="0.1515625" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/fragment_person.xml" value="0.1515625" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/fragment_shopping.xml" value="0.1515625" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/layout.xml" value="0.10625" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/list_item_buying.xml" value="0.1192084942084942" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/list_item_goods.xml" value="0.25" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/list_item_history.xml" value="0.2259963768115942" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/list_item_shopping.xml" value="0.2259963768115942" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/login_layout.xml" value="0.15572916666666667" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/login_success_layout.xml" value="0.1703125" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/registered_layout.xml" value="0.15572916666666667" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/shopping_bottom.xml" value="0.20104754230459307" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/shpping_bottom.xml" value="0.2259963768115942" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/title.xml" value="0.2265625" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/layout/top_bar.xml" value="0.2" />
|
||||||
|
<entry key="..\:/Android/LinShopping/app/src/main/res/menu/bottom_nav_menu.xml" value="0.12083333333333333" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" 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,45 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.android.application'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk 30
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.ronglin.linshopping"
|
||||||
|
minSdk 24
|
||||||
|
targetSdk 30
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
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.2.0'
|
||||||
|
implementation 'com.google.android.material:material:1.3.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
||||||
|
implementation 'androidx.navigation:navigation-fragment:2.3.5'
|
||||||
|
implementation 'androidx.navigation:navigation-ui:2.3.5'
|
||||||
|
testImplementation 'junit:junit:4.+'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.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,20 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"artifactType": {
|
||||||
|
"type": "APK",
|
||||||
|
"kind": "Directory"
|
||||||
|
},
|
||||||
|
"applicationId": "com.ronglin.linshopping",
|
||||||
|
"variantName": "release",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "SINGLE",
|
||||||
|
"filters": [],
|
||||||
|
"attributes": [],
|
||||||
|
"versionCode": 1,
|
||||||
|
"versionName": "1.0",
|
||||||
|
"outputFile": "app-release.apk"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"elementType": "File"
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.ronglin.linshopping;
|
||||||
|
|
||||||
|
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.ronglin.linshopping", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.ronglin.linshopping" >
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@drawable/photo"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@drawable/photo"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.LinShopping" >
|
||||||
|
<activity
|
||||||
|
android:name=".RegisteredActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="@string/app_name" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.ronglin.linshopping;
|
||||||
|
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
|
public interface AppCompatActivity {
|
||||||
|
void onCheckedChanged(RadioGroup group, int checkedId);
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.ronglin.linshopping;
|
||||||
|
|
||||||
|
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.ronglin.linshopping.application.Goods;
|
||||||
|
import com.ronglin.linshopping.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,49 @@
|
|||||||
|
package com.ronglin.linshopping;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.navigation.NavController;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
|
import androidx.navigation.ui.AppBarConfiguration;
|
||||||
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
|
import com.ronglin.linshopping.databinding.ActivityMainBinding;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private ActivityMainBinding binding;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.ronglin.linshopping;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.ronglin.linshopping.R;
|
||||||
|
|
||||||
|
public class OtherActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.other_activity_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.look:
|
||||||
|
Intent intent = new Intent(OtherActivity.this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.ronglin.linshopping;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.ronglin.linshopping.application.Database;
|
||||||
|
import com.ronglin.linshopping.application.MySQLiteHelper;
|
||||||
|
import com.ronglin.linshopping.application.Person;
|
||||||
|
import com.ronglin.linshopping.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,73 @@
|
|||||||
|
package com.ronglin.linshopping.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.ronglin.linshopping.GoodsDialog;
|
||||||
|
import com.ronglin.linshopping.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,183 @@
|
|||||||
|
package com.ronglin.linshopping.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,139 @@
|
|||||||
|
package com.ronglin.linshopping.application;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import com.ronglin.linshopping.R;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Goods {
|
||||||
|
private ArrayList<Bitmap> bitmaps;
|
||||||
|
private String goodsName;
|
||||||
|
private String describe;
|
||||||
|
private ArrayList<String> tags;
|
||||||
|
private int price;
|
||||||
|
|
||||||
|
public static ArrayList<Goods> GOODSLIST =new ArrayList<>();
|
||||||
|
public static Goods DEULT_GOODS = new Goods();
|
||||||
|
|
||||||
|
public Goods(){
|
||||||
|
this.bitmaps = new ArrayList<>();
|
||||||
|
this.goodsName = "";
|
||||||
|
this.describe = "";
|
||||||
|
this.tags = new ArrayList<>();
|
||||||
|
this.price = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Goods(String goodsName, String describe, String[] tags, int price){
|
||||||
|
this();
|
||||||
|
this.goodsName = goodsName;
|
||||||
|
this.describe = describe;
|
||||||
|
this.price = price;
|
||||||
|
this.tags.addAll(Arrays.asList(tags));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Bitmap> getBitmaps() {
|
||||||
|
return bitmaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBitmaps(ArrayList<Bitmap> bitmaps) {
|
||||||
|
this.bitmaps = bitmaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGoodsName() {
|
||||||
|
return goodsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodsName(String goodsName) {
|
||||||
|
this.goodsName = goodsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescribe() {
|
||||||
|
return describe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescribe(String describe) {
|
||||||
|
this.describe = describe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTags(ArrayList<String> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(int price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Goods goods){
|
||||||
|
return this.getGoodsName().equals(goods.getGoodsName())
|
||||||
|
&& this.getTags().equals(goods.getTags())
|
||||||
|
&& this.getDescribe().equals(goods.getDescribe())
|
||||||
|
&& this.getPrice() == goods.getPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toPriceString(int price){
|
||||||
|
StringBuffer sb = new StringBuffer(String.valueOf(price));
|
||||||
|
//小于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,'.');
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getDefaultGoodsList(Context context){
|
||||||
|
|
||||||
|
GOODSLIST.clear();
|
||||||
|
Goods goods1 = new Goods("南方大橘子","美味多汁,清凉解渴",new String[]{"水果","南方橘子","大橘子"},5000);
|
||||||
|
goods1.setDescribe("美味多汁,清凉解渴,美味多汁,清凉解渴,美味多汁,清凉解渴,美味多汁,清凉解渴,美味多汁,清凉解渴");
|
||||||
|
Goods goods2 = new Goods("北方丑橘","长相出众,深得人心",new String[]{"丑陋","丑橘子"},1500);
|
||||||
|
goods2.setDescribe("长相出众,深得人心,长相出众,深得人心,长相出众,深得人心,长相出众,深得人心,长相出众,深得人心");
|
||||||
|
Goods goods3 = new Goods("东方少水橘","干涩难吃,买给朋友",new String[]{"少水"},1500);
|
||||||
|
goods3.setDescribe("干涩难吃,买给朋友,干涩难吃,买给朋友,干涩难吃,买给朋友,干涩难吃,买给朋友,干涩难吃,买给朋友");
|
||||||
|
Goods goods4 = new Goods("西方升天橘","下了泻药,便秘必备",new String[]{"有毒"},100);
|
||||||
|
goods4.setDescribe("下了泻药,便秘必备,下了泻药,便秘必备,下了泻药,便秘必备,下了泻药,便秘必备,下了泻药,便秘必备");
|
||||||
|
|
||||||
|
|
||||||
|
ArrayList<Bitmap> bitmaps1 = new ArrayList<>();
|
||||||
|
bitmaps1.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.orange1));
|
||||||
|
goods1.setBitmaps(bitmaps1);
|
||||||
|
|
||||||
|
ArrayList<Bitmap> bitmaps2 = new ArrayList<>();
|
||||||
|
bitmaps2.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.orange));
|
||||||
|
goods2.setBitmaps(bitmaps2);
|
||||||
|
|
||||||
|
ArrayList<Bitmap> bitmaps3 = new ArrayList<>();
|
||||||
|
bitmaps3.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.orange3));
|
||||||
|
goods3.setBitmaps(bitmaps3);
|
||||||
|
|
||||||
|
ArrayList<Bitmap> bitmaps4 = new ArrayList<>();
|
||||||
|
bitmaps4.add(BitmapFactory.decodeResource(context.getResources(), R.drawable.orange4));
|
||||||
|
goods4.setBitmaps(bitmaps4);
|
||||||
|
|
||||||
|
|
||||||
|
GOODSLIST.add(goods1);
|
||||||
|
GOODSLIST.add(goods2);
|
||||||
|
GOODSLIST.add(goods3);
|
||||||
|
GOODSLIST.add(goods4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
package com.ronglin.linshopping.application;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
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.ronglin.linshopping.GoodsDialog;
|
||||||
|
import com.ronglin.linshopping.R;
|
||||||
|
import com.ronglin.linshopping.ui.person.PersonFragment;
|
||||||
|
import com.ronglin.linshopping.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.ronglin.linshopping.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,"LinShopping.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,66 @@
|
|||||||
|
package com.ronglin.linshopping.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,133 @@
|
|||||||
|
package com.ronglin.linshopping.application;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
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.ronglin.linshopping.GoodsDialog;
|
||||||
|
import com.ronglin.linshopping.R;
|
||||||
|
import com.ronglin.linshopping.databinding.FragmentShoppingBinding;
|
||||||
|
import com.ronglin.linshopping.databinding.ListItemGoodsBinding;
|
||||||
|
import com.ronglin.linshopping.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,26 @@
|
|||||||
|
package com.ronglin.linshopping.ui.goods;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.ronglin.linshopping.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,277 @@
|
|||||||
|
package com.ronglin.linshopping.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.ronglin.linshopping.RegisteredActivity;
|
||||||
|
import com.ronglin.linshopping.application.BuyingListAdapter;
|
||||||
|
import com.ronglin.linshopping.application.Database;
|
||||||
|
import com.ronglin.linshopping.application.Goods;
|
||||||
|
import com.ronglin.linshopping.application.MySQLiteHelper;
|
||||||
|
import com.ronglin.linshopping.application.Person;
|
||||||
|
import com.ronglin.linshopping.databinding.FragmentPersonBinding;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
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.ronglin.linshopping.ui.person;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.ronglin.linshopping.application.Database;
|
||||||
|
import com.ronglin.linshopping.application.Goods;
|
||||||
|
import com.ronglin.linshopping.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.ronglin.linshopping.ui.shopping;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.ronglin.linshopping.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;
|
||||||
|
}
|
||||||
|
}
|
@ -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: 1.0 KiB |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 233 B |
@ -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>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="false">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#FFA500" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#c0c0c0" />
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 790 B |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 1017 B |
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>
|
After Width: | Height: | Size: 412 KiB |
After Width: | Height: | Size: 248 KiB |
After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 442 KiB |
After Width: | Height: | Size: 520 KiB |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 696 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 419 KiB |
After Width: | Height: | Size: 409 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 219 KiB |
After Width: | Height: | Size: 295 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.5 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="#2980b9" android:width="3dp" />
|
||||||
|
</shape>
|
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 799 B |
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#FF018786"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<!--商品界面两条蓝色线条,白框加蓝色框组成!-->
|
||||||
|
<item android:bottom="3dp" android:top="3dp">
|
||||||
|
<shape>
|
||||||
|
<solid android:color="#FFFFFFFF"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
After Width: | Height: | Size: 957 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 402 B |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 554 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 56 KiB |
@ -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/red"
|
||||||
|
android:text="TextView" />
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,31 @@
|
|||||||
|
<?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>
|
||||||
|
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/listViewGoods"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:divider="#FFD8BFD8"
|
||||||
|
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>
|