本文整理汇总了Java中com.uber.sdk.android.rides.RideParameters类的典型用法代码示例。如果您正苦于以下问题:Java RideParameters类的具体用法?Java RideParameters怎么用?Java RideParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RideParameters类属于com.uber.sdk.android.rides包,在下文中一共展示了RideParameters类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadInformationTimeOnly_whenEstimatesSuccessfulButViewDestroyed
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformationTimeOnly_whenEstimatesSuccessfulButViewDestroyed() throws Exception {
stubPriceApiSuccessful();
stubTimeApiWithProductIdSuccessful();
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.build();
controller.destroy();
controller.loadRideInformation(rideParameters);
assertThat(controller.pendingDelegate.view).isNull();
assertThat(controller.pendingDelegate.callback).isNull();
countDownLatch.await(3, TimeUnit.SECONDS);
verifyZeroInteractions(callback);
verifyZeroInteractions(view);
}
示例2: testLoadInformationWithProductId_whenTimeOnly
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformationWithProductId_whenTimeOnly() throws Exception {
stubPriceApi(aResponse().withStatus(500));
stubTimeApiWithProductIdSuccessful();
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.build();
controller.loadRideInformation(rideParameters);
countDownLatch.countDown();
countDownLatch.await(3, TimeUnit.SECONDS);
verify(callback).onRideInformationLoaded();
verify(callback, never()).onError(Mockito.any(ApiError.class));
verify(callback, never()).onError(Mockito.any(Throwable.class));
ArgumentCaptor<TimeEstimate> timeCaptor = ArgumentCaptor.forClass(TimeEstimate.class);
verify(view).showEstimate(timeCaptor.capture());
assertThat(timeCaptor.getValue().getEstimate()).isEqualTo(120);
}
示例3: testLoadInformationNoProductId_whenTimeOnly
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformationNoProductId_whenTimeOnly() throws Exception {
stubPriceApi(aResponse().withStatus(500));
stubTimeApiSuccessful();
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.build();
controller.loadRideInformation(rideParameters);
countDownLatch.countDown();
countDownLatch.await(3, TimeUnit.SECONDS);
verify(callback).onRideInformationLoaded();
verify(callback, never()).onError(Mockito.any(ApiError.class));
verify(callback, never()).onError(Mockito.any(Throwable.class));
ArgumentCaptor<TimeEstimate> timeCaptor = ArgumentCaptor.forClass(TimeEstimate.class);
verify(view).showEstimate(timeCaptor.capture());
assertThat(timeCaptor.getValue().getEstimate()).isEqualTo(120);
}
示例4: setUp
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setDropoffLocation(valueOf(DROP_OFF_LATITUDE),
valueOf(DROP_OFF_LONGITUDE), DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.build();
Moshi moshi = new Moshi.Builder()
.add(new BigDecimalAdapter())
.build();
okHttpClient = new OkHttpClient.Builder()
.addInterceptor(new HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BODY))
.readTimeout(1, TimeUnit.SECONDS)
.retryOnConnectionFailure(false)
.build();
countDownLatch = new CountDownLatch(2);
service = new Retrofit.Builder()
.addConverterFactory(MoshiConverterFactory.create(moshi))
.callbackExecutor(new Executor() {
@Override
public void execute(@Nonnull Runnable command) {
command.run();
countDownLatch.countDown();
}
})
.client(okHttpClient)
.baseUrl("http://localhost:" + wireMockRule.port())
.build()
.create(RidesService.class);
controller = new RideRequestButtonController(view, service, callback);
}
示例5: testLoadInformationNoProductId_whenEstimatesSuccessful
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformationNoProductId_whenEstimatesSuccessful() throws Exception {
stubPriceApiSuccessful();
stubTimeApiSuccessful();
rideParameters = new RideParameters.Builder()
.setDropoffLocation(valueOf(DROP_OFF_LATITUDE),
valueOf(DROP_OFF_LONGITUDE), DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.build();
controller.loadRideInformation(rideParameters);
countDownLatch.await(3, TimeUnit.SECONDS);
verify(callback).onRideInformationLoaded();
verify(callback, never()).onError(Mockito.any(ApiError.class));
verify(callback, never()).onError(Mockito.any(Throwable.class));
ArgumentCaptor<PriceEstimate> priceCaptor = ArgumentCaptor.forClass(PriceEstimate.class);
ArgumentCaptor<TimeEstimate> timeCaptor = ArgumentCaptor.forClass(TimeEstimate.class);
verify(view).showEstimate(timeCaptor.capture(), priceCaptor.capture());
assertThat(priceCaptor.getValue().getEstimate()).isEqualTo("$5.75");
assertThat(timeCaptor.getValue().getEstimate()).isEqualTo(100);
}
示例6: testLoadInformation_wheNoPickup
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformation_wheNoPickup() {
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setDropoffLocation(valueOf(DROP_OFF_LATITUDE),
valueOf(DROP_OFF_LONGITUDE), DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.build();
controller.loadRideInformation(rideParameters);
verify(view).showDefaultView();
verify(view, never()).showEstimate(any(TimeEstimate.class));
verify(view, never()).showEstimate(any(TimeEstimate.class), any(PriceEstimate.class));
}
示例7: testLoadInformation_wheNoPickupLongitude
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformation_wheNoPickupLongitude() {
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(valueOf(PICKUP_LATITUDE), null, PICKUP_NICKNAME, PICKUP_ADDRESS)
.setDropoffLocation(valueOf(DROP_OFF_LATITUDE),
valueOf(DROP_OFF_LONGITUDE), DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.build();
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("Pickup point latitude is set in " +
"RideParameters but not the longitude.");
controller.loadRideInformation(rideParameters);
}
示例8: testLoadInformation_wheNoPickupLatitude
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformation_wheNoPickupLatitude() {
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(null, valueOf(PICKUP_LONGITUDE), PICKUP_NICKNAME, PICKUP_ADDRESS)
.setDropoffLocation(null, valueOf(DROP_OFF_LONGITUDE), DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.build();
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("Pickup point longitude is set in " +
"RideParameters but not the latitude.");
controller.loadRideInformation(rideParameters);
}
示例9: testLoadInformation_wheNoDropOffLatitude
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformation_wheNoDropOffLatitude() {
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.setDropoffLocation(null, valueOf(DROP_OFF_LONGITUDE), DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.build();
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("Dropoff point longitude is set in RideParameters but not the latitude.");
controller.loadRideInformation(rideParameters);
}
示例10: testLoadInformation_wheNoDropOffLongitude
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Test
public void testLoadInformation_wheNoDropOffLongitude() {
rideParameters = new RideParameters.Builder()
.setProductId(PRODUCT_ID)
.setPickupLocation(valueOf(PICKUP_LATITUDE), valueOf(PICKUP_LONGITUDE),
PICKUP_NICKNAME, PICKUP_ADDRESS)
.setDropoffLocation(valueOf(DROP_OFF_LATITUDE), null, DROP_OFF_NICKNAME, DROP_OFF_ADDRESS)
.build();
expectedException.expect(NullPointerException.class);
expectedException.expectMessage("Dropoff point latitude is set in RideParameters but not the longitude.");
controller.loadRideInformation(rideParameters);
}
示例11: loadRideInformation
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
public void loadRideInformation(@NonNull RideParameters rideParameters) {
if (rideParameters.getPickupLatitude() != null) {
checkNotNull(rideParameters.getPickupLongitude(), "Pickup point latitude is set in " +
"RideParameters but not the longitude.");
}
if (rideParameters.getPickupLongitude() != null) {
checkNotNull(rideParameters.getPickupLatitude(), "Pickup point longitude is set in " +
"RideParameters but not the latitude.");
}
if (rideParameters.getDropoffLatitude() != null) {
checkNotNull(rideParameters.getDropoffLongitude(), "Dropoff point latitude is set in " +
"RideParameters but not the longitude.");
}
if (rideParameters.getDropoffLongitude() != null) {
checkNotNull(rideParameters.getDropoffLatitude(), "Dropoff point longitude is set in" +
" RideParameters but not the latitude.");
}
cancelAllPending();
if (rideParameters.getPickupLatitude() != null) {
if (rideParameters.getDropoffLatitude() != null) {
TimePriceDelegate pendingDelegate = new TimePriceDelegate(rideRequestButtonView, rideRequestButtonCallback);
loadPriceEstimate(
rideParameters.getPickupLatitude().floatValue(),
rideParameters.getPickupLongitude().floatValue(),
rideParameters.getDropoffLatitude().floatValue(),
rideParameters.getDropoffLongitude().floatValue(),
rideParameters.getProductId(),
pendingDelegate);
this.pendingDelegate = pendingDelegate;
} else {
pendingDelegate = new TimeDelegate(rideRequestButtonView, rideRequestButtonCallback);
}
loadTimeEstimate(
pendingDelegate,
rideParameters.getPickupLatitude().floatValue(),
rideParameters.getPickupLongitude().floatValue(),
rideParameters.getProductId());
} else {
rideRequestButtonView.showDefaultView();
}
}
示例12: onCreate
import com.uber.sdk.android.rides.RideParameters; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
configuration = new SessionConfiguration.Builder()
.setRedirectUri(REDIRECT_URI)
.setClientId(CLIENT_ID)
.setServerToken(SERVER_TOKEN)
.build();
validateConfiguration(configuration);
ServerTokenSession session = new ServerTokenSession(configuration);
RideParameters rideParametersForProduct = new RideParameters.Builder()
.setProductId(UBERX_PRODUCT_ID)
.setPickupLocation(PICKUP_LAT, PICKUP_LONG, PICKUP_NICK, PICKUP_ADDR)
.setDropoffLocation(DROPOFF_LAT, DROPOFF_LONG, DROPOFF_NICK, DROPOFF_ADDR)
.build();
// This button demonstrates deep-linking to the Uber app (default button behavior).
blackButton = (RideRequestButton) findViewById(R.id.uber_button_black);
blackButton.setRideParameters(rideParametersForProduct);
blackButton.setSession(session);
blackButton.setCallback(this);
blackButton.loadRideInformation();
RideParameters rideParametersCheapestProduct = new RideParameters.Builder()
.setPickupLocation(PICKUP_LAT, PICKUP_LONG, PICKUP_NICK, PICKUP_ADDR)
.setDropoffLocation(DROPOFF_LAT, DROPOFF_LONG, DROPOFF_NICK, DROPOFF_ADDR)
.build();
// This button demonstrates launching the RideRequestActivity (customized button behavior).
// You can optionally setRideParameters for pre-filled pickup and dropoff locations.
RideRequestButton uberButtonWhite = (RideRequestButton) findViewById(R.id.uber_button_white);
RideRequestActivityBehavior rideRequestActivityBehavior = new RideRequestActivityBehavior(this,
WIDGET_REQUEST_CODE, configuration);
uberButtonWhite.setRequestBehavior(rideRequestActivityBehavior);
uberButtonWhite.setRideParameters(rideParametersForProduct);
uberButtonWhite.setSession(session);
uberButtonWhite.loadRideInformation();
}