當前位置: 首頁>>代碼示例>>Java>>正文


Java DataMapItem.fromDataItem方法代碼示例

本文整理匯總了Java中com.google.android.gms.wearable.DataMapItem.fromDataItem方法的典型用法代碼示例。如果您正苦於以下問題:Java DataMapItem.fromDataItem方法的具體用法?Java DataMapItem.fromDataItem怎麽用?Java DataMapItem.fromDataItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.wearable.DataMapItem的用法示例。


在下文中一共展示了DataMapItem.fromDataItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    LOGD(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());

    for (DataEvent event : dataEvents) {
        LOGD(TAG, "Uri is: " + event.getDataItem().getUri());
        DataMapItem mapItem = DataMapItem.fromDataItem(event.getDataItem());
        String path = event.getDataItem().getUri().getPath();
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            if (PATH_RESPONSE.equals(path)) {
                // we have a response
                DataMap data = mapItem.getDataMap();
                saveFeedback(data);
            }
        } else if (event.getType() == DataEvent.TYPE_DELETED) {
            if (path.startsWith(SessionAlarmService.PATH_FEEDBACK)) {
                Uri uri = event.getDataItem().getUri();
                dismissLocalNotification(uri.getLastPathSegment());
            }
        }
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:23,代碼來源:FeedbackWearableListenerService.java

示例2: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "Data changed");
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                ConfigurationHelper.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);
        // This can happen from this method more often when phone changes
        updateUiForConfigDataMap(config);
    }
}
 
開發者ID:jimmykane,項目名稱:Athletica,代碼行數:22,代碼來源:WatchFaceService.java

示例3: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                WatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
 
開發者ID:marcouberti,項目名稱:adrenaline_watch_face,代碼行數:21,代碼來源:SonicBoomFace.java

示例4: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG,"onDataChanged "+dataEvents);
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(WatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
 
開發者ID:marcouberti,項目名稱:adrenaline_watch_face,代碼行數:21,代碼來源:WatchFaceCompanionConfigActivity.java

示例5: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
    dataEvents.close();
    for (DataEvent event : events) {
        Uri uri = event.getDataItem().getUri();
        String path = uri.getPath();
        if (WEAR_PATH.equals(path)) {
            DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
            byte[] realmAsset = item.getDataMap().getByteArray(DATA_ASSET_FILE);
            if (realmAsset != null) {
                toFile(realmAsset);
                getBaseContext().sendBroadcast(new Intent(DATA_STORY_CHANGED));
            }
        }
    }
}
 
開發者ID:LadyViktoria,項目名稱:wearDrip,代碼行數:18,代碼來源:ListenerService.java

示例6: deleteSingleIgcFile

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
private void deleteSingleIgcFile(DataItem item) {
    item.freeze();
    DataMapItem dataMapItem = DataMapItem.fromDataItem(item);
    String filename = dataMapItem.getDataMap().getString(Statics.DATADELETE);
    File dir = getFilesDir();
    File[] subFiles = dir.listFiles();
    if (subFiles != null) {
        for (File file : subFiles) {
            if (filename.contains(Statics.getUTCdateReverse())) return;
            if (file.getName().equals(filename)) {
                if (file.delete()) {
                    if (debugMode) Log.d(TAG, "File " + filename + " is deleted.");
                    Wearable.DataApi.deleteDataItems(mGoogleApiClient, item.getUri());
                } else {
                    if (debugMode) Log.d(TAG, "File " + filename + " delete error.");
                }
            }
        }
    }
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:21,代碼來源:MainWearActivity.java

示例7: getExceptionFromWear

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
private void getExceptionFromWear(DataItem dataItem) {
    if (debugMode) Log.d(TAG, "Exception from wear!!!");
    dataItem.freeze();
    DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
    ByteArrayInputStream bis = new ByteArrayInputStream(dataMapItem.getDataMap().getByteArray("exception"));
    Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItem.getUri());
    try {

        ObjectInputStream ois = new ObjectInputStream(bis);
        Throwable ex = (Throwable) ois.readObject();
        FirebaseCrash.log("board: " + dataMapItem.getDataMap().getString("board"));
        FirebaseCrash.log("fingerprint: " + dataMapItem.getDataMap().getString("fingerprint"));
        FirebaseCrash.log("model: " + dataMapItem.getDataMap().getString("model"));
        FirebaseCrash.log("manufacturer: " + dataMapItem.getDataMap().getString("manufacturer"));
        FirebaseCrash.log("product: " + dataMapItem.getDataMap().getString("product"));
        FirebaseCrash.report(ex);
    } catch (IOException | ClassNotFoundException e) {
        FirebaseCrash.report(e);
        if (debugMode) Log.e(TAG, Log.getStackTraceString(e));
    }
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:22,代碼來源:MainActivity.java

示例8: getBTFailed

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
private void getBTFailed(DataItem dataItem) {
    dataItem.freeze();
    final Uri dataItemUri = dataItem.getUri();
    DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
    final int reason = dataMapItem.getDataMap().getInt("reason");
    if (debugMode) Log.d(TAG, "BT failed on wear, reason: " + reason);
    switch (reason) {
        case Statics.MY_BT_FAILED_NO_BT:
            Toast.makeText(getApplicationContext(), R.string.bt_failed_no_bt, Toast.LENGTH_LONG).show();
            break;
        case Statics.MY_BT_FAILED_NO_DEVICE:
            Toast.makeText(getApplicationContext(), R.string.bt_failed_no_device, Toast.LENGTH_LONG).show();
            break;
        case Statics.MY_BT_FAILED_USER:
            Toast.makeText(getApplicationContext(), R.string.bt_failed_user, Toast.LENGTH_LONG).show();
            break;
    }
    Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri);
    prefs.edit().putBoolean(Statics.PREFUSEBTVARIO, false).apply();
    checkBoxBT.setChecked(false);
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:22,代碼來源:MainActivity.java

示例9: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    for (DataEvent dataEvent : dataEventBuffer) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                DigitalWatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d("WatchFace", "Config DataItem updated:" + config);
        updateUiForConfigDataMap(config);
    }
}
 
開發者ID:passiondroid,項目名稱:SunshineApp,代碼行數:20,代碼來源:WatchFace.java

示例10: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "onDataChanged: " + dataEvents);

    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            String path = event.getDataItem().getUri().getPath();
            Log.d(TAG, "onDataChanged: Path" + path);
            switch (path) {
                case Consts.Paths.GAME_INFORMATION:
                    DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
                    GameInformation info = GameInformation.fromDataMap(item.getDataMap());
                    GameState.getInstance().update(info);
                    updateDisplay();
                    break;
            }
        }
    }
}
 
開發者ID:jordond,項目名稱:powerhour,代碼行數:20,代碼來源:GameActivity.java

示例11: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
 
開發者ID:marcouberti,項目名稱:american_sunsets_watch_face,代碼行數:21,代碼來源:SunsetsWatchFace.java

示例12: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);

    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
    dataEvents.close();

    if (!mGoogleApiClient.isConnected()) {
        ConnectionResult connectionResult = mGoogleApiClient
                .blockingConnect(30, TimeUnit.SECONDS);
        if (!connectionResult.isSuccess()) {
            Log.e(TAG, "Service failed to connect to GoogleApiClient.");
            return;
        }
    }

    for(DataEvent event : events) {
        if(event.getType() == DataEvent.TYPE_CHANGED) {
            String path = event.getDataItem().getUri().getPath();
            if(DataInterface.PATH_NOTIFICATION.equals(path)) {
                DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
                updateOrShowNotification(dataMapItem);
            }
        }
    }
}
 
開發者ID:devmil,項目名稱:parrot-zik-2-supercharge,代碼行數:27,代碼來源:NotificationListenerService.java

示例13: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "onDataChanged: " + dataEvents);
    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
    dataEvents.close();
    for (DataEvent event : events) {
        Log.d(TAG, "Event: " + event.getDataItem().toString());
        Uri uri = event.getDataItem().getUri();
        String path = uri.getPath();

        if (path.equals(Path.GRADE_SYSTEM)) {
            DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
            String gradeSystem = dataMapItem.getDataMap().getString(Path.GRADE_SYSTEM_KEY);
            if (gradeSystem != null) {
                SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
                SharedPreferences.Editor editor = sharedPref.edit();
                editor.putString(Path.PREF_GRAD_SYSTEM_TYPE, gradeSystem);
                editor.commit();
            }
        }
    }
}
 
開發者ID:google,項目名稱:climb-tracker,代碼行數:23,代碼來源:WearDataLayerListenerService.java

示例14: getBitmapFromDataApi

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
public Bitmap getBitmapFromDataApi(String path) {
    final Uri uri = getUriForDataItem(path);

    Log.d(TAG, "Load bitmap " + path + " " + uri.toString());

    if (uri != null) {
        final DataApi.DataItemResult result = Wearable.DataApi.getDataItem(mApiClient, uri).await();
        if (result != null && result.getDataItem() != null) {

            Log.d(TAG, "From DataApi");

            final DataMapItem dataMapItem = DataMapItem.fromDataItem(result.getDataItem());
            final Asset firstAsset = dataMapItem.getDataMap().getAsset(imageAssetName);
            if (firstAsset != null) {
                Bitmap bitmap = loadBitmapFromAsset(firstAsset);
                return bitmap;
            }
        }
    }

    Log.d(TAG, "can't find " + path + " [" + imageAssetName + "] in DataApi");

    return null;
}
 
開發者ID:florent37,項目名稱:DaVinci,代碼行數:25,代碼來源:DaVinci.java

示例15: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Config DataItem updated:" + config);
        }
        updateUiForConfigDataMap(config);
    }
}
 
開發者ID:marcouberti,項目名稱:african_sunsets_watch_face,代碼行數:21,代碼來源:WatchFaceCompanionConfigActivity.java


注:本文中的com.google.android.gms.wearable.DataMapItem.fromDataItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。