添加权限
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
MainActivity
private CartExpanableListview expanableListview;
private CartPresenter cartPresenter;
private CheckBox check_all;
private TextView text_total;
private TextView text_buy;
private CartBean cartBean;
private RelativeLayout relative_progress;
boolean flag=false;
private LinearLayout linear_bottom;
private CountPriceBean countPriceBean;
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
if (msg.what == 0){
countPriceBean = (CountPriceBean) msg.obj;
text_total.setText("合计:¥"+ countPriceBean.getPrice());
text_buy.setText("去计算("+ countPriceBean.getCount()+")");
}
}
};
private MyAdapter myAdapter;
private TextView bianji;
private LinearLayout linear8;
private LinearLayout liner1;
private Button btn3del;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
check_all = (CheckBox) findViewById(R.id.check_all);
text_total = (TextView) findViewById(R.id.text_total);
text_buy = (TextView) findViewById(R.id.text_buy);
expanableListview = (CartExpanableListview) findViewById(R.id.expanable_listview);
relative_progress = (RelativeLayout) findViewById(R.id.relative_progress);
linear_bottom = (LinearLayout) findViewById(R.id.linear_layout);
bianji = (TextView) findViewById(R.id.bianji);
linear8 = (LinearLayout) findViewById(R.id.linear8);
btn3del = (Button) findViewById(R.id.but3);
expanableListview.setGroupIndicator(null);
cartPresenter=new CartPresenter(this);
check_all.setOnClickListener(this);
text_buy.setOnClickListener(this);
bianji.setOnClickListener(this);
btn3del.setOnClickListener(this);
}
@Override
protected void onResume() {
super.onResume();
relative_progress.setVisibility(View.VISIBLE);
cartPresenter.getCartData(ApiUtil.cartUrl);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.check_all:
myAdapter.setAllCheck(check_all.isChecked());
break;
case R.id.text_buy:
final String price = countPriceBean.getPrice();
Map<String, String> params = new HashMap<>();
params.put("uid","3939");
params.put("price", String.valueOf(price));
OkHttp3Util.doPost(ApiUtil.createCartUrl, params, new Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
if (response.isSuccessful()){
final String json = response.body().string();
runOnUiThread(new Runnable() {
@Override
public void run() {
CountPriceBean countPriceBean=new CountPriceBean( price,1);
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
intent.putExtra("order",countPriceBean);
startActivity(intent);
}
});
}
}
});
break;
case R.id.bianji:
if (flag){
bianji.setText("编辑");
flag=false;
linear8.setVisibility(View.VISIBLE);
linear_bottom.setVisibility(View.INVISIBLE);
}else
{
bianji.setText("完成");
flag=true;
linear8.setVisibility(View.INVISIBLE);
linear_bottom.setVisibility(View.VISIBLE);
}
break;
case R.id.but3:
for (int i= 0;i<cartBean.getData().size();i++){
if (cartBean.getData().get(i).isGroupChecked()==true){
for (int j=0;j<cartBean.getData().get(i).getList().size();j++){
if (cartBean.getData().get(i).getList().get(j).getSelected() == 1) {
Log.d("ggg",cartBean.getData().get(i).getList().get(j).getPid()+"");
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/deleteCart?uid=3939&pid=" + cartBean.getData().get(i).getList().get(j).getPid(), new Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
if (response.isSuccessful()) {
String string = response.body().string();
Log.d("cccc", string);
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "删除成功", Toast.LENGTH_SHORT).show();
cartPresenter.getCartData(ApiUtil.cartUrl);
}
});
}
}
});
}
}
}
}
break;
}
}
@Override
public void getSuccessCartJson(CartBean cartBean) {
relative_progress.setVisibility(View.GONE);
this.cartBean = cartBean;
if (cartBean != null){
for (int i= 0;i<cartBean.getData().size();i++){
if (isAllChildInGroupSelected(i)){
cartBean.getData().get(i).setGroupChecked(true);
}
}
changeAllState(isAllGroupChecked());
myAdapter = new MyAdapter(MainActivity.this, cartBean,handler,relative_progress,cartPresenter);
expanableListview.setAdapter(myAdapter);
for (int i= 0;i<cartBean.getData().size();i++){
expanableListview.expandGroup(i);
}
myAdapter.sendPriceAndCount();
}else {
Toast.makeText(MainActivity.this,"购物车为空,去逛逛",Toast.LENGTH_SHORT).show();
}
}
/**
* 全选是否选中
* @param allGroupChecked
*/
private void changeAllState(boolean allGroupChecked) {
check_all.setChecked(allGroupChecked);
}
/**
* 是否所有的组选中
* @return
*/
private boolean isAllGroupChecked() {
for (int i =0;i<cartBean.getData().size();i++){
if (! cartBean.getData().get(i).isGroupChecked()){
return false;
}
}
return true;
}
/**
* 一个组中所有的子条目是否选中
* @param groupPosition
* @return
*/
private boolean isAllChildInGroupSelected(int groupPosition) {
for (int i= 0;i<cartBean.getData().get(groupPosition).getList().size();i++){
if (cartBean.getData().get(groupPosition).getList().get(i).getSelected() ==0){
return false;
}
}
return true;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (cartPresenter!=null){
cartPresenter.destory();
}
}
}
Main2Activity
private TextView text_order;
private TextView text_kuan;
private ImageView tu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Intent intent = getIntent();
final CountPriceBean countPriceBean = (CountPriceBean) intent.getSerializableExtra("order");
text_kuan = (TextView) findViewById(R.id.text_kuan);
text_order = (TextView) findViewById(R.id.text_order);
tu = (ImageView) findViewById(R.id.maidongxidetupian);
text_kuan.setText("实付款: ¥"+countPriceBean.getPrice());
text_order.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/createOrder?uid=3939&price=" + countPriceBean.getPrice(), new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String string = response.body().string();
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Toast.makeText(Main2Activity.this, string,Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
startActivity(intent);
}
});
}
});
}
});
}
public void huiqu2(View view) {
AlertDialog.Builder ab=new AlertDialog.Builder(Main2Activity.this);
ab.setTitle("你在三思三思~~~~");
ab.setPositiveButton("去意已决", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
});
ab.setNegativeButton("再看看",null);
ab.show();
}
public void dingdanzhongxin(View view) {
Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
startActivity(intent);
}
}
Main3Activity
private TabLayout tabLayout
private ViewPager viewPager
private List<String> list
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main3)
tabLayout = (TabLayout) findViewById(R.id.tab2)
viewPager = (ViewPager) findViewById(R.id.view_pager2)
tabLayout.setTabMode(TabLayout.MODE_FIXED)
tabLayout.setTabGravity(GRAVITY_FILL)
list = new ArrayList<>()
list.add("全部")
list.add("待付款")
list.add("待收货")
list.add("已完成")
list.add("已取消")
viewPager.setOffscreenPageLimit(list.size())
//1.给viewPager设置适配器
/**
* 管理者对象有几种????
* getSupportFragmentManager()...activity管理他身上的fragment的时候使用
* getChildFragmentManager()...fragment嵌套的时候,,,管理孩子需要使用这个管理者
* getFragmentManager()....孩子里面还有fragment的话就使用这个
*/
viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
//2.重写这个方法getPageTitle,,,得到当前页面的标题
@Override
public CharSequence getPageTitle(int position) {
return list.get(position)
}
@Override
public Fragment getItem(int position) {
NewsFragment1 newsFragment = new NewsFragment1()
//应该要做的是传值,,,,去fragment里面获取,,,获取到值之后,,,在进行url路径的拼接
Bundle bundle = new Bundle()
bundle.putString("name",list.get(position))
newsFragment.setArguments(bundle)
return newsFragment
}
@Override
public int getCount() {
return list.size()
}
})
//3.将tabLayout和viewPager关联起来
tabLayout.setupWithViewPager(viewPager)
}
}
Main4Activity
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
imageView= (ImageView) findViewById(R.id.shuxing);
ObjectAnimator y = ObjectAnimator.ofFloat(imageView, "y", 0, 10, 200, 250, 500, 800);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageView, "scaleX", 2, 1);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageView, "scaleY",2, 1);
ObjectAnimator alpha = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1.0f);
ObjectAnimator rotationX = ObjectAnimator.ofFloat(imageView, "rotationX", 0, 360);
ObjectAnimator rotationY = ObjectAnimator.ofFloat(imageView, "rotationY", 0, 360);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(3000);
animatorSet.play(y).with(scaleX).with(scaleY).with(alpha).with(rotationX).with(rotationY);
animatorSet.start();
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
Intent intent=new Intent(Main4Activity.this,MainActivity.class);
startActivity(intent);
finish();
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
}
}
Main5Activity
private TextView tile;
private TextView price;
private TextView bran;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main5);
tile = (TextView) findViewById(R.id.title2);
price = (TextView) findViewById(R.id.price2);
bran = (TextView) findViewById(R.id.branprice2);
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/getProductDetail?pid=2&source=android", new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, final Response response) throws IOException {
if (response.isSuccessful()){
final String string = response.body().string();
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Log.d("hhhh",string);
if (string!=null||"".equals(string)){
Gson gson=new Gson();
GoodsBean goodsBean = gson.fromJson(string, GoodsBean.class);
GoodsBean.DataBean list = goodsBean.getData();
tile.setText(list.getTitle());
price.setText("¥:"+list.getPrice());
bran.setText("原价:"+list.getBargainPrice());
bran.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
String[] split = list.getImages().split("\\|");
}else
{
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
}
});
}
public void gouwuche(View view) {
Intent intent=new Intent(Main5Activity.this,MainActivity.class);
startActivity(intent);
}
public void jiaru(View view) {
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/addCart?uid=3939&pid=2&source=android", new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Intent intent=new Intent(Main5Activity.this,MainActivity.class);
startActivity(intent);
Toast.makeText(Main5Activity.this,"加购成功",Toast.LENGTH_SHORT).show();
}
});
}
}
});
}
}
NewsFragment1
private List<Dingbean.DataBean> list=new ArrayList<>();
List<Dingbean.DataBean> list1=new ArrayList<>();
private Base base;
private ListView lv;
int page=3;
Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what==1) {
Log.d("cccc", "进来了");
if ("全部".equals(name)) {
list.clear();
list.addAll(dingbean.getData());
if (list.size() > 0) {
setaba();
} else {
Toast.makeText(getActivity(), "没有此类型的商品订单哦", Toast.LENGTH_SHORT).show();
}
} else if ("待付款".equals(name)) {
Log.d("lllll", name);
if (list1.size() > 0) {
list.clear();
for (int i = 0; i < list1.size(); i++) {
if (list1.get(i).getStatus() == 0) {
list.add(list1.get(i));
}
}
if (list.size() > 0) {
setaba();
} else {
Toast.makeText(getActivity(), "没有此类型的商品订单哦", Toast.LENGTH_SHORT).show();
}
} else {
getshuju();
}
} else if ("待收货".equals(name)) {
Log.d("lllll", name);
if (list1.size() > 0) {
list.clear();
for (int i = 0; i < list1.size(); i++) {
if (list1.get(i).getStatus() == 0) {
list.add(list1.get(i));
}
}
if (list.size() > 0) {
setaba();
} else {
Toast.makeText(getActivity(), "没有此类型的商品订单哦", Toast.LENGTH_SHORT).show();
}
} else {
getshuju();
}
} else if ("已完成".equals(name)) {
Log.d("----", name);
if (list1.size() > 0) {
list.clear();
for (int i = 0; i < list1.size(); i++) {
if (list1.get(i).getStatus() == 2) {
list.add(list1.get(i));
}
}
if (list.size() > 0) {
setaba();
} else {
Toast.makeText(getActivity(), "没有此类型的商品订单哦", Toast.LENGTH_SHORT).show();
}
} else {
getshuju();
}
} else if ("已取消".equals(name)) {
Log.d("----", name);
if (list1.size() > 0) {
list.clear();
for (int i = 0; i < list1.size(); i++) {
if (list1.get(i).getStatus() == 2) {
list.add(list1.get(i));
}
}
if (list.size() > 0) {
setaba();
} else {
Toast.makeText(getActivity(), "没有此类型的商品订单哦", Toast.LENGTH_SHORT).show();
}
} else {
getshuju();
}
}
}else if (msg.what==2){
getshuju();
setaba();
}
}
};
private String name;
private Dingbean dingbean;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.ding, container, false);
lv = view.findViewById(R.id.lvvv);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
name = getArguments().getString("name", "");
Log.d("nnnn", name);
if (name.equals("全部")){
getshuju();
}else if (name.equals("待付款")){
Log.d("vvvv","进来了");
handler.sendEmptyMessage(1);
}else if (name.equals("待收货")){
handler.sendEmptyMessage(1);
}else if (name.equals("已完成")){
handler.sendEmptyMessage(1);
}else if (name.equals("已取消")){
handler.sendEmptyMessage(1);
}
}
private void getshuju() {
page++;
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/getOrders?uid=3939&page=1", new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String string = response.body().string();
if (response.isSuccessful()){
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Gson gson=new Gson();
dingbean = gson.fromJson(string, Dingbean.class);
list1.clear();
list1.addAll(dingbean.getData());
handler.sendEmptyMessage(1);
}
});
}
}
});
}
private void setaba() {
if (base==null){
base = new Base(getActivity(),list,handler);
lv.setAdapter(base);
}else
{
base.notifyDataSetChanged();
}
}
}
接口Huiactivity
void getSuccessCartJson(CartBean cartBean);
接口Huiprestener
void getSuccessCartJson(CartBean cartBean);
MyAdapter extends BaseExpandableListAdapter
private CartPresenter cartPresenter;
private RelativeLayout relative_progress;
private Handler handler;
private CartBean cartBean;
private Context context;
private int allSize;
private int ai;
public MyAdapter(Context context, CartBean cartBean, Handler handler, RelativeLayout relative_progress, CartPresenter cartPresenter) {
this.context = context;
this.cartBean = cartBean;
this.handler = handler;
this.relative_progress = relative_progress;
this.cartPresenter = cartPresenter;
}
@Override
public int getGroupCount() {
return cartBean.getData().size();
}
@Override
public int getChildrenCount(int groupPosition) {
return cartBean.getData().get(groupPosition).getList().size();
}
@Override
public Object getGroup(int groupPosition) {
return cartBean.getData().get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return cartBean.getData().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_item_layout,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 CartBean.DataBean dataBean = cartBean.getData().get(groupPosition);
holder.check_group.setChecked(dataBean.isGroupChecked());
holder.text_group.setText(dataBean.getSellerName());
holder.check_group.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
relative_progress.setVisibility(View.VISIBLE);
size = dataBean.getList().size();
i = 0;
updateChildInGroup(dataBean,holder.check_group.isChecked());
}
});
return view;
}
/**
* 根据组的状态 更改组中 子条目的状态
* @param dataBean
* @param checked
*/
private int i;
private int size;
private void updateChildInGroup(final CartBean.DataBean dataBean, final boolean checked) {
CartBean.DataBean.ListBean listBean = dataBean.getList().get(i);
Map<String, String> params = new HashMap<>();
params.put("uid","3939");
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("https://www.zhaoapi.cn/product/updateCarts", params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
i = i+1;
if (i<size){
updateChildInGroup(dataBean,checked);
}else {
cartPresenter.getCartData(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_item_layout,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_good);
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 CartBean.DataBean.ListBean listBean = cartBean.getData().get(groupPosition).getList().get(childPosition);
holder.text_num.setText(listBean.getNum()+"");
holder.text_price.setText("¥"+listBean.getBargainPrice());
holder.text_title.setText(listBean.getTitle());
holder.check_child.setChecked(listBean.getSelected()==0? false:true);
Glide.with(context).load(listBean.getImages().split("\\|")[0]).into(holder.image_good);
holder.check_child.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateCart(listBean,true,false);
}
});
holder.text_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateCart(listBean,false,true);
}
});
holder.text_jian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = listBean.getNum();
if (num == 1){
return;
}
updateCart(listBean,false,false);
}
});
holder.text_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deleteCart(listBean);
}
});
return view;
}
/**
* 删除购物车
* @param listBean
*/
private void deleteCart(CartBean.DataBean.ListBean listBean) {
relative_progress.setVisibility(View.VISIBLE);
Map<String, String> params = new HashMap<>();
params.put("uid","3939");
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()){
cartPresenter.getCartData(ApiUtil.cartUrl);
}
}
});
}
/**
* 更新购物车的方法.....isUpdateCheck true表示更新选中状态,,,false表示更改数量...isAdd表示数量是否增加,false表示数量减少
* @param listBean
* @param isUpdateCheck
*/
private void updateCart(CartBean.DataBean.ListBean listBean, boolean isUpdateCheck, boolean isAdd) {
relative_progress.setVisibility(View.VISIBLE);
Map<String, String> params = new HashMap<>();
params.put("uid","3939");
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()));
if (isUpdateCheck){
params.put("selected", String.valueOf(listBean.getSelected() == 1?0:1));
}else {
if (isAdd){
params.put("num", String.valueOf(listBean.getNum()+1));
}else {
params.put("num", String.valueOf(listBean.getNum()-1));
}
}
OkHttp3Util.doPost("https://www.zhaoapi.cn/product/updateCarts", params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
cartPresenter.getCartData(ApiUtil.cartUrl);
}
}
});
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
/**
* 计算价格
*/
public void sendPriceAndCount() {
double price = 0;
int count = 0;
for (int i=0;i<cartBean.getData().size();i++){
for (int j = 0;j<cartBean.getData().get(i).getList().size();j++){
if (cartBean.getData().get(i).getList().get(j).getSelected() == 1){
price += cartBean.getData().get(i).getList().get(j).getNum() * cartBean.getData().get(i).getList().get(j).getBargainPrice();
count += cartBean.getData().get(i).getList().get(j).getNum();
}
}
}
DecimalFormat decimalFormat = new DecimalFormat("#.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);
}
/**
* 根据全选状态 改变网络上所有的子条目
* @param checked
*/
public void setAllCheck(boolean checked) {
List<CartBean.DataBean.ListBean> listAll = new ArrayList<>();
for (int i=0;i<cartBean.getData().size();i++){
for (int j = 0;j<cartBean.getData().get(i).getList().size();j++){
listAll.add(cartBean.getData().get(i).getList().get(j));
}
}
allSize = listAll.size();
ai = 0;
updateAllItem(listAll,checked);
}
/**
* 使用递归 更改所有的子条目状态
* @param list
* @param checked
*/
private void updateAllItem(final List<CartBean.DataBean.ListBean> list, final boolean checked) {
relative_progress.setVisibility(View.VISIBLE);
CartBean.DataBean.ListBean listBean = list.get(ai);
Map<String, String> params = new HashMap<>();
params.put("uid","3939");
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("https://www.zhaoapi.cn/product/updateCarts", params, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
ai = ai +1;
if (ai <allSize){
updateAllItem(list,checked);
}else {
cartPresenter.getCartData(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;
}
}
OkHttp3Util
private static OkHttpClient okHttpClient = null;
private OkHttp3Util() {
}
public static OkHttpClient getInstance() {
if (okHttpClient == null) {
synchronized (OkHttp3Util.class) {
if (okHttpClient == null) {
File sdcache = new File(Environment.getExternalStorageDirectory(), "cache");
int cacheSize = 10 * 1024 * 1024;
okHttpClient = new OkHttpClient.Builder()
.connectTimeout(15, TimeUnit.SECONDS)
.writeTimeout(20, TimeUnit.SECONDS)
.readTimeout(20, TimeUnit.SECONDS)
.cache(new Cache(sdcache.getAbsoluteFile(), cacheSize))
.build();
}
}
}
return okHttpClient;
}
/**
* get请求
* 参数1 url
* 参数2 回调Callback
*/
public static void doGet(String oldUrl, Callback callback) {
Map<String,String> map = new HashMap<>();
map.put("source","android");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(oldUrl);
if (oldUrl.contains("?")){
if (oldUrl.indexOf("?") == oldUrl.length()-1){
}else {
stringBuilder.append("&");
}
}else {
stringBuilder.append("?");
}
for (Map.Entry<String,String> entry: map.entrySet()) {
stringBuilder.append(entry.getKey())
.append("=")
.append(entry.getValue())
.append("&");
}
if (stringBuilder.indexOf("&") != -1){
stringBuilder.deleteCharAt(stringBuilder.lastIndexOf("&"));
}
String newUrl = stringBuilder.toString();
OkHttpClient okHttpClient = getInstance();
Request request = new Request.Builder().url(newUrl).build();
Call call = okHttpClient.newCall(request);
call.enqueue(callback);
}
/**
* post请求
* 参数1 url
* 参数2 Map<String, String> params post请求的时候给服务器传的数据
* add..("","")
* add()
*/
public static void doPost(String url, Map<String, String> params, Callback callback) {
Map<String,String> map = new HashMap<>();
map.put("source","android");
OkHttpClient okHttpClient = getInstance();
FormBody.Builder builder = new FormBody.Builder();
for (String key : params.keySet()) {
builder.add(key, params.get(key));
}
for (Map.Entry<String,String> entry: map.entrySet()) {
builder.add(entry.getKey(),entry.getValue());
}
Request request = new Request.Builder().url(url).post(builder.build()).build();
Call call = okHttpClient.newCall(request);
call.enqueue(callback);
}
/**
* post请求上传文件....包括图片....流的形式传任意文件...
* 参数1 url
* file表示上传的文件
* fileName....文件的名字,,例如aaa.jpg
* params ....传递除了file文件 其他的参数放到map集合
*
*/
public static void uploadFile(String url, File file, String fileName,Map<String,String> params) {
OkHttpClient okHttpClient = getInstance();
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM);
if (params != null){
for (String key : params.keySet()){
builder.addFormDataPart(key,params.get(key));
}
}
builder.addFormDataPart("file",fileName,RequestBody.create(MediaType.parse("application/octet-stream"),file));
MultipartBody multipartBody = builder.build();
Request request = new Request.Builder().url(url).post(multipartBody).build();
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("upload",e.getLocalizedMessage());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
String s = response.body().string();
Log.e("upload","上传--"+s);
}
}
});
}
/**
* Post请求发送JSON数据....{"name":"zhangsan","pwd":"123456"}
* 参数一:请求Url
* 参数二:请求的JSON
* 参数三:请求回调
*/
public static void doPostJson(String url, String jsonParams, Callback callback) {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonParams);
Request request = new Request.Builder().url(url).post(requestBody).build();
Call call = getInstance().newCall(request);
call.enqueue(callback);
}
/**
* 下载文件 以流的形式把apk写入的指定文件 得到file后进行安装
* 参数er:请求Url
* 参数san:保存文件的文件夹....download
*/
public static void download(final Activity context, final String url, final String saveDir) {
Request request = new Request.Builder().url(url).build();
Call call = getInstance().newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, final Response response) throws IOException {
InputStream is = null;
byte[] buf = new byte[2048];
int len = 0;
FileOutputStream fos = null;
try {
is = response.body().byteStream();
final String fileDir = isExistDir(saveDir);
File file = new File(fileDir, getNameFromUrl(url));
fos = new FileOutputStream(file);
while ((len = is.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fos.flush();
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "下载成功:" + fileDir + "," + getNameFromUrl(url), Toast.LENGTH_SHORT).show();
}
});
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
context.startActivity(intent);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) is.close();
if (fos != null) fos.close();
}
}
});
}
/**
* 判断下载目录是否存在......并返回绝对路径
*
* @param saveDir
* @return
* @throws IOException
*/
public static String isExistDir(String saveDir) throws IOException {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File downloadFile = new File(Environment.getExternalStorageDirectory(), saveDir);
if (!downloadFile.mkdirs()) {
downloadFile.createNewFile();
}
String savePath = downloadFile.getAbsolutePath();
Log.e("savePath", savePath);
return savePath;
}
return null;
}
/**
* @param url
* @return 从下载连接中解析出文件名
*/
private static String getNameFromUrl(String url) {
return url.substring(url.lastIndexOf("/") + 1);
}
/**
* 公共参数拦截器
*/
private static class CommonParamsInterceptor implements Interceptor{
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
String method = request.method();
String oldUrl = request.url().toString();
Log.e("---拦截器",request.url()+"---"+request.method()+"--"+request.header("User-agent"));
Map<String,String> map = new HashMap<>();
map.put("source","android");
if ("GET".equals(method)){
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(oldUrl);
if (oldUrl.contains("?")){
if (oldUrl.indexOf("?") == oldUrl.length()-1){
}else {
stringBuilder.append("&");
}
}else {
stringBuilder.append("?");
}
for (Map.Entry<String,String> entry: map.entrySet()) {
stringBuilder.append(entry.getKey())
.append("=")
.append(entry.getValue())
.append("&");
}
if (stringBuilder.indexOf("&") != -1){
stringBuilder.deleteCharAt(stringBuilder.lastIndexOf("&"));
}
String newUrl = stringBuilder.toString();
request = request.newBuilder()
.url(newUrl)
.build();
}else if ("POST".equals(method)){
RequestBody oldRequestBody = request.body();
if (oldRequestBody instanceof FormBody){
FormBody oldBody = (FormBody) oldRequestBody;
FormBody.Builder builder = new FormBody.Builder();
for (int i=0;i<oldBody.size();i++){
builder.add(oldBody.name(i),oldBody.value(i));
}
for (Map.Entry<String,String> entry:map.entrySet()) {
builder.add(entry.getKey(),entry.getValue());
}
FormBody newBody = builder.build();
request = request.newBuilder()
.url(oldUrl)
.post(newBody)
.build();
}
}
Response response = chain.proceed(request);
return response;
}
}
/**
* 网络缓存的拦截器......注意在这里更改cache-control头是很危险的,一般客户端不进行更改,,,,服务器端直接指定
*
* 没网络取缓存的时候,一般都是在数据库或者sharedPerfernce中取出来的
*
*
*
*/
}
ApiUtil
public static final String cartUrl = "https://www.zhaoapi.cn/product/getCarts?uid=3939";
public static final String addCartUrl = "https://www.zhaoapi.cn/product/addCart";
public static final String deleteCartUrl = "https://www.zhaoapi.cn/product/deleteCart";
public static final String updateCartUrl = "https://www.zhaoapi.cn/product/updateCarts";
public static final String createCartUrl = "https://www.zhaoapi.cn/product/createOrder";
}
Base extends BaseAdapter
Context context
List<Dingbean.DataBean> list
Handler handler
int page=3
public Base(Context context, List<Dingbean.DataBean> list, Handler handler) {
this.context=context
this.list=list
this.handler=handler
}
@Override
public int getCount() {
return list.size()
}
@Override
public Object getItem(int i) {
return list.get(i)
}
@Override
public long getItemId(int i) {
return i
}
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
final Holder vh
if (view==null){
vh=new Holder()
view=View.inflate(context,R.layout.dingdan,null)
vh.titile = view.findViewById(R.id.dingtitile)
vh.price = view.findViewById(R.id.dingprice)
vh.time = view.findViewById(R.id.dingtime)
vh.zt = view.findViewById(R.id.zhuangtai)
vh.dan = view.findViewById(R.id.dan)
view.setTag(vh)
}else
{
vh= (Holder) view.getTag()
}
vh.titile.setText(list.get(i).getTitle())
vh.price.setText("价格:"+list.get(i).getPrice())
vh.time.setText("时间:"+list.get(i).getCreatetime())
Log.d("ffff",list.get(i).getStatus()+"")
if (list.get(i).getStatus()==0){
vh.zt.setText("待付款")
vh.zt.setTextColor(Color.RED)
}else if (list.get(i).getStatus()==1){
vh.zt.setText("已支付")
}else if (list.get(i).getStatus()==2){
vh.zt.setText("已取消")
}
if (list.get(i).getStatus()==0){
vh.dan.setText("取消订单")
vh.dan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final AlertDialog.Builder ab=new AlertDialog.Builder(context)
ab.setTitle("确认取消订单吗?")
ab.setPositiveButton("是", new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialogInterface, final int j) {
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/updateOrder?uid=2766&status=2&orderId="+list.get(i).getOrderid(), new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
final String string = response.body().string()
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, string,Toast.LENGTH_SHORT).show()
page++
OkHttp3Util.doGet("https://www.zhaoapi.cn/product/getOrders?uid=2766&page=6", new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String string = response.body().string()
if (response.isSuccessful()){
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Gson gson=new Gson()
Dingbean dingbean = gson.fromJson(string, Dingbean.class)
list.clear()
list.addAll(dingbean.getData())
vh.zt.setTextColor(Color.GRAY)
notifyDataSetChanged()
List<Dingbean.DataBean> data = dingbean.getData()
Message message=Message.obtain()
message.obj=data
message.what=2
handler.sendMessage(message)
}
})
}
}
})
}
})
}
}
})
}
})
ab.setNegativeButton("否",null)
ab.show()
}
})
}else
{
vh.dan.setText("查看订单")
}
return view
}
class Holder{
Button dan
TextView zt
TextView time
TextView price
TextView titile
}
}
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);
}
}
CartModel
private Huiprestener prestener;
public CartModel(Huiprestener presenter) {
this.prestener=presenter;
}
public void getCartData(final String cartUrl) {
OkHttp3Util.doGet(cartUrl, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e(cartUrl,e.getLocalizedMessage());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
final String json = response.body().string();
CommonUtils.runOnUIThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
CartBean cartBean = gson.fromJson(json, CartBean.class);
prestener.getSuccessCartJson(cartBean);
}
});
}
}
});
}
}
CartPresenter implements Huiprestener
private Huiactivity huiac;
private CartModel cartModel;
public CartPresenter(Huiactivity huiac) {
cartModel = new CartModel(this);
cartModel.getCartData(cartUrl);
this.huiac=huiac;
}
@Override
public void getSuccessCartJson(CartBean cartBean) {
huiac.getSuccessCartJson(cartBean);
}
public void getCartData(String cartUrl) {
cartModel.getCartData(cartUrl);
}
public void destory(){
if (huiac!=null){
huiac=null;
}
}
}
CommonUtils
public static final String TAG = "Dash";
private static SharedPreferences sharedPreferences;
/**
* DashApplication.getAppContext()可以使用,但是会使用系统默认的主题样式,如果你自定义了某些样式可能不会被使用
* @param layoutId
* @return
*/
public static View inflate(int layoutId) {
View view = View.inflate(DashApplication.getAppContext(), layoutId, null);
return view;
}
/**
* dip---px
*
* @param dip 设备独立像素device independent px....1dp = 3px 1dp = 2px 1dp = 1.5px
* @return
*/
public static int dip2px(int dip) {
float density = DashApplication.getAppContext().getResources().getDisplayMetrics().density;
int px = (int) (dip * density + 0.5f);
return px;
}
/**
* px-dip
*
* @param px
* @return
*/
public static int px2dip(int px) {
float density = DashApplication.getAppContext().getResources().getDisplayMetrics().density;
int dip = (int) (px / density + 0.5f);
return dip;
}
/**
* 获取资源中的字符串
* @param stringId
* @return
*/
public static String getString(int stringId) {
return DashApplication.getAppContext().getResources().getString(stringId);
}
public static Drawable getDrawable(int did) {
return DashApplication.getAppContext().getResources().getDrawable(did);
}
public static int getDimens(int id) {
return DashApplication.getAppContext().getResources().getDimensionPixelSize(id);
}
/**
* sp存入字符串类型的值
* @param flag
* @param str
*/
public static void saveSp(String flag, String str) {
if (sharedPreferences == null) {
sharedPreferences = DashApplication.getAppContext().getSharedPreferences(TAG, DashApplication.getAppContext().MODE_PRIVATE);
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(flag, str);
edit.commit();
}
public static String getSp(String flag) {
if (sharedPreferences == null) {
sharedPreferences = DashApplication.getAppContext().getSharedPreferences(TAG, DashApplication.getAppContext().MODE_PRIVATE);
}
return sharedPreferences.getString(flag, "");
}
public static boolean getBoolean(String tag) {
if (sharedPreferences == null) {
sharedPreferences = DashApplication.getAppContext().getSharedPreferences(TAG, DashApplication.getAppContext().MODE_PRIVATE);
}
return sharedPreferences.getBoolean(tag, false);
}
public static void putBoolean(String tag, boolean content) {
if (sharedPreferences == null) {
sharedPreferences = DashApplication.getAppContext().getSharedPreferences(TAG, DashApplication.getAppContext().MODE_PRIVATE);
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putBoolean(tag, content);
edit.commit();
}
/**
* 清除sp数据
* @param tag
*/
public static void clearSp(String tag) {
if (sharedPreferences == null) {
sharedPreferences = DashApplication.getAppContext().getSharedPreferences(TAG, DashApplication.getAppContext().MODE_PRIVATE);
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.remove(tag);
edit.commit();
}
/**
* 自己写的运行在主线程的方法
* 如果是主线程,执行任务,否则使用handler发送到主线程中去执行
*
*
* @param runable
*/
public static void runOnUIThread(Runnable runable) {
if (android.os.Process.myTid() == DashApplication.getMainThreadId()) {
runable.run();
} else {
DashApplication.getAppHanler().post(runable);
}
}
}
DashApplication extends Application
private static Context context;
private static Handler handler;
private static int mainId;
public static boolean isLoginSuccess;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
handler = new Handler();
mainId = Process.myTid();
}
/**
* 对外提供了context
* @return
*/
public static Context getAppContext() {
return context;
}
/**
* 得到全局的handler
* @return
*/
public static Handler getAppHanler() {
return handler;
}
/**
* 获取主线程id
* @return
*/
public static int getMainThreadId() {
return mainId;
}
}
CartBean
private String msg;
private String code;
private List<DataBean> data;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
public boolean isGroupChecked() {
return isGroupChecked;
}
public void setGroupChecked(boolean groupChecked) {
isGroupChecked = groupChecked;
}
/**
* list : [{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":1,"pid":22,"price":799,"pscid":1,"selected":0,"sellerid":15,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}]
* sellerName : 商家15
* sellerid : 15
*/
private boolean isGroupChecked;
private String sellerName;
private String sellerid;
private List<ListBean> list;
public String getSellerName() {
return sellerName;
}
public void setSellerName(String sellerName) {
this.sellerName = sellerName;
}
public String getSellerid() {
return sellerid;
}
public void setSellerid(String sellerid) {
this.sellerid = sellerid;
}
public List<ListBean> getList() {
return list;
}
public void setList(List<ListBean> list) {
this.list = list;
}
public static class ListBean {
/**
* bargainPrice : 111.99
* createtime : 2017-10-14T21:48:08
* detailUrl : https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends
* images : https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg
* num : 1
* pid : 22
* price : 799.0
* pscid : 1
* selected : 0
* sellerid : 15
* subhead : 每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下
* title : 北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g
*/
private double bargainPrice;
private String createtime;
private String detailUrl;
private String images;
private int num;
private int pid;
private double price;
private int pscid;
private int selected;
private int sellerid;
private String subhead;
private String title;
public double getBargainPrice() {
return bargainPrice;
}
public void setBargainPrice(double bargainPrice) {
this.bargainPrice = bargainPrice;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getDetailUrl() {
return detailUrl;
}
public void setDetailUrl(String detailUrl) {
this.detailUrl = detailUrl;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getPscid() {
return pscid;
}
public void setPscid(int pscid) {
this.pscid = pscid;
}
public int getSelected() {
return selected;
}
public void setSelected(int selected) {
this.selected = selected;
}
public int getSellerid() {
return sellerid;
}
public void setSellerid(int sellerid) {
this.sellerid = sellerid;
}
public String getSubhead() {
return subhead;
}
public void setSubhead(String subhead) {
this.subhead = subhead;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
}
}
CountPriceBean implements Serializable
private String price;
private int count;
private List<Integer> integers;
public List<Integer> getIntegers() {
return integers;
}
public void setIntegers(List<Integer> integers) {
this.integers = integers;
}
public CountPriceBean(String price, int count, List<Integer> integers) {
this.price = price;
this.count = count;
this.integers = integers;
}
public CountPriceBean(String price, int count) {
this.price = price;
this.count = count;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
Dingbean
private String code;
private String msg;
private String page;
private List<DataBean> data;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
/**
* createtime : 2017-12-18T14:43:15
* orderid : 3454
* price : 99.99
* status : 0
* title : 订单测试标题2766
* uid : 2766
*/
private String createtime;
private int orderid;
private double price;
private int status;
private String title;
private int uid;
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public int getOrderid() {
return orderid;
}
public void setOrderid(int orderid) {
this.orderid = orderid;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
}
}
GoodsBean
private String msg;
private SellerBean seller;
private String code;
private DataBean data;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public SellerBean getSeller() {
return seller;
}
public void setSeller(SellerBean seller) {
this.seller = seller;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public DataBean getData() {
return data;
}
public void setData(DataBean data) {
this.data = data;
}
public static class SellerBean {
/**
* description : 我是商家18
* icon : http://120.27.23.105/images/icon.png
* name : 商家18
* productNums : 999
* score : 5.0
* sellerid : 18
*/
private String description;
private String icon;
private String name;
private int productNums;
private double score;
private int sellerid;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getProductNums() {
return productNums;
}
public void setProductNums(int productNums) {
this.productNums = productNums;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public int getSellerid() {
return sellerid;
}
public void setSellerid(int sellerid) {
this.sellerid = sellerid;
}
}
public static class DataBean {
/**
* bargainPrice : 111.99
* createtime : 2017-10-14T21:39:05
* detailUrl : https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends
* images : https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg
* itemtype : 1
* pid : 2
* price : 299.0
* pscid : 1
* salenum : 999
* sellerid : 18
* subhead : 每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下
* title : 北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g
*/
private double bargainPrice;
private String createtime;
private String detailUrl;
private String images;
private int itemtype;
private int pid;
private double price;
private int pscid;
private int salenum;
private int sellerid;
private String subhead;
private String title;
public double getBargainPrice() {
return bargainPrice;
}
public void setBargainPrice(double bargainPrice) {
this.bargainPrice = bargainPrice;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getDetailUrl() {
return detailUrl;
}
public void setDetailUrl(String detailUrl) {
this.detailUrl = detailUrl;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images;
}
public int getItemtype() {
return itemtype;
}
public void setItemtype(int itemtype) {
this.itemtype = itemtype;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getPscid() {
return pscid;
}
public void setPscid(int pscid) {
this.pscid = pscid;
}
public int getSalenum() {
return salenum;
}
public void setSalenum(int salenum) {
this.salenum = salenum;
}
public int getSellerid() {
return sellerid;
}
public void setSellerid(int sellerid) {
this.sellerid = sellerid;
}
public String getSubhead() {
return subhead;
}
public void setSubhead(String subhead) {
this.subhead = subhead;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
}