Compare commits

..

1 Commits

Author SHA1 Message Date
wangyi 9575df1702 实验四new
2 years ago

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="http://maven.aliyun.com/nexus/content/repositories/jcenter" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
</component>
</project>

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -1,50 +0,0 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.llw.cart"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//Gson
implementation 'com.google.code.gson:gson:2.8.6'
//RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//RecyclerView
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.47'
//
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
//
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-14'
//使Header
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-14'
}

@ -1,27 +0,0 @@
package com.llw.cart;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.llw.cart", appContext.getPackageName());
}
}

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.llw.cart">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -1,389 +0,0 @@
package com.llw.cart;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.llw.cart.adapter.StoreAdapter;
import com.llw.cart.bean.CarResponse;
import com.llw.cart.util.Constant;
import com.llw.cart.util.GoodsCallback;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @author llw
*/
public class MainActivity extends AppCompatActivity implements GoodsCallback, View.OnClickListener {
public static final String TAG = "MainActivity";
private RecyclerView rvStore;
private StoreAdapter storeAdapter;
private List<CarResponse.OrderDataBean> mList = new ArrayList<>();
private TextView tvEdit;//编辑
private ImageView ivCheckedAll;//全选
private TextView tvTotal;//合计价格
private TextView tvSettlement;//结算
private LinearLayout layEdit;//编辑底部布局
private TextView tvShareGoods;//分享商品
private TextView tvCollectGoods;//收藏商品
private TextView tvDeleteGoods;//删除商品
private boolean isEdit = false;//是否编辑
private boolean isAllChecked = false;//是否全选
private List<Integer> shopIdList = new ArrayList<>();//店铺列表
private double totalPrice = 0.00;//商品总价
private int totalCount = 0;//商品总数量
private AlertDialog dialog;//弹窗
private boolean isHaveGoods = false;//购物车是否有商品
private SmartRefreshLayout refresh;//刷新布局
private LinearLayout layEmpty;//空布局
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
/**
*
*/
private void initView() {
//设置亮色状态栏模式 systemUiVisibility在Android11中弃用了可以尝试一下。
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
rvStore = findViewById(R.id.rv_store);
tvEdit = findViewById(R.id.tv_edit);
ivCheckedAll = findViewById(R.id.iv_checked_all);
tvTotal = findViewById(R.id.tv_total);
tvSettlement = findViewById(R.id.tv_settlement);
layEdit = findViewById(R.id.lay_edit);
tvShareGoods = findViewById(R.id.tv_share_goods);
tvCollectGoods = findViewById(R.id.tv_collect_goods);
tvDeleteGoods = findViewById(R.id.tv_delete_goods);
refresh = findViewById(R.id.refresh);
layEmpty = findViewById(R.id.lay_empty);
//禁用下拉刷新和上拉加载更多
refresh.setEnableRefresh(false);
refresh.setEnableLoadMore(false);
//下拉刷新监听
refresh.setOnRefreshListener(refreshLayout -> initView());
tvEdit.setOnClickListener(this);
ivCheckedAll.setOnClickListener(this);
tvSettlement.setOnClickListener(this);
tvShareGoods.setOnClickListener(this);
tvCollectGoods.setOnClickListener(this);
tvDeleteGoods.setOnClickListener(this);
CarResponse carResponse = new Gson().fromJson(Constant.CAR_JSON, CarResponse.class);
mList.addAll(carResponse.getOrderData());
storeAdapter = new StoreAdapter(R.layout.item_store, mList, this);
rvStore.setLayoutManager(new LinearLayoutManager(this));
rvStore.setAdapter(storeAdapter);
//店铺点击
storeAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
CarResponse.OrderDataBean storeBean = mList.get(position);
if (view.getId() == R.id.iv_checked_store) {
storeBean.setChecked(!storeBean.isChecked());
storeAdapter.notifyDataSetChanged();
//传递选中店铺的id
if (storeBean.isChecked()) {
//全选商品
storeAdapter.controlGoods(storeBean.getShopId(), true);
//添加到列表中
if (!shopIdList.contains(storeBean.getShopId())) {
//如果列表中没有这个店铺Id且当前店铺为选中状态
shopIdList.add(storeBean.getShopId());
}
} else {
//清除全选商品
storeAdapter.controlGoods(storeBean.getShopId(), false);
//从列表中清除
if (shopIdList.contains(storeBean.getShopId())) {
shopIdList.remove((Integer) storeBean.getShopId());
}
}
//控制页面全选
controlAllChecked();
}
}
});
//有商品
isHaveGoods = true;
//下拉加载数据完成后,关闭下拉刷新动画
refresh.finishRefresh();
//隐藏布局
layEmpty.setVisibility(View.GONE);
}
/**
*
*/
private void controlAllChecked() {
if (shopIdList.size() == mList.size() && mList.size() != 0) {
//全选
ivCheckedAll.setImageDrawable(getDrawable(R.drawable.ic_checked));
isAllChecked = true;
} else {
//不全选
ivCheckedAll.setImageDrawable(getDrawable(R.drawable.ic_check));
isAllChecked = false;
}
//计算价格
calculationPrice();
}
/**
*
*
* @param shopId id
*/
@Override
public void checkedStore(int shopId, boolean state) {
for (CarResponse.OrderDataBean bean : mList) {
//遍历
if (shopId == bean.getShopId()) {
bean.setChecked(state);
storeAdapter.notifyDataSetChanged();
//记录选中店铺的shopid,添加到一个列表中。
if (!shopIdList.contains(bean.getShopId()) && state) {
//如果列表中没有这个店铺Id且当前店铺为选中状态
shopIdList.add(bean.getShopId());
} else {
if (shopIdList.contains(bean.getShopId())) {
//通过list.indexOf获取属性的在列表中的下标不过强转Integer更简洁
shopIdList.remove((Integer) bean.getShopId());
}
}
}
}
//控制页面全选
controlAllChecked();
}
/**
*
*/
@Override
public void calculationPrice() {
//每次计算之前先置零
totalPrice = 0.00;
totalCount = 0;
//循环购物车中的店铺列表
for (int i = 0; i < mList.size(); i++) {
CarResponse.OrderDataBean orderDataBean = mList.get(i);
//循环店铺中的商品列表
for (int j = 0; j < orderDataBean.getCartlist().size(); j++) {
CarResponse.OrderDataBean.CartlistBean cartlistBean = orderDataBean.getCartlist().get(j);
//当有选中商品时计算数量和价格
if (cartlistBean.isChecked()) {
totalCount++;
totalPrice += cartlistBean.getPrice() * cartlistBean.getCount();
}
}
}
tvTotal.setText("¥" + totalPrice);
tvSettlement.setText(totalCount == 0 ? "结算" : "结算(" + totalCount + ")");
}
/**
*
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_edit://编辑
if (!isHaveGoods) {
showMsg("当前购物车空空如也~");
return;
}
if (isEdit) {
tvEdit.setText("编辑");
layEdit.setVisibility(View.GONE);
isEdit = false;
} else {
tvEdit.setText("完成");
layEdit.setVisibility(View.VISIBLE);
isEdit = true;
}
break;
case R.id.iv_checked_all://全选
if (!isHaveGoods) {
showMsg("当前购物车空空如也~");
return;
}
if (isAllChecked) {
//取消全选
isSelectAllStore(false);
} else {
//全选
isSelectAllStore(true);
}
break;
case R.id.tv_settlement://结算
if (!isHaveGoods) {
showMsg("当前购物车空空如也~");
return;
}
if (totalCount == 0) {
showMsg("请选择要结算的商品");
return;
}
//弹窗
dialog = new AlertDialog.Builder(this)
.setMessage("总计:" + totalCount + "种商品," + totalPrice + "元")
.setPositiveButton("确定", (dialog, which) -> deleteGoods())
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
.create();
dialog.show();
break;
case R.id.tv_delete_goods://删除
if (totalCount == 0) {
showMsg("请选择要删除的商品");
return;
}
//弹窗
dialog = new AlertDialog.Builder(this)
.setMessage("确定要删除所选商品吗?")
.setPositiveButton("确定", (dialog, which) -> deleteGoods())
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
.create();
dialog.show();
break;
case R.id.tv_collect_goods://收藏
if (totalCount == 0) {
showMsg("请选择要收藏的商品");
return;
}
showMsg("收藏成功!");
break;
case R.id.tv_share_goods://分享
if (totalCount == 0) {
showMsg("请选择要分享的商品");
return;
}
showMsg("分享成功!");
break;
default:
break;
}
}
/**
*
*/
private void deleteGoods() {
//店铺列表
List<CarResponse.OrderDataBean> storeList = new ArrayList<>();
for (int i = 0; i < mList.size(); i++) {
CarResponse.OrderDataBean store = mList.get(i);
if (store.isChecked()) {
//店铺如果选择则添加到此列表中
storeList.add(store);
}
//商品列表
List<CarResponse.OrderDataBean.CartlistBean> goodsList = new ArrayList<>();
List<CarResponse.OrderDataBean.CartlistBean> goods = store.getCartlist();
//循环店铺中的商品列表
for (int j = 0; j < goods.size(); j++) {
CarResponse.OrderDataBean.CartlistBean cartlistBean = goods.get(j);
//当有选中商品时添加到此列表中
if (cartlistBean.isChecked()) {
goodsList.add(cartlistBean);
}
}
//删除商品
goods.removeAll(goodsList);
}
//删除店铺
mList.removeAll(storeList);
shopIdList.clear();//删除了选中商品,清空已选择的标识
controlAllChecked();//控制去全选
//改变界面UI
tvEdit.setText("编辑");
layEdit.setVisibility(View.GONE);
isEdit = false;
//刷新数据
storeAdapter.notifyDataSetChanged();
if (mList.size() <= 0) {
//无商品
isHaveGoods = false;
//启用下拉刷新
refresh.setEnableRefresh(true);
//显示空布局
layEmpty.setVisibility(View.VISIBLE);
}
}
/**
*
*
* @param state
*/
private void isSelectAllStore(boolean state) {
//修改背景
ivCheckedAll.setImageDrawable(getDrawable(state ? R.drawable.ic_checked : R.drawable.ic_check));
for (CarResponse.OrderDataBean orderDataBean : mList) {
//商品是否选中
storeAdapter.controlGoods(orderDataBean.getShopId(), state);
//店铺是否选中
checkedStore(orderDataBean.getShopId(), state);
}
isAllChecked = state;
}
/**
* Toast
*
* @param msg
*/
private void showMsg(String msg) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
}

@ -1,49 +0,0 @@
package com.llw.cart.adapter;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.llw.cart.bean.CarResponse;
import com.llw.cart.R;
import java.util.List;
/**
*
*
* @author llw
*/
public class GoodsAdapter extends BaseQuickAdapter<CarResponse.OrderDataBean.CartlistBean, BaseViewHolder> {
public GoodsAdapter(int layoutResId, @Nullable List<CarResponse.OrderDataBean.CartlistBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, CarResponse.OrderDataBean.CartlistBean item) {
helper.setText(R.id.tv_good_name, item.getProductName())
.setText(R.id.tv_good_color, item.getColor())
.setText(R.id.tv_good_size, item.getSize())
.setText(R.id.tv_goods_price, item.getPrice() + "")
.setText(R.id.tv_goods_num, item.getCount() + "");
ImageView goodImg = helper.getView(R.id.iv_goods);
Glide.with(mContext).load(item.getDefaultPic()).into(goodImg);
ImageView checkedGoods = helper.getView(R.id.iv_checked_goods);
//判断商品是否选中
if (item.isChecked()) {
checkedGoods.setImageDrawable(mContext.getDrawable(R.drawable.ic_checked));
} else {
checkedGoods.setImageDrawable(mContext.getDrawable(R.drawable.ic_check));
}
//添加点击事件
helper.addOnClickListener(R.id.iv_checked_goods)//选中商品
.addOnClickListener(R.id.tv_increase_goods_num)//增加商品
.addOnClickListener(R.id.tv_reduce_goods_num);//减少商品
}
}

@ -1,155 +0,0 @@
package com.llw.cart.adapter;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.llw.cart.MainActivity;
import com.llw.cart.bean.CarResponse;
import com.llw.cart.R;
import com.llw.cart.util.GoodsCallback;
import java.util.List;
/**
*
*
* @author llw
*/
public class StoreAdapter extends BaseQuickAdapter<CarResponse.OrderDataBean, BaseViewHolder> {
private RecyclerView rvGood;
//商品回调
private GoodsCallback goodsCallback;
//店铺对象
private List<CarResponse.OrderDataBean> storeBean;
public StoreAdapter(int layoutResId, @Nullable List<CarResponse.OrderDataBean> data, GoodsCallback goodsCallback) {
super(layoutResId, data);
this.goodsCallback = goodsCallback;
storeBean = data;//赋值
}
@Override
protected void convert(BaseViewHolder helper, final CarResponse.OrderDataBean item) {
rvGood = helper.getView(R.id.rv_goods);
helper.setText(R.id.tv_store_name, item.getShopName());
ImageView checkedStore = helper.getView(R.id.iv_checked_store);
if (item.isChecked()) {
checkedStore.setImageDrawable(mContext.getDrawable(R.drawable.ic_checked));
} else {
checkedStore.setImageDrawable(mContext.getDrawable(R.drawable.ic_check));
}
//点击事件
helper.addOnClickListener(R.id.iv_checked_store);//选中店铺
final GoodsAdapter goodsAdapter = new GoodsAdapter(R.layout.item_good, item.getCartlist());
rvGood.setLayoutManager(new LinearLayoutManager(mContext));
rvGood.setAdapter(goodsAdapter);
//商品item中的点击事件
goodsAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
CarResponse.OrderDataBean.CartlistBean goodsBean = item.getCartlist().get(position);
switch (view.getId()) {
case R.id.iv_checked_goods://选中商品
//如果已选中则取消选中,未选中则选中
goodsBean.setChecked(!goodsBean.isChecked());
//刷新适配器
goodsAdapter.notifyDataSetChanged();
//控制店铺是否选中
controlStore(item);
//商品控制价格
goodsCallback.calculationPrice();
break;
case R.id.tv_increase_goods_num://增加商品数量
updateGoodsNum(goodsBean, goodsAdapter,true);
break;
case R.id.tv_reduce_goods_num://减少商品数量
updateGoodsNum(goodsBean, goodsAdapter,false);
break;
default:
break;
}
}
});
}
/**
*
* @param goodsBean
* @param goodsAdapter
* @param state true false
*/
private void updateGoodsNum(CarResponse.OrderDataBean.CartlistBean goodsBean, GoodsAdapter goodsAdapter,boolean state) {
//其实商品应该还有一个库存值或者其他的限定值我这里写一个假的库存值为10
int inventory = 10;
int count = goodsBean.getCount();
if(state){
if (count >= inventory){
Toast.makeText(mContext,"商品数量不可超过库存值~",Toast.LENGTH_SHORT).show();
return;
}
count++;
}else {
if (count <= 1){
Toast.makeText(mContext,"已是最低商品数量~",Toast.LENGTH_SHORT).show();
return;
}
count--;
}
goodsBean.setCount(count);//设置商品数量
//刷新适配器
goodsAdapter.notifyDataSetChanged();
//计算商品价格
goodsCallback.calculationPrice();
}
/**
*
*/
private void controlStore(CarResponse.OrderDataBean item) {
int num = 0;
for (CarResponse.OrderDataBean.CartlistBean bean : item.getCartlist()) {
if (bean.isChecked()) {
++num;
}
}
if (num == item.getCartlist().size()) {
//全选中 传递需要选中的店铺的id过去
goodsCallback.checkedStore(item.getShopId(), true);
} else {
goodsCallback.checkedStore(item.getShopId(), false);
}
}
/**
*
*/
public void controlGoods(int shopId, boolean state) {
//根据店铺id选中该店铺下所有商品
for (CarResponse.OrderDataBean orderDataBean : storeBean) {
//店铺id等于传递过来的店铺id 则选中该店铺下所有商品
if (orderDataBean.getShopId() == shopId) {
for (CarResponse.OrderDataBean.CartlistBean cartlistBean : orderDataBean.getCartlist()) {
cartlistBean.setChecked(state);
//刷新
notifyDataSetChanged();
}
}
}
}
}

@ -1,196 +0,0 @@
package com.llw.cart.bean;
import java.util.List;
/**
*
* @author llw
*/
public class CarResponse {
/**
* code : 200
* orderData : [{"shopId":1,"shopName":"京东自营","cartlist":[{"id":1,"shopId":1,"shopName":"京东自营","defaultPic":"https://img30.360buyimg.com/popWareDetail/jfs/t3208/194/7616404169/244198/369625db/58b7d093N03520fb7.jpg","productId":1,"productName":"三只松鼠_零食大礼包","color":"黑色","size":"18L","price":20,"count":1},{"id":2,"shopId":1,"shopName":"京东自营","defaultPic":"https://img14.360buyimg.com/n0/jfs/t2971/15/167732091/93002/204c1016/574d9d9aNe4e6fa7a.jpg","productId":2,"productName":"小米心跳手环","color":"白色","size":"20XXL","price":148,"count":1}]},{"shopId":2,"shopName":"海澜之家","cartlist":[{"id":1,"shopId":2,"shopName":"海澜之家","defaultPic":"https://img30.360buyimg.com/popWaterMark/jfs/t4075/83/1343091204/132469/9034cb9c/5873496bN68020ba8.jpg","productId":1,"productName":"短袖T恤男 2017夏季新品","color":"蓝色","size":"30X","price":181,"count":1}]},{"shopId":3,"shopName":"OPPO官方旗舰店","cartlist":[{"id":1,"shopId":3,"shopName":"OPPO官方旗舰店","defaultPic":"https://img10.360buyimg.com/cms/jfs/t6064/272/2163314583/157700/442d6477/593c1c49N7c63a7d9.jpg","productId":1,"productName":"OPPO R11 全网通","color":"蓝色","size":"30X","price":1999,"count":1},{"id":2,"shopId":3,"shopName":"OPPO官方旗舰店","defaultPic":"https://img14.360buyimg.com/n0/jfs/t3142/194/4953241722/254855/1651c2b1/585b9021Nf653e48a.jpg","productId":1,"productName":"OPPO R9 全网通","color":"蓝色","size":"30X","price":999,"count":1}]}]
*/
private int code;
private List<OrderDataBean> orderData;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public List<OrderDataBean> getOrderData() {
return orderData;
}
public void setOrderData(List<OrderDataBean> orderData) {
this.orderData = orderData;
}
public static class OrderDataBean {
/**
* shopId : 1
* shopName :
* cartlist : [{"id":1,"shopId":1,"shopName":"京东自营","defaultPic":"https://img30.360buyimg.com/popWareDetail/jfs/t3208/194/7616404169/244198/369625db/58b7d093N03520fb7.jpg","productId":1,"productName":"三只松鼠_零食大礼包","color":"黑色","size":"18L","price":20,"count":1},{"id":2,"shopId":1,"shopName":"京东自营","defaultPic":"https://img14.360buyimg.com/n0/jfs/t2971/15/167732091/93002/204c1016/574d9d9aNe4e6fa7a.jpg","productId":2,"productName":"小米心跳手环","color":"白色","size":"20XXL","price":148,"count":1}]
*/
private int shopId;
private String shopName;
private List<CartlistBean> cartlist;
private boolean isChecked;//店铺是否选中
public int getShopId() {
return shopId;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public List<CartlistBean> getCartlist() {
return cartlist;
}
public void setCartlist(List<CartlistBean> cartlist) {
this.cartlist = cartlist;
}
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
isChecked = checked;
}
public static class CartlistBean {
/**
* id : 1
* shopId : 1
* shopName :
* defaultPic : https://img30.360buyimg.com/popWareDetail/jfs/t3208/194/7616404169/244198/369625db/58b7d093N03520fb7.jpg
* productId : 1
* productName : _
* color :
* size : 18L
* price : 20
* count : 1
*/
private int id;
private int shopId;
private String shopName;
private String defaultPic;
private int productId;
private String productName;
private String color;
private String size;
private int price;
private int count;
private boolean isChecked;//商品是否选中
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
isChecked = checked;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getShopId() {
return shopId;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getDefaultPic() {
return defaultPic;
}
public void setDefaultPic(String defaultPic) {
this.defaultPic = defaultPic;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
}
}

@ -1,95 +0,0 @@
package com.llw.cart.util;
/**
*
* @author llw
*/
public class Constant {
public static final String CAR_JSON = "{ \"code\" : 200 ,\n" +
" \"orderData\" : [\n" +
" {\n" +
"\n" +
" \"shopId\": 1,\n" +
" \"shopName\":\"水果拼盘\",\n" +
" \"cartlist\": [\n" +
" {\n" +
" \"id\": 1,\n" +
" \"shopId\": 1,\n" +
" \"shopName\": \"水果拼盘\",\n" +
" \"defaultPic\": \"https://tse1-mm.cn.bing.net/th/id/OIP-C.vJftgCb8g6v_gSHsD5HGNgHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7\",\n" +
" \"productId\": 1,\n" +
" \"productName\": \"优质新鲜水果\",\n" +
" \"color\": \"\",\n" +
" \"size\": \"\",\n" +
" \"price\": 25,\n" +
" \"count\":1\n" +
" },\n" +
" {\n" +
" \"id\": 2,\n" +
" \"shopId\": 1,\n" +
" \"shopName\": \"\",\n" +
" \"defaultPic\": \"https://tse4-mm.cn.bing.net/th/id/OIP-C.L32QENiAMoSmmqLf1Ks2BgHaFS?w=288&h=206&c=7&r=0&o=5&pid=1.7\",\n" +
" \"productId\": 2,\n" +
" \"productName\": \"花彩拼盘\",\n" +
" \"color\": \"\",\n" +
" \"size\": \"\",\n" +
" \"price\": 16,\n" +
" \"count\": 1\n" +
" }\n" +
" ]\n" +
" }\n" +
" ,\n" +
" {\n" +
" \"shopId\": 2,\n" +
" \"shopName\":\"水果奶茶\",\n" +
" \"cartlist\": [\n" +
" {\n" +
" \"id\": 1,\n" +
" \"shopId\": 2,\n" +
" \"shopName\": \"水果奶茶\",\n" +
" \"defaultPic\": \"https://tse4-mm.cn.bing.net/th/id/OIP-C.THBnn4_4YiWfbtKTlzdZawHaLG?w=199&h=298&c=7&r=0&o=5&pid=1.7\",\n" +
" \"productId\": 1,\n" +
" \"productName\": \"青柠芒果\",\n" +
" \"color\": \"\",\n" +
" \"size\": \"\",\n" +
" \"price\": 15,\n" +
" \"count\":1\n" +
" }\n" +
" ]\n" +
" }\n" +
" ,\n" +
" {\n" +
" \"shopId\": 3,\n" +
" \"shopName\":\"水果蛋糕\",\n" +
" \"cartlist\": [\n" +
" {\n" +
" \"id\": 1,\n" +
" \"shopId\": 3,\n" +
" \"shopName\": \"水果蛋糕\",\n" +
" \"defaultPic\": \"https://tse1-mm.cn.bing.net/th/id/OIP-C.-MylYp2cdCyNM5ijjLQqSwHaHa?w=192&h=191&c=7&r=0&o=5&pid=1.7\",\n" +
" \"productId\": 1,\n" +
" \"productName\": \"多彩水果拼盘蛋糕\",\n" +
" \"color\": \"\",\n" +
" \"size\": \"\",\n" +
" \"price\": 50,\n" +
" \"count\":1\n" +
" },\n" +
" {\n" +
" \"id\": 2,\n" +
" \"shopId\": 3,\n" +
" \"shopName\": \"水果蛋糕\",\n" +
" \"defaultPic\": \"https://tse1-mm.cn.bing.net/th/id/OIP-C.GFSAz_9r7WIXWpGCo72K3AHaGv?w=218&h=199&c=7&r=0&o=5&pid=1.7\",\n" +
" \"productId\": 1,\n" +
" \"productName\": \"心动情人草莓蛋糕\",\n" +
" \"color\": \"\",\n" +
" \"size\": \"\",\n" +
" \"price\": 68,\n" +
" \"count\":1\n" +
" }\n" +
" ]\n" +
" }\n" +
"\n" +
" ]\n" +
"}";
}

@ -1,21 +0,0 @@
package com.llw.cart.util;
/**
*
* @author llw
*/
public interface GoodsCallback {
/**
*
* @param shopId id
* @param state
*/
void checkedStore(int shopId,boolean state);
/**
*
*/
void calculationPrice();
}

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="#000"
android:width="0.5dp"/>
</shape>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save