use of com.amazonaws.services.cognitoidentityprovider.model.DeviceType in project aws-sdk-android by aws-amplify.
the class DeviceOperations method _listDevices.
private ReturningRunnable<ListDevicesResult> _listDevices(final Integer limit, final String paginationToken) {
return new ReturningRunnable<ListDevicesResult>() {
@Override
public ListDevicesResult run() throws Exception {
final ListDevicesRequest listDevicesRequest = new ListDevicesRequest();
listDevicesRequest.setAccessToken(mobileClient.getTokens().getAccessToken().getTokenString());
listDevicesRequest.setLimit(limit);
listDevicesRequest.setPaginationToken(paginationToken);
final com.amazonaws.services.cognitoidentityprovider.model.ListDevicesResult listDevicesResult = userpoolLL.listDevices(listDevicesRequest);
final ArrayList<Device> devices = new ArrayList<Device>(limit);
for (DeviceType deviceType : listDevicesResult.getDevices()) {
devices.add(marshallDeviceTypeToDevice(deviceType));
}
return new ListDevicesResult(devices, listDevicesResult.getPaginationToken());
}
};
}
use of com.amazonaws.services.cognitoidentityprovider.model.DeviceType in project aws-sdk-android by aws-amplify.
the class CognitoUser method listDevices.
/**
* Fetches the list of all remembered devices for this user, runs in current
* thread.
*
* @param limit REQUIRED: Maximum number of devices to be returned in this
* call, defaults to 10.
* @param paginationToken REQUIRED: Token to continue an earlier search.
* @param callback REQUIRED: {@link DevicesHandler} callback.
*/
public void listDevices(int limit, String paginationToken, DevicesHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
try {
final ListDevicesResult listDevicesResult = listDevicesInternal(getCachedSession(), limit, paginationToken);
final List<CognitoDevice> devicesList = new ArrayList<CognitoDevice>();
for (final DeviceType device : listDevicesResult.getDevices()) {
devicesList.add(new CognitoDevice(device, this, context));
}
callback.onSuccess(devicesList);
} catch (final Exception e) {
callback.onFailure(e);
}
}
use of com.amazonaws.services.cognitoidentityprovider.model.DeviceType in project aws-sdk-android by aws-amplify.
the class CognitoUser method listDevicesInBackground.
/**
* Fetches the list of all remembered devices for this user.
*
* @param limit REQUIRED: Maximum number of devices to be returned in this
* call, defaults to 10.
* @param paginationToken REQUIRED: Token to continue an earlier search.
* @param callback REQUIRED: {@link DevicesHandler} callback.
*/
public void listDevicesInBackground(final int limit, final String paginationToken, final DevicesHandler callback) {
if (callback == null) {
throw new CognitoParameterInvalidException("callback is null");
}
final CognitoUser user = this;
new Thread(new Runnable() {
@Override
public void run() {
final Handler handler = new Handler(context.getMainLooper());
Runnable returnCallback;
try {
final ListDevicesResult listDevicesResult = listDevicesInternal(user.getCachedSession(), limit, paginationToken);
final List<CognitoDevice> devicesList = new ArrayList<CognitoDevice>();
for (final DeviceType device : listDevicesResult.getDevices()) {
devicesList.add(new CognitoDevice(device, user, context));
}
returnCallback = new Runnable() {
@Override
public void run() {
callback.onSuccess(devicesList);
}
};
} catch (final Exception e) {
returnCallback = new Runnable() {
@Override
public void run() {
callback.onFailure(e);
}
};
}
handler.post(returnCallback);
}
}).start();
}
Aggregations