本文整理了Java中com.google.android.gms.common.api.Status.isSuccess()
方法的一些代码示例,展示了Status.isSuccess()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.isSuccess()
方法的具体详情如下:
包路径:com.google.android.gms.common.api.Status
类名称:Status
方法名:isSuccess
[英]Returns true if the operation was successful.
[中]如果操作成功,则返回true。
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
Toast
.makeText(getActivity(),
R.string.location_req_success_msg,
Toast.LENGTH_LONG)
.show();
} else {
Toast
.makeText(getActivity(), status.getStatusMessage(),
Toast.LENGTH_LONG)
.show();
getActivity().finish();
}
}
});
代码示例来源:origin: google/santa-tracker-android
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
SantaLog.v(
TAG,
String.format(
"App Indexing API: Recorded ["
+ title
+ "] view successfully."));
} else {
SantaLog.e(
TAG,
"App Indexing API: There was an error recording the view."
+ status.toString());
}
}
});
代码示例来源:origin: google/santa-tracker-android
@Override
public void onResult(Status status) {
mApiClient.disconnect(); // disconnecting here because of a potential race
if (status.isSuccess()) {
SantaLog.v(
TAG,
"App Indexing API: Recorded ["
+ title
+ "] view end successfully.");
} else {
SantaLog.e(
TAG,
"App Indexing API: There was an error recording the view end."
+ status.toString());
}
}
});
代码示例来源:origin: googlesamples/android-nearby
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Subscribed successfully.");
} else {
logAndShowSnackbar("Could not subscribe, status = " + status);
mSubscribeSwitch.setChecked(false);
}
}
});
代码示例来源:origin: googlesamples/android-nearby
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Subscribed successfully.");
startService(getBackgroundSubscribeServiceIntent());
} else {
Log.e(TAG, "Operation failed. Error: " +
NearbyMessagesStatusCodes.getStatusCodeString(
status.getStatusCode()));
}
}
});
代码示例来源:origin: patloew/RxFit
@Test
public void HistoryRegisterDataUpdateListenerSingle_DataType_StatusException() {
HistoryRegisterDataUpdateListenerSingle single = PowerMockito.spy(new HistoryRegisterDataUpdateListenerSingle(rxFit, pendingIntent, null, dataType, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(historyApi.registerDataUpdateListener(Matchers.eq(apiClient), Matchers.any(DataUpdateListenerRegistrationRequest.class))).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void HistoryRegisterDataUpdateListenerSingle_DataType_DataSource_StatusException() {
HistoryRegisterDataUpdateListenerSingle single = PowerMockito.spy(new HistoryRegisterDataUpdateListenerSingle(rxFit, pendingIntent, dataSource, dataType, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(historyApi.registerDataUpdateListener(Matchers.eq(apiClient), Matchers.any(DataUpdateListenerRegistrationRequest.class))).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void SensorsRemoveDataPointIntentObservable_Success() {
PendingIntent pendingIntent = Mockito.mock(PendingIntent.class);
SensorsRemoveDataPointIntentSingle single = PowerMockito.spy(new SensorsRemoveDataPointIntentSingle(rxFit, pendingIntent, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(true);
when(sensorsApi.remove(apiClient, pendingIntent)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertSingleValue(Single.create(single).test(), status);
}
代码示例来源:origin: patloew/RxFit
@Test
public void SessionInsertObservable_StatusException() {
SessionInsertRequest sessionInsertRequest = Mockito.mock(SessionInsertRequest.class);
SessionInsertSingle single = PowerMockito.spy(new SessionInsertSingle(rxFit, sessionInsertRequest, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(sessionsApi.insertSession(apiClient, sessionInsertRequest)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void SessionRegisterObservable_StatusException() {
PendingIntent pendingIntent = Mockito.mock(PendingIntent.class);
SessionRegisterSingle single = PowerMockito.spy(new SessionRegisterSingle(rxFit, pendingIntent, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(sessionsApi.registerForSessions(apiClient, pendingIntent)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void RecordingSubscribeObservable_DataSource_StatusException() {
RecordingSubscribeSingle single = PowerMockito.spy(new RecordingSubscribeSingle(rxFit, dataSource, null, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(recordingApi.subscribe(apiClient, dataSource)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void RecordingUnsubscribeObservable_DataSource_Success() {
RecordingUnsubscribeSingle single = PowerMockito.spy(new RecordingUnsubscribeSingle(rxFit, dataSource, null, null, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(true);
when(recordingApi.unsubscribe(apiClient, dataSource)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertSingleValue(Single.create(single).test(), status);
}
代码示例来源:origin: patloew/RxFit
@Test
public void ConfigDisableFitObservable_Success() {
ConfigDisableFitSingle single = PowerMockito.spy(new ConfigDisableFitSingle(rxFit, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(true);
when(configApi.disableFit(apiClient)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertSingleValue(Single.create(single).test(), status);
}
代码示例来源:origin: patloew/RxFit
@Test
public void ConfigDisableFitObservable_StatusException() {
ConfigDisableFitSingle single = PowerMockito.spy(new ConfigDisableFitSingle(rxFit, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(configApi.disableFit(apiClient)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void BleClaimDeviceObservable_DeviceAddress_Success() {
String deviceAddress = "deviceAddress";
BleClaimDeviceSingle single = PowerMockito.spy(new BleClaimDeviceSingle(rxFit, null, deviceAddress, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(true);
when(bleApi.claimBleDevice(apiClient, deviceAddress)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertSingleValue(Single.create(single).test(), status);
}
代码示例来源:origin: patloew/RxFit
@Test
public void BleUnclaimDeviceObservable_DeviceAddress_Success() {
String deviceAddress = "deviceAddress";
BleUnclaimDeviceSingle single = PowerMockito.spy(new BleUnclaimDeviceSingle(rxFit, null, deviceAddress, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(true);
when(bleApi.unclaimBleDevice(apiClient, deviceAddress)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertSingleValue(Single.create(single).test(), status);
}
代码示例来源:origin: patloew/RxFit
@Test
public void BleUnclaimDeviceObservable_DeviceAddress_StatusException() {
String deviceAddress = "deviceAddress";
BleUnclaimDeviceSingle single = PowerMockito.spy(new BleUnclaimDeviceSingle(rxFit, null, deviceAddress, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(bleApi.unclaimBleDevice(apiClient, deviceAddress)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void SessionStartObservable_StatusException() {
SessionStartSingle single = PowerMockito.spy(new SessionStartSingle(rxFit, session, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(sessionsApi.startSession(apiClient, session)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void BleClaimDeviceObservable_DeviceAddress_StatusException() {
String deviceAddress = "deviceAddress";
BleClaimDeviceSingle single = PowerMockito.spy(new BleClaimDeviceSingle(rxFit, null, deviceAddress, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(false);
when(bleApi.claimBleDevice(apiClient, deviceAddress)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertError(Single.create(single).test(), StatusException.class);
}
代码示例来源:origin: patloew/RxFit
@Test
public void BleUnclaimDeviceObservable_BleDevice_Success() {
BleUnclaimDeviceSingle single = PowerMockito.spy(new BleUnclaimDeviceSingle(rxFit, bleDevice, null, null, null));
setPendingResultValue(status);
when(status.isSuccess()).thenReturn(true);
when(bleApi.unclaimBleDevice(apiClient, bleDevice)).thenReturn(pendingResult);
setupBaseSingleSuccess(single);
assertSingleValue(Single.create(single).test(), status);
}
内容来源于网络,如有侵权,请联系作者删除!