@ -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 @@
|
|||||||
|
DeliciousFoodApp
|
@ -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,409 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DBNavigator.Project.DatabaseBrowserManager">
|
||||||
|
<autoscroll-to-editor value="false" />
|
||||||
|
<autoscroll-from-editor value="true" />
|
||||||
|
<show-object-properties value="true" />
|
||||||
|
<loaded-nodes />
|
||||||
|
</component>
|
||||||
|
<component name="DBNavigator.Project.DatabaseFileManager">
|
||||||
|
<open-files />
|
||||||
|
</component>
|
||||||
|
<component name="DBNavigator.Project.Settings">
|
||||||
|
<connections />
|
||||||
|
<browser-settings>
|
||||||
|
<general>
|
||||||
|
<display-mode value="TABBED" />
|
||||||
|
<navigation-history-size value="100" />
|
||||||
|
<show-object-details value="false" />
|
||||||
|
</general>
|
||||||
|
<filters>
|
||||||
|
<object-type-filter>
|
||||||
|
<object-type name="SCHEMA" enabled="true" />
|
||||||
|
<object-type name="USER" enabled="true" />
|
||||||
|
<object-type name="ROLE" enabled="true" />
|
||||||
|
<object-type name="PRIVILEGE" enabled="true" />
|
||||||
|
<object-type name="CHARSET" enabled="true" />
|
||||||
|
<object-type name="TABLE" enabled="true" />
|
||||||
|
<object-type name="VIEW" enabled="true" />
|
||||||
|
<object-type name="MATERIALIZED_VIEW" enabled="true" />
|
||||||
|
<object-type name="NESTED_TABLE" enabled="true" />
|
||||||
|
<object-type name="COLUMN" enabled="true" />
|
||||||
|
<object-type name="INDEX" enabled="true" />
|
||||||
|
<object-type name="CONSTRAINT" enabled="true" />
|
||||||
|
<object-type name="DATASET_TRIGGER" enabled="true" />
|
||||||
|
<object-type name="DATABASE_TRIGGER" enabled="true" />
|
||||||
|
<object-type name="SYNONYM" enabled="true" />
|
||||||
|
<object-type name="SEQUENCE" enabled="true" />
|
||||||
|
<object-type name="PROCEDURE" enabled="true" />
|
||||||
|
<object-type name="FUNCTION" enabled="true" />
|
||||||
|
<object-type name="PACKAGE" enabled="true" />
|
||||||
|
<object-type name="TYPE" enabled="true" />
|
||||||
|
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
|
||||||
|
<object-type name="ARGUMENT" enabled="true" />
|
||||||
|
<object-type name="DIMENSION" enabled="true" />
|
||||||
|
<object-type name="CLUSTER" enabled="true" />
|
||||||
|
<object-type name="DBLINK" enabled="true" />
|
||||||
|
</object-type-filter>
|
||||||
|
</filters>
|
||||||
|
<sorting>
|
||||||
|
<object-type name="COLUMN" sorting-type="NAME" />
|
||||||
|
<object-type name="FUNCTION" sorting-type="NAME" />
|
||||||
|
<object-type name="PROCEDURE" sorting-type="NAME" />
|
||||||
|
<object-type name="ARGUMENT" sorting-type="POSITION" />
|
||||||
|
<object-type name="TYPE ATTRIBUTE" sorting-type="POSITION" />
|
||||||
|
</sorting>
|
||||||
|
<default-editors>
|
||||||
|
<object-type name="VIEW" editor-type="SELECTION" />
|
||||||
|
<object-type name="PACKAGE" editor-type="SELECTION" />
|
||||||
|
<object-type name="TYPE" editor-type="SELECTION" />
|
||||||
|
</default-editors>
|
||||||
|
</browser-settings>
|
||||||
|
<navigation-settings>
|
||||||
|
<lookup-filters>
|
||||||
|
<lookup-objects>
|
||||||
|
<object-type name="SCHEMA" enabled="true" />
|
||||||
|
<object-type name="USER" enabled="false" />
|
||||||
|
<object-type name="ROLE" enabled="false" />
|
||||||
|
<object-type name="PRIVILEGE" enabled="false" />
|
||||||
|
<object-type name="CHARSET" enabled="false" />
|
||||||
|
<object-type name="TABLE" enabled="true" />
|
||||||
|
<object-type name="VIEW" enabled="true" />
|
||||||
|
<object-type name="MATERIALIZED VIEW" enabled="true" />
|
||||||
|
<object-type name="INDEX" enabled="true" />
|
||||||
|
<object-type name="CONSTRAINT" enabled="true" />
|
||||||
|
<object-type name="DATASET TRIGGER" enabled="true" />
|
||||||
|
<object-type name="DATABASE TRIGGER" enabled="true" />
|
||||||
|
<object-type name="SYNONYM" enabled="false" />
|
||||||
|
<object-type name="SEQUENCE" enabled="true" />
|
||||||
|
<object-type name="PROCEDURE" enabled="true" />
|
||||||
|
<object-type name="FUNCTION" enabled="true" />
|
||||||
|
<object-type name="PACKAGE" enabled="true" />
|
||||||
|
<object-type name="TYPE" enabled="true" />
|
||||||
|
<object-type name="DIMENSION" enabled="false" />
|
||||||
|
<object-type name="CLUSTER" enabled="false" />
|
||||||
|
<object-type name="DBLINK" enabled="true" />
|
||||||
|
</lookup-objects>
|
||||||
|
<force-database-load value="false" />
|
||||||
|
<prompt-connection-selection value="true" />
|
||||||
|
<prompt-schema-selection value="true" />
|
||||||
|
</lookup-filters>
|
||||||
|
</navigation-settings>
|
||||||
|
<dataset-grid-settings>
|
||||||
|
<general>
|
||||||
|
<enable-zooming value="true" />
|
||||||
|
<enable-column-tooltip value="true" />
|
||||||
|
</general>
|
||||||
|
<sorting>
|
||||||
|
<nulls-first value="true" />
|
||||||
|
<max-sorting-columns value="4" />
|
||||||
|
</sorting>
|
||||||
|
<audit-columns>
|
||||||
|
<column-names value="" />
|
||||||
|
<visible value="true" />
|
||||||
|
<editable value="false" />
|
||||||
|
</audit-columns>
|
||||||
|
</dataset-grid-settings>
|
||||||
|
<dataset-editor-settings>
|
||||||
|
<text-editor-popup>
|
||||||
|
<active value="false" />
|
||||||
|
<active-if-empty value="false" />
|
||||||
|
<data-length-threshold value="100" />
|
||||||
|
<popup-delay value="1000" />
|
||||||
|
</text-editor-popup>
|
||||||
|
<values-actions-popup>
|
||||||
|
<show-popup-button value="true" />
|
||||||
|
<element-count-threshold value="1000" />
|
||||||
|
<data-length-threshold value="250" />
|
||||||
|
</values-actions-popup>
|
||||||
|
<general>
|
||||||
|
<fetch-block-size value="100" />
|
||||||
|
<fetch-timeout value="30" />
|
||||||
|
<trim-whitespaces value="true" />
|
||||||
|
<convert-empty-strings-to-null value="true" />
|
||||||
|
<select-content-on-cell-edit value="true" />
|
||||||
|
<large-value-preview-active value="true" />
|
||||||
|
</general>
|
||||||
|
<filters>
|
||||||
|
<prompt-filter-dialog value="true" />
|
||||||
|
<default-filter-type value="BASIC" />
|
||||||
|
</filters>
|
||||||
|
<qualified-text-editor text-length-threshold="300">
|
||||||
|
<content-types>
|
||||||
|
<content-type name="Text" enabled="true" />
|
||||||
|
<content-type name="Properties" enabled="true" />
|
||||||
|
<content-type name="XML" enabled="true" />
|
||||||
|
<content-type name="DTD" enabled="true" />
|
||||||
|
<content-type name="HTML" enabled="true" />
|
||||||
|
<content-type name="XHTML" enabled="true" />
|
||||||
|
<content-type name="Java" enabled="true" />
|
||||||
|
<content-type name="SQL" enabled="true" />
|
||||||
|
<content-type name="PL/SQL" enabled="true" />
|
||||||
|
<content-type name="JSON" enabled="true" />
|
||||||
|
<content-type name="JSON5" enabled="true" />
|
||||||
|
<content-type name="Groovy" enabled="true" />
|
||||||
|
<content-type name="AIDL" enabled="true" />
|
||||||
|
<content-type name="YAML" enabled="true" />
|
||||||
|
<content-type name="Manifest" enabled="true" />
|
||||||
|
</content-types>
|
||||||
|
</qualified-text-editor>
|
||||||
|
<record-navigation>
|
||||||
|
<navigation-target value="VIEWER" />
|
||||||
|
</record-navigation>
|
||||||
|
</dataset-editor-settings>
|
||||||
|
<code-editor-settings>
|
||||||
|
<general>
|
||||||
|
<show-object-navigation-gutter value="false" />
|
||||||
|
<show-spec-declaration-navigation-gutter value="true" />
|
||||||
|
<enable-spellchecking value="true" />
|
||||||
|
<enable-reference-spellchecking value="false" />
|
||||||
|
</general>
|
||||||
|
<confirmations>
|
||||||
|
<save-changes value="false" />
|
||||||
|
<revert-changes value="true" />
|
||||||
|
<exit-on-changes value="ASK" />
|
||||||
|
</confirmations>
|
||||||
|
</code-editor-settings>
|
||||||
|
<code-completion-settings>
|
||||||
|
<filters>
|
||||||
|
<basic-filter>
|
||||||
|
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="role" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="user" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||||
|
<user-schema>
|
||||||
|
<filter-element type="OBJECT" id="table" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="index" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="function" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="package" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="type" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||||
|
</user-schema>
|
||||||
|
<public-schema>
|
||||||
|
<filter-element type="OBJECT" id="table" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="view" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="materialized view" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="index" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="constraint" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="trigger" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="synonym" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="sequence" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="procedure" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="function" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="package" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="type" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="dimension" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="cluster" selected="false" />
|
||||||
|
<filter-element type="OBJECT" id="dblink" selected="false" />
|
||||||
|
</public-schema>
|
||||||
|
<any-schema>
|
||||||
|
<filter-element type="OBJECT" id="table" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="index" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="function" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="package" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="type" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||||
|
</any-schema>
|
||||||
|
</basic-filter>
|
||||||
|
<extended-filter>
|
||||||
|
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="function" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
|
||||||
|
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="schema" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="user" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="role" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="privilege" selected="true" />
|
||||||
|
<user-schema>
|
||||||
|
<filter-element type="OBJECT" id="table" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="index" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="function" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="package" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="type" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||||
|
</user-schema>
|
||||||
|
<public-schema>
|
||||||
|
<filter-element type="OBJECT" id="table" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="index" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="function" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="package" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="type" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||||
|
</public-schema>
|
||||||
|
<any-schema>
|
||||||
|
<filter-element type="OBJECT" id="table" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="materialized view" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="index" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="constraint" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="trigger" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="synonym" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="sequence" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="procedure" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="function" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="package" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="type" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dimension" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="cluster" selected="true" />
|
||||||
|
<filter-element type="OBJECT" id="dblink" selected="true" />
|
||||||
|
</any-schema>
|
||||||
|
</extended-filter>
|
||||||
|
</filters>
|
||||||
|
<sorting enabled="true">
|
||||||
|
<sorting-element type="RESERVED_WORD" id="keyword" />
|
||||||
|
<sorting-element type="RESERVED_WORD" id="datatype" />
|
||||||
|
<sorting-element type="OBJECT" id="column" />
|
||||||
|
<sorting-element type="OBJECT" id="table" />
|
||||||
|
<sorting-element type="OBJECT" id="view" />
|
||||||
|
<sorting-element type="OBJECT" id="materialized view" />
|
||||||
|
<sorting-element type="OBJECT" id="index" />
|
||||||
|
<sorting-element type="OBJECT" id="constraint" />
|
||||||
|
<sorting-element type="OBJECT" id="trigger" />
|
||||||
|
<sorting-element type="OBJECT" id="synonym" />
|
||||||
|
<sorting-element type="OBJECT" id="sequence" />
|
||||||
|
<sorting-element type="OBJECT" id="procedure" />
|
||||||
|
<sorting-element type="OBJECT" id="function" />
|
||||||
|
<sorting-element type="OBJECT" id="package" />
|
||||||
|
<sorting-element type="OBJECT" id="type" />
|
||||||
|
<sorting-element type="OBJECT" id="dimension" />
|
||||||
|
<sorting-element type="OBJECT" id="cluster" />
|
||||||
|
<sorting-element type="OBJECT" id="dblink" />
|
||||||
|
<sorting-element type="OBJECT" id="schema" />
|
||||||
|
<sorting-element type="OBJECT" id="role" />
|
||||||
|
<sorting-element type="OBJECT" id="user" />
|
||||||
|
<sorting-element type="RESERVED_WORD" id="function" />
|
||||||
|
<sorting-element type="RESERVED_WORD" id="parameter" />
|
||||||
|
</sorting>
|
||||||
|
<format>
|
||||||
|
<enforce-code-style-case value="true" />
|
||||||
|
</format>
|
||||||
|
</code-completion-settings>
|
||||||
|
<execution-engine-settings>
|
||||||
|
<statement-execution>
|
||||||
|
<fetch-block-size value="100" />
|
||||||
|
<execution-timeout value="20" />
|
||||||
|
<debug-execution-timeout value="600" />
|
||||||
|
<focus-result value="false" />
|
||||||
|
<prompt-execution value="false" />
|
||||||
|
</statement-execution>
|
||||||
|
<script-execution>
|
||||||
|
<command-line-interfaces />
|
||||||
|
<execution-timeout value="300" />
|
||||||
|
</script-execution>
|
||||||
|
<method-execution>
|
||||||
|
<execution-timeout value="30" />
|
||||||
|
<debug-execution-timeout value="600" />
|
||||||
|
<parameter-history-size value="10" />
|
||||||
|
</method-execution>
|
||||||
|
</execution-engine-settings>
|
||||||
|
<operation-settings>
|
||||||
|
<transactions>
|
||||||
|
<uncommitted-changes>
|
||||||
|
<on-project-close value="ASK" />
|
||||||
|
<on-disconnect value="ASK" />
|
||||||
|
<on-autocommit-toggle value="ASK" />
|
||||||
|
</uncommitted-changes>
|
||||||
|
<multiple-uncommitted-changes>
|
||||||
|
<on-commit value="ASK" />
|
||||||
|
<on-rollback value="ASK" />
|
||||||
|
</multiple-uncommitted-changes>
|
||||||
|
</transactions>
|
||||||
|
<session-browser>
|
||||||
|
<disconnect-session value="ASK" />
|
||||||
|
<kill-session value="ASK" />
|
||||||
|
<reload-on-filter-change value="false" />
|
||||||
|
</session-browser>
|
||||||
|
<compiler>
|
||||||
|
<compile-type value="KEEP" />
|
||||||
|
<compile-dependencies value="ASK" />
|
||||||
|
<always-show-controls value="false" />
|
||||||
|
</compiler>
|
||||||
|
</operation-settings>
|
||||||
|
<ddl-file-settings>
|
||||||
|
<extensions>
|
||||||
|
<mapping file-type-id="VIEW" extensions="vw" />
|
||||||
|
<mapping file-type-id="TRIGGER" extensions="trg" />
|
||||||
|
<mapping file-type-id="PROCEDURE" extensions="prc" />
|
||||||
|
<mapping file-type-id="FUNCTION" extensions="fnc" />
|
||||||
|
<mapping file-type-id="PACKAGE" extensions="pkg" />
|
||||||
|
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
|
||||||
|
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
|
||||||
|
<mapping file-type-id="TYPE" extensions="tpe" />
|
||||||
|
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
|
||||||
|
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
|
||||||
|
</extensions>
|
||||||
|
<general>
|
||||||
|
<lookup-ddl-files value="true" />
|
||||||
|
<create-ddl-files value="false" />
|
||||||
|
<synchronize-ddl-files value="true" />
|
||||||
|
<use-qualified-names value="false" />
|
||||||
|
<make-scripts-rerunnable value="true" />
|
||||||
|
</general>
|
||||||
|
</ddl-file-settings>
|
||||||
|
<general-settings>
|
||||||
|
<regional-settings>
|
||||||
|
<date-format value="MEDIUM" />
|
||||||
|
<number-format value="UNGROUPED" />
|
||||||
|
<locale value="SYSTEM_DEFAULT" />
|
||||||
|
<use-custom-formats value="false" />
|
||||||
|
</regional-settings>
|
||||||
|
<environment>
|
||||||
|
<environment-types>
|
||||||
|
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
|
||||||
|
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
|
||||||
|
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
|
||||||
|
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
|
||||||
|
</environment-types>
|
||||||
|
<visibility-settings>
|
||||||
|
<connection-tabs value="true" />
|
||||||
|
<dialog-headers value="true" />
|
||||||
|
<object-editor-tabs value="true" />
|
||||||
|
<script-editor-tabs value="false" />
|
||||||
|
<execution-result-tabs value="true" />
|
||||||
|
</visibility-settings>
|
||||||
|
</environment>
|
||||||
|
</general-settings>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetDropDown">
|
||||||
|
<value>
|
||||||
|
<entry key="app">
|
||||||
|
<State>
|
||||||
|
<targetSelectedWithDropDown>
|
||||||
|
<Target>
|
||||||
|
<type value="QUICK_BOOT_TARGET" />
|
||||||
|
<deviceKey>
|
||||||
|
<Key>
|
||||||
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
|
<value value="C:\Users\songl\.android\avd\Pixel_3a_API_34_extension_level_7_x86_64.avd" />
|
||||||
|
</Key>
|
||||||
|
</deviceKey>
|
||||||
|
</Target>
|
||||||
|
</targetSelectedWithDropDown>
|
||||||
|
<timeTargetWasSelectedWithDropDown value="2024-05-23T04:33:51.360675700Z" />
|
||||||
|
</State>
|
||||||
|
</entry>
|
||||||
|
</value>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<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,17 @@
|
|||||||
|
<?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>
|
||||||
|
<component name="VisualizationToolProject">
|
||||||
|
<option name="state">
|
||||||
|
<ProjectState>
|
||||||
|
<option name="scale" value="0.7260503968935927" />
|
||||||
|
</ProjectState>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1 @@
|
|||||||
|
/build
|
@ -0,0 +1,47 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.androidApplication)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "com.example.deliciousfoodapp"
|
||||||
|
compileSdk = 34
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "com.example.deliciousfoodapp"
|
||||||
|
minSdk = 24
|
||||||
|
targetSdk = 34
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = 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(libs.appcompat)
|
||||||
|
implementation(libs.material)
|
||||||
|
implementation(libs.activity)
|
||||||
|
implementation(libs.constraintlayout)
|
||||||
|
implementation(libs.legacy.support.v4)
|
||||||
|
implementation(libs.recyclerview)
|
||||||
|
implementation(libs.navigation.fragment)
|
||||||
|
implementation(libs.navigation.ui)
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
androidTestImplementation(libs.ext.junit)
|
||||||
|
androidTestImplementation(libs.espresso.core)
|
||||||
|
}
|
@ -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.deliciousfoodapp;
|
||||||
|
|
||||||
|
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.deliciousfoodapp", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
<?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.DeliciousFoodApp"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".ProductDetailsActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".AlarmClockActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".UserinformationActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/Theme.DeliciousFoodApp" />
|
||||||
|
<activity
|
||||||
|
android:name=".IndexActivity"
|
||||||
|
android:exported="true" />
|
||||||
|
<activity
|
||||||
|
android:name=".RegisterinformationActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".RegisterActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".LoginActivity"
|
||||||
|
android:exported="true" />
|
||||||
|
<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>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,168 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
public class AlarmClockActivity extends AppCompatActivity implements View.OnClickListener, ServiceConnection {
|
||||||
|
|
||||||
|
private TextView timeTextView, dateTextView, dayOfWeekTextView;
|
||||||
|
private Handler handler2;
|
||||||
|
EditText etInput;
|
||||||
|
TextView tvOut;
|
||||||
|
Button btnStartService,btnStopService,btnBindService,btnUnbindService,btnSync;
|
||||||
|
Intent serviceIntent;
|
||||||
|
MyService.MyBinder binder=null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_alarm_clock);
|
||||||
|
|
||||||
|
timeTextView = findViewById(R.id.timeTextView);
|
||||||
|
dateTextView = findViewById(R.id.dateTextView);
|
||||||
|
dayOfWeekTextView = findViewById(R.id.dayOfWeekTextView);
|
||||||
|
|
||||||
|
handler2 = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
updateTimeAndDate();
|
||||||
|
|
||||||
|
serviceIntent=new Intent(AlarmClockActivity.this,MyService.class);
|
||||||
|
initCompent(); //初始化组件
|
||||||
|
btnClickListener(); //给5个按钮添加事件监听
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
startUpdateTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
stopUpdateTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startUpdateTask() {
|
||||||
|
updateTask.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopUpdateTask() {
|
||||||
|
handler2.removeCallbacks(updateTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable updateTask = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateTimeAndDate();
|
||||||
|
handler2.postDelayed(this, 1000); // 每秒更新一次
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private void updateTimeAndDate() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
|
||||||
|
SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEE", Locale.getDefault());
|
||||||
|
|
||||||
|
String time = timeFormat.format(calendar.getTime());
|
||||||
|
String date = dateFormat.format(calendar.getTime());
|
||||||
|
String dayOfWeek = dayOfWeekFormat.format(calendar.getTime());
|
||||||
|
|
||||||
|
timeTextView.setText("Time: " + time);
|
||||||
|
dateTextView.setText("Date: " + date);
|
||||||
|
dayOfWeekTextView.setText("Day of Week: " + dayOfWeek);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void back2(View view) {
|
||||||
|
Intent intent = new Intent(AlarmClockActivity.this, IndexActivity.class);
|
||||||
|
intent.putExtra("id",1);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCompent() {
|
||||||
|
etInput=findViewById(R.id.etInput);
|
||||||
|
tvOut=findViewById(R.id.tvOut);
|
||||||
|
btnStartService=findViewById(R.id.btnStartService);
|
||||||
|
btnStopService=findViewById(R.id.btnStopService);
|
||||||
|
btnBindService=findViewById(R.id.btnBindService);
|
||||||
|
btnUnbindService=findViewById(R.id.btnUnBindService);
|
||||||
|
btnSync=findViewById(R.id.btnSync);
|
||||||
|
}
|
||||||
|
private void btnClickListener() {
|
||||||
|
btnStartService.setOnClickListener(this);
|
||||||
|
btnStopService.setOnClickListener(this);
|
||||||
|
btnBindService.setOnClickListener(this);
|
||||||
|
btnUnbindService.setOnClickListener(this);
|
||||||
|
btnSync.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (view.getId() == R.id.btnStartService) {
|
||||||
|
serviceIntent.putExtra("data", etInput.getText().toString());
|
||||||
|
startService(serviceIntent); // 启动服务传递参数
|
||||||
|
} else if (view.getId() == R.id.btnStopService) {
|
||||||
|
stopService(serviceIntent);
|
||||||
|
} else if (view.getId() == R.id.btnBindService) {
|
||||||
|
bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
|
||||||
|
} else if (view.getId() == R.id.btnUnBindService) {
|
||||||
|
unbindService(this);
|
||||||
|
} else if (view.getId() == R.id.btnSync) {
|
||||||
|
if (binder != null) { // 绑定服务后,同步服务数据
|
||||||
|
binder.setData(etInput.getText().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected(ComponentName name, IBinder iBinder) {
|
||||||
|
binder= (MyService.MyBinder) iBinder;
|
||||||
|
binder.getService().setCallback(new MyService.CallBack() {
|
||||||
|
@Override
|
||||||
|
public void dataChanged(String data) {
|
||||||
|
Message msg = new Message();
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString("data", data);
|
||||||
|
msg.setData(b);
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Handler handler=new Handler(){
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
Log.v("Timer","handleMessage()..");
|
||||||
|
super.handleMessage(msg);
|
||||||
|
String str=(String)msg.obj;
|
||||||
|
tvOut.setText(msg.getData().getString("data"));
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HomeMyAdapter extends BaseAdapter {
|
||||||
|
private List<Map<String, Object>> datas;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public HomeMyAdapter(List<Map<String, Object>> datas, Context mContext) {
|
||||||
|
this.datas = datas;
|
||||||
|
this.mContext = mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
// 返回数据的总数
|
||||||
|
return datas.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
// 返回在list中指定位置的数据的内容
|
||||||
|
return datas.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
// 返回数据在list中所在的位置
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
final ViewHolder holder;
|
||||||
|
if (convertView == null) {
|
||||||
|
// 使用自定义的布局文件作为Layout
|
||||||
|
convertView = LayoutInflater.from(mContext).inflate(
|
||||||
|
R.layout.homelist_item_layout, null);
|
||||||
|
// 减少findView的次数
|
||||||
|
holder = new ViewHolder();
|
||||||
|
// 初始化布局中的元素
|
||||||
|
holder.mImageView = (ImageView)
|
||||||
|
convertView.findViewById(R.id.imageview);
|
||||||
|
convertView.setTag(holder);
|
||||||
|
} else {
|
||||||
|
holder = (ViewHolder) convertView.getTag();
|
||||||
|
}
|
||||||
|
// 从传入的数据中提取数据并绑定到指定的view中
|
||||||
|
holder.mImageView.setImageResource((Integer) datas.get(position).get("img"));
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
static class ViewHolder {
|
||||||
|
ImageView mImageView;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class HomeNewAdapter extends BaseAdapter {
|
||||||
|
List<Map<String,Object>> datas;
|
||||||
|
Context mContext;
|
||||||
|
HomeNewAdapter(List<Map<String,Object>> datas, Context mContext){
|
||||||
|
this.datas=datas;
|
||||||
|
this.mContext=mContext;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return datas.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return datas.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
ViewHolder holder;
|
||||||
|
if(convertView==null){
|
||||||
|
convertView= LayoutInflater.from(mContext).inflate(R.layout.homelist_item_layout,null);
|
||||||
|
holder=new ViewHolder();
|
||||||
|
holder.mImageView=convertView.findViewById(R.id.imageview);
|
||||||
|
convertView.setTag(holder);
|
||||||
|
}else{
|
||||||
|
holder= (ViewHolder) convertView.getTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.mImageView.setImageResource((Integer) datas.get(position).get("img"));
|
||||||
|
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ViewHolder {
|
||||||
|
ImageView mImageView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.db.UserDbHelper;
|
||||||
|
import com.example.deliciousfoodapp.entity.UserInfo;
|
||||||
|
|
||||||
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
EdgeToEdge.enable(this);
|
||||||
|
setContentView(R.layout.activity_login);
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||||
|
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
Button button1 = findViewById(R.id.buttonlogin);
|
||||||
|
Button button2 = findViewById(R.id.buttonregister);
|
||||||
|
EditText name = findViewById(R.id.editText);
|
||||||
|
EditText password = findViewById(R.id.editText2);
|
||||||
|
|
||||||
|
CheckBox rememberpassword = findViewById(R.id.rememberpassword);
|
||||||
|
|
||||||
|
//获取mSharedPreferences实例
|
||||||
|
SharedPreferences mSharedPreferences = getSharedPreferences("user", MODE_PRIVATE);
|
||||||
|
|
||||||
|
//是否勾选了记住密码
|
||||||
|
final boolean[] is_remember = {mSharedPreferences.getBoolean("is_remember", false)};
|
||||||
|
if (is_remember[0]) {
|
||||||
|
String username = mSharedPreferences.getString("username", null);
|
||||||
|
String userpassword = mSharedPreferences.getString("userpassword", null);
|
||||||
|
name.setText(username);
|
||||||
|
password.setText(userpassword);
|
||||||
|
rememberpassword.setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
button1.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String s = name.getText().toString();
|
||||||
|
String s1 = password.getText().toString();
|
||||||
|
CheckBox checkBox = findViewById(R.id.checkBox); // 找到布局文件中的 CheckBox
|
||||||
|
// 检查复选框是否被勾选
|
||||||
|
boolean isAgreed = checkBox.isChecked();
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(s) && TextUtils.isEmpty(s1)) {
|
||||||
|
Toast.makeText(LoginActivity.this, "请输入用户名和密码", Toast.LENGTH_SHORT).show();
|
||||||
|
} else if (!isAgreed) {
|
||||||
|
// 如果复选框未被勾选,弹出提示
|
||||||
|
Toast.makeText(LoginActivity.this, "请同意《用户服务协议》及《基本功能隐私协议》", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
UserInfo login = UserDbHelper.getInstance(LoginActivity.this).login(s);
|
||||||
|
if (login != null) {
|
||||||
|
if (s.equals(login.getUsername()) && s1.equals(login.getPassword())) {
|
||||||
|
SharedPreferences.Editor edit = mSharedPreferences.edit();
|
||||||
|
edit.putBoolean("is_remember", is_remember[0]);
|
||||||
|
edit.putString("username", s);
|
||||||
|
edit.putString("userpassword", s1);
|
||||||
|
edit.apply();
|
||||||
|
|
||||||
|
Intent intent = new Intent(LoginActivity.this, IndexActivity.class);
|
||||||
|
intent.putExtra("username",s);
|
||||||
|
startActivity(intent);
|
||||||
|
Toast.makeText(LoginActivity.this, "恭喜登录成功", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(LoginActivity.this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(LoginActivity.this, "未注册", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
button2.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//记住密码复选框
|
||||||
|
rememberpassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
is_remember[0] = isChecked;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
EdgeToEdge.enable(this);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||||
|
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
|
||||||
|
Button button = (Button) findViewById(R.id.button);
|
||||||
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent=new Intent(MainActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.db.CarDbHelper;
|
||||||
|
import com.example.deliciousfoodapp.entity.FoodInfo;
|
||||||
|
|
||||||
|
public class ProductDetailsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private ImageView product_img;
|
||||||
|
private TextView product_title;
|
||||||
|
private TextView product_price;
|
||||||
|
private TextView product_details;
|
||||||
|
private TextView product_next;
|
||||||
|
private FoodInfo foodInfo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
EdgeToEdge.enable(this);
|
||||||
|
setContentView(R.layout.activity_product_details);
|
||||||
|
|
||||||
|
//获取传递的数据
|
||||||
|
foodInfo=(FoodInfo) getIntent().getSerializableExtra("foodInfo");
|
||||||
|
|
||||||
|
//返回
|
||||||
|
findViewById(R.id.toolbar).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//初始化控件
|
||||||
|
product_img = findViewById(R.id.product_img);
|
||||||
|
product_title = findViewById(R.id.product_title);
|
||||||
|
product_price = findViewById(R.id.product_price);
|
||||||
|
product_details = findViewById(R.id.product_details);
|
||||||
|
product_next = findViewById(R.id.product_next);
|
||||||
|
|
||||||
|
//设置数据
|
||||||
|
if(null!=foodInfo){
|
||||||
|
product_img.setImageResource(foodInfo.getFood_img());
|
||||||
|
product_title.setText(foodInfo.getFood_title());
|
||||||
|
product_details.setText(foodInfo.getFood_details());
|
||||||
|
product_next.setText(foodInfo.getFood_next());
|
||||||
|
product_price.setText(foodInfo.getFood_price()+"");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//加入购物车
|
||||||
|
findViewById(R.id.addCar).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
//加入到购物车
|
||||||
|
int row = CarDbHelper.getInstance(ProductDetailsActivity.this).addCar("zsan",foodInfo.getFood_id(),foodInfo.getFood_img(),foodInfo.getFood_title(),foodInfo.getFood_price());
|
||||||
|
if(row>0){
|
||||||
|
Toast.makeText(ProductDetailsActivity.this,"添加成功",Toast.LENGTH_SHORT).show();
|
||||||
|
}else {
|
||||||
|
Toast.makeText(ProductDetailsActivity.this,"添加失败",Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.db.UserDbHelper;
|
||||||
|
|
||||||
|
public class RegisterActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
|
||||||
|
//定义字符串用来保存各个信息
|
||||||
|
private String username_str = "";
|
||||||
|
private String password_str = "";
|
||||||
|
private String surepassword_str = "";
|
||||||
|
private String phone_str = "";
|
||||||
|
private String email_str = "";
|
||||||
|
private String address_str = "";
|
||||||
|
//默认为男性选中
|
||||||
|
private String genderRadioGroup_str = "男";
|
||||||
|
private String taste_str = "1";
|
||||||
|
|
||||||
|
//组件定义
|
||||||
|
EditText username_edit, password_edit, surepassword_edit, phone_edit, email_edit, address_edit;
|
||||||
|
RadioGroup genderRadioGroup_group;
|
||||||
|
RadioButton nan_but, nv_but;
|
||||||
|
CheckBox sour, sweet, spicy;
|
||||||
|
Button register;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_register);
|
||||||
|
//组件初始化
|
||||||
|
username_edit = (EditText) findViewById(R.id.usernamebox);
|
||||||
|
password_edit = (EditText) findViewById(R.id.passwordbox);
|
||||||
|
surepassword_edit = (EditText) findViewById(R.id.surepasswordbox);
|
||||||
|
phone_edit = (EditText) findViewById(R.id.phonebox);
|
||||||
|
email_edit = (EditText) findViewById(R.id.emailbox);
|
||||||
|
address_edit = (EditText) findViewById(R.id.addressbox);
|
||||||
|
genderRadioGroup_group = (RadioGroup) findViewById(R.id.genderRadioGroup);
|
||||||
|
//添加监听事件
|
||||||
|
genderRadioGroup_group.setOnCheckedChangeListener(this);
|
||||||
|
nan_but = (RadioButton) findViewById(R.id.maleRadioButton);
|
||||||
|
sour = (CheckBox) findViewById(R.id.checkbox_sour);
|
||||||
|
sweet = (CheckBox) findViewById(R.id.checkbox_sweet);
|
||||||
|
spicy = (CheckBox) findViewById(R.id.checkbox_spicy);
|
||||||
|
register = (Button) findViewById(R.id.referbutton);
|
||||||
|
register.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (view.getId() == R.id.referbutton) {
|
||||||
|
// 获取用户名、手机号、密码等信息
|
||||||
|
username_str = username_edit.getText().toString();
|
||||||
|
password_str = password_edit.getText().toString();
|
||||||
|
surepassword_str = surepassword_edit.getText().toString();
|
||||||
|
phone_str = phone_edit.getText().toString();
|
||||||
|
email_str = email_edit.getText().toString();
|
||||||
|
address_str = address_edit.getText().toString();
|
||||||
|
|
||||||
|
// 获取喜欢的口味即复选框的值
|
||||||
|
taste_str = ""; // 清除上一次已经选中的选项
|
||||||
|
if (sour.isChecked()) {
|
||||||
|
taste_str += sour.getText().toString();
|
||||||
|
}
|
||||||
|
if (sweet.isChecked()) {
|
||||||
|
taste_str += sweet.getText().toString();
|
||||||
|
}
|
||||||
|
if (spicy.isChecked()) {
|
||||||
|
taste_str += spicy.getText().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(username_str) && TextUtils.isEmpty(password_str)) {
|
||||||
|
Toast.makeText(RegisterActivity.this, "请输入用户名和密码", Toast.LENGTH_SHORT).show();
|
||||||
|
} else if (!password_str.equals(surepassword_str)) {
|
||||||
|
Toast.makeText(RegisterActivity.this, "两次输入的密码不一致", Toast.LENGTH_SHORT).show();
|
||||||
|
}else if (password_str.length() < 6 ) {
|
||||||
|
Toast.makeText(RegisterActivity.this, "密码必须包含至少6位的数字、字母或符号", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else if (phone_str.length() < 11 ||phone_str.length() > 11) {
|
||||||
|
Toast.makeText(RegisterActivity.this, "请正确填写11位手机号", Toast.LENGTH_SHORT).show();
|
||||||
|
}else {
|
||||||
|
int row = UserDbHelper.getInstance(RegisterActivity.this).register(username_str, password_str, surepassword_str, phone_str, email_str, address_str, genderRadioGroup_str, taste_str);
|
||||||
|
if (row > 0) {
|
||||||
|
Intent intent = new Intent(this, RegisterinformationActivity.class);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("usernamebox", username_str);
|
||||||
|
bundle.putString("passwordbox", password_str);
|
||||||
|
bundle.putString("surepasswordbox", surepassword_str);
|
||||||
|
bundle.putString("phonebox", phone_str);
|
||||||
|
bundle.putString("emailbox", email_str);
|
||||||
|
bundle.putString("addressbox", address_str);
|
||||||
|
bundle.putString("genderRadioGroup", genderRadioGroup_str);
|
||||||
|
bundle.putString("tastebox", taste_str);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
startActivity(intent);
|
||||||
|
Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(RegisterActivity.this, "注册失败", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
|
//根据用户选择来改变sex_str的值
|
||||||
|
genderRadioGroup_str = checkedId == R.id.maleRadioButton ? "男性" : "女性";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
|
public class RegisterinformationActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
EdgeToEdge.enable(this);
|
||||||
|
setContentView(R.layout.activity_registerinformation);
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||||
|
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
|
Intent intent=this.getIntent();
|
||||||
|
Bundle bundle=intent.getExtras();
|
||||||
|
String username=bundle.getString("usernamebox");
|
||||||
|
String password=bundle.getString("passwordbox");
|
||||||
|
String surepassword=bundle.getString("surepasswordbox");
|
||||||
|
String phone=bundle.getString("phonebox");
|
||||||
|
String email=bundle.getString("emailbox");
|
||||||
|
String address=bundle.getString("addressbox");
|
||||||
|
String gender=bundle.getString("genderRadioGroup");
|
||||||
|
String taste=bundle.getString("tastebox");
|
||||||
|
TextView show_text=(TextView)findViewById(R.id.show_content);
|
||||||
|
show_text.setText("用户名为:"+username+"\n"+"登录密码为:"+password+"\n"+"确认密码为:"
|
||||||
|
+surepassword+"\n"+"手机号码为:"+phone+"\n"+"电子邮箱为:"+email+"\n"+"所在地为:"
|
||||||
|
+address+"\n"+"性别是:"+gender+"\n"+"喜欢的口味是:"+taste+"\n");
|
||||||
|
return insets;
|
||||||
|
});
|
||||||
|
Button gobackbutton = (Button) findViewById(R.id.gobackbutton);
|
||||||
|
gobackbutton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
new AlertDialog.Builder(RegisterinformationActivity.this).setTitle("系统提示")
|
||||||
|
.setMessage("请确认所有信息都正确后再点击“确定")
|
||||||
|
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Intent intent=new Intent(RegisterinformationActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}).setNegativeButton("返回", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package com.example.deliciousfoodapp.adapter;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.R;
|
||||||
|
import com.example.deliciousfoodapp.entity.CarInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CarListAdapter extends RecyclerView.Adapter<CarListAdapter.MyHolder> {
|
||||||
|
private List<CarInfo> mCarInfoList=new ArrayList<>();
|
||||||
|
public void setCarInfoList(List<CarInfo> list){
|
||||||
|
this.mCarInfoList=list;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
|
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.car_list_item,null);
|
||||||
|
|
||||||
|
return new MyHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull MyHolder holder, int position) {
|
||||||
|
|
||||||
|
//绑定数据
|
||||||
|
CarInfo carInfo=mCarInfoList.get(position);
|
||||||
|
holder.product_img.setImageResource(carInfo.getProduct_img());
|
||||||
|
holder.product_title.setText(carInfo.getProduct_title());
|
||||||
|
holder.product_price.setText(carInfo.getProduct_price()+"");
|
||||||
|
holder.product_count.setText(carInfo.getProduct_count()+"");
|
||||||
|
|
||||||
|
//设置点击事件
|
||||||
|
holder.btn_subtract.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
if(null!=mOnItemClickListner){
|
||||||
|
mOnItemClickListner.onSubTractOnClick(carInfo,position);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
holder.btn_plus.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(null!=mOnItemClickListner){
|
||||||
|
mOnItemClickListner.onPlusOnClick(carInfo,position);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (mOnItemClickListner!=null){
|
||||||
|
mOnItemClickListner.delOnClick(carInfo,position);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mCarInfoList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class MyHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
|
ImageView product_img;
|
||||||
|
TextView product_title;
|
||||||
|
TextView product_price;
|
||||||
|
TextView product_count;
|
||||||
|
TextView btn_subtract;
|
||||||
|
TextView btn_plus;
|
||||||
|
|
||||||
|
public MyHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
product_img=itemView.findViewById(R.id.product_img);
|
||||||
|
product_title=itemView.findViewById(R.id.product_title);
|
||||||
|
product_price=itemView.findViewById(R.id.product_price);
|
||||||
|
product_count=itemView.findViewById(R.id.product_count);
|
||||||
|
btn_subtract=itemView.findViewById(R.id.btn_subtract);
|
||||||
|
btn_plus=itemView.findViewById(R.id.btn_plus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private onItemClickListener mOnItemClickListner;
|
||||||
|
public void setOnItemClickListner(onItemClickListener mOnItemClickListner) {
|
||||||
|
this.mOnItemClickListner = mOnItemClickListner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface onItemClickListener{
|
||||||
|
void onPlusOnClick(CarInfo carInfo,int position);
|
||||||
|
void onSubTractOnClick(CarInfo carInfo,int position);
|
||||||
|
void delOnClick(CarInfo carInfo,int position);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
package com.example.deliciousfoodapp.db;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.entity.CarInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CarDbHelper extends SQLiteOpenHelper {
|
||||||
|
private static CarDbHelper sHelper;
|
||||||
|
private static final String DB_NAME = "car.db"; //数据库名
|
||||||
|
private static final int VERSION = 1; //版本号
|
||||||
|
//必须实现其中一个构方法
|
||||||
|
public CarDbHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
|
||||||
|
super(context, name, factory, version);
|
||||||
|
}
|
||||||
|
//创建单例,供使用调用该类里面的的增删改查的方法
|
||||||
|
public synchronized static CarDbHelper getInstance(Context context) {
|
||||||
|
if (null == sHelper) {
|
||||||
|
sHelper = new CarDbHelper(context, DB_NAME, null, VERSION);
|
||||||
|
}
|
||||||
|
return sHelper;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
//创建car_table表
|
||||||
|
db.execSQL("create table car_table(_id integer primary key autoincrement, " +
|
||||||
|
"username text," + //用户名
|
||||||
|
"product_id text," +
|
||||||
|
"product_img integer," +
|
||||||
|
"product_title text," +
|
||||||
|
"product_price integer," +
|
||||||
|
"product_count integer" +
|
||||||
|
")");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
//添加到购物车
|
||||||
|
public int addCar(String username, int product_id, int product_img,String product_title,int product_price) {
|
||||||
|
|
||||||
|
//判断是否添加过商品,如果添加过,只需要修改商品的数量即可
|
||||||
|
CarInfo addCar=isaddCar(username,product_id);
|
||||||
|
if (addCar==null){
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
//填充占位符
|
||||||
|
values.put("username", username);
|
||||||
|
values.put("product_id", product_id);
|
||||||
|
values.put("product_img", product_img);
|
||||||
|
values.put("product_title", product_title);
|
||||||
|
values.put("product_price", product_price);
|
||||||
|
values.put("product_count", 1);
|
||||||
|
String nullColumnHack = "values(null,?,?,?,?,?,?)";
|
||||||
|
//执行
|
||||||
|
int insert = (int) db.insert("car_table", nullColumnHack, values);
|
||||||
|
db.close();
|
||||||
|
return insert;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return updateProduct(addCar.getCar_id(),addCar);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改购物车
|
||||||
|
|
||||||
|
public int updateProduct(int car_id,CarInfo carInfo) {
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
// 填充占位符
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("product_count", carInfo.getProduct_count()+1);
|
||||||
|
// 执行SQL
|
||||||
|
int update = db.update("car_table", values, " _id=?", new String[]{car_id+""});
|
||||||
|
// 关闭数据库连接
|
||||||
|
db.close();
|
||||||
|
return update;
|
||||||
|
|
||||||
|
}
|
||||||
|
//减少购物车内商品的数量
|
||||||
|
public int subStartupdateProduct(int car_id,CarInfo carInfo) {
|
||||||
|
if (carInfo.getProduct_count()>=2){
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
// 填充占位符
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("product_count", carInfo.getProduct_count()-1);
|
||||||
|
// 执行SQL
|
||||||
|
int update = db.update("car_table", values, " _id=?", new String[]{car_id+""});
|
||||||
|
// 关闭数据库连接
|
||||||
|
db.close();
|
||||||
|
return update;
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
//根据用户名和商品ID判断有没有添加过商品到购物车
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public CarInfo isaddCar(String username,int product_id) {
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
CarInfo carInfo = null;
|
||||||
|
String sql = "select _id,username,product_id,product_img,product_title, product_price,product_count from car_table where username=? and product_id=?";
|
||||||
|
String[] selectionArgs = {username,product_id+""};
|
||||||
|
Cursor cursor = db.rawQuery(sql, selectionArgs);
|
||||||
|
if (cursor.moveToNext()) {
|
||||||
|
int car_id = cursor.getInt(cursor.getColumnIndex("_id"));
|
||||||
|
String name = cursor.getString(cursor.getColumnIndex("username"));
|
||||||
|
int productId = cursor.getInt(cursor.getColumnIndex("product_id"));
|
||||||
|
int product_img = cursor.getInt(cursor.getColumnIndex("product_img"));
|
||||||
|
String product_title = cursor.getString(cursor.getColumnIndex("product_title"));
|
||||||
|
int product_price = cursor.getInt(cursor.getColumnIndex("product_price"));
|
||||||
|
int product_count = cursor.getInt(cursor.getColumnIndex("product_count"));
|
||||||
|
carInfo = new CarInfo(car_id, name, productId,product_img, product_title,product_price,product_count);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
db.close();
|
||||||
|
return carInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据用户名查找
|
||||||
|
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<CarInfo> queryCarList(String username) {
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
List<CarInfo> list = new ArrayList<>();
|
||||||
|
String sql = "select _id,username,product_id,product_img,product_title, product_price,product_count from car_table where username=? ";
|
||||||
|
String[] selectionArgs = {username};
|
||||||
|
Cursor cursor = db.rawQuery(sql, selectionArgs);
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
int car_id = cursor.getInt(cursor.getColumnIndex("_id"));
|
||||||
|
String name = cursor.getString(cursor.getColumnIndex("username"));
|
||||||
|
int productId = cursor.getInt(cursor.getColumnIndex("product_id"));
|
||||||
|
int product_img = cursor.getInt(cursor.getColumnIndex("product_img"));
|
||||||
|
String product_title = cursor.getString(cursor.getColumnIndex("product_title"));
|
||||||
|
int product_price = cursor.getInt(cursor.getColumnIndex("product_price"));
|
||||||
|
int product_count = cursor.getInt(cursor.getColumnIndex("product_count"));
|
||||||
|
list.add(new CarInfo(car_id, name, productId,product_img, product_title,product_price,product_count));
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
db.close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除购物车商品
|
||||||
|
public int delete(String car_id) {
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
// 执行SQL
|
||||||
|
int delete = db.delete("car_table", " _id=?", new String[]{car_id});
|
||||||
|
// 关闭数据库连接
|
||||||
|
db.close();
|
||||||
|
return delete;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,145 @@
|
|||||||
|
package com.example.deliciousfoodapp.db;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.entity.UserInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UserDbHelper extends SQLiteOpenHelper {
|
||||||
|
private static UserDbHelper sHelper;
|
||||||
|
private static final String DB_NAME = "user2.db"; //数据库名
|
||||||
|
private static final int VERSION = 1; //版本号
|
||||||
|
|
||||||
|
private static final String TABLE_NAME = "user_table";
|
||||||
|
|
||||||
|
//必须实现其中一个构方法
|
||||||
|
public UserDbHelper(@Nullable Context context) {
|
||||||
|
super(context, DB_NAME, null, VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建单例,供使用调用该类里面的的增删改查的方法
|
||||||
|
public synchronized static UserDbHelper getInstance(Context context) {
|
||||||
|
if (null == sHelper) {
|
||||||
|
sHelper = new UserDbHelper(context);
|
||||||
|
}
|
||||||
|
return sHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
//创建user_table表
|
||||||
|
db.execSQL("create table " + TABLE_NAME + "(user_id integer primary key autoincrement, " +
|
||||||
|
"username text," + //用户名
|
||||||
|
"password text," + //密码
|
||||||
|
"surepassword text," +
|
||||||
|
"phone text," +
|
||||||
|
"email text," +
|
||||||
|
"address text," +
|
||||||
|
"gender text," +
|
||||||
|
"taste text" +
|
||||||
|
")");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//登录
|
||||||
|
/**
|
||||||
|
* 登录 根据用户名查找用户
|
||||||
|
*/
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public UserInfo login(String username) {
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
UserInfo userInfo = null;
|
||||||
|
String sql = "select user_id,username,password,surepassword,phone,email,address,gender,taste from " + TABLE_NAME + " where username=?";
|
||||||
|
String[] selectionArgs = {username};
|
||||||
|
Cursor cursor = db.rawQuery(sql, selectionArgs);
|
||||||
|
if (cursor.moveToNext()) {
|
||||||
|
int user_id = cursor.getInt(cursor.getColumnIndex("user_id"));
|
||||||
|
String name = cursor.getString(cursor.getColumnIndex("username"));
|
||||||
|
String password = cursor.getString(cursor.getColumnIndex("password"));
|
||||||
|
String surepassword= cursor.getString(cursor.getColumnIndex("surepassword"));
|
||||||
|
String phone = cursor.getString(cursor.getColumnIndex("phone"));
|
||||||
|
String email= cursor.getString(cursor.getColumnIndex("email"));
|
||||||
|
String address = cursor.getString(cursor.getColumnIndex("address"));
|
||||||
|
String gender= cursor.getString(cursor.getColumnIndex("gender"));
|
||||||
|
String taste = cursor.getString(cursor.getColumnIndex("taste"));
|
||||||
|
userInfo = new UserInfo(user_id, name, password,surepassword,phone,email,address,gender,taste);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
//db.close();
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
//注册
|
||||||
|
public int register(String username, String password,String surepassword,String phone,String email,String address,String gender,String taste) {
|
||||||
|
//获取SQLiteDatabase实例
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
//填充占位符
|
||||||
|
values.put("username", username);
|
||||||
|
values.put("password", password);
|
||||||
|
values.put("surepassword", surepassword);
|
||||||
|
values.put("phone", phone);
|
||||||
|
values.put("email", email);
|
||||||
|
values.put("address", address);
|
||||||
|
values.put("gender", gender);
|
||||||
|
values.put("taste", taste);
|
||||||
|
//执行
|
||||||
|
int insert =(int) db.insert(TABLE_NAME, null, values);
|
||||||
|
//db.close();
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除数据
|
||||||
|
public void delete(SQLiteDatabase sqLiteDatabase, int id) {
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
db.delete(TABLE_NAME, "user_id=?", new String[]{String.valueOf(id)});
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询数据
|
||||||
|
@SuppressLint("Range")
|
||||||
|
public List<UserInfo> querydata(SQLiteDatabase sqLiteDatabase) {
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, "user_id ASC");
|
||||||
|
List<UserInfo> list = new ArrayList<>();
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
int id = cursor.getInt(cursor.getColumnIndex("user_id")); // Check if "user_id" is the correct column name
|
||||||
|
Log.i("SQLite","id="+id);
|
||||||
|
String username = cursor.getString(cursor.getColumnIndex("username"));
|
||||||
|
Log.i("SQLite","username="+username);
|
||||||
|
String password = cursor.getString(cursor.getColumnIndex("password"));
|
||||||
|
Log.i("SQLite","password="+password);
|
||||||
|
String surepassword = cursor.getString(cursor.getColumnIndex("surepassword"));
|
||||||
|
Log.i("SQLite","surepassword="+surepassword);
|
||||||
|
String phone = cursor.getString(cursor.getColumnIndex("phone"));
|
||||||
|
Log.i("SQLite","phone="+phone);
|
||||||
|
String email = cursor.getString(cursor.getColumnIndex("email"));
|
||||||
|
Log.i("SQLite","email="+email);
|
||||||
|
String address = cursor.getString(cursor.getColumnIndex("address"));
|
||||||
|
Log.i("SQLite","address="+address);
|
||||||
|
String gender = cursor.getString(cursor.getColumnIndex("gender"));
|
||||||
|
Log.i("SQLite","gender="+gender);
|
||||||
|
String taste = cursor.getString(cursor.getColumnIndex("taste"));
|
||||||
|
Log.i("SQLite","taste="+taste);
|
||||||
|
list.add(new UserInfo(id, username, password, surepassword, phone, email, address, gender, taste));
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
//db.close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package com.example.deliciousfoodapp.entity;
|
||||||
|
|
||||||
|
public class CarInfo {
|
||||||
|
private int car_id;
|
||||||
|
private String username;
|
||||||
|
private int product_id;
|
||||||
|
private int product_img;
|
||||||
|
private String product_title;
|
||||||
|
private int product_price;
|
||||||
|
private int product_count;
|
||||||
|
|
||||||
|
|
||||||
|
public CarInfo(int car_id, String username, int product_id, int product_img, String product_title, int product_price, int product_count) {
|
||||||
|
this.car_id = car_id;
|
||||||
|
this.username = username;
|
||||||
|
this.product_id = product_id;
|
||||||
|
this.product_img = product_img;
|
||||||
|
this.product_title = product_title;
|
||||||
|
this.product_price = product_price;
|
||||||
|
this.product_count = product_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProduct_count() {
|
||||||
|
return product_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct_count(int product_count) {
|
||||||
|
this.product_count = product_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCar_id() {
|
||||||
|
return car_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCar_id(int car_id) {
|
||||||
|
this.car_id = car_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProduct_id() {
|
||||||
|
return product_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct_id(int product_id) {
|
||||||
|
this.product_id = product_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProduct_img() {
|
||||||
|
return product_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct_img(int product_img) {
|
||||||
|
this.product_img = product_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProduct_title() {
|
||||||
|
return product_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct_title(String product_title) {
|
||||||
|
this.product_title = product_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProduct_price() {
|
||||||
|
return product_price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct_price(int product_price) {
|
||||||
|
this.product_price = product_price;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.example.deliciousfoodapp.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class FoodInfo implements Serializable {
|
||||||
|
private int food_id;
|
||||||
|
private int food_img;
|
||||||
|
private String food_title;
|
||||||
|
private String food_details;
|
||||||
|
private int food_price;
|
||||||
|
|
||||||
|
private String food_next;
|
||||||
|
public FoodInfo(int food_id, int food_img, String food_title, String food_details, int food_price,String food_next) {
|
||||||
|
this.food_id = food_id;
|
||||||
|
this.food_img = food_img;
|
||||||
|
this.food_title = food_title;
|
||||||
|
this.food_details = food_details;
|
||||||
|
this.food_price = food_price;
|
||||||
|
this.food_next = food_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFood_id() {
|
||||||
|
return food_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood_id(int food_id) {
|
||||||
|
this.food_id = food_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFood_img() {
|
||||||
|
return food_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood_img(int food_img) {
|
||||||
|
this.food_img = food_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFood_title() {
|
||||||
|
return food_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood_title(String food_title) {
|
||||||
|
this.food_title = food_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFood_details() {
|
||||||
|
return food_details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood_details(String food_details) {
|
||||||
|
this.food_details = food_details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFood_price() {
|
||||||
|
return food_price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood_price(int food_price) {
|
||||||
|
this.food_price = food_price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFood_next() {
|
||||||
|
return food_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood_next(String food_next) {
|
||||||
|
this.food_next = food_next;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package com.example.deliciousfoodapp.entity;
|
||||||
|
|
||||||
|
public class UserInfo {
|
||||||
|
private int user_id;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String surepassword;
|
||||||
|
private String phone;
|
||||||
|
private String email;
|
||||||
|
private String address;
|
||||||
|
private String gender;
|
||||||
|
private String taste;
|
||||||
|
public static UserInfo sUserInfo;
|
||||||
|
public static UserInfo getUserInfo(){
|
||||||
|
return sUserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserInfo(int user_id, String username, String password,String surepassword,String phone,String email,String address,String gender,String taste) {
|
||||||
|
this.user_id = user_id;
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.surepassword = surepassword;
|
||||||
|
this.phone = phone;
|
||||||
|
this.email = email;
|
||||||
|
this.address = address;
|
||||||
|
this.gender = gender;
|
||||||
|
this.taste = taste;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUser_id() {
|
||||||
|
return user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser_id(int user_id) {
|
||||||
|
this.user_id = user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 getSurepassword() {
|
||||||
|
return surepassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSurepassword(String surepassword) {
|
||||||
|
this.surepassword = surepassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String adress) {
|
||||||
|
this.address = adress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGender() {
|
||||||
|
return gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGender(String gender) {
|
||||||
|
this.gender = gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaste() {
|
||||||
|
return taste;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaste(String taste) {
|
||||||
|
this.taste = taste;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class homeFragment extends Fragment {
|
||||||
|
|
||||||
|
private ListView mListView;
|
||||||
|
private HomeNewAdapter myAdapter;
|
||||||
|
private List<Map<String, Object>> datas = new ArrayList<>(); // 使用datas作为数据源
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
||||||
|
|
||||||
|
initData(); // 使用datas作为数据源
|
||||||
|
|
||||||
|
mListView = view.findViewById(R.id.homelistview);
|
||||||
|
myAdapter = new HomeNewAdapter(datas, requireContext()); // 使用datas作为数据源
|
||||||
|
mListView.setAdapter(myAdapter);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义数据,也可以添加网络数据
|
||||||
|
private void initData() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("img", R.drawable.one);
|
||||||
|
datas.add(map);
|
||||||
|
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put("img", R.drawable.two);
|
||||||
|
datas.add(map);
|
||||||
|
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put("img", R.drawable.three);
|
||||||
|
datas.add(map);
|
||||||
|
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put("img", R.drawable.four);
|
||||||
|
datas.add(map);
|
||||||
|
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put("img", R.drawable.five);
|
||||||
|
datas.add(map);
|
||||||
|
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put("img", R.drawable.six);
|
||||||
|
datas.add(map);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.R;
|
||||||
|
|
||||||
|
public class personFragment extends Fragment {
|
||||||
|
|
||||||
|
TextView tv_username;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_person, container, false);
|
||||||
|
tv_username = view.findViewById(R.id.tv_username);
|
||||||
|
|
||||||
|
//退出登录
|
||||||
|
view.findViewById(R.id.exit).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("温馨提示")
|
||||||
|
.setMessage("确定要退出登录吗?")
|
||||||
|
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// 取消退出登录操作
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// 退出登录的逻辑
|
||||||
|
getActivity().finish();
|
||||||
|
// 打开登录页面
|
||||||
|
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//查看食谱
|
||||||
|
// view.findViewById(R.id.exit).setOnClickListener(new View.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(View v) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
// 设置用户数据
|
||||||
|
String username = getActivity().getIntent().getStringExtra("username");
|
||||||
|
if (username != null) {
|
||||||
|
// 设置用户名数据到tv_username位置
|
||||||
|
tv_username.setText(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Button button = view.findViewById(R.id.exit); // 在fragment的布局中找到按钮
|
||||||
|
// button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onClick(View v) {
|
||||||
|
// Intent intent = new Intent(getActivity(), LoginActivity.class); // 使用getActivity()获取当前fragment所在的activity
|
||||||
|
// startActivity(intent);
|
||||||
|
// }
|
||||||
|
// });
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.example.deliciousfoodapp.placeholder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class for providing sample content for user interfaces created by
|
||||||
|
* Android template wizards.
|
||||||
|
* <p>
|
||||||
|
* TODO: Replace all uses of this class before publishing your app.
|
||||||
|
*/
|
||||||
|
public class PlaceholderContent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array of sample (placeholder) items.
|
||||||
|
*/
|
||||||
|
public static final List<PlaceholderItem> ITEMS = new ArrayList<PlaceholderItem>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of sample (placeholder) items, by ID.
|
||||||
|
*/
|
||||||
|
public static final Map<String, PlaceholderItem> ITEM_MAP = new HashMap<String, PlaceholderItem>();
|
||||||
|
|
||||||
|
private static final int COUNT = 25;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Add some sample items.
|
||||||
|
for (int i = 1; i <= COUNT; i++) {
|
||||||
|
addItem(createPlaceholderItem(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addItem(PlaceholderItem item) {
|
||||||
|
ITEMS.add(item);
|
||||||
|
ITEM_MAP.put(item.id, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PlaceholderItem createPlaceholderItem(int position) {
|
||||||
|
return new PlaceholderItem(String.valueOf(position), "Item " + position, makeDetails(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String makeDetails(int position) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("Details about Item: ").append(position);
|
||||||
|
for (int i = 0; i < position; i++) {
|
||||||
|
builder.append("\nMore details information here.");
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A placeholder item representing a piece of content.
|
||||||
|
*/
|
||||||
|
public static class PlaceholderItem {
|
||||||
|
public final String id;
|
||||||
|
public final String content;
|
||||||
|
public final String details;
|
||||||
|
|
||||||
|
public PlaceholderItem(String id, String content, String details) {
|
||||||
|
this.id = id;
|
||||||
|
this.content = content;
|
||||||
|
this.details = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
package com.example.deliciousfoodapp;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.deliciousfoodapp.R;
|
||||||
|
import com.example.deliciousfoodapp.adapter.CarListAdapter;
|
||||||
|
import com.example.deliciousfoodapp.db.CarDbHelper;
|
||||||
|
import com.example.deliciousfoodapp.entity.CarInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class shopFragment extends Fragment {
|
||||||
|
|
||||||
|
private View rootview;
|
||||||
|
private RecyclerView recyclerView;
|
||||||
|
private TextView total;
|
||||||
|
private Button btn_total;
|
||||||
|
|
||||||
|
private CarListAdapter mCarListAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
rootview=inflater.inflate(R.layout.fragment_shop, container, false);
|
||||||
|
recyclerView=rootview.findViewById(R.id.recyclerView);
|
||||||
|
total=rootview.findViewById(R.id.total);
|
||||||
|
btn_total=rootview.findViewById(R.id.btn_total);
|
||||||
|
|
||||||
|
return rootview;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
//初始化mCarListAdapter
|
||||||
|
mCarListAdapter = new CarListAdapter();
|
||||||
|
//设置适配器
|
||||||
|
recyclerView.setAdapter(mCarListAdapter);
|
||||||
|
|
||||||
|
//recyclerView点击事件
|
||||||
|
mCarListAdapter.setOnItemClickListner(new CarListAdapter.onItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onPlusOnClick(CarInfo carInfo, int position) {
|
||||||
|
//加
|
||||||
|
CarDbHelper.getInstance(getActivity()).updateProduct(carInfo.getCar_id(),carInfo);
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delOnClick(CarInfo carInfo, int position) {
|
||||||
|
|
||||||
|
new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle("温馨提示")
|
||||||
|
.setMessage("确认是否要删除商品")
|
||||||
|
.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
CarDbHelper.getInstance(getActivity()).delete(carInfo.getCar_id()+"");
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSubTractOnClick(CarInfo carInfo, int position) {
|
||||||
|
|
||||||
|
//减
|
||||||
|
CarDbHelper.getInstance(getActivity()).subStartupdateProduct(carInfo.getCar_id(),carInfo);
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//结算点击事件
|
||||||
|
btn_total.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTotalData(List<CarInfo> list){
|
||||||
|
int toTalCount=0;
|
||||||
|
for (int i= 0; i < list.size(); i++) {
|
||||||
|
int price=list.get(i).getProduct_price()*list.get(i).getProduct_count();
|
||||||
|
toTalCount=toTalCount+price;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置数据
|
||||||
|
total.setText(toTalCount+".00");
|
||||||
|
}
|
||||||
|
public void loadData(){
|
||||||
|
//获取数据,用户名写死
|
||||||
|
List<CarInfo> carList= CarDbHelper.getInstance(getActivity()).queryCarList("zsan");
|
||||||
|
//设置数据
|
||||||
|
mCarListAdapter.setCarInfoList(carList);
|
||||||
|
//计算总的价格
|
||||||
|
setTotalData(carList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 124 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 130 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 99 KiB |
After Width: | Height: | Size: 113 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 120 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 112 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 133 KiB |
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 133 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 129 KiB |