master
chenjunda 2 years ago
parent 724a75b963
commit 037b683990

@ -94,7 +94,6 @@
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND> </AND>
</match> </match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule> </rule>
</section> </section>
<section> <section>

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="D:\android_pro\android_avd\.android\avd\Pixel_3a_XL_API_30.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-04-24T12:42:06.815400300Z" />
</component>
</project>

@ -4,10 +4,10 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="GRADLE" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-11" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

@ -4,8 +4,8 @@ android {
compileSdkVersion 30 compileSdkVersion 30
buildToolsVersion "30.0.2" buildToolsVersion "30.0.2"
defaultConfig { defaultConfig {
applicationId "com.example.orangesale_05" applicationId "com.example.orangesale_end"
minSdkVersion 23 minSdkVersion 26
targetSdkVersion 30 targetSdkVersion 30
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -21,7 +21,6 @@ android {
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
} }
} }
dependencies { dependencies {
@ -32,4 +31,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'liji.library.dev:citypickerview:1.1.0' implementation 'liji.library.dev:citypickerview:1.1.0'
implementation "com.squareup.okhttp3:okhttp:4.2.2"
implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.12'
} }

@ -1,4 +1,4 @@
package com.example.orangesale_05; package com.example.orangesale_end;
import android.content.Context; import android.content.Context;
@ -22,6 +22,6 @@ public class ExampleInstrumentedTest {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.orangesale_05", appContext.getPackageName()); assertEquals("com.example.orangesale_end", appContext.getPackageName());
} }
} }

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.orangesale_05"> package="com.example.orangesale_end">
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:usesCleartextTraffic="true"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
@ -20,6 +21,10 @@
<activity android:name=".activity.UserActivity" /> <activity android:name=".activity.UserActivity" />
<activity android:name=".activity.CategoryActivity" /> <activity android:name=".activity.CategoryActivity" />
<activity android:name=".activity.IndexActivity" /> <activity android:name=".activity.IndexActivity" />
<service
android:name=".service.TimeService"
android:enabled="true" />
</application> </application>
</manifest> </manifest>

@ -1,68 +0,0 @@
package com.example.orangesale_05.dataoperation;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import androidx.annotation.Nullable;
public class OrangeDatabase extends SQLiteOpenHelper {
public OrangeDatabase(@Nullable Context context) {
super(context, "orange.db3", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
//创建用户表
String sql = "create table orange_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50))";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
/**
*
*
* @param sqLiteDatabase
* @param username
* @param password
* @param sex
* @param city
*/
public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city) {
ContentValues contentValues = new ContentValues();
contentValues.put("username", username);
contentValues.put("password", password);
contentValues.put("sex", sex);
contentValues.put("city", city);
sqLiteDatabase.insert("orange_user", null, contentValues);
sqLiteDatabase.close();
}
/**
*
*
* @param sqLiteDatabase
* @param bundle
* @return
*/
public Bundle queryUserInfo(SQLiteDatabase sqLiteDatabase, Bundle bundle) {
String username = bundle.getString("username");
Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=?", new String[]{username});
if (cursor != null) {
while (cursor.moveToNext()) {
bundle.putString("sex", cursor.getString(3));
bundle.putString("city", cursor.getString(4));
}
}
cursor.close();
sqLiteDatabase.close();
return bundle;
}
}

@ -1,21 +0,0 @@
package com.example.orangesale_05.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.orangesale_05.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;
}
}

@ -1,21 +0,0 @@
package com.example.orangesale_05.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.orangesale_05.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;
}
}

@ -1,9 +1,8 @@
package com.example.orangesale_05; package com.example.orangesale_end;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@ -11,9 +10,12 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.example.orangesale_05.activity.IndexActivity; import com.example.orangesale_end.activity.IndexActivity;
import com.example.orangesale_05.activity.RegisterActivity; import com.example.orangesale_end.activity.RegisterActivity;
import com.example.orangesale_05.dataoperation.OrangeDatabase; import com.example.orangesale_end.entity.OrangeUser;
import com.example.orangesale_end.netrequest.OkHttpUser;
import java.io.IOException;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button registerButton, loginButton; private Button registerButton, loginButton;
@ -23,7 +25,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.user_login); setContentView(R.layout.user_login);
init(); init();
} }
@ -36,19 +37,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
break; break;
case R.id.login: case R.id.login:
//注册时,我们引入了数据库,登录这里可以通过数据库进行验证,验证跳转到首页,不通过进行提示 //注册时,我们引入了数据库,登录这里可以通过数据库进行验证,验证跳转到首页,不通过进行提示
if (validateLogin()) { Thread thread = new Thread(runnable);
Intent intent1 = new Intent(MainActivity.this, IndexActivity.class); thread.start();
Bundle bundle = new Bundle();
OrangeDatabase orangeDatabase = new OrangeDatabase(MainActivity.this);
bundle.putString("username", usernameText.getText().toString());
bundle = orangeDatabase.queryUserInfo(orangeDatabase.getReadableDatabase(), bundle);
intent1.putExtras(bundle);
startActivity(intent1);
} else {
Toast.makeText(MainActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show();
}
break; break;
} }
} }
//界面组件初始化 //界面组件初始化
@ -63,18 +56,37 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
/** /**
* *
*
* @return
*/ */
private boolean validateLogin() { Runnable runnable = new Runnable() {
String username = usernameText.getText().toString(); @Override
String password = paswdEdit.getText().toString(); public void run() {
OrangeDatabase orangeDatabase = new OrangeDatabase(MainActivity.this); String username = usernameText.getText().toString();
SQLiteDatabase sqLiteDatabase = orangeDatabase.getReadableDatabase(); String password = paswdEdit.getText().toString();
Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=? and password=?", new String[]{username, password}); OrangeUser orangeUser = new OrangeUser();
if (cursor.getCount() > 0) { orangeUser.setUsername(username);
return true; orangeUser.setPassword(password);
OkHttpUser okHttpUser = new OkHttpUser();
OrangeUser orangeUser1 = null;
try {
orangeUser1 = okHttpUser.userLogin(orangeUser);
if (orangeUser1 != null) {
Intent intent1 = new Intent(MainActivity.this, IndexActivity.class);
Bundle bundle = new Bundle();
bundle.putString("username", usernameText.getText().toString());
bundle.putString("password", orangeUser1.getPassword());
bundle.putString("city", orangeUser1.getCity());
bundle.putString("sex", orangeUser1.getSex());
intent1.putExtras(bundle);
startActivity(intent1);
} else {
//解决在子线程中调用Toast的异常情况处理
Looper.prepare();
Toast.makeText(MainActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show();
Looper.loop();
}
} catch (IOException e) {
e.printStackTrace();
}
} }
return false; };
}
} }

@ -1,4 +1,4 @@
package com.example.orangesale_05.activity; package com.example.orangesale_end.activity;
import android.app.Activity; import android.app.Activity;
import android.app.FragmentManager; import android.app.FragmentManager;
@ -8,10 +8,10 @@ import android.widget.ListView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import com.example.orangesale_05.adapter.Adapter; import com.example.orangesale_end.adapter.Adapter;
import com.example.orangesale_05.entity.Product; import com.example.orangesale_end.entity.Product;
import com.example.orangesale_05.fragment.SetDetailFragment; import com.example.orangesale_end.fragment.SetDetailFragment;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -63,17 +63,15 @@ public class CategoryActivity extends Activity {
productCategory.add("橙子"); productCategory.add("橙子");
productCategory.add("柚子"); productCategory.add("柚子");
Product product = new Product(); Product product = new Product();
product.setImageUrlId(R.drawable.jz1); product.setImageUrlId(R.drawable.arrow_down);
product.setProductName("橘子"); product.setProductName("橘子");
product.setProductPrice(new BigDecimal("9.9")); product.setProductPrice(new BigDecimal("9.9"));
Product product1 = new Product(); Product product1 = new Product();
product1.setImageUrlId(R.drawable.jz1); product1.setImageUrlId(R.drawable.cz1);
product1.setProductName("橙子"); product1.setProductName("橙子");
product1.setProductPrice(new BigDecimal("29.9")); product1.setProductPrice(new BigDecimal("29.9"));
Product product2 = new Product(); Product product2 = new Product();
product2.setImageUrlId(R.drawable.yz1); product2.setImageUrlId(R.drawable.arrow_left);
product2.setProductName("柚子"); product2.setProductName("柚子");
product2.setProductPrice(new BigDecimal("19.9")); product2.setProductPrice(new BigDecimal("19.9"));
productList.add(product); productList.add(product);

@ -1,4 +1,4 @@
package com.example.orangesale_05.activity; package com.example.orangesale_end.activity;
import android.app.Activity; import android.app.Activity;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
@ -9,11 +9,12 @@ import android.widget.LinearLayout;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import com.example.orangesale_05.fragment.IndexFragment; import com.example.orangesale_end.fragment.IndexFragment;
import com.example.orangesale_05.fragment.PearsonFragment; import com.example.orangesale_end.fragment.PearsonFragment;
import com.example.orangesale_05.fragment.ProductFragment; import com.example.orangesale_end.fragment.ProductFragment;
import com.example.orangesale_05.fragment.ShoppingCartFragment; import com.example.orangesale_end.fragment.ShoppingCartFragment;
import com.example.orangesale_end.service.TimeService;
public class IndexActivity extends Activity implements View.OnClickListener { public class IndexActivity extends Activity implements View.OnClickListener {
private IndexFragment indexFragment; private IndexFragment indexFragment;
@ -28,6 +29,8 @@ public class IndexActivity extends Activity implements View.OnClickListener {
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
init(); init();
initIndexFragment(); initIndexFragment();
Thread thread = new Thread(runnable);
thread.start();
} }
/** /**
@ -71,7 +74,7 @@ public class IndexActivity extends Activity implements View.OnClickListener {
if (indexFragment == null) { if (indexFragment == null) {
indexFragment = new IndexFragment(); indexFragment = new IndexFragment();
} }
transaction.replace(R.id.main_content, indexFragment); transaction.replace(R.id.main_content0, indexFragment);
transaction.commit(); transaction.commit();
} }
@ -84,7 +87,7 @@ public class IndexActivity extends Activity implements View.OnClickListener {
if (productFragment == null) { if (productFragment == null) {
productFragment = new ProductFragment(); productFragment = new ProductFragment();
} }
transaction.replace(R.id.main_content, productFragment); transaction.replace(R.id.main_content0, productFragment);
transaction.commit(); transaction.commit();
} }
@ -97,7 +100,7 @@ public class IndexActivity extends Activity implements View.OnClickListener {
if (shoppingCartFragment == null) { if (shoppingCartFragment == null) {
shoppingCartFragment = new ShoppingCartFragment(); shoppingCartFragment = new ShoppingCartFragment();
} }
transaction.replace(R.id.main_content, shoppingCartFragment); transaction.replace(R.id.main_content0, shoppingCartFragment);
transaction.commit(); transaction.commit();
} }
@ -113,8 +116,13 @@ public class IndexActivity extends Activity implements View.OnClickListener {
pearsonFragment = new PearsonFragment(); pearsonFragment = new PearsonFragment();
pearsonFragment.setArguments(bundle); pearsonFragment.setArguments(bundle);
} }
transaction.replace(R.id.main_content, pearsonFragment); transaction.replace(R.id.main_content0, pearsonFragment);
transaction.commit(); transaction.commit();
} }
Runnable runnable = () -> {
Intent intent = new Intent(IndexActivity.this, TimeService.class);
startService(intent);
};
} }

@ -1,10 +1,9 @@
package com.example.orangesale_05.activity; package com.example.orangesale_end.activity;
import android.content.ContentValues;
import android.content.Intent; import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Looper;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@ -16,8 +15,11 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.lljjcoder.citypickerview.widget.CityPicker; import com.lljjcoder.citypickerview.widget.CityPicker;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import com.example.orangesale_05.dataoperation.OrangeDatabase; import com.example.orangesale_end.entity.OrangeUser;
import com.example.orangesale_end.netrequest.OkHttpUser;
import java.io.IOException;
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener { public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
private EditText usernameEdit, passwordEdit, surePasswordEdit; private EditText usernameEdit, passwordEdit, surePasswordEdit;
@ -60,7 +62,9 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL
break; break;
case R.id.reg_register: case R.id.reg_register:
//注册验证方法 //注册验证方法
validateRegister(); //validateRegister();
Thread thread = new Thread(runnable);
thread.start();
break; break;
} }
@ -106,44 +110,6 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL
} }
/**
*
*/
public void validateRegister() {
String username = usernameEdit.getText().toString();
String password = passwordEdit.getText().toString();
String surePassword = surePasswordEdit.getText().toString();
String city = cityText.getText().toString();
//判断两次密码是否输入一致
if (password.equals(surePassword)) {
//这里也可以再进行其它的验证,如是否符合要求等,符合就进行插入数据库操作
if (!username.equals("") || !password.equals("")) {
if (!city.equals("")) {
Bundle bundle = new Bundle();
bundle.putString("username", username);
bundle.putString("password", password);
bundle.putString("sex", sexStr);
bundle.putString("city", city);
//本节将使用安卓自身带的SQLite数据库的方式存储注册的信息之前直接传输显示在界面是的方式
OrangeDatabase orangeDatabase = new OrangeDatabase(RegisterActivity.this);
SQLiteDatabase sqLiteDatabase = orangeDatabase.getWritableDatabase();
insertData(sqLiteDatabase, bundle);
Intent intent = new Intent(RegisterActivity.this, IndexActivity.class);
intent.putExtras(bundle);
startActivity(intent);
} else {
Toast.makeText(RegisterActivity.this, "请选择地址", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(RegisterActivity.this, "账号或密码未填写", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(RegisterActivity.this, "两次密码输入不一致", Toast.LENGTH_SHORT).show();
}
}
@Override @Override
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
//根据用户选择来改变sex的值 //根据用户选择来改变sex的值
@ -151,18 +117,60 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL
} }
/** /**
* *
*
* @param sqLiteDatabase
* @param bundle
*/ */
private void insertData(SQLiteDatabase sqLiteDatabase, Bundle bundle) { Runnable runnable = new Runnable() {
ContentValues contentValues = new ContentValues(); @Override
contentValues.put("username", bundle.getString("username")); public void run() {
contentValues.put("password", bundle.getString("password")); String username = usernameEdit.getText().toString();
contentValues.put("sex", bundle.getString("sex")); String password = passwordEdit.getText().toString();
contentValues.put("city", bundle.getString("city")); String surePassword = surePasswordEdit.getText().toString();
sqLiteDatabase.insert("orange_user", null, contentValues); String city = cityText.getText().toString();
sqLiteDatabase.close(); //判断两次密码是否输入一致
} if (password.equals(surePassword)) {
//这里也可以再进行其它的验证,如是否符合要求等,符合就进行插入数据库操作
if (!username.equals("") || !password.equals("")) {
if (!city.equals("")) {
Bundle bundle = new Bundle();
bundle.putString("username", username);
bundle.putString("password", password);
bundle.putString("sex", sexStr);
bundle.putString("city", city);
OrangeUser orangeUser = new OrangeUser();
orangeUser.setUsername(username);
orangeUser.setPassword(password);
orangeUser.setCity(city);
orangeUser.setSex(sexStr);
//将使用安卓自身带的SQLite数据库换成调用okhttp的方式
OkHttpUser okHttpUser = new OkHttpUser();
try {
if (okHttpUser.userRegister(orangeUser)) {
Intent intent = new Intent(RegisterActivity.this, IndexActivity.class);
intent.putExtras(bundle);
startActivity(intent);
} else {
Looper.prepare();
Toast.makeText(RegisterActivity.this, "注册失败!", Toast.LENGTH_SHORT).show();
Looper.loop();
}
} catch (IOException e) {
e.printStackTrace();
}
} else {
Looper.prepare();
Toast.makeText(RegisterActivity.this, "请选择地址", Toast.LENGTH_SHORT).show();
Looper.loop();
}
} else {
Looper.prepare();
Toast.makeText(RegisterActivity.this, "账号或密码未填写", Toast.LENGTH_SHORT).show();
Looper.loop();
}
} else {
Looper.prepare();
Toast.makeText(RegisterActivity.this, "两次密码输入不一致", Toast.LENGTH_SHORT).show();
Looper.loop();
}
}
};
} }

@ -1,4 +1,4 @@
package com.example.orangesale_05.activity; package com.example.orangesale_end.activity;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@ -10,7 +10,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
public class UserActivity extends Activity implements View.OnClickListener { public class UserActivity extends Activity implements View.OnClickListener {
private ImageView userIconImage; private ImageView userIconImage;
@ -38,7 +38,7 @@ public class UserActivity extends Activity implements View.OnClickListener {
userPayLine = findViewById(R.id.user_pay); userPayLine = findViewById(R.id.user_pay);
userSettingLine = findViewById(R.id.user_setting); userSettingLine = findViewById(R.id.user_setting);
userGeneralLine = findViewById(R.id.user_general); userGeneralLine = findViewById(R.id.user_general);
userSearchProductLine = findViewById(R.id.user_searchProduct); // userSearchProductLine = findViewById(R.id.user_searchProduct);
userSearchProductLine.setOnClickListener(this); userSearchProductLine.setOnClickListener(this);
setData(); setData();
} }
@ -57,10 +57,10 @@ public class UserActivity extends Activity implements View.OnClickListener {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.user_searchProduct: /*case R.id.user_searchProduct:
Intent intent1 = new Intent(UserActivity.this, CategoryActivity.class); Intent intent1 = new Intent(UserActivity.this, CategoryActivity.class);
startActivity(intent1); startActivity(intent1);
break; break;*/
} }
} }
} }

@ -1,4 +1,4 @@
package com.example.orangesale_05.adapter; package com.example.orangesale_end.adapter;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
@ -9,7 +9,7 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.TextView; import android.widget.TextView;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import java.util.List; import java.util.List;

@ -0,0 +1,78 @@
package com.example.orangesale_end.adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.orangesale_end.R;
import com.example.orangesale_end.entity.Condition;
import java.util.List;
public class ListViewAdapter extends BaseAdapter {
private List<Condition> conditionList;
private LayoutInflater layoutInflater;
private int selectedPosition = -1;
private int selectColor = Color.GRAY;
public ListViewAdapter(Context context, List<Condition> conditionList) {
this.conditionList = conditionList;
this.layoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return conditionList.size();
}
@Override
public Object getItem(int position) {
return conditionList.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) {
convertView = layoutInflater.inflate(R.layout.product_condition_item, null);
viewHolder = new ViewHolder();
viewHolder.imageView = convertView.findViewById(R.id.condition_icon);
viewHolder.jiange = convertView.findViewById(R.id.image_jiange);
viewHolder.textView = convertView.findViewById(R.id.condition_name);
viewHolder.linearLayout = convertView.findViewById(R.id.item_bg);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Condition condition = conditionList.get(position);
if (condition != null) {
viewHolder.imageView.setBackgroundResource(condition.getConditionIcon());
viewHolder.textView.setText(condition.getConditionName());
viewHolder.jiange.setBackgroundColor(Color.rgb(207, 207, 207));
if (selectedPosition == position) {
viewHolder.linearLayout.setBackgroundColor(selectColor);
}
}
return convertView;
}
class ViewHolder {
ImageView imageView, jiange;
TextView textView;
LinearLayout linearLayout;
}
}

@ -1,7 +1,6 @@
package com.example.orangesale_05.adapter; package com.example.orangesale_end.adapter;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -9,28 +8,29 @@ import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import com.example.orangesale_05.entity.Product; import com.example.orangesale_end.entity.OrangeProductPack;
import java.util.List; import java.util.List;
public class ProductAdapter extends BaseAdapter { public class ProductAdapter extends BaseAdapter {
private List<Product> productList; //private List<Product> productList;
private List<OrangeProductPack> orangeProductList;
private LayoutInflater layoutInflater; private LayoutInflater layoutInflater;
public ProductAdapter(Context context, List<Product> productList) { public ProductAdapter(Context context, List<OrangeProductPack> orangeProductList) {
this.productList = productList; this.orangeProductList = orangeProductList;
this.layoutInflater = LayoutInflater.from(context); this.layoutInflater = LayoutInflater.from(context);
} }
@Override @Override
public int getCount() { public int getCount() {
return productList.size(); return orangeProductList.size();
} }
@Override @Override
public Object getItem(int position) { public Object getItem(int position) {
return productList.get(position); return orangeProductList.get(position);
} }
@Override @Override
@ -44,19 +44,18 @@ public class ProductAdapter extends BaseAdapter {
if (convertView == null) { if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.categoty_detail_content, null); convertView = layoutInflater.inflate(R.layout.categoty_detail_content, null);
viewHolder = new ViewHolder(); viewHolder = new ViewHolder();
viewHolder.productImage = convertView.findViewById(R.id.category_product_image1); viewHolder.productImage = convertView.findViewById(R.id.category_product_image);
viewHolder.productName = convertView.findViewById(R.id.category_product_name1); viewHolder.productName = convertView.findViewById(R.id.category_product_name);
viewHolder.productPrice = convertView.findViewById(R.id.category_product_price1); viewHolder.productPrice = convertView.findViewById(R.id.category_product_price);
convertView.setTag(viewHolder); convertView.setTag(viewHolder);
} else { } else {
viewHolder = (ViewHolder) convertView.getTag(); viewHolder = (ViewHolder) convertView.getTag();
} }
Product product = productList.get(position); OrangeProductPack product = orangeProductList.get(position);
Log.i("product", "getView: "+product.toString());
if (product != null) { if (product != null) {
viewHolder.productImage.setBackgroundResource(product.getImageUrlId()); viewHolder.productImage.setImageBitmap(product.getImgBitmap());
viewHolder.productName.setText(product.getProductName()); viewHolder.productName.setText(product.getName());
viewHolder.productPrice.setText(String.valueOf(product.getProductPrice())); viewHolder.productPrice.setText(String.format("%s元", String.valueOf(product.getPrice())));
} }
return convertView; return convertView;
} }
@ -65,4 +64,5 @@ public class ProductAdapter extends BaseAdapter {
ImageView productImage; ImageView productImage;
TextView productName, productPrice; TextView productName, productPrice;
} }
} }

@ -0,0 +1,30 @@
package com.example.orangesale_end.entity;
public class Condition {
private Integer conditionIcon;
private String conditionName;
public Integer getConditionIcon() {
return conditionIcon;
}
public void setConditionIcon(Integer conditionIcon) {
this.conditionIcon = conditionIcon;
}
public String getConditionName() {
return conditionName;
}
public void setConditionName(String conditionName) {
this.conditionName = conditionName;
}
@Override
public String toString() {
return "Condition{" +
"conditionIcon=" + conditionIcon +
", conditionName='" + conditionName + '\'' +
'}';
}
}

@ -0,0 +1,52 @@
package com.example.orangesale_end.entity;
import java.sql.Timestamp;
public class OrangeMessage {
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Timestamp getSendTime() {
return sendTime;
}
public void setSendTime(Timestamp sendTime) {
this.sendTime = sendTime;
}
public String getUsed() {
return used;
}
public void setUsed(String used) {
this.used = used;
}
private Integer id;
private String content;
private Timestamp sendTime;
private String used;
@Override
public String toString() {
return "OrangeMessage{" +
"id=" + id +
", content='" + content + '\'' +
", sendTime=" + sendTime +
", used='" + used + '\'' +
'}';
}
}

@ -0,0 +1,64 @@
package com.example.orangesale_end.entity;
import java.math.BigDecimal;
import java.sql.Timestamp;
public class OrangeProduct {
private Integer id;
private String name;
private BigDecimal price;
private String imgUrl;
@Override
public String toString() {
return "OrangeProduct{" +
"id=" + id +
", name='" + name + '\'' +
", price=" + price +
", imgUrl='" + imgUrl + '\'' +
", addTime=" + addTime +
'}';
}
public Timestamp getAddTime() {
return addTime;
}
public void setAddTime(Timestamp addTime) {
this.addTime = addTime;
}
private Timestamp addTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
}

@ -0,0 +1,66 @@
package com.example.orangesale_end.entity;
import android.graphics.Bitmap;
import java.math.BigDecimal;
import java.sql.Timestamp;
public class OrangeProductPack {
private Integer id;
private String name;
private Timestamp addTime;
private Bitmap imgBitmap;
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
private BigDecimal price;
@Override
public String toString() {
return "OrangeProductPack{" +
"id=" + id +
", name='" + name + '\'' +
", addTime=" + addTime +
", imgBitmap=" + imgBitmap +
", price=" + price +
'}';
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Timestamp getAddTime() {
return addTime;
}
public void setAddTime(Timestamp addTime) {
this.addTime = addTime;
}
public Bitmap getImgBitmap() {
return imgBitmap;
}
public void setImgBitmap(Bitmap imgBitmap) {
this.imgBitmap = imgBitmap;
}
}

@ -1,4 +1,4 @@
package com.example.orangesale_05.entity; package com.example.orangesale_end.entity;
public class OrangeUser { public class OrangeUser {
private Integer id; private Integer id;

@ -1,4 +1,4 @@
package com.example.orangesale_05.entity; package com.example.orangesale_end.entity;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -27,15 +27,8 @@ public class Product {
public void setImageUrlId(Integer imageUrlId) { public void setImageUrlId(Integer imageUrlId) {
this.imageUrlId = imageUrlId; this.imageUrlId = imageUrlId;
} }
public Integer getImageCar() {
return imageCar;
}
public void setImageCar(Integer imageCar) {
this.imageCar = imageCar;
}
private Integer imageUrlId,imageCar; private Integer imageUrlId;
private String productName; private String productName;
private BigDecimal productPrice; private BigDecimal productPrice;

@ -0,0 +1,44 @@
package com.example.orangesale_end.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;
}

@ -1,6 +1,7 @@
package com.example.orangesale_05.fragment; package com.example.orangesale_end.fragment;
import android.app.Fragment; import android.app.Fragment;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -12,20 +13,25 @@ import android.widget.SearchView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import com.example.orangesale_05.adapter.ProductAdapter; import com.example.orangesale_end.adapter.ProductAdapter;
import com.example.orangesale_05.entity.Product; import com.example.orangesale_end.entity.OrangeProductPack;
import com.example.orangesale_end.entity.Product;
import com.example.orangesale_end.netrequest.OkHttpClientProduct;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class IndexFragment extends Fragment implements View.OnClickListener { public class IndexFragment extends Fragment implements View.OnClickListener {
private SearchView searchView; private SearchView searchView;
private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine; private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine;
private GridView gridView; private GridView gridView;
private List<Product> productList;
private ProductAdapter productAdapter; private ProductAdapter productAdapter;
private List<Product> productList;
private List<OrangeProductPack> list = new ArrayList<>();
@Nullable @Nullable
@Override @Override
@ -58,9 +64,8 @@ public class IndexFragment extends Fragment implements View.OnClickListener {
appleLine = view.findViewById(R.id.apple); appleLine = view.findViewById(R.id.apple);
appleLine.setOnClickListener(this); appleLine.setOnClickListener(this);
gridView = view.findViewById(R.id.index_famous_gridview); gridView = view.findViewById(R.id.index_famous_gridview);
initData(); //initData();
productAdapter = new ProductAdapter(getActivity(), productList); new SearchProductTask().execute();
gridView.setAdapter(productAdapter);
} }
@ -78,32 +83,26 @@ public class IndexFragment extends Fragment implements View.OnClickListener {
product.setImageUrlId(R.drawable.jz1); product.setImageUrlId(R.drawable.jz1);
product.setProductName("橘子"); product.setProductName("橘子");
product.setProductPrice(new BigDecimal("9.9")); product.setProductPrice(new BigDecimal("9.9"));
Product product1 = new Product(); Product product1 = new Product();
product1.setImageUrlId(R.drawable.cz2); product1.setImageUrlId(R.drawable.cz1);
product1.setProductName("橙子"); product1.setProductName("橙子");
product1.setProductPrice(new BigDecimal("29.9")); product1.setProductPrice(new BigDecimal("29.9"));
Product product2 = new Product(); Product product2 = new Product();
product2.setImageUrlId(R.drawable.yz2); product2.setImageUrlId(R.drawable.yz1);
product2.setProductName("柚子"); product2.setProductName("柚子");
product2.setProductPrice(new BigDecimal("19.9")); product2.setProductPrice(new BigDecimal("19.9"));
Product product3 = new Product(); Product product3 = new Product();
product3.setImageUrlId(R.drawable.xg2); product3.setImageUrlId(R.drawable.xg1);
product3.setProductName("西瓜"); product3.setProductName("西瓜");
product3.setProductPrice(new BigDecimal("19.9")); product3.setProductPrice(new BigDecimal("19.9"));
Product product4 = new Product(); Product product4 = new Product();
product4.setImageUrlId(R.drawable.pg1); product4.setImageUrlId(R.drawable.pg1);
product4.setProductName("苹果"); product4.setProductName("苹果");
product4.setProductPrice(new BigDecimal("49.9")); product4.setProductPrice(new BigDecimal("49.9"));
Product product5 = new Product(); Product product5 = new Product();
product5.setImageUrlId(R.drawable.nm2); product5.setImageUrlId(R.drawable.nm1);
product5.setProductName("柠檬"); product5.setProductName("柠檬");
product5.setProductPrice(new BigDecimal("9.9")); product5.setProductPrice(new BigDecimal("9.9"));
productList.add(product); productList.add(product);
productList.add(product1); productList.add(product1);
productList.add(product2); productList.add(product2);
@ -112,4 +111,27 @@ public class IndexFragment extends Fragment implements View.OnClickListener {
productList.add(product5); productList.add(product5);
} }
/**
*
*/
class SearchProductTask extends AsyncTask<Void, Void, List<OrangeProductPack>> {
@Override
protected List<OrangeProductPack> doInBackground(Void... voids) {
OkHttpClientProduct clientProduct = new OkHttpClientProduct();
try {
list = clientProduct.getProductPack();
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
@Override
protected void onPostExecute(List<OrangeProductPack> orangeProducts) {
productAdapter = new ProductAdapter(getActivity(), list);
gridView.setAdapter(productAdapter);
}
}
} }

@ -1,4 +1,4 @@
package com.example.orangesale_05.fragment; package com.example.orangesale_end.fragment;
import android.app.Fragment; import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
@ -12,7 +12,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
public class PearsonFragment extends Fragment implements View.OnClickListener { public class PearsonFragment extends Fragment implements View.OnClickListener {
private ImageView userIconImage; private ImageView userIconImage;

@ -0,0 +1,102 @@
package com.example.orangesale_end.fragment;
import android.app.Fragment;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.Spinner;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.example.orangesale_end.R;
import com.example.orangesale_end.adapter.ListViewAdapter;
import com.example.orangesale_end.adapter.ProductAdapter;
import com.example.orangesale_end.entity.Condition;
import com.example.orangesale_end.entity.OrangeProductPack;
import com.example.orangesale_end.netrequest.OkHttpClientProduct;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ProductFragment extends Fragment {
private Spinner conditonListSpinner;
private ListViewAdapter listViewAdapter;
private List<Condition> conditionList;
private GridView productGridView;
private List<OrangeProductPack> orangeProductList = new ArrayList<>();
@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);
init(view);
return view;
}
/**
*
*
* @param view
*/
private void init(View view) {
conditonListSpinner = view.findViewById(R.id.product_select_condition);
initCondList();
listViewAdapter = new ListViewAdapter(getActivity(), conditionList);
conditonListSpinner.setAdapter(listViewAdapter);
productGridView = view.findViewById(R.id.product_list);
new SearchProductTask().execute();
}
/**
* conditionList
*/
private void initCondList() {
conditionList = new ArrayList<>();
Condition allCondition = new Condition();
allCondition.setConditionIcon(R.drawable.all);
allCondition.setConditionName("全部");
Condition saleCondition = new Condition();
saleCondition.setConditionIcon(R.drawable.salenum);
saleCondition.setConditionName("按销量高低排序");
Condition timeCondition = new Condition();
timeCondition.setConditionIcon(R.drawable.time);
timeCondition.setConditionName("按上市时间排序");
Condition priceCondition = new Condition();
priceCondition.setConditionIcon(R.drawable.price);
priceCondition.setConditionName("按商品价格排序");
conditionList.add(allCondition);
conditionList.add(saleCondition);
conditionList.add(timeCondition);
conditionList.add(priceCondition);
}
/**
*
*/
class SearchProductTask extends AsyncTask<Void, Void, List<OrangeProductPack>> {
@Override
protected List<OrangeProductPack> doInBackground(Void... voids) {
OkHttpClientProduct clientProduct = new OkHttpClientProduct();
try {
orangeProductList = clientProduct.getProductPack();
} catch (IOException e) {
e.printStackTrace();
}
return orangeProductList;
}
@Override
protected void onPostExecute(List<OrangeProductPack> orangeProducts) {
ProductAdapter productAdapter = new ProductAdapter(getActivity(), orangeProductList);
productGridView.setAdapter(productAdapter);
}
}
}

@ -1,4 +1,4 @@
package com.example.orangesale_05.fragment; package com.example.orangesale_end.fragment;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Fragment; import android.app.Fragment;
@ -13,14 +13,14 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.example.orangesale_05.R; import com.example.orangesale_end.R;
import com.example.orangesale_05.activity.CategoryActivity; import com.example.orangesale_end.activity.CategoryActivity;
import java.util.Objects; import java.util.Objects;
public class SetDetailFragment extends Fragment { public class SetDetailFragment extends Fragment {
private View view; private View view;
private ImageView imageView,imageCar; private ImageView imageView;
private TextView nameText, priceText; private TextView nameText, priceText;
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@ -35,7 +35,6 @@ public class SetDetailFragment extends Fragment {
Objects.requireNonNull(categoryActivity).setOnChangeListener(product -> { Objects.requireNonNull(categoryActivity).setOnChangeListener(product -> {
Log.i("sss", "onCreateView: " + product.getProductName()); Log.i("sss", "onCreateView: " + product.getProductName());
imageView.setBackgroundResource(product.getImageUrlId()); imageView.setBackgroundResource(product.getImageUrlId());
imageCar.setBackgroundResource(product.getImageCar());
nameText.setText(product.getProductName()); nameText.setText(product.getProductName());
priceText.setText(product.getProductPrice().toString()); priceText.setText(product.getProductPrice().toString());
}); });
@ -46,10 +45,9 @@ public class SetDetailFragment extends Fragment {
* *
*/ */
private void init() { private void init() {
imageView = view.findViewById(R.id.category_product_image1); imageView = view.findViewById(R.id.category_product_image);
nameText = view.findViewById(R.id.category_product_name1); nameText = view.findViewById(R.id.category_product_name);
priceText = view.findViewById(R.id.category_product_price1); priceText = view.findViewById(R.id.category_product_price);
imageCar = view.findViewById(R.id.category_product_car);
} }
} }

@ -0,0 +1,61 @@
package com.example.orangesale_end.fragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.example.orangesale_end.R;
import com.example.orangesale_end.entity.ShoppingCart;
import java.util.ArrayList;
import java.util.List;
public class ShoppingCartFragment extends Fragment implements View.OnClickListener {
private Button walkButton;
private List<ShoppingCart> cartList = new ArrayList<>();
private ProductFragment productFragment;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view;
if (cartList.size() > 0) {
//有商品
view = LayoutInflater.from(getActivity()).inflate(R.layout.cart_have_product, container, false);
} else {
view = LayoutInflater.from(getActivity()).inflate(R.layout.cart_no_product, container, false);
}
init(view);
return view;
}
/**
*
*/
private void init(View view) {
walkButton = view.findViewById(R.id.random_search);
walkButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.random_search:
//开启事务fragment的控制是由事务来实现的
FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (productFragment == null) {
productFragment = new ProductFragment();
}
transaction.replace(R.id.main_content0, productFragment);
transaction.commit();
break;
}
}
}

@ -0,0 +1,80 @@
package com.example.orangesale_end.netrequest;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.example.orangesale_end.entity.OrangeProduct;
import com.example.orangesale_end.entity.OrangeProductPack;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class OkHttpClientProduct {
/**
*
*
* @return
*/
public List<OrangeProduct> getProduct() throws IOException {
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url("http://10.21.183.162:8081/orange/product/search")
.build();
Response response = okHttpClient.newCall(request).execute();
JSONObject jsonObject = JSON.parseObject(Objects.requireNonNull(response.body()).string());
List<OrangeProduct> list = JSON.parseObject(jsonObject.getString("data"), new TypeReference<List<OrangeProduct>>() {
});
return list;
}
/**
*
*
* @param imgUrl
* @return
* @throws IOException
*/
public Bitmap getImageBitMap(String imgUrl) throws IOException {
Bitmap bitmap;
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(imgUrl)
.build();
Response response = okHttpClient.newCall(request).execute();
byte[] bytes = Objects.requireNonNull(response.body()).bytes();
bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
return bitmap;
}
/**
*
*
* @return
* @throws IOException
*/
public List<OrangeProductPack> getProductPack() throws IOException {
List<OrangeProductPack> packList = new ArrayList<>();
List<OrangeProduct> list = getProduct();
for (OrangeProduct orangeProduct : list) {
OrangeProductPack orangeProductPack = new OrangeProductPack();
orangeProductPack.setId(orangeProduct.getId());
orangeProductPack.setImgBitmap(getImageBitMap(orangeProduct.getImgUrl()));
orangeProductPack.setAddTime(orangeProduct.getAddTime());
orangeProductPack.setPrice(orangeProduct.getPrice());
packList.add(orangeProductPack);
}
return packList;
}
}

@ -0,0 +1,39 @@
package com.example.orangesale_end.netrequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.orangesale_end.entity.OrangeMessage;
import java.io.IOException;
import java.util.Objects;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class OkHttpMessage {
/**
*
*
* @return
*/
public OrangeMessage consumeMessage() throws IOException {
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url("http://10.21.183.162:8081/orange/message/consumeMessage")
.build();
Response response = okHttpClient.newCall(request).execute();
JSONObject jsonObject = JSON.parseObject(Objects.requireNonNull(response.body()).string());
OrangeMessage orangeMessage = JSON.toJavaObject(jsonObject.getJSONObject("data"), OrangeMessage.class);
/**
*
*/
Request request1 = new Request.Builder()
.url("http://10.21.183.162:8081/orange/message/updateMessage")
.build();
okHttpClient.newCall(request1).execute();
return orangeMessage;
}
}

@ -0,0 +1,71 @@
package com.example.orangesale_end.netrequest;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.orangesale_end.entity.OrangeUser;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class OkHttpUser {
/**
*
*
* @param orangeUser
*/
public OrangeUser userLogin(OrangeUser orangeUser) throws IOException {
OkHttpClient okHttpClient= new OkHttpClient();
//数据类型为json格式
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
//将对象转为JSON字符串
String jsonStr = JSONObject.toJSONString(orangeUser);
RequestBody requestBody = RequestBody.create(jsonStr, mediaType);
Request request = new Request.Builder()
.url("http://10.21.183.162:8081/orange/user/login")
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute();
String responseStr = response.body().string();
System.out.println("responseStr = " + responseStr);
JSONObject jsonObject = JSON.parseObject(responseStr);
JSONObject jsonObject1 = jsonObject.getJSONObject("data");
OrangeUser orangeUser1 = JSON.toJavaObject(jsonObject1, OrangeUser.class);
return orangeUser1;
}
/**
*
*
* @param orangeUser
* @return
* @throws IOException
*/
public boolean userRegister(OrangeUser orangeUser) throws IOException {
OkHttpClient okHttpClient = new OkHttpClient();
//数据类型为json格式
MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
//将对象转为JSON字符串
String jsonStr = JSONObject.toJSONString(orangeUser);
RequestBody requestBody = RequestBody.create(jsonStr, mediaType);
Request request = new Request.Builder()
.url("http://10.21.183.162:8081/orange/user/register")
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute();
JSONObject jsonObject = JSON.parseObject(response.body().string());
Log.i("register", "userRegister: "+jsonObject);
return jsonObject.getBoolean("flag");
}
}

@ -0,0 +1,105 @@
package com.example.orangesale_end.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.AsyncTask;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import com.example.orangesale_end.R;
import com.example.orangesale_end.entity.OrangeMessage;
import com.example.orangesale_end.netrequest.OkHttpMessage;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
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() {
new ConsumeMessageTask().execute();
}
}, 0, period);
return super.onStartCommand(intent, flags, startId);
}
class ConsumeMessageTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
/**
* NotificationChannelandroid8.0ApptargetSDKVersion>=26
* channel
* Failed to post notification on channel null
*/
OkHttpMessage okHttpMessage = new OkHttpMessage();
OrangeMessage orangeMessage;
try {
orangeMessage = okHttpMessage.consumeMessage();
if (!Objects.isNull(orangeMessage)) {
Log.i("orangeMessage", "run: " + orangeMessage.toString());
NotificationChannel channel = new NotificationChannel("channel", "通知", NotificationManager.IMPORTANCE_DEFAULT);
manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
builder = new NotificationCompat.Builder(TimeService.this);
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
builder.setContentTitle("来自Melon的系统通知消息" + " " + formatter.format(date));
builder.setSmallIcon(R.drawable.cz1);
builder.setChannelId("channel");
builder.setContentText(orangeMessage.getContent());
builder.setAutoCancel(true);
builder.setDefaults(Notification.DEFAULT_ALL);
Notification notification = builder.build();
manager.notify(1, notification);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

@ -1,170 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 603 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 61 KiB

@ -15,7 +15,7 @@
<include layout="@layout/content_user"/> <include layout="@layout/content_user"/>
</LinearLayout>--> </LinearLayout>-->
<FrameLayout <FrameLayout
android:id="@+id/main_content" android:id="@+id/main_content0"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" /> android:layout_weight="1" />

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/shoppingcart_title" />
<!--有商品时的布局-->
<GridView
android:id="@+id/cart_productList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="1" />
</LinearLayout>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<include layout="@layout/shoppingcart_title" />
<!--无商品时的布局-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="160dp"
android:orientation="vertical">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="@drawable/gwc" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="Cart is Empty ~"
android:textColor="#B5B5B5"
android:textSize="20sp" />
<Button
android:id="@+id/random_search"
android:layout_width="180dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="25dp"
android:background="@drawable/button_login"
android:text="go shopping..."
android:textColor="#fff"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>

@ -6,9 +6,9 @@
<TextView <TextView
android:id="@+id/categor_titles" android:id="@+id/categor_titles"
android:layout_width="100dp" android:layout_width="match_parent"
android:gravity="center" android:gravity="center"
android:layout_height="60dp" android:layout_height="wrap_content"
android:textSize="18sp" android:textSize="18sp"
android:text="标题" /> android:text="标题" />
</LinearLayout> </LinearLayout>

@ -2,50 +2,31 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#fff"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
<LinearLayout android:id="@+id/category_product_image"
android:layout_width="match_parent" android:layout_width="120dp"
android:layout_height="match_parent" android:layout_marginTop="5dp"
android:orientation="horizontal"> android:layout_height="120dp"
<ImageView android:layout_gravity="center" />
android:id="@+id/category_product_image1"
android:layout_width="100dp" <TextView
android:layout_height="100dp" android:id="@+id/category_product_name"
android:layout_gravity="left" android:layout_width="wrap_content"
android:layout_marginLeft="10dp" android:layout_height="30dp"
android:layout_marginTop="20dp"/> android:layout_gravity="center"
android:layout_marginTop="2dp"
<LinearLayout android:textColor="#050505"
android:layout_width="match_parent" android:textSize="16sp" />
android:layout_height="wrap_content"
android:orientation="vertical"> <TextView
<TextView android:id="@+id/category_product_price"
android:id="@+id/category_product_name1" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="30dp"
android:layout_height="30dp" android:layout_gravity="center"
android:layout_marginTop="50dp" android:layout_marginTop="2dp"
android:textColor="#050505" android:gravity="center"
android:textSize="23sp" android:textColor="#050505"
android:textStyle="bold"/> android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="@+id/category_product_price1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:textColor="#050505"
android:textSize="23sp"
android:textStyle="bold"/>
<ImageView
android:id="@+id/category_product_car"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="right"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -5,30 +5,7 @@
android:background="#E8E8E8" android:background="#E8E8E8"
android:orientation="vertical"> android:orientation="vertical">
<!--标题--> <include layout="@layout/content_product_title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/h5"
android:orientation="horizontal">
<ImageView
android:id="@+id/category_return"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/arrow_left" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="center"
android:text="商品种类"
android:textColor="#FFF"
android:textSize="20sp" />
</LinearLayout>
<!--分类标题和内容--> <!--分类标题和内容-->
<LinearLayout <LinearLayout
@ -39,14 +16,14 @@
<ListView <ListView
android:id="@+id/category_title_list" android:id="@+id/category_title_list"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_height="match_parent"
android:layout_height="match_parent" /> android:layout_weight="1" />
<!--内容--> <!--内容-->
<FrameLayout <FrameLayout
android:id="@+id/category_detail" android:id="@+id/category_detail"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="4"/> android:layout_weight="3" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

@ -1,11 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<TextView <include layout="@layout/content_product_title" />
android:id="@+id/textView"
<Spinner
android:id="@+id/product_select_condition"
android:layout_width="match_parent"
android:paddingHorizontal="1dp"
android:layout_height="wrap_content" />
<GridView
android:id="@+id/product_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="product" /> android:layout_marginTop="10dp"
android:background="#E8E8E8"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:numColumns="2"/>
</LinearLayout> </LinearLayout>

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--标题-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#ff3366"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/category_return"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/arrow_left" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="center"
android:text="商品"
android:layout_marginRight="40dp"
android:textColor="#FFF"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="shop" />
</LinearLayout>

@ -27,15 +27,15 @@
android:textColor="#000" android:textColor="#000"
android:textSize="18sp"/> android:textSize="18sp"/>
<!-- <TextView--> <!-- <TextView-->
<!-- android:layout_width="0dp"--> <!-- android:layout_width="0dp"-->
<!-- android:layout_height="50dp"--> <!-- android:layout_height="50dp"-->
<!-- android:layout_marginLeft="5dp"--> <!-- android:layout_marginLeft="5dp"-->
<!-- android:layout_weight="1”--> <!-- android:layout_weight="1”-->
<!-- android:text="热门商品"--> <!-- android:text="热门商品"-->
<!-- android:gravity="center_vertical"--> <!-- android:gravity="center_vertical"-->
<!-- android:textColor="#000"--> <!-- android:textColor="#000"-->
<!-- android:textSize="18sp" />--> <!-- android:textSize="18sp" />-->
<ImageView <ImageView
android:layout_width="25dp" android:layout_width="25dp"

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#fff"
android:orientation="horizontal">
<ImageView
android:id="@+id/condition_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/condition_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text="销量"
android:textSize="18sp" />
</LinearLayout>
<ImageView
android:id="@+id/image_jiange"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:background="#CFCFCF" />
</LinearLayout>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F2F2F2"
android:orientation="vertical">
<include layout="@layout/shoppingcart_title" />
<include layout="@layout/cart_no_product" />
</LinearLayout>

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--标题-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#ff3366"
android:orientation="horizontal">
<ImageView
android:id="@+id/shopcart_return"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/arrow_left" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="center"
android:text="shopping cart"
android:layout_marginRight="40dp"
android:textColor="#FFF"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>

@ -22,9 +22,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="23sp" android:textSize="23sp"
android:textColor="@color/h3" android:textColor="@color/h5"
android:textStyle="italic" android:textStyle="italic"
android:text="YaYa水果店" /> android:text="WaterMelon" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

@ -24,7 +24,7 @@
android:textSize="23sp" android:textSize="23sp"
android:textColor="@color/h5" android:textColor="@color/h5"
android:textStyle="italic" android:textStyle="italic"
android:text="YaYa水果店" /> android:text="WaterMelon" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

@ -27,3 +27,4 @@
<color name="h8">#ff0066</color> <color name="h8">#ff0066</color>
</resources> </resources>

@ -3,9 +3,9 @@
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/h5</item>
<item name="colorPrimaryDark">#FF9800</item> <item name="colorPrimaryDark">@color/h5</item>
<item name="colorAccent">#00BCD4</item> <item name="colorAccent">@color/colorAccent</item>
</style> </style>
</resources> </resources>

@ -1,4 +1,4 @@
package com.example.orangesale_05; package com.example.orangesale_end;
import org.junit.Test; import org.junit.Test;

@ -18,7 +18,7 @@ allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
} }
} }

@ -1,4 +1,4 @@
#Fri Feb 05 17:20:02 CST 2021 #Thu Feb 18 14:44:42 CST 2021
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

@ -1,2 +1,2 @@
include ':app' include ':app'
rootProject.name='OrangeSale_05' rootProject.name='OrangeSale_End'

Loading…
Cancel
Save