GoodsActivity
package com.bwie.gouwuche.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bwie.gouwuche.R;
import com.bwie.gouwuche.adapter.MyAdapter;
import com.bwie.gouwuche.bean.CountPriceBean;
import com.bwie.gouwuche.bean.GoodsBean;
import com.bwie.gouwuche.custom.CartExpanableListview;
import com.bwie.gouwuche.presenter.GoodsPresenter;
import com.bwie.gouwuche.util.ApiUtil;
import com.bwie.gouwuche.util.OkHttp3Util;
import com.bwie.gouwuche.view.IGoodsView;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class GoodsActivity extends AppCompatActivity implements IGoodsView, View.OnClickListener {
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
countPriceBean = (CountPriceBean) msg.obj;
text_heji.setText("合计:¥" + countPriceBean.getPriceString());
text_jiesuan.setText("去计算(" + countPriceBean.getCount() + ")");
}
}
};
private CartExpanableListview elv;
private CheckBox check_quanxuan;
private TextView text_heji;
private TextView text_jiesuan;
private GoodsPresenter goodsPresenter;
private RelativeLayout relative_progress;
private CountPriceBean countPriceBean;
private GoodsBean goodsBean;
private MyAdapter myAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goods);
elv = findViewById(R.id.elv);
check_quanxuan = findViewById(R.id.check_quanxuan);
text_heji = findViewById(R.id.text_heji);
text_jiesuan = findViewById(R.id.text_jiesuan);
relative_progress = findViewById(R.id.relative_progress);
elv.setGroupIndicator(null);
goodsPresenter = new GoodsPresenter(this);
check_quanxuan.setOnClickListener(this);
text_jiesuan.setOnClickListener(this);
}
@Override
protected void onResume() {
super.onResume();
relative_progress.setVisibility(View.VISIBLE);
goodsPresenter.getData(ApiUtil.cartUrl);
}
@Override
public void getSuccess(final GoodsBean goodsBean) {
this.goodsBean=goodsBean;
runOnUiThread(new Runnable() {
@Override
public void run() {
relative_progress.setVisibility(View.GONE);
List<GoodsBean.DataBean> data = goodsBean.getData();
if (data!=null){
for (int i=0;i<data.size();i++){
List<GoodsBean.DataBean.ListBean> listBeans = data.get(i).getList();
data.get(i).setGroupChecked(isAllChildInGroupChecked(listBeans));
}
check_quanxuan.setChecked(isAllGroupChecked(data));
myAdapter = new MyAdapter(GoodsActivity.this, data, handler, goodsPresenter, relative_progress);
elv.setAdapter(myAdapter);
for (int i=0;i<data.size();i++){
elv.expandGroup(i);
}
myAdapter.sendPriceAndCount();
}else {
Toast.makeText(GoodsActivity.this,"购物车空,请添加购物车",Toast.LENGTH_SHORT).show();
}
}
});
}
private boolean isAllGroupChecked(List<GoodsBean.DataBean> data) {
for (int i=0;i<data.size();i++){
if (!data.get(i).isGroupChecked()) {
return false;
}
}
return true;
}
private boolean isAllChildInGroupChecked(List<GoodsBean.DataBean.ListBean> listBeans) {
for(int i=0;i<listBeans.size();i++){
if (listBeans.get(i).getSelected()==0){
return false;
}
}
return true;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.check_quanxuan:
myAdapter.setAllChildsChecked(check_quanxuan.isChecked());
break;
case R.id.text_jiesuan:
final String priceString = countPriceBean.getPriceString();
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("price",priceString);
OkHttp3Util.doPost(ApiUtil.createCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
runOnUiThread(new Runnable() {
@Override
public void run() {
CountPriceBean countPriceBean = new CountPriceBean(priceString, 1);
Intent intent = new Intent(GoodsActivity.this, DingDanActivity.class);
intent.putExtra("price",countPriceBean);
startActivity(intent);
}
});
}
}
});
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bwie.gouwuche.activity.GoodsActivity">
<TextView
android:id="@+id/cc"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="购物车"
android:textSize="20sp" />
<TextView
android:id="@+id/vv"
android:layout_below="@+id/cc"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000" />
<ScrollView
android:layout_below="@+id/vv"
android:layout_above="@+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.bwie.gouwuche.custom.CartExpanableListview
android:id="@+id/elv"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.bwie.gouwuche.custom.CartExpanableListview>
<LinearLayout
android:layout_marginTop="20dp"
android:background="#00ff00"
android:layout_width="match_parent"
android:layout_height="500dp">
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:visibility="gone"
android:id="@+id/relative_progress"
android:layout_above="@+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<LinearLayout
android:id="@+id/linear"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_quanxuan"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:button="@null"
android:layout_height="wrap_content"
android:background="@drawable/check_box_selector"/>
<TextView
android:id="@+id/text_quanxuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全选" />
<TextView
android:id="@+id/text_heji"
android:layout_width="0dp"
android:layout_weight="2"
android:gravity="center"
android:layout_height="match_parent"
android:text="合计:¥0.00"/>
<TextView
android:id="@+id/text_jiesuan"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center"
android:background="#ff0000"
android:textColor="#ffffff"
android:layout_height="match_parent"
android:text="结算(0)"/>
</LinearLayout>
</RelativeLayout>
CountPriceBean
package com.bwie.gouwuche.bean;
import java.io.Serializable;
/**
* Created by lenovo on 2018/1/13.
*/
public class CountPriceBean implements Serializable {
private String priceString;
private int count;
public String getPriceString() {
return priceString;
}
public void setPriceString(String priceString) {
this.priceString = priceString;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public CountPriceBean(String priceString, int count) {
this.priceString = priceString;
this.count = count;
}
public CountPriceBean() {
}
}
package com.bwie.gouwuche.custom;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ExpandableListView;
/**
* Created by lenovo on 2017/12/28.
*/
public class CartExpanableListview extends ExpandableListView {
public CartExpanableListview(Context context) {
super(context);
}
public CartExpanableListview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CartExpanableListview(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height= MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, height);
}
}
GoodsBean
private boolean isGroupChecked;
public boolean isGroupChecked() {
return isGroupChecked;
}
public void setGroupChecked(boolean groupChecked) {
isGroupChecked = groupChecked;
}
MyAdapter
package com.bwie.gouwuche.adapter;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bwie.gouwuche.R;
import com.bwie.gouwuche.bean.CountPriceBean;
import com.bwie.gouwuche.bean.GoodsBean;
import com.bwie.gouwuche.presenter.GoodsPresenter;
import com.bwie.gouwuche.util.ApiUtil;
import com.bwie.gouwuche.util.OkHttp3Util;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
/**
* Created by lenovo on 2018/1/2.
*/
public class MyAdapter extends BaseExpandableListAdapter {
Context context;
List<GoodsBean.DataBean> data;
Handler handler;
GoodsPresenter goodsPresenter;
RelativeLayout relative_progress;
private int childIndex;
private int allIndex;
public MyAdapter(Context context, List<GoodsBean.DataBean> data, Handler handler, GoodsPresenter goodsPresenter, RelativeLayout relative_progress) {
this.context=context;
this.data=data;
this.handler=handler;
this.goodsPresenter=goodsPresenter;
this.relative_progress=relative_progress;
}
@Override
public int getGroupCount() {
return data.size();
}
@Override
public int getChildrenCount(int groupPosition) {
return data.get(groupPosition).getList().size();
}
@Override
public Object getGroup(int groupPosition) {
return data.get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return data.get(groupPosition).getList().get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public View getGroupView(int groupPosition, boolean b, View view, ViewGroup viewGroup) {
final GroupHolder holder;
if (view==null){
view=View.inflate(context, R.layout.group_items,null);
holder=new GroupHolder();
holder.check_group=view.findViewById(R.id.check_group);
holder.text_group=view.findViewById(R.id.text_group);
view.setTag(holder);
}else {
holder= (GroupHolder) view.getTag();
}
final GoodsBean.DataBean dataBean = data.get(groupPosition);
holder.text_group.setText(dataBean.getSellerName());
holder.check_group.setChecked(dataBean.isGroupChecked());
holder.check_group.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
relative_progress.setVisibility(View.VISIBLE);
childIndex = 0;
upDateAllChildInGroup(dataBean,holder.check_group.isChecked());
}
});
return view;
}
private void upDateAllChildInGroup(final GoodsBean.DataBean dataBean, final boolean checked) {
GoodsBean.DataBean.ListBean listBean = dataBean.getList().get(childIndex);
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("sellerid", String.valueOf(listBean.getSellerid()));
params.put("pid", String.valueOf(listBean.getPid()));
params.put("selected", String.valueOf(checked ? 1 : 0));
params.put("num", String.valueOf(listBean.getNum()));
OkHttp3Util.doPost(ApiUtil.updateCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
childIndex++;
if (childIndex<dataBean.getList().size()){
upDateAllChildInGroup(dataBean,checked);
}else {
goodsPresenter.getData(ApiUtil.cartUrl);
}
}
}
});
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean b, View view, ViewGroup viewGroup) {
ChildHolder holder;
if (view==null){
view=View.inflate(context,R.layout.child_items,null);
holder=new ChildHolder();
holder.text_add = view.findViewById(R.id.text_add);
holder.text_num = view.findViewById(R.id.text_num);
holder.text_jian = view.findViewById(R.id.text_jian);
holder.text_title = view.findViewById(R.id.text_title);
holder.text_price = view.findViewById(R.id.text_price);
holder.image_good = view.findViewById(R.id.image_goods);
holder.check_child = view.findViewById(R.id.check_child);
holder.text_delete = view.findViewById(R.id.text_delete);
view.setTag(holder);
}else {
holder= (ChildHolder) view.getTag();
}
final GoodsBean.DataBean.ListBean listBean = data.get(groupPosition).getList().get(childPosition);
holder.text_title.setText(listBean.getTitle());
holder.text_price.setText("¥"+listBean.getBargainPrice());
Glide.with(context).load(listBean.getImages().split("\\|")[0]).into(holder.image_good);
holder.check_child.setChecked(listBean.getSelected()==0 ? false :true);
holder.text_num.setText(listBean.getNum()+"");
holder.check_child.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
relative_progress.setVisibility(View.VISIBLE);
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("sellerid", String.valueOf(listBean.getSellerid()));
params.put("pid", String.valueOf(listBean.getPid()));
params.put("selected", String.valueOf(listBean.getSelected()==0 ? 1 : 0));
params.put("num", String.valueOf(listBean.getNum()));
OkHttp3Util.doPost(ApiUtil.updateCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
goodsPresenter.getData(ApiUtil.cartUrl);
}
}
});
}
});
holder.text_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
relative_progress.setVisibility(View.VISIBLE);
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("sellerid", String.valueOf(listBean.getSellerid()));
params.put("pid", String.valueOf(listBean.getPid()));
params.put("selected", String.valueOf(listBean.getSelected()));
params.put("num", String.valueOf(listBean.getNum()+1));
OkHttp3Util.doPost(ApiUtil.updateCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
goodsPresenter.getData(ApiUtil.cartUrl);
}
}
});
}
});
holder.text_jian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num=listBean.getNum();
if (num==1){
return;
}
relative_progress.setVisibility(View.VISIBLE);
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("sellerid", String.valueOf(listBean.getSellerid()));
params.put("pid", String.valueOf(listBean.getPid()));
params.put("selected", String.valueOf(listBean.getSelected()));
params.put("num", String.valueOf(num-1));
OkHttp3Util.doPost(ApiUtil.updateCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
goodsPresenter.getData(ApiUtil.cartUrl);
}
}
});
}
});
holder.text_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
relative_progress.setVisibility(View.VISIBLE);
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("pid", String.valueOf(listBean.getPid()));
OkHttp3Util.doPost(ApiUtil.deleteCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
goodsPresenter.getData(ApiUtil.cartUrl);
}
}
});
}
});
return view;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public void sendPriceAndCount() {
double price=0;
int count=0;
for (int i=0;i<data.size();i++){
List<GoodsBean.DataBean.ListBean> listBeans = data.get(i).getList();
for (int j=0;j<listBeans.size();j++){
if (listBeans.get(j).getSelected()==1) {
price +=listBeans.get(j).getBargainPrice() * listBeans.get(j).getNum();
count +=listBeans.get(j).getNum();
}
}
}
DecimalFormat decimalFormat = new DecimalFormat("0.00");
String priceString = decimalFormat.format(price);
CountPriceBean countPriceBean = new CountPriceBean(priceString, count);
Message msg=Message.obtain();
msg.what=0;
msg.obj=countPriceBean;
handler.sendMessage(msg);
}
public void setAllChildsChecked(boolean checked) {
List<GoodsBean.DataBean.ListBean> allList=new ArrayList<>();
for (int i=0;i<data.size();i++){
List<GoodsBean.DataBean.ListBean> listBeans = data.get(i).getList();
for (int j=0;j<listBeans.size();j++){
allList.add(listBeans.get(j));
}
}
relative_progress.setVisibility(View.VISIBLE);
allIndex = 0;
upDateAllChecked(allList,checked);
}
private void upDateAllChecked(final List<GoodsBean.DataBean.ListBean> allList, final boolean checked) {
relative_progress.setVisibility(View.VISIBLE);
GoodsBean.DataBean.ListBean listBean = allList.get(allIndex);
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
params.put("sellerid", String.valueOf(listBean.getSellerid()));
params.put("pid", String.valueOf(listBean.getPid()));
params.put("selected", String.valueOf(checked ? 1 : 0));
params.put("num", String.valueOf(listBean.getNum()));
OkHttp3Util.doPost(ApiUtil.updateCartUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
allIndex++;
if (allIndex<allList.size()) {
upDateAllChecked(allList,checked);
}else {
goodsPresenter.getData(ApiUtil.cartUrl);
}
}
}
});
}
private class GroupHolder{
CheckBox check_group;
TextView text_group;
}
private class ChildHolder{
CheckBox check_child;
ImageView image_good;
TextView text_title;
TextView text_price;
TextView text_jian;
TextView text_num;
TextView text_add;
TextView text_delete;
}
}
<?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:padding="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:background="@drawable/check_box_selector"/>
<TextView
android:id="@+id/text_group"
android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:text="京东自营"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<RelativeLayout
android:id="@+id/rel"
android:layout_toLeftOf="@+id/text_delete"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/check_child"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:button="@null"
android:background="@drawable/check_box_selector"/>
<ImageView
android:id="@+id/image_goods"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/check_child"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@mipmap/ic_launcher"/>
<TextView
android:id="@+id/text_title"
android:layout_toRightOf="@+id/image_goods"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/image_goods"
android:minLines="2"
android:maxLines="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sddssdsd"/>
<TextView
android:id="@+id/text_price"
android:layout_toRightOf="@+id/image_goods"
android:layout_marginLeft="10dp"
android:layout_alignBottom="@+id/image_goods"
android:textColor="#ff0000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sddssdsd"/>
<LinearLayout
android:layout_alignParentRight="true"
android:layout_alignBottom="@+id/image_goods"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/text_jian"
android:padding="5dp"
android:background="@drawable/bian_kuang_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一"/>
<TextView
android:id="@+id/text_num"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/bian_kuang_line"
android:text="1"/>
<TextView
android:id="@+id/text_add"
android:padding="5dp"
android:background="@drawable/bian_kuang_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="十"/>
</LinearLayout>
</RelativeLayout>
<TextView
android:id="@+id/text_delete"
android:layout_marginLeft="3dp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/rel"
android:layout_alignBottom="@+id/rel"
android:background="#ff0000"
android:gravity="center"
android:textColor="#ffffff"
android:layout_width="50dp"
android:layout_height="match_parent"
android:text="删除"/>
</RelativeLayout>
GoodsModel
package com.bwie.gouwuche.model;
import com.bwie.gouwuche.bean.GoodsBean;
import com.bwie.gouwuche.presenter.GoodsPresenter;
import com.bwie.gouwuche.presenter.IGoodsPresenter;
import com.bwie.gouwuche.util.OkHttp3Util;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
/**
* Created by lenovo on 2018/1/13.
*/
public class GoodsModel {
private IGoodsPresenter iGoodsPresenter;
public GoodsModel(GoodsPresenter iGoodsPresenter) {
this.iGoodsPresenter=iGoodsPresenter;
}
public void getData(String goodsUrl){
Map<String, String> params=new HashMap<>();
params.put("uid","2797");
OkHttp3Util.doPost(goodsUrl, params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
String json=response.body().string();
GoodsBean goodsBean = new Gson().fromJson(json, GoodsBean.class);
iGoodsPresenter.getSuccess(goodsBean);
}
}
});
}
}
GoodsPresenter
package com.bwie.gouwuche.presenter;
import com.bwie.gouwuche.bean.GoodsBean;
import com.bwie.gouwuche.model.GoodsModel;
import com.bwie.gouwuche.view.IGoodsView;
/**
* Created by lenovo on 2018/1/13.
*/
public class GoodsPresenter implements IGoodsPresenter{
private GoodsModel goodsModel;
private IGoodsView iGoodsView;
public GoodsPresenter(IGoodsView iGoodsView) {
this.iGoodsView =iGoodsView;
goodsModel = new GoodsModel(this);
}
public void getData(String goodsUrl){
goodsModel.getData(goodsUrl);
}
@Override
public void getSuccess(GoodsBean goodsBean) {
iGoodsView.getSuccess(goodsBean);
}
}