当前位置: 首页>>代码示例>>Java>>正文


Java GoogleApiClientTask类代码示例

本文整理汇总了Java中com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask的典型用法代码示例。如果您正苦于以下问题:Java GoogleApiClientTask类的具体用法?Java GoogleApiClientTask怎么用?Java GoogleApiClientTask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GoogleApiClientTask类属于com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager包,在下文中一共展示了GoogleApiClientTask类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: zoomToFitMyLocation

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
@Override
public void zoomToFitMyLocation(final List<LatLong> coords) {
    mGApiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            final Location myLocation = LocationServices.FusedLocationApi.getLastLocation(getGoogleApiClient());
            if (myLocation != null) {
                final List<LatLong> updatedCoords = new ArrayList<LatLong>(coords);
                updatedCoords.add(MapUtils.locationToCoord(myLocation));
                zoomToFit(updatedCoords);
            } else {
                zoomToFit(coords);
            }
        }
    });
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:17,代码来源:GoogleMapFragment.java

示例2: zoomToFitMyLocation

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
@Override
public void zoomToFitMyLocation(final List<LatLong> coords) {
    mGApiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            final Location myLocation = LocationServices.FusedLocationApi.getLastLocation(getGoogleApiClient());
            if (myLocation != null) {
                final List<LatLong> updatedCoords = new ArrayList<LatLong>(coords);
                updatedCoords.add(DroneHelper.LocationToCoord(myLocation));
                zoomToFit(updatedCoords);
            } else {
                zoomToFit(coords);
            }
        }
    });
}
 
开发者ID:sommishra,项目名称:DroidPlanner-Tower,代码行数:17,代码来源:GoogleMapFragment.java

示例3: onCreate

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    final Context context = getApplicationContext();
    apiClientMgr = new GoogleApiClientManager(context, handler, apisList);
    appPrefs = new AppPreferences(context);
    broadcastManager = LocalBroadcastManager.getInstance(context);

    apiClientMgr.start();
    apiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            Wearable.DataApi.addListener(getGoogleApiClient(), BaseActivity.this);
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:18,代码来源:BaseActivity.java

示例4: reloadVehicleData

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
protected void reloadVehicleData(String dataType){
    final String dataPath = WearUtils.VEHICLE_DATA_PREFIX + dataType;
    apiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            final Uri dataItemUri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path(dataPath)
                    .build();

            Wearable.DataApi.getDataItems(getGoogleApiClient(), dataItemUri)
                    .setResultCallback(new ResultCallback<DataItemBuffer>() {
                        @Override
                        public void onResult(DataItemBuffer dataItemBuffer) {
                            final int dataCount = dataItemBuffer.getCount();
                            for(int i = 0; i < dataCount; i++) {
                                final DataItem dataItem = dataItemBuffer.get(i);
                                if (dataItem != null)
                                    onDataItemReceived(dataItem, DataEvent.TYPE_CHANGED);
                            }

                            dataItemBuffer.release();
                        }
                    });
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:26,代码来源:BaseActivity.java

示例5: updateContextStreamNotification

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
private void updateContextStreamNotification() {
    final String dataPath = WearUtils.VEHICLE_DATA_PREFIX + AttributeType.STATE;
    apiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            final Uri dataItemUri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path(dataPath).build();

            Wearable.DataApi.getDataItems(getGoogleApiClient(), dataItemUri)
                    .setResultCallback(new ResultCallback<DataItemBuffer>() {
                        @Override
                        public void onResult(DataItemBuffer dataItems) {
                            final int dataCount = dataItems.getCount();
                            for (int i = 0; i < dataCount; i++) {
                                final DataItem dataItem = dataItems.get(i);
                                handleDataItem(dataItem, DataEvent.TYPE_CHANGED);
                            }

                            dataItems.release();
                        }
                    });
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:24,代码来源:WearReceiverService.java

示例6: asyncPutDataItem

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
/**
 * Asynchronously push/update a data item using the Wearable.DataApi api to connected wear
 * nodes.
 * @param apiClientMgr google api client manager
 * @param path non-null path
 * @param dataMapBundle non-null data bundle
 * @return true if the task was successfully queued.
 */
public static boolean asyncPutDataItem(GoogleApiClientManager apiClientMgr, final String path,
                                       final Bundle dataMapBundle) {
    return apiClientMgr.addTaskToBackground(new GoogleApiClientTask() {

        @Override
        public void doRun() {
            final PutDataMapRequest dataMap = PutDataMapRequest.create(path);
            dataMap.getDataMap().putAll(DataMap.fromBundle(dataMapBundle));
            PutDataRequest request = dataMap.asPutDataRequest();
            final DataApi.DataItemResult result = Wearable.DataApi
                    .putDataItem(getGoogleApiClient(), request)
                    .await();

            final Status status = result.getStatus();
            if (!status.isSuccess()) {
                Log.e(TAG, "Failed to relay the data: " + status.getStatusCode());
            }
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:29,代码来源:WearUtils.java

示例7: onDestroy

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
@Override
public void onDestroy(){
    super.onDestroy();
    apiClientMgr.addTask(new GoogleApiClientTask() {
        @Override
        protected void doRun() {
            Wearable.DataApi.removeListener(getGoogleApiClient(), BaseActivity.this);
        }
    });
    apiClientMgr.stopSafely();
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:12,代码来源:BaseActivity.java

示例8: asyncSendMessage

import com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask; //导入依赖的package包/类
/**
 * Asynchronously send a message using the Wearable.MessageApi api to connected wear nodes.
 *
 * @param apiClientMgr google api client manager
 * @param msgPath      non-null path for the message
 * @param msgData      optional message data
 * @return true if the message task was successfully queued.
 */
public static boolean asyncSendMessage(GoogleApiClientManager apiClientMgr,
                                       final String msgPath, final byte[] msgData) {
    return apiClientMgr.addTaskToBackground(new GoogleApiClientTask() {

        @Override
        public void doRun() {
            final GoogleApiClient apiClient = getGoogleApiClient();

            NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi
                    .getConnectedNodes(apiClient)
                    .await();

            for (Node node : nodes.getNodes()) {
                Log.d(TAG, "Sending message to " + node.getDisplayName());
                final MessageApi.SendMessageResult result = Wearable.MessageApi
                        .sendMessage(apiClient, node.getId(), msgPath, msgData)
                        .await();

                final Status status = result.getStatus();
                if (!status.isSuccess()) {
                    Log.e(TAG, "Failed to relay the data: " + status.getStatusCode());
                }
            }
        }
    });
}
 
开发者ID:DroidPlanner,项目名称:tower-wear,代码行数:35,代码来源:WearUtils.java


注:本文中的com.o3dr.services.android.lib.util.googleApi.GoogleApiClientManager.GoogleApiClientTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。