@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 public void onMapReady(GoogleMap googleMap) { super.onMapReady(googleMap); mMap = googleMap; // Check if we were successful in obtaining the map. if (mMap != null) { GPSTracker gpsTracker = new GPSTracker(mContext); LatLng currentLatLng = new LatLng(gpsTracker.getLatitude(), gpsTracker.getLongitude()); mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLatLng)); mMap.setOnMarkerClickListener(this); presenter.getDriver(model.userToken, currentLatLng.latitude, currentLatLng.longitude); } }
@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; } } }