|
|
@@ -1,18 +1,27 @@
|
|
|
package com.modular.booking.activity.services;
|
|
|
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.drawable.Drawable;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Parcelable;
|
|
|
+import android.support.v7.app.ActionBar;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.widget.AbsListView;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.common.LogUtil;
|
|
|
+import com.common.data.ListUtils;
|
|
|
import com.core.base.OABaseActivity;
|
|
|
import com.core.widget.CustomerListView;
|
|
|
+import com.core.widget.DrawableCenterTextView;
|
|
|
import com.core.widget.PinnedSectionListView;
|
|
|
import com.flipboard.bottomsheet.BottomSheetLayout;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
|
@@ -43,7 +52,7 @@ import rx.android.schedulers.AndroidSchedulers;
|
|
|
public class DishSelectActivity extends OABaseActivity {
|
|
|
|
|
|
public static final String TAG = "DishSelectActivity";
|
|
|
- private CircleImageView mCircleImage;
|
|
|
+ private CircleImageView iv_header;
|
|
|
private TextView tv_title;
|
|
|
private TextView tv_sub;
|
|
|
private BottomSheetLayout mBottmSheetLayout;
|
|
|
@@ -53,7 +62,16 @@ public class DishSelectActivity extends OABaseActivity {
|
|
|
|
|
|
private ShoppingCartPanel mShoppingCartPanel;
|
|
|
|
|
|
- private Button bt_bottom;
|
|
|
+ private Button bt_bottom;
|
|
|
+ private ImageView max_img;
|
|
|
+ private ImageView mBackImageView;
|
|
|
+ private DrawableCenterTextView mSearchTv;
|
|
|
+ private RelativeLayout mRelativeTop;
|
|
|
+ private Drawable drawBg;
|
|
|
+
|
|
|
+ private ImageView ivShopCar;
|
|
|
+ private TextView tvShopSure;
|
|
|
+ private TextView tvTotalPrice;
|
|
|
|
|
|
private List<ProductCategory> productCategories=new ArrayList<>();
|
|
|
List<ProductCategory> productAllCategorys=new ArrayList<>();
|
|
|
@@ -72,26 +90,58 @@ public class DishSelectActivity extends OABaseActivity {
|
|
|
}
|
|
|
|
|
|
private void initView(){
|
|
|
+ View view = LayoutInflater.from(ct).inflate(R.layout.action_book_service, null);
|
|
|
+ mBackImageView = (ImageView) view.findViewById(R.id.book_service_back);
|
|
|
+ mSearchTv = (DrawableCenterTextView) view.findViewById(R.id.book_service_et);
|
|
|
+ mRelativeTop = (RelativeLayout) view.findViewById(R.id.book_service_action);
|
|
|
+ ActionBar bar = this.getSupportActionBar();
|
|
|
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
+ drawBg = getResources().getDrawable(R.color.antionbarcolor);
|
|
|
+ bar.setBackgroundDrawable(drawBg);
|
|
|
+ bar.setCustomView(view);
|
|
|
+
|
|
|
mShoppingCartPanel = new ShoppingCartPanel(this);
|
|
|
- getSupportActionBar().setTitle("选菜");
|
|
|
lv_product_category= findViewById(R.id.lv_product_category);
|
|
|
mBottmSheetLayout=findViewById(R.id.bottom_sheet_layout);
|
|
|
lv_product=findViewById(R.id.lv_dish_product);
|
|
|
-// ll_bottom=findViewById(R.id.ll_bottom);
|
|
|
+ ll_bottom=findViewById(R.id.ll_bottom);
|
|
|
bt_bottom=findViewById(R.id.bt_bottom);
|
|
|
+ iv_header =findViewById(R.id.iv_header);
|
|
|
+ max_img = findViewById(R.id.max_img);
|
|
|
+ tv_title =findViewById(R.id.tv_title);
|
|
|
+ tv_sub =findViewById(R.id.tv_sub);
|
|
|
+ ivShopCar=findViewById(R.id.ivShopCar);
|
|
|
+ tvShopSure=findViewById(R.id.tvShopSure);
|
|
|
+ tvTotalPrice=findViewById(R.id.tvTotalPrice);
|
|
|
+
|
|
|
itemDishCategoryListAdapter=new ItemDishCategoryListAdapter(DishSelectActivity.this,productCategories);
|
|
|
lv_product_category.setAdapter( itemDishCategoryListAdapter);
|
|
|
lv_product_category.setSelection(0);
|
|
|
|
|
|
|
|
|
itemDishPinnedListAdapter=new ItemDishPinnedListAdapter(mContext,productAllCategorys);
|
|
|
+ itemDishPinnedListAdapter.setAnimTargetView(ivShopCar);
|
|
|
lv_product.setAdapter(itemDishPinnedListAdapter);
|
|
|
|
|
|
-// lv_product_category.setItemChecked(0,true);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
private boolean isClickTrigger=true;
|
|
|
private void initEvent(){
|
|
|
- bt_bottom.setOnClickListener(new View.OnClickListener() {
|
|
|
+ tvShopSure.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ //先确保购物车不为空
|
|
|
+ if (!ListUtils.isEmpty(ShoppingCart.getInstance().getShoppingList())) {
|
|
|
+ setResult(0x01,new Intent().putParcelableArrayListExtra("data", (ArrayList<? extends Parcelable>) ShoppingCart.getInstance().getShoppingList()));
|
|
|
+ finish();
|
|
|
+ }else{
|
|
|
+ ToastMessage("您的购物车是空的哦");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ ll_bottom.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
showShoppingCartPanel();
|
|
|
@@ -237,13 +287,28 @@ public class DishSelectActivity extends OABaseActivity {
|
|
|
Subscription mSubscription;
|
|
|
|
|
|
public void onShoppingCartChange(Object o) {
|
|
|
- // refreshBottomUi();
|
|
|
+ refreshBottomUi();
|
|
|
LogUtil.d(TAG,"o:"+o.toString());
|
|
|
mShoppingCartPanel.refreshPanel();
|
|
|
itemDishCategoryListAdapter.notifyDataSetChanged();
|
|
|
itemDishPinnedListAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
+ private void refreshBottomUi() {
|
|
|
+ ShoppingCart shoppingCart = ShoppingCart.getInstance();
|
|
|
+ int totalCount = shoppingCart.getTotalQuantity();
|
|
|
+ double totalPrice = shoppingCart.getTotalPrice();
|
|
|
+ if (totalCount>0) {
|
|
|
+ tvTotalPrice.setText("共¥" + totalPrice);
|
|
|
+ ivShopCar.setBackgroundResource(R.drawable.icon_shop_car);
|
|
|
+ ivShopCar.setImageDrawable(getResources().getDrawable(R.drawable.icon_shop_car));
|
|
|
+ }else{
|
|
|
+ tvTotalPrice.setText(getString(R.string.tv_shop_empty) );
|
|
|
+ ivShopCar.setBackgroundResource(R.drawable.icon_shop_empty);
|
|
|
+ ivShopCar.setImageDrawable(getResources().getDrawable(R.drawable.icon_shop_empty));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|