@Override public void onCostResult(String cost) { model.cost = cost; Intent intent = new Intent(mContext, OrderConfirmActivity.class); intent.putExtra(Extras.BOOKING_TYPE, Constant.BOOK_TYPE_SHOPPING); intent.putExtra(Extras.BOOKING_INFO, model); startActivity(intent); }
private boolean validInput() { model.shopDetails = edtShopDetails.getText().toString().trim(); model.locationDetails = edtLocationDetails.getText().toString().trim(); model.items = edtItems.getText().toString().trim(); model.cost = edtCost.getText().toString().trim(); if (model.driverToken == null || model.driverToken.isEmpty()) { model.driverToken = ""; } if (model.latFrom == 0 || model.lngFrom == 0) { Snackbar.make( findViewById(R.id.tab_container), getString(R.string.snackbar_picklocationfrom), Snackbar.LENGTH_SHORT) .show(); tvAddressFrom.setError(""); return false; } if (model.latTo == 0 || model.lngTo == 0) { Snackbar.make( findViewById(R.id.tab_container), getString(R.string.snackbar_picklocationto), Snackbar.LENGTH_SHORT) .show(); tvAddressTo.setError(""); return false; } if (model.items.isEmpty()) { edtItems.setError(getText(R.string.error_itemsempty)); return false; } if (model.cost.isEmpty()) { edtCost.setError(getText(R.string.error_costempty)); return false; } return true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; presenter = new OrderShoppingPresenter(this); model = new OrderShoppingModel(); initView(); SharedPreferences loginPreferences = getSharedPreferences(Preferences.LOGIN_PREFERENCES, MODE_PRIVATE); model.userToken = loginPreferences.getString(Preferences.LOGIN_PREFERENCES_USER_TOKEN, ""); initMap(); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { LatLng receivedLatLng; switch (requestCode) { case RequestCodes.PICK_DRIVER: model.driverName = data.getStringExtra(Extras.PICKED_DRIVER_NAME); model.driverToken = data.getStringExtra(Extras.PICKED_DRIVER_TOKEN); tvDriverName.setText(model.driverName); tvDriverName.setError(null); break; case RequestCodes.PICK_LOCATION_FROM: receivedLatLng = data.getParcelableExtra(Extras.PICKED_LATLNG); model.latFrom = receivedLatLng.latitude; model.lngFrom = receivedLatLng.longitude; model.addressFrom = data.getStringExtra(Extras.PICKED_ADDRESS); tvAddressFrom.setText(model.addressFrom); tvAddressFrom.setError(null); break; case RequestCodes.PICK_LOCATION_TO: receivedLatLng = data.getParcelableExtra(Extras.PICKED_LATLNG); model.latTo = receivedLatLng.latitude; model.lngTo = receivedLatLng.longitude; model.addressTo = data.getStringExtra(Extras.PICKED_ADDRESS); tvAddressTo.setText(model.addressTo); tvAddressTo.setError(null); break; } } }