當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。