use of retrofit.client.Response in project glasquare by davidvavra.
the class CheckInSearchActivity method loadData.
@Override
protected void loadData() {
showProgress(R.string.loading);
LocationUtils.getRecentLocation(new LocationUtils.LocationListener() {
@Override
public void onLocationAcquired(Location location) {
String ll = LocationUtils.getLatLon(location);
Api.get().create(SearchVenues.class).searchForCheckIn(ll, new Callback<SearchVenues.SearchResponse>() {
@Override
public void success(SearchVenues.SearchResponse venuesResponse, Response response) {
showContent(new CheckInSearchAdapter(venuesResponse.getVenues()), new CardSelectedListener() {
@Override
public void onCardSelected(Object item) {
SearchVenues.Venue venue = (SearchVenues.Venue) item;
CheckInActivity.call(CheckInSearchActivity.this, venue.id, venue.name);
}
});
}
@Override
public void failure(RetrofitError retrofitError) {
showError(R.string.error_please_try_again);
}
});
}
@Override
public void onLocationFailed() {
showError(R.string.no_location);
}
});
}
use of retrofit.client.Response in project connect-android-sdk by telenordigital.
the class MobileConnectSdkProfile method onStartAuthorization.
@Override
public void onStartAuthorization(Map<String, String> parameters, final OnStartAuthorizationCallback callback) {
super.onStartAuthorization(parameters, callback);
lastAuthNonce = UUID.randomUUID().toString();
parameters.put("nonce", lastAuthNonce);
if (parameters.get(ConnectUtils.ACR_VALUES_PARAM_NAME) == null) {
parameters.put(ConnectUtils.ACR_VALUES_PARAM_NAME, "2");
}
if (isInitialized()) {
callback.onSuccess();
return;
}
TelephonyManager phMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = phMgr.getNetworkOperator();
if (TextUtils.isEmpty(networkOperator)) {
callback.onError();
return;
}
final String mcc = networkOperator.substring(0, 3);
final String mnc = networkOperator.substring(3);
getOperatorDiscoveryApi().getOperatorDiscoveryResult_ForMccMnc(getOperatorDiscoveryAuthHeader(), operatorDiscoveryConfig.getOperatorDiscoveryRedirectUri(), mcc, mnc, new Callback<OperatorDiscoveryAPI.OperatorDiscoveryResult>() {
@Override
public void success(OperatorDiscoveryAPI.OperatorDiscoveryResult operatorDiscoveryResult, Response response) {
initAndContinue(operatorDiscoveryResult, callback);
}
@Override
public void failure(RetrofitError error) {
callback.onError();
}
});
}
use of retrofit.client.Response in project connect-android-sdk by telenordigital.
the class ConnectSdk method sendAnalyticsData.
private static void sendAnalyticsData() {
if (getWellKnownConfig().getAnalyticsEndpoint() == null) {
return;
}
String accessToken = getAccessToken();
final String auth = accessToken != null ? "Bearer " + accessToken : null;
final String subject = getIdToken() != null ? getIdToken().getSubject() : null;
RestHelper.getAnalyticsApi(getWellKnownConfig().getAnalyticsEndpoint()).sendAnalyticsData(auth, new AnalyticsAPI.SDKAnalyticsData(getApplicationName(), getApplicationVersion(), subject, getLogSessionId(), getAdvertisingId(), tsSdkInitiliazation, tsLoginButtonClicked, tsRedirectUrlInvoked, tsTokenResponseReceived), new ResponseCallback() {
@Override
public void success(Response response) {
}
@Override
public void failure(RetrofitError error) {
Log.e(ConnectUtils.LOG_TAG, "Failed to send analytics data", error);
}
});
}
use of retrofit.client.Response in project matrix-android-sdk by matrix-org.
the class LoginRestClient method loginWithToken.
/**
* Attempt a user/token log in.
*
* @param user the user name
* @param token the token
* @param txn_id the client transaction id to include in the request
* @param deviceName the device name
* @param callback the callback success and failure callback
*/
public void loginWithToken(final String user, final String token, final String txn_id, String deviceName, final ApiCallback<Credentials> callback) {
// privacy
// final String description = "loginWithPassword user : " + user;
final String description = "loginWithPassword user";
TokenLoginParams params = new TokenLoginParams();
params.user = user;
params.token = token;
params.txn_id = txn_id;
if ((null != deviceName) && !TextUtils.isEmpty(deviceName.trim())) {
params.initial_device_display_name = deviceName.trim();
} else {
params.initial_device_display_name = Build.MODEL.trim();
}
try {
mApi.login(params, new RestAdapterCallback<JsonObject>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
loginWithToken(user, token, txn_id, callback);
}
}) {
@Override
public void success(JsonObject jsonObject, Response response) {
onEventSent();
mCredentials = gson.fromJson(jsonObject, Credentials.class);
callback.onSuccess(mCredentials);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
use of retrofit.client.Response in project matrix-android-sdk by matrix-org.
the class ProfileRestClient method refreshTokens.
/**
* Attempt a user/password registration.
* @param callback the callback success and failure callback
*/
public void refreshTokens(final ApiCallback<Credentials> callback) {
final String description = "refreshTokens";
TokenRefreshParams params = new TokenRefreshParams();
params.refresh_token = mCredentials.refreshToken;
try {
mApi.tokenrefresh(params, new RestAdapterCallback<TokenRefreshResponse>(description, mUnsentEventsManager, callback, null) {
@Override
public void success(TokenRefreshResponse tokenreponse, Response response) {
onEventSent();
mCredentials.refreshToken = tokenreponse.refresh_token;
mCredentials.accessToken = tokenreponse.access_token;
if (null != callback) {
callback.onSuccess(mCredentials);
}
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
Aggregations