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


Java PutDataMapRequest.createWithAutoAppendedId方法代码示例

本文整理汇总了Java中com.google.android.gms.wearable.PutDataMapRequest.createWithAutoAppendedId方法的典型用法代码示例。如果您正苦于以下问题:Java PutDataMapRequest.createWithAutoAppendedId方法的具体用法?Java PutDataMapRequest.createWithAutoAppendedId怎么用?Java PutDataMapRequest.createWithAutoAppendedId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.wearable.PutDataMapRequest的用法示例。


在下文中一共展示了PutDataMapRequest.createWithAutoAppendedId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncTicketsToWear

import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
private void syncTicketsToWear(String path) {
    Uri uri = Uri.parse(path);
    final ArrayList<DataMap> dataCities = new ArrayList<DataMap>();
    String cityName = uri.getLastPathSegment();

    List<City> cities = CityManager.get(getApplicationContext()).getTicketsInCity(cityName, getApplicationContext());

    for (final City city : cities) {
        final DataMap dataMap = new DataMap();
        dataMap.putLong("id", city.id);
        dataMap.putString("city", city.city);
        dataMap.putString("country", city.country);
        dataMap.putInt("validity", city.validity);
        dataMap.putString("price", city.price);
        dataMap.putString("currency", city.currency);
        dataMap.putString("price_note", city.priceNote);
        dataMap.putString("note", city.note);

        dataCities.add(dataMap);
    }
    PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/tickets");
    data.getDataMap().putDataMapArrayList("tickets", dataCities);
    syncDataItem(data);
}
 
开发者ID:avast,项目名称:sms-ticket,代码行数:25,代码来源:WearableService.java

示例2: sendSmsNotification

import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
private void sendSmsNotification(Ticket t, int status) {
    DebugLog.d("Send ticket to wear" + t.toString());
    final DataMap dataMap = new DataMap();
    dataMap.putLong("id", t.getId());
    dataMap.putLong("city_id", t.getCityId());
    dataMap.putString("city", t.getCity());
    dataMap.putInt("status", status);
    dataMap.putString("hash", t.getHash());
    dataMap.putString("text", t.getText());
    dataMap.putLong("valid_from", t.getValidFrom().toMillis(true));
    dataMap.putLong("valid_to", t.getValidTo().toMillis(true));
    dataMap.putLong("notification_id", t.getNotificationId());

    PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/notification");
    data.getDataMap().putDataMap("notification", dataMap);
    syncDataItem(data);
}
 
开发者ID:avast,项目名称:sms-ticket,代码行数:18,代码来源:WearableService.java

示例3: onSave

import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
@Override
public void onSave(long tweetId, String[] urls, final Handler.Callback callback) {
    PutDataMapRequest dataMap = PutDataMapRequest.createWithAutoAppendedId(Constants.PATH_POCKET_SAVE);
    dataMap.getDataMap().putStringArray("urls", urls);
    dataMap.getDataMap().putLong("id", tweetId);

    PutDataRequest request = dataMap.asPutDataRequest();
    PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
            .putDataItem(mGoogleApiClient, request);
    pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
        @Override
        public void onResult(DataApi.DataItemResult dataItemResult) {
            Log.i(TAG, "data send status:" + dataItemResult.getStatus());
            callback.handleMessage(null);
        }
    });
}
 
开发者ID:glanceable,项目名称:GlanceTweet,代码行数:18,代码来源:TweetGridPagerAdapter.java

示例4: sendError

import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
/**
 * Sends error to wearable.
 */
private void sendError(String message) {
    DebugLog.e(message);
    PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/error");
    data.getDataMap().putString("error_message", message);
    syncDataItem(data);
}
 
开发者ID:avast,项目名称:sms-ticket,代码行数:10,代码来源:WearableService.java

示例5: syncCitiesToWear

import com.google.android.gms.wearable.PutDataMapRequest; //导入方法依赖的package包/类
private void syncCitiesToWear() {
    CityManager cityManager = CityManager.get(getApplicationContext());
    List<City> cities = cityManager.getUniqueCities(getApplication());
    if (cities.size() > 0) {
        ArrayList<City> orderedCities = new ArrayList<>();
        LocationManager lm = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
        Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (location != null) {
            City closest = cityManager.getClosest(this, location.getLatitude(), location.getLongitude());
            if (closest != null) {
                orderedCities.add(closest);

                for (int i = 0; i < cities.size(); i++) {
                    if (closest.id != cities.get(i).id) {
                        orderedCities.add(cities.get(i));
                    }
                }
            } else {
                orderedCities.addAll(cities);
            }
        }

        final ArrayList<DataMap> dataCities = new ArrayList<DataMap>();

        for (final City city : orderedCities) {
            final DataMap dataMap = new DataMap();
            dataMap.putLong("id", city.id);
            dataMap.putString("city", city.city);
            dataMap.putString("country", city.country);

            dataCities.add(dataMap);
        }

        if (dataCities.size() == 0) {
            UpdateService.call(getApplicationContext(), false);
            sendError(getResources().getString(R.string.error_zero_cities));
        } else {
            PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/cities");
            data.getDataMap().putDataMapArrayList("cities", dataCities);
            syncDataItem(data);
        }

    } else {
        UpdateService.call(getApplicationContext(), false);
        sendError(getResources().getString(R.string.error_zero_cities));
    }

}
 
开发者ID:avast,项目名称:sms-ticket,代码行数:49,代码来源:WearableService.java


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