Runnable runnable = new Runnable(){
public void run() {
try{
if (wearable.Asset == null)
{
final AutoResetEvent downloadEvent = new AutoResetEvent(false);
MethodDelegate<Void, AssetReceivedCallbackArgs> assetReceivedCallback
= new MethodDelegate<Void, AssetReceivedCallbackArgs>()
{
public Void execute(AssetReceivedCallbackArgs e) {
AssetDownload transfer = e.getTransfer();
Asset asset = e.getAsset();
if (transfer.Success && asset instanceof AssetWearable)
{
// Update this wearable with the freshly downloaded asset
wearable.Asset = (AssetWearable)asset;
if (wearable.Asset.Decode())
{
DecodeWearableParams(wearable);
JLogger.debug("Downloaded wearable asset " + wearable.WearableType + " with " + wearable.Asset.Params.size() +
" visual params and " + wearable.Asset.Textures.size() + " textures");
}
else
{
wearable.Asset = null;
JLogger.error("Failed to decode asset:" + "\n" +
Utils.bytesToHexDebugString(asset.AssetData, ""));
}
}
else
{
JLogger.warn("Wearable " + wearable.AssetID + "(" + wearable.WearableType + ") failed to download, " +
transfer.Status);
}
downloadEvent.set();
return null;
}
};
// Fetch this wearable asset
Client.assets.RequestAsset(wearable.AssetID, wearable.AssetType, true, assetReceivedCallback);
if (!downloadEvent.waitOne(WEARABLE_TIMEOUT))
{
JLogger.error("Timed out downloading wearable asset " + wearable.AssetID + " (" + wearable.WearableType + ")");
success.set(false);
}