public PendingResult<DataApi.GetFdForAssetResult> getFdForAsset( MobvoiApiClient mobvoiApiClient, final Asset asset) { if (asset == null) throw new IllegalArgumentException("asset is null"); if ((asset.getDigest() == null) || (asset.getData() != null)) throw new IllegalArgumentException( "invalid asset, digest = " + asset.getDigest() + ", data = " + asset.getData()); return mobvoiApiClient.setResult( new WearableResult<GetFdForAssetResult>() { protected void connect(WearableAdapter adapter) throws RemoteException { adapter.getFdForAsset(this, asset); } protected DataApi.GetFdForAssetResult create(Status status) { return new DataApiImpl.GetFdForAssetResultImpl(status, null); } }); }
public PendingResult<DataItemBuffer> getDataItems(MobvoiApiClient mobvoiApiClient) { return mobvoiApiClient.setResult( new WearableResult<DataItemBuffer>() { @Override protected void connect(WearableAdapter adapter) throws RemoteException { Log.d(TAG, "connect getDataItems"); // adapter.getDataItems(this); } @Override protected DataItemBuffer create(Status status) { Log.d(TAG, "create DataItemBuffer : " + status); return new DataItemBuffer(status); } }); }
@Override public PendingResult<DataItemResult> putDataItem( MobvoiApiClient mobvoiApiClient, final PutDataRequest putDataRequest) { return mobvoiApiClient.setResult( new WearableResult<DataItemResult>() { @Override protected void connect(WearableAdapter adapter) throws RemoteException { Log.d(TAG, "putDataItem connect..."); adapter.putDataItem(this, putDataRequest); } @Override protected DataItemResult create(Status status) { Log.d(TAG, "create DataItemResult : " + status); return new DataItemResultImpl(status, null); } }); }
@Override public PendingResult<Status> addListener(MobvoiApiClient mobvoiApiClient, DataListener listener) { final WearableListener wearableListener = new WearableListener(listener); return mobvoiApiClient.setResult( new WearableResult<Status>() { @Override protected void connect(WearableAdapter adapter) throws RemoteException { Log.d(TAG, "WearableAdapter add WearableListener"); adapter.addDataListener(this, wearableListener); } @Override protected Status create(Status status) { Log.d(TAG, "create addListener status: " + status); return status; } }); }
@Override public void onConnectionSuspended(int cause) { Log.e(TAG, "手表端:CMS服务挂起 cause:" + cause); mobvoiApiClient.connect(); }
@Override protected void onStart() { super.onStart(); mobvoiApiClient.connect(); }