Skip to content

Commit

Permalink
- Done #413
Browse files Browse the repository at this point in the history
- Done #406
  • Loading branch information
Jose Torres committed Feb 24, 2016
1 parent 8d236ff commit a983e32
Show file tree
Hide file tree
Showing 25 changed files with 249 additions and 81 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ android {
productFlavors {
production {
applicationId "com.bentonow.bentonow"
versionName '1.22-rc01'
versionName '1.22-rc02'
}
stage {
applicationId "com.bentonow.bentonow.stage"
versionName '1.22-rc01-dev'
versionName '1.22-rc02-dev'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,15 @@ public void onClick(View view) {
});

viewHolder.getTxtNumberAddOn().setText(String.valueOf(mDishDao.countItemsById(mDish.itemId)));
viewHolder.getImgGradient().setVisibility(iDishSelected == position ? View.VISIBLE : View.INVISIBLE);


/* if (mDishDao.isSoldOut(mDish, true, bIsMenuOD)) {
viewHolder.getImgSoldOut().setVisibility(View.VISIBLE);
viewHolder.getImgGradient().setVisibility(View.VISIBLE);
if (mDish.is_oa_only == 1) {
viewHolder.getImgAddDish().setImageResource(R.drawable.ic_action_content_add_circle_outline_gray);
viewHolder.getImgRemoveDish().setImageResource(R.drawable.ic_action_content_remove_circle_outline_gray);
viewHolder.getImgAddDish().setOnClickListener(null);
viewHolder.getImgRemoveDish().setOnClickListener(null);
} else if (!mDishDao.canBeAdded(mDish)) {
viewHolder.getImgSoldOut().setVisibility(View.VISIBLE);
viewHolder.getImgGradient().setVisibility(View.VISIBLE);
viewHolder.getImgAddDish().setImageResource(R.drawable.ic_action_content_add_circle_outline_gray);
// viewHolder.getImgRemoveDish().setImageResource(R.drawable.ic_action_content_remove_circle_outline_gray);
viewHolder.getImgAddDish().setOnClickListener(null);
} else {
viewHolder.getImgSoldOut().setVisibility(View.INVISIBLE);
viewHolder.getImgGradient().setVisibility(iDishSelected == position ? View.VISIBLE : View.INVISIBLE);
viewHolder.getImgAddDish().setImageResource(R.drawable.ic_action_content_add_circle_outline);
viewHolder.getImgRemoveDish().setImageResource(R.drawable.ic_action_content_remove_circle_outline);
}*/


if (!mDishDao.canBeAdded(mDish) || mDishDao.isSoldOut(mDish, true, bIsMenuOD)) {
viewHolder.getImgSoldOut().setVisibility(View.GONE);
} else if (!mDishDao.canBeAdded(mDish) || mDishDao.isSoldOut(mDish, true, bIsMenuOD)) {
viewHolder.getImgSoldOut().setVisibility(View.VISIBLE);
viewHolder.getImgGradient().setVisibility(View.VISIBLE);

Expand All @@ -133,12 +118,12 @@ public void onClick(View view) {

} else {
viewHolder.getImgSoldOut().setVisibility(View.INVISIBLE);
viewHolder.getImgGradient().setVisibility(iDishSelected == position ? View.VISIBLE : View.INVISIBLE);
viewHolder.getImgAddDish().setImageResource(R.drawable.ic_action_content_add_circle_outline);
viewHolder.getImgRemoveDish().setImageResource(R.drawable.ic_action_content_remove_circle_outline);
}

viewHolder.getTxtDescription().setVisibility(iDishSelected == position ? View.VISIBLE : View.INVISIBLE);
viewHolder.getTxtOaLabel().setVisibility(mDish.is_oa_only == 0 || iDishSelected == position ? View.GONE : View.VISIBLE);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,27 @@ public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

viewHolder.getBtnAddToBento().setVisibility(!added ? View.VISIBLE : View.GONE);

viewHolder.getBtnAddToBento().setOnClickListener(new View.OnClickListener() {
viewHolder.getBtnAddToBento().setOnClickListener(mDish.is_oa_only == 1 ? null : new View.OnClickListener() {
@Override
public void onClick(View view) {
mListener.onAddToBentoClick(position);
DebugUtils.logDebug("onAddToBentoClick()", position);
}
});

viewHolder.getBtnAdded().setOnClickListener(new View.OnClickListener() {
viewHolder.getBtnAdded().setOnClickListener(mDish.is_oa_only == 1 ? null : new View.OnClickListener() {
@Override
public void onClick(View view) {
mListener.onAddedClick(position);
DebugUtils.logDebug("onAddedClick()", position);
}
});

if (!mDishDao.canBeAdded(mDish)) {
if (mDish.is_oa_only == 1) {
viewHolder.getBtnAddToBento().setText(IosCopyDao.get("oa-only-od-btn"));
viewHolder.getImgSoldOut().setVisibility(View.GONE);
getItem(position).can_be_added = 0;
} else if (!mDishDao.canBeAdded(mDish)) {
viewHolder.getBtnAddToBento().setText(IosCopyDao.get("reached-max-button"));
viewHolder.getImgSoldOut().setVisibility(View.GONE);
getItem(position).can_be_added = 0;
Expand All @@ -158,6 +162,7 @@ public void onClick(View view) {
getItem(position).can_be_added = 1;
}

viewHolder.getTxtOaLabel().setVisibility(mDish.is_oa_only == 0 || selected ? View.GONE : View.VISIBLE);

return convertView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ public void onClick(View view) {
} else
viewHolder.getTxtDescription().setVisibility(View.GONE);

if (!dishDao.canBeAdded(mDish)) {
if (mDish.is_oa_only == 1) {
viewHolder.getBtnAddToBento().setText(IosCopyDao.get("oa-only-od-btn"));
viewHolder.getImgSoldOut().setVisibility(View.GONE);
getItem(position).can_be_added = 0;
} else if (!dishDao.canBeAdded(mDish)) {
viewHolder.getBtnAddToBento().setText(IosCopyDao.get("reached-max-button"));
viewHolder.getImgSoldOut().setVisibility(View.GONE);
getItem(position).can_be_added = 0;
Expand All @@ -145,6 +149,9 @@ public void onClick(View view) {
getItem(position).can_be_added = 1;
}


viewHolder.getTxtOaLabel().setVisibility(mDish.is_oa_only == 0 || selected ? View.GONE : View.VISIBLE);

return convertView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public boolean onTouch(View v, MotionEvent event) {

@Override
public void show() {

//TODO Dont show dialog if is in background
super.show();
// set dialog enter animations
view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import com.bentonow.bentonow.R;
import com.bentonow.bentonow.Utils.AndroidUtil;
import com.bentonow.bentonow.Utils.BentoNowUtils;
import com.bentonow.bentonow.Utils.DebugUtils;
import com.bentonow.bentonow.Utils.GoogleAnalyticsUtil;
import com.bentonow.bentonow.Utils.MixpanelUtils;
import com.bentonow.bentonow.controllers.BaseFragmentActivity;
import com.bentonow.bentonow.controllers.dialog.ConfirmationDialog;
import com.bentonow.bentonow.model.user.CouponRequest;
import com.bentonow.bentonow.ui.AutoFitTxtView;
import com.bentonow.bentonow.ui.BackendEditText;
import com.bentonow.bentonow.web.request.UserRequest;
Expand All @@ -31,7 +31,7 @@ public class BummerActivity extends BaseFragmentActivity implements View.OnClick
private EditText txt_email;
private AutoFitTxtView txtAddress;

private String sCurrentLocation = "";
private CouponRequest mCoupon;


@Override
Expand All @@ -41,22 +41,20 @@ protected void onCreate(Bundle savedInstanceState) {

initActionbar();

sCurrentLocation = getIntent().getExtras().getString(TAG_INVALID_ADDRESS);
mCoupon = getIntent().getExtras().getParcelable(CouponRequest.TAG);

txt_email = (BackendEditText) findViewById(R.id.txt_email);

if (sCurrentLocation == null || sCurrentLocation.isEmpty())
sCurrentLocation = BentoNowUtils.getFullAddress();

getTxtAddress().setText(sCurrentLocation);
getTxtAddress().setText(mCoupon.address);

try {
JSONObject params = new JSONObject();
params.put("Address", sCurrentLocation);
params.put("Address", mCoupon.address);
MixpanelUtils.track("Selected Address Outside of Service Area", params);
} catch (Exception e) {
DebugUtils.logError(TAG, e);
}

}

public void onChangePressed(View view) {
Expand All @@ -69,7 +67,10 @@ public void onSubmitPressed(View view) {
mDialog.addAcceptButton("OK", null);
mDialog.show();
} else {
UserRequest.requestCoupon(txt_email.getText().toString(), "outside of delivery zone", new TextHttpResponseHandler() {

mCoupon.email = txt_email.getText().toString();

UserRequest.requestCoupon(mCoupon, new TextHttpResponseHandler() {
@SuppressWarnings("deprecation")
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
Expand Down Expand Up @@ -119,7 +120,6 @@ protected void onDestroy() {
}



private AutoFitTxtView getTxtAddress() {
if (txtAddress == null)
txtAddress = (AutoFitTxtView) findViewById(R.id.txt_address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import com.bentonow.bentonow.dao.MenuDao;
import com.bentonow.bentonow.listener.InterfaceCustomerService;
import com.bentonow.bentonow.model.Menu;
import com.bentonow.bentonow.model.user.CouponRequest;
import com.bentonow.bentonow.service.BentoCustomerService;
import com.bentonow.bentonow.ui.BackendTextView;
import com.bentonow.bentonow.web.request.UserRequest;
import com.google.android.gms.maps.model.LatLng;
import com.loopj.android.http.TextHttpResponseHandler;

import org.apache.http.Header;
Expand Down Expand Up @@ -171,7 +173,18 @@ public void onSubmitPressed() {
mDialog.addAcceptButton("OK", null);
mDialog.show();
} else {
UserRequest.requestCoupon(getEditTxtEmail().getText().toString(), sStatus, new TextHttpResponseHandler() {
CouponRequest mCoupon = new CouponRequest();
mCoupon.reason = sStatus;
mCoupon.email = getEditTxtEmail().getText().toString();
mCoupon.address = BentoNowUtils.getFullAddress();

LatLng mLocation = BentoNowUtils.getOrderLocation();
if (mLocation != null) {
mCoupon.lat = String.valueOf(mLocation.latitude);
mCoupon.lng = String.valueOf(mLocation.longitude);
}

UserRequest.requestCoupon(mCoupon, new TextHttpResponseHandler() {
@SuppressWarnings("deprecation")
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.bentonow.bentonow.listener.OnCustomDragListener;
import com.bentonow.bentonow.model.AutoCompleteModel;
import com.bentonow.bentonow.model.Order;
import com.bentonow.bentonow.model.user.CouponRequest;
import com.bentonow.bentonow.parse.InitParse;
import com.bentonow.bentonow.ui.BackendTextView;
import com.bentonow.bentonow.web.BentoNowApi;
Expand Down Expand Up @@ -420,8 +421,14 @@ private void getMenusByLocation(String responseString) {
DebugUtils.logDebug(TAG, "onContinuePressed AppState " + MenuDao.gateKeeper.getAppState());

if (MenuDao.gateKeeper.getAppState().contains("map,no_service")) {
CouponRequest mCoupon = new CouponRequest();
mCoupon.reason = "outside of delivery zone";
mCoupon.address = getTxtAddress().getText().toString();
mCoupon.lat = String.valueOf(mLastOrderLocation.latitude);
mCoupon.lng = String.valueOf(mLastOrderLocation.longitude);

Intent mIntentBummer = new Intent(DeliveryLocationActivity.this, BummerActivity.class);
mIntentBummer.putExtra(BummerActivity.TAG_INVALID_ADDRESS, getTxtAddress().getText().toString());
mIntentBummer.putExtra(CouponRequest.TAG, mCoupon);
startActivity(mIntentBummer);
} else if (MenuDao.gateKeeper.getAppState().contains("build")) {
switch (optOpenScreen) {
Expand Down Expand Up @@ -903,6 +910,13 @@ protected FilterResults performFiltering(CharSequence constraint) {
if (bAllowRequest) {
bAllowRequest = false;
resultList = autocomplete(constraint.toString());
runOnUiThread(new Runnable() {
@Override
public void run() {
notifyDataSetChanged();
}
});

bAllowRequest = true;

// Assign the data to the FilterResults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ private void addAddOnDishes() {
getListAdapter().aListDish.add(dishModel);
}

for (DishModel dishModel : mMenu.oaItems) {
if (dishModel.type.equals("addon")) {
dishModel.is_oa_only = 1;
getListAdapter().aListDish.add(dishModel);
}
}


getListAdapter().aListDish.addAll(aSoldDish);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

for (DishModel dishModel : mMenu.oaItems) {
if (dishModel.type.equals("main")) {
dishModel.is_oa_only = 1;
getListAdapter().add(dishModel);
}
}

getListAdapter().addAll(aSoldDish);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ protected void onCreate(Bundle savedInstanceState) {
getListAdapter().add(dishModel);
}

for (DishModel dishModel : mMenu.oaItems) {
if (dishModel.type.equals("side")) {
dishModel.is_oa_only = 1;
getListAdapter().add(dishModel);
}
}

getListAdapter().addAll(aSoldDish);
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/bentonow/bentonow/dao/StockDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public static boolean isSold(int itemId, boolean countCurrent) {
}
} catch (Exception ex) {
DebugUtils.logError(TAG, ex);
return false;
}
}
return false;
return true;
}


Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/bentonow/bentonow/model/DishModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class DishModel implements Parcelable {
public String qty;
public int count_max;
public int can_be_added;
public int is_oa_only;

public DishModel() {

Expand All @@ -40,6 +41,7 @@ public DishModel(Parcel parcel) {
qty = parcel.readString();
count_max = parcel.readInt();
can_be_added = parcel.readInt();
is_oa_only = parcel.readInt();
}

@Override
Expand All @@ -57,6 +59,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(qty);
dest.writeInt(count_max);
dest.writeInt(can_be_added);
dest.writeInt(is_oa_only);
}


Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/bentonow/bentonow/model/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class Menu implements Parcelable {
public String day_text = "";
public String day_text2 = "";
public String displayStartTime = "";
public List<DishModel> dishModels;
public List<DishModel> dishModels = new ArrayList<>();
public List<DishModel> oaItems = new ArrayList<>();
public List<TimesModel> listTimeModel = new ArrayList<>();

public Menu() {
Expand All @@ -42,8 +43,10 @@ public Menu(Parcel parcel) {
day_text2 = parcel.readString();
displayStartTime = parcel.readString();
dishModels = new ArrayList<>();
oaItems = new ArrayList<>();
listTimeModel = new ArrayList<>();
parcel.readList(dishModels, DishModel.class.getClassLoader());
parcel.readList(oaItems, DishModel.class.getClassLoader());
parcel.readList(listTimeModel, TimesModel.class.getClassLoader());
}

Expand All @@ -61,6 +64,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(day_text2);
dest.writeString(displayStartTime);
dest.writeList(dishModels);
dest.writeList(oaItems);
dest.writeList(listTimeModel);
}

Expand Down
Loading

0 comments on commit a983e32

Please sign in to comment.