diff --git a/Test1/.idea/androidTestResultsUserPreferences.xml b/Test1/.idea/androidTestResultsUserPreferences.xml new file mode 100644 index 0000000..b294cbc --- /dev/null +++ b/Test1/.idea/androidTestResultsUserPreferences.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/Test1/.idea/dbnavigator.xml b/Test1/.idea/dbnavigator.xml new file mode 100644 index 0000000..0fba2e2 --- /dev/null +++ b/Test1/.idea/dbnavigator.xml @@ -0,0 +1,613 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/Test1/app/build.gradle b/Test1/app/build.gradle index 986ae0e..29908b0 100644 --- a/Test1/app/build.gradle +++ b/Test1/app/build.gradle @@ -33,6 +33,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'com.google.android.material:material:1.5.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation 'com.android.car.ui:car-ui-lib:2.0.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' diff --git a/Test1/app/src/main/AndroidManifest.xml b/Test1/app/src/main/AndroidManifest.xml index 7cebf00..f3294cb 100644 --- a/Test1/app/src/main/AndroidManifest.xml +++ b/Test1/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ + - diff --git a/Test1/app/src/main/java/com/example/test1/Activity/CategoryActivity.java b/Test1/app/src/main/java/com/example/test1/Activity/CategoryActivity.java index c9b6e29..ea70792 100644 --- a/Test1/app/src/main/java/com/example/test1/Activity/CategoryActivity.java +++ b/Test1/app/src/main/java/com/example/test1/Activity/CategoryActivity.java @@ -3,11 +3,15 @@ package com.example.test1.Activity; import android.app.Activity; import android.app.FragmentManager; import android.app.FragmentTransaction; +import android.content.Intent; import android.os.Bundle; +import android.view.View; import android.widget.ListView; +import android.widget.Toast; import androidx.annotation.Nullable; +import com.example.test1.Database; import com.example.test1.Fragment.SetDetailFragment; import com.example.test1.R; import com.example.test1.adapter.Adapter; @@ -18,7 +22,7 @@ import java.util.ArrayList; import java.util.List; -public class CategoryActivity extends Activity { +public class CategoryActivity extends Activity implements View.OnClickListener{ public OnChangeListener onchangedListener; private List productList; private List productCategory = new ArrayList<>(); @@ -50,6 +54,16 @@ public class CategoryActivity extends Activity { this.onchangedListener = onChangeListener; } + @Override + public void onClick(View view) { + switch (view.getId()){ + case R.id.category_return: + Intent intent1=new Intent(CategoryActivity.this, MainActivity.class); + startActivity(intent1); + break; + } + } + public interface OnChangeListener { void changeText(Product product); } @@ -79,6 +93,15 @@ public class CategoryActivity extends Activity { productList.add(product2); } + public void onClick1(View view) { + switch (view.getId()){ + case R.id.category_return: + Intent intent1=new Intent(CategoryActivity.this, MainActivity.class); + startActivity(intent1); + break; + } + } + /** * 初始化组件 */ diff --git a/Test1/app/src/main/java/com/example/test1/Activity/IndexActivity.java b/Test1/app/src/main/java/com/example/test1/Activity/IndexActivity.java index 76cfe0c..e69970f 100644 --- a/Test1/app/src/main/java/com/example/test1/Activity/IndexActivity.java +++ b/Test1/app/src/main/java/com/example/test1/Activity/IndexActivity.java @@ -1,4 +1,128 @@ package com.example.test1.Activity; -public class IndexActivity { +import android.app.Activity; +import android.app.FragmentTransaction; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.LinearLayout; + +import androidx.annotation.Nullable; + +import com.example.test1.Fragment.IndexFragment; +import com.example.test1.Fragment.PersonFragment; +import com.example.test1.Fragment.ProductFragment; +import com.example.test1.Fragment.ShoppingCartFragment; +import com.example.test1.R; +import com.example.test1.service.TimeService; + +public class IndexActivity extends Activity implements View.OnClickListener { + private IndexFragment indexFragment; + private ProductFragment productFragment; + private ShoppingCartFragment shoppingCartFragment; + private PersonFragment pearsonFragment; + private LinearLayout indexLine, productLine, shoppingCartLine, pearsonLine; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.navigate); + init(); + initIndexFragment(); + Thread thread = new Thread(runnable); + thread.start(); + } + + /** + * 组件初始化 + */ + private void init() { + indexLine = findViewById(R.id.content_index); + indexLine.setOnClickListener(this); + productLine = findViewById(R.id.content_product); + productLine.setOnClickListener(this); + shoppingCartLine = findViewById(R.id.content_cart); + shoppingCartLine.setOnClickListener(this); + pearsonLine = findViewById(R.id.content_pearson); + pearsonLine.setOnClickListener(this); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.content_index: + initIndexFragment(); + break; + case R.id.content_product: + initproductFragment(); + break; + case R.id.content_cart: + initshoppingCartFragment(); + break; + case R.id.content_pearson: + initpearsonFragment(); + break; + } + } + + /** + * 初始化首页Fragment + */ + private void initIndexFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (indexFragment == null) { + indexFragment = new IndexFragment(); + } + transaction.replace(R.id.main_content, indexFragment); + transaction.commit(); + } + + /** + * 初始化产品Fragment + */ + private void initproductFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (productFragment == null) { + productFragment = new ProductFragment(); + } + transaction.replace(R.id.main_content, productFragment); + transaction.commit(); + } + + /** + * 初始化购物车Fragment + */ + private void initshoppingCartFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (shoppingCartFragment == null) { + shoppingCartFragment = new ShoppingCartFragment(); + } + transaction.replace(R.id.main_content, shoppingCartFragment); + transaction.commit(); + } + + /** + * 初始化个人Fragment + */ + private void initpearsonFragment() { + //开启事务,fragment的控制是由事务来实现的 + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (pearsonFragment == null) { + Intent intent = IndexActivity.this.getIntent(); + Bundle bundle = intent.getExtras(); + pearsonFragment = new PersonFragment(); + pearsonFragment.setArguments(bundle); + } + transaction.replace(R.id.main_content, pearsonFragment); + transaction.commit(); + } + + Runnable runnable = () -> { + Intent intent = new Intent(IndexActivity.this, TimeService.class); + startService(intent); + }; + } diff --git a/Test1/app/src/main/java/com/example/test1/Activity/IntroductionActivity.java b/Test1/app/src/main/java/com/example/test1/Activity/IntroductionActivity.java index 26c11b2..df38d4e 100644 --- a/Test1/app/src/main/java/com/example/test1/Activity/IntroductionActivity.java +++ b/Test1/app/src/main/java/com/example/test1/Activity/IntroductionActivity.java @@ -59,26 +59,26 @@ private TextView btn,btn1; private void initData() { data = new ArrayList>(); Map map = new HashMap(); - map.put("icon",R.drawable.lvintroduction); + map.put("icon",R.drawable.lvlogo); map.put("title","LV"); map.put("content","路易威登(Louis Vuitton),法国奢侈品品牌,隶属于酩悦·轩尼诗-路易·威登集团,经营产品包括手提包,旅行用品,小型皮具,配饰,鞋履,成衣,腕表,高级珠宝及个性化订制服务等。"); data.add(map); map = new HashMap(); - map.put("icon",R.drawable.hermersintroduction); + map.put("icon",R.drawable.hermeslogo); map.put("title","hermers"); map.put("content","爱马仕(Hermès)是法国奢侈品品牌,由蒂埃利·爱马仕(Thierry Hermès)于1837年在法国巴黎创立。 [1] 拥有皮具和马具、女士丝制品、男士丝制品、女士成衣、男士成衣、鞋履、腰带、帽子、手套、珠宝、钟表、香水、美妆、家具和生活艺术、餐瓷、petit h十六大工艺部门。 [41] "); data.add(map); map = new HashMap(); - map.put("icon",R.drawable.miumiuintroduction); + map.put("icon",R.drawable.miumiulogo); map.put("title","miumiu"); map.put("content","Miu Miu是Miuccia Prada于1992年创立的品牌。 [6] \n" + "Miu Miu率性且充满实验风格,与Prada是同一设计理念的另一种表达方式,注重优雅精致且不乏趣味,将女性气质发挥到极致。通过成衣、皮具、眼镜、具备突破意义的广告大片,及有独特视角的女人的故事短片系列,使品牌呈现了现代女性的多面特质。"); data.add(map); map = new HashMap(); - map.put("icon",R.drawable.pradaintroduction); + map.put("icon",R.drawable.pradalogo); map.put("title","prada"); map.put("content","普拉达(PRADA)是意大利奢侈品牌,由玛丽奥·普拉达于1913年在意大利米兰创建。缪西娅·普拉达(Miuccia Prada)的独特天赋在于对新创意的不懈追求,融合了对知识的好奇心和文化兴趣,从而开辟了先驱之路。她不仅能够预测时尚趋势,更能够引领时尚潮流。 [5] "); data.add(map); diff --git a/Test1/app/src/main/java/com/example/test1/Activity/MainActivity.java b/Test1/app/src/main/java/com/example/test1/Activity/MainActivity.java index ffd3514..135b22c 100644 --- a/Test1/app/src/main/java/com/example/test1/Activity/MainActivity.java +++ b/Test1/app/src/main/java/com/example/test1/Activity/MainActivity.java @@ -50,7 +50,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe break; case R.id.login: if(validateLogin()){ - Intent intent = new Intent(MainActivity.this, CategoryActivity.class); + Intent intent = new Intent(MainActivity.this, IndexActivity.class); Bundle bundle=new Bundle(); Database dateBase=new Database(MainActivity.this); bundle.putString("username",usernameText.getText().toString()); diff --git a/Test1/app/src/main/java/com/example/test1/Activity/registerActivity.java b/Test1/app/src/main/java/com/example/test1/Activity/registerActivity.java index 5f0cc51..20690ec 100644 --- a/Test1/app/src/main/java/com/example/test1/Activity/registerActivity.java +++ b/Test1/app/src/main/java/com/example/test1/Activity/registerActivity.java @@ -21,7 +21,7 @@ import com.lljjcoder.citypickerview.widget.CityPicker; public class registerActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener { private EditText usernameEdit, passwordEdit, surePasswordEdit; - private TextView cityText; + private TextView cityText,numberText; private CityPicker cityPicker; private Button regButton; private RadioGroup sexGroup; @@ -40,6 +40,7 @@ public class registerActivity extends AppCompatActivity implements View.OnClickL */ private void init() { cityText = findViewById(R.id.province); + numberText = findViewById(R.id.reg_number); cityText.setOnClickListener(this); usernameEdit = findViewById(R.id.username); passwordEdit = findViewById(R.id.password); @@ -114,6 +115,7 @@ public class registerActivity extends AppCompatActivity implements View.OnClickL String password = passwordEdit.getText().toString(); String surePassword = surePasswordEdit.getText().toString(); String city = cityText.getText().toString(); + String number = numberText.getText().toString(); //判断两次密码是否输入一致 if (password.equals(surePassword)) { //这里也可以再进行其它的验证,如是否符合要求等,符合就进行插入数据库操作 @@ -124,6 +126,7 @@ public class registerActivity extends AppCompatActivity implements View.OnClickL bundle.putString("password", password); bundle.putString("sex", sexStr); bundle.putString("city", city); + bundle.putString("number", number); intent.putExtras(bundle); //用SQLite数据库存储注册信息 Database dateBase= new Database(registerActivity.this); @@ -156,6 +159,7 @@ public class registerActivity extends AppCompatActivity implements View.OnClickL contentValues.put("password",bundle.getString("password")); contentValues.put("sex",bundle.getString("sex")); contentValues.put("city",bundle.getString("city")); + contentValues.put("number",bundle.getString("number")); sqLiteDatabase.insert("good_user",null,contentValues); sqLiteDatabase.close(); } diff --git a/Test1/app/src/main/java/com/example/test1/Activity/userActivity.java b/Test1/app/src/main/java/com/example/test1/Activity/userActivity.java index cb07934..8702356 100644 --- a/Test1/app/src/main/java/com/example/test1/Activity/userActivity.java +++ b/Test1/app/src/main/java/com/example/test1/Activity/userActivity.java @@ -15,8 +15,8 @@ import com.example.test1.R; public class userActivity extends AppCompatActivity { private ImageView userSexline, userCityLine, userPayLine, userSettingLine, - userGeneralLine, usernameLine, userIconImage; - private TextView userCityText, userSexText, usernameText; + userGeneralLine, usernameLine, userIconImage,userNumberLine; + private TextView userCityText, userSexText, usernameText,userNumberText; private LinearLayout userSearchProductLine; @Override @@ -33,9 +33,11 @@ public class userActivity extends AppCompatActivity { usernameText = findViewById(R.id.user_username); userSexText = findViewById(R.id.user_sex); userCityText = findViewById(R.id.user_city); + userNumberText = findViewById(R.id.user_number); usernameLine = findViewById(R.id.user_username_line); userSexline = findViewById(R.id.user_sex_line); userCityLine = findViewById(R.id.user_city_line); + userNumberLine = findViewById(R.id.user_number_line); userPayLine = findViewById(R.id.user_pay); userSettingLine = findViewById(R.id.user_setting); userGeneralLine = findViewById(R.id.user_general); @@ -55,6 +57,7 @@ public class userActivity extends AppCompatActivity { usernameText.setText(String.format("用户名:%s", bundle.getString("username"))); userSexText.setText(String.format("性别:%s", bundle.getString("sex"))); userCityText.setText(String.format("城市:%s", bundle.getString("city"))); + userNumberText.setText(String.format("电话:%s", bundle.getString("number"))); } public void onClick(View v) { diff --git a/Test1/app/src/main/java/com/example/test1/Database.java b/Test1/app/src/main/java/com/example/test1/Database.java index a3a9039..1e0aa50 100644 --- a/Test1/app/src/main/java/com/example/test1/Database.java +++ b/Test1/app/src/main/java/com/example/test1/Database.java @@ -11,15 +11,16 @@ import androidx.annotation.Nullable; public class Database extends SQLiteOpenHelper { + public Database(@Nullable Context context) { - super(context, "orange", null, 1); + super(context, "good", null, 4); } @Override public void onCreate(SQLiteDatabase db) { //创建用户表 - String sql = "create table good_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50))"; + String sql = "create table good_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50),number carchar(50))"; db.execSQL(sql); } @@ -29,12 +30,13 @@ public class Database extends SQLiteOpenHelper { } //插入数据 - public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city) { + public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city, String number ) { ContentValues contentValues = new ContentValues(); contentValues.put("username", username); contentValues.put("password", password); contentValues.put("sex", sex); contentValues.put("city", city); + contentValues.put("number", number); sqLiteDatabase.insert("good_user", null, contentValues); sqLiteDatabase.close(); } @@ -47,6 +49,7 @@ public class Database extends SQLiteOpenHelper { while (cursor.moveToNext()) { bundle.putString("sex", cursor.getString(3)); bundle.putString("city", cursor.getString(4)); + bundle.putString("number", cursor.getString(5)); } } cursor.close(); diff --git a/Test1/app/src/main/java/com/example/test1/Fragment/IndexFragment.java b/Test1/app/src/main/java/com/example/test1/Fragment/IndexFragment.java new file mode 100644 index 0000000..b27d090 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/Fragment/IndexFragment.java @@ -0,0 +1,110 @@ +package com.example.test1.Fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.GridView; +import android.widget.LinearLayout; +import android.widget.SearchView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.test1.R; +import com.example.test1.adapter.ProductAdapter; +import com.example.test1.entity.Product; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + + +public class IndexFragment extends Fragment implements View.OnClickListener { + private SearchView searchView; + private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine; + private GridView gridView; + private ProductAdapter productAdapter; + private List productList; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index, container, false); + init(view); + return view; + } + + /** + * 初始化组件 + */ + private void init(View view) { + searchView = view.findViewById(R.id.searchView); + searchView.setOnClickListener(this); + orangeLine = view.findViewById(R.id.chengzi); + orangeLine.setOnClickListener(this); + youziLine = view.findViewById(R.id.youzi); + youziLine.setOnClickListener(this); + juziLine = view.findViewById(R.id.juzi); + juziLine.setOnClickListener(this); + xiguaLine = view.findViewById(R.id.xigua); + xiguaLine.setOnClickListener(this); + liLine = view.findViewById(R.id.li); + liLine.setOnClickListener(this); + lemonLine = view.findViewById(R.id.lemon); + lemonLine.setOnClickListener(this); + mangguoLine = view.findViewById(R.id.mangguo); + mangguoLine.setOnClickListener(this); + appleLine = view.findViewById(R.id.apple); + appleLine.setOnClickListener(this); + gridView = view.findViewById(R.id.index_famous_gridview); + initData(); + productAdapter = new ProductAdapter(getActivity(), productList); + gridView.setAdapter(productAdapter); + } + + + @Override + public void onClick(View v) { + + } + + /** + * 初始化商品数据 + */ + private void initData() { + productList = new ArrayList<>(); + Product product = new Product(); + product.setImageUrlId(R.drawable.lv1); + product.setProductName("lv"); + product.setProductPrice(new BigDecimal("19999")); + Product product1 = new Product(); + product1.setImageUrlId(R.drawable.lv2); + product1.setProductName("prada"); + product1.setProductPrice(new BigDecimal("29999")); + Product product2 = new Product(); + product2.setImageUrlId(R.drawable.miumiu1); + product2.setProductName("miumiu"); + product2.setProductPrice(new BigDecimal("19999")); + Product product3 = new Product(); + product3.setImageUrlId(R.drawable.prada1); + product3.setProductName("hermes"); + product3.setProductPrice(new BigDecimal("29999")); + Product product4 = new Product(); + product4.setImageUrlId(R.drawable.prada2); + product4.setProductName("cn"); + product4.setProductPrice(new BigDecimal("49999")); + Product product5 = new Product(); + product5.setImageUrlId(R.drawable.hermes1); + product5.setProductName("diao"); + product5.setProductPrice(new BigDecimal("39999")); + productList.add(product); + productList.add(product1); + productList.add(product2); + productList.add(product3); + productList.add(product4); + productList.add(product5); + + } +} diff --git a/Test1/app/src/main/java/com/example/test1/Fragment/PersonFragment.java b/Test1/app/src/main/java/com/example/test1/Fragment/PersonFragment.java new file mode 100644 index 0000000..202dde5 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/Fragment/PersonFragment.java @@ -0,0 +1,64 @@ +package com.example.test1.Fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.test1.R; + +public class PersonFragment extends Fragment implements View.OnClickListener { + private ImageView userIconImage; + private TextView usernameText, userSexText, userCityText; + private ImageView usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine; + + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.user, container, false); + init(view); + return view; + } + + /** + * 组件初始化 + */ + private void init(View view) { + userIconImage = view.findViewById(R.id.user_icon); + usernameText = view.findViewById(R.id.user_username); + userSexText = view.findViewById(R.id.user_sex); + userCityText = view.findViewById(R.id.user_city); + usernameLine = view.findViewById(R.id.user_username_line); + userSexline = view.findViewById(R.id.user_sex_line); + userCityLine = view.findViewById(R.id.user_city_line); + userPayLine = view.findViewById(R.id.user_pay); + userSettingLine = view.findViewById(R.id.user_setting); + userGeneralLine = view.findViewById(R.id.user_general); + setData(); + } + + /** + * 组件赋值 + */ + private void setData() { + Bundle bundle = getArguments(); + usernameText.setText(String.format("用户名:%s", bundle.getString("username"))); + userSexText.setText(String.format("性别:%s", bundle.getString("sex"))); + userCityText.setText(String.format("城市:%s", bundle.getString("city"))); + } + + @Override + public void onClick(View v) { + + } + + +} diff --git a/Test1/app/src/main/java/com/example/test1/Fragment/ProductFragment.java b/Test1/app/src/main/java/com/example/test1/Fragment/ProductFragment.java new file mode 100644 index 0000000..578e4e0 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/Fragment/ProductFragment.java @@ -0,0 +1,21 @@ +package com.example.test1.Fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.test1.R; + +public class ProductFragment extends Fragment { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_product, container, false); + return view; + } +} diff --git a/Test1/app/src/main/java/com/example/test1/Fragment/ShoppingCartFragment.java b/Test1/app/src/main/java/com/example/test1/Fragment/ShoppingCartFragment.java new file mode 100644 index 0000000..c7d1b73 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/Fragment/ShoppingCartFragment.java @@ -0,0 +1,21 @@ +package com.example.test1.Fragment; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.example.test1.R; + +public class ShoppingCartFragment extends Fragment { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_shopping, container, false); + return view; + } +} diff --git a/Test1/app/src/main/java/com/example/test1/adapter/ProductAdapter.java b/Test1/app/src/main/java/com/example/test1/adapter/ProductAdapter.java new file mode 100644 index 0000000..0cd1e39 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/adapter/ProductAdapter.java @@ -0,0 +1,69 @@ +package com.example.test1.adapter; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import com.example.test1.R; +import com.example.test1.entity.Product; + +import java.util.List; + +public class ProductAdapter extends BaseAdapter { + private List productList; + private LayoutInflater layoutInflater; + + public ProductAdapter(Context context, List productList) { + this.productList = productList; + this.layoutInflater = LayoutInflater.from(context); + } + + @Override + public int getCount() { + return productList.size(); + } + + @Override + public Object getItem(int position) { + return productList.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder viewHolder; + if (convertView == null) { + Log.i("aa", "getView: "+"aa"); + convertView = layoutInflater.inflate(R.layout.category_detail_content, null); + viewHolder = new ViewHolder(); + viewHolder.productImage = convertView.findViewById(R.id.category_product_image); + viewHolder.productName = convertView.findViewById(R.id.category_product_name); + viewHolder.productPrice = convertView.findViewById(R.id.category_product_price); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + Product product = productList.get(position); + Log.i("product", "getView: "+product.toString()); + if (product != null) { + viewHolder.productImage.setBackgroundResource(product.getImageUrlId()); + viewHolder.productName.setText(product.getProductName()); + viewHolder.productPrice.setText(String.valueOf(product.getProductPrice())); + } + return convertView; + } + + class ViewHolder { + ImageView productImage; + TextView productName, productPrice; + } +} diff --git a/Test1/app/src/main/java/com/example/test1/entity/BrandBean.java b/Test1/app/src/main/java/com/example/test1/entity/BrandBean.java index 61ebfbe..02417d9 100644 --- a/Test1/app/src/main/java/com/example/test1/entity/BrandBean.java +++ b/Test1/app/src/main/java/com/example/test1/entity/BrandBean.java @@ -40,4 +40,14 @@ public class BrandBean implements Serializable { public void setImg(int img) { this.img = img; } + + @Override + public String toString() { + return "Condition{" + + "conditionIcon=" + img + + "conditionIcon=" + sales + + "conditionIcon=" + price + + ", conditionName='" + name + '\'' + + '}'; + } } diff --git a/Test1/app/src/main/java/com/example/test1/entity/Product.java b/Test1/app/src/main/java/com/example/test1/entity/Product.java index 98103ab..4591d51 100644 --- a/Test1/app/src/main/java/com/example/test1/entity/Product.java +++ b/Test1/app/src/main/java/com/example/test1/entity/Product.java @@ -31,4 +31,13 @@ public class Product { private Integer imageUrlId; private String productName; private BigDecimal productPrice; + + @Override + public String toString() { + return "Product{" + + "imageUrlId=" + imageUrlId + + ", productName='" + productName + '\'' + + ", productPrice=" + productPrice + + '}'; + } } diff --git a/Test1/app/src/main/java/com/example/test1/entity/ShoppingCart.java b/Test1/app/src/main/java/com/example/test1/entity/ShoppingCart.java new file mode 100644 index 0000000..951c901 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/entity/ShoppingCart.java @@ -0,0 +1,43 @@ +package com.example.test1.entity; + +public class ShoppingCart { + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getProductId() { + return ProductId; + } + + public void setProductId(Integer productId) { + ProductId = productId; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + private Integer id; + private Integer userId; + private Integer ProductId; + /** + * 购买数量 + */ + private Integer number; +} diff --git a/Test1/app/src/main/java/com/example/test1/service/TimeService.java b/Test1/app/src/main/java/com/example/test1/service/TimeService.java new file mode 100644 index 0000000..f758385 --- /dev/null +++ b/Test1/app/src/main/java/com/example/test1/service/TimeService.java @@ -0,0 +1,88 @@ +package com.example.test1.service; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import android.os.IBinder; + +import androidx.annotation.Nullable; +import androidx.core.app.NotificationCompat; + +import com.example.test1.R; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +public class TimeService extends Service { + private static Timer timer = null; + private NotificationManager manager; + private NotificationCompat.Builder builder; + + @Nullable + @Override + public IBinder onBind(Intent intent) { + return null; + } + + /** + * 清除通知 + */ + private void cleanAllNotification() { + manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + manager.cancelAll(); + if (timer != null) { + timer.cancel(); + timer = null; + } + + } + + /** + * 添加通知 + */ + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + long period = 60 * 1000; //1分钟一个周期 + if (timer == null) { + timer = new Timer(); + } + timer.schedule(new TimerTask() { + @Override + public void run() { + /** + * NotificationChannel是android8.0新增的特性,如果App的targetSDKVersion>=26, + * 没有设置channel通知渠道的话,就会导致通知无法展示。 + * 报错内容:Failed to post notification on channel “null” + */ + NotificationChannel channel = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + channel = new NotificationChannel("channel", "通知", NotificationManager.IMPORTANCE_DEFAULT); + } + manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + manager.createNotificationChannel(channel); + } + builder = new NotificationCompat.Builder(TimeService.this); + builder.setContentTitle("提醒系统当前时间"); + builder.setSmallIcon(R.drawable.lv1); + builder.setChannelId("channel"); + Date date = new Date(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + builder.setContentText("系统当前时间为:" + formatter.format(date)); + builder.setAutoCancel(true); + builder.setDefaults(Notification.DEFAULT_ALL); + Notification notification = builder.build(); + manager.notify(1, notification); + + } + }, 0, period); + + return super.onStartCommand(intent, flags, startId); + } +} diff --git a/Test1/app/src/main/res/drawable/baobao.png b/Test1/app/src/main/res/drawable/baobao.png new file mode 100644 index 0000000..44ff9fa Binary files /dev/null and b/Test1/app/src/main/res/drawable/baobao.png differ diff --git a/Test1/app/src/main/res/drawable/bl.png b/Test1/app/src/main/res/drawable/bl.png new file mode 100644 index 0000000..0f975fb Binary files /dev/null and b/Test1/app/src/main/res/drawable/bl.png differ diff --git a/Test1/app/src/main/res/drawable/bllogo.png b/Test1/app/src/main/res/drawable/bllogo.png new file mode 100644 index 0000000..5b87a95 Binary files /dev/null and b/Test1/app/src/main/res/drawable/bllogo.png differ diff --git a/Test1/app/src/main/res/drawable/channellogo.png b/Test1/app/src/main/res/drawable/channellogo.png new file mode 100644 index 0000000..5012e51 Binary files /dev/null and b/Test1/app/src/main/res/drawable/channellogo.png differ diff --git a/Test1/app/src/main/res/drawable/cn.png b/Test1/app/src/main/res/drawable/cn.png new file mode 100644 index 0000000..8181e99 Binary files /dev/null and b/Test1/app/src/main/res/drawable/cn.png differ diff --git a/Test1/app/src/main/res/drawable/diao.png b/Test1/app/src/main/res/drawable/diao.png new file mode 100644 index 0000000..d13e91b Binary files /dev/null and b/Test1/app/src/main/res/drawable/diao.png differ diff --git a/Test1/app/src/main/res/drawable/diaologo.png b/Test1/app/src/main/res/drawable/diaologo.png new file mode 100644 index 0000000..fb7b82b Binary files /dev/null and b/Test1/app/src/main/res/drawable/diaologo.png differ diff --git a/Test1/app/src/main/res/drawable/guccilogo.png b/Test1/app/src/main/res/drawable/guccilogo.png new file mode 100644 index 0000000..f871202 Binary files /dev/null and b/Test1/app/src/main/res/drawable/guccilogo.png differ diff --git a/Test1/app/src/main/res/drawable/hermes.png b/Test1/app/src/main/res/drawable/hermes.png new file mode 100644 index 0000000..3482b64 Binary files /dev/null and b/Test1/app/src/main/res/drawable/hermes.png differ diff --git a/Test1/app/src/main/res/drawable/hermeslogo.png b/Test1/app/src/main/res/drawable/hermeslogo.png new file mode 100644 index 0000000..9f833b1 Binary files /dev/null and b/Test1/app/src/main/res/drawable/hermeslogo.png differ diff --git a/Test1/app/src/main/res/drawable/index.png b/Test1/app/src/main/res/drawable/index.png new file mode 100644 index 0000000..24b11e6 Binary files /dev/null and b/Test1/app/src/main/res/drawable/index.png differ diff --git a/Test1/app/src/main/res/drawable/index_menu.xml b/Test1/app/src/main/res/drawable/index_menu.xml new file mode 100644 index 0000000..14636dd --- /dev/null +++ b/Test1/app/src/main/res/drawable/index_menu.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/drawable/kucci.jpg b/Test1/app/src/main/res/drawable/kucci.jpg new file mode 100644 index 0000000..cc54cbe Binary files /dev/null and b/Test1/app/src/main/res/drawable/kucci.jpg differ diff --git a/Test1/app/src/main/res/drawable/lv.png b/Test1/app/src/main/res/drawable/lv.png new file mode 100644 index 0000000..ad69165 Binary files /dev/null and b/Test1/app/src/main/res/drawable/lv.png differ diff --git a/Test1/app/src/main/res/drawable/lvlogo.jpg b/Test1/app/src/main/res/drawable/lvlogo.jpg new file mode 100644 index 0000000..011aec0 Binary files /dev/null and b/Test1/app/src/main/res/drawable/lvlogo.jpg differ diff --git a/Test1/app/src/main/res/drawable/lvlogo1.jpg b/Test1/app/src/main/res/drawable/lvlogo1.jpg new file mode 100644 index 0000000..68b68b9 Binary files /dev/null and b/Test1/app/src/main/res/drawable/lvlogo1.jpg differ diff --git a/Test1/app/src/main/res/drawable/miumiu.png b/Test1/app/src/main/res/drawable/miumiu.png new file mode 100644 index 0000000..b969929 Binary files /dev/null and b/Test1/app/src/main/res/drawable/miumiu.png differ diff --git a/Test1/app/src/main/res/drawable/miumiulogo.png b/Test1/app/src/main/res/drawable/miumiulogo.png new file mode 100644 index 0000000..020d3e4 Binary files /dev/null and b/Test1/app/src/main/res/drawable/miumiulogo.png differ diff --git a/Test1/app/src/main/res/drawable/person.png b/Test1/app/src/main/res/drawable/person.png new file mode 100644 index 0000000..eb97ade Binary files /dev/null and b/Test1/app/src/main/res/drawable/person.png differ diff --git a/Test1/app/src/main/res/drawable/prada.png b/Test1/app/src/main/res/drawable/prada.png new file mode 100644 index 0000000..5b5ad62 Binary files /dev/null and b/Test1/app/src/main/res/drawable/prada.png differ diff --git a/Test1/app/src/main/res/drawable/pradalogo.jpg b/Test1/app/src/main/res/drawable/pradalogo.jpg new file mode 100644 index 0000000..9365d96 Binary files /dev/null and b/Test1/app/src/main/res/drawable/pradalogo.jpg differ diff --git a/Test1/app/src/main/res/drawable/pradalogo1.webp b/Test1/app/src/main/res/drawable/pradalogo1.webp new file mode 100644 index 0000000..81edbce Binary files /dev/null and b/Test1/app/src/main/res/drawable/pradalogo1.webp differ diff --git a/Test1/app/src/main/res/drawable/product.png b/Test1/app/src/main/res/drawable/product.png new file mode 100644 index 0000000..acd9602 Binary files /dev/null and b/Test1/app/src/main/res/drawable/product.png differ diff --git a/Test1/app/src/main/res/drawable/reg_number.png b/Test1/app/src/main/res/drawable/reg_number.png new file mode 100644 index 0000000..ae1f423 Binary files /dev/null and b/Test1/app/src/main/res/drawable/reg_number.png differ diff --git a/Test1/app/src/main/res/drawable/shoppingcart.png b/Test1/app/src/main/res/drawable/shoppingcart.png new file mode 100644 index 0000000..76cdc70 Binary files /dev/null and b/Test1/app/src/main/res/drawable/shoppingcart.png differ diff --git a/Test1/app/src/main/res/drawable/user_number.png b/Test1/app/src/main/res/drawable/user_number.png new file mode 100644 index 0000000..4997077 Binary files /dev/null and b/Test1/app/src/main/res/drawable/user_number.png differ diff --git a/Test1/app/src/main/res/layout/content_category.xml b/Test1/app/src/main/res/layout/content_category.xml index c9f40cc..f7e4bc8 100644 --- a/Test1/app/src/main/res/layout/content_category.xml +++ b/Test1/app/src/main/res/layout/content_category.xml @@ -12,12 +12,18 @@ android:background="#B9B9FF" android:orientation="horizontal"> - + android:textSize="18sp" + android:layout_marginTop="-5dp" + android:layout_gravity="center_horizontal" + android:textColor="@color/black" + android:src="@drawable/zuo" + android:onClick="onClick" + android:text="返回" + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/layout/content_nav.xml b/Test1/app/src/main/res/layout/content_nav.xml new file mode 100644 index 0000000..0e6b4f8 --- /dev/null +++ b/Test1/app/src/main/res/layout/content_nav.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/layout/content_product.xml b/Test1/app/src/main/res/layout/content_product.xml new file mode 100644 index 0000000..c946607 --- /dev/null +++ b/Test1/app/src/main/res/layout/content_product.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/layout/content_shopping.xml b/Test1/app/src/main/res/layout/content_shopping.xml new file mode 100644 index 0000000..e152fbb --- /dev/null +++ b/Test1/app/src/main/res/layout/content_shopping.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/layout/index_famous.xml b/Test1/app/src/main/res/layout/index_famous.xml new file mode 100644 index 0000000..200c7c2 --- /dev/null +++ b/Test1/app/src/main/res/layout/index_famous.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/layout/navigate.xml b/Test1/app/src/main/res/layout/navigate.xml new file mode 100644 index 0000000..b49d09a --- /dev/null +++ b/Test1/app/src/main/res/layout/navigate.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/layout/register.xml b/Test1/app/src/main/res/layout/register.xml index 15a5368..edd68ec 100644 --- a/Test1/app/src/main/res/layout/register.xml +++ b/Test1/app/src/main/res/layout/register.xml @@ -31,7 +31,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" - android:layout_marginTop="10dp" + android:layout_marginTop="3dp" android:orientation="horizontal"> + + + + + + android:layout_marginTop="-18dp"> + + + + + + + + \ No newline at end of file diff --git a/Test1/app/src/main/res/values/refs.xml b/Test1/app/src/main/res/values/refs.xml new file mode 100644 index 0000000..a6b3dae --- /dev/null +++ b/Test1/app/src/main/res/values/refs.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file