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


Java DataItem類代碼示例

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


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

示例1: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(LOG_TAG, " in data changed");
    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            if (item.getUri().getPath().compareTo(WEATHER_PATH) == 0) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
                weather_id = dataMap.getInt(WEATHER_ID);
                high_temp = dataMap.getDouble(HIGH_TEMP);
                low_temp = dataMap.getDouble(LOW_TEMP);
            }
        } else if (event.getType() == DataEvent.TYPE_DELETED) {
            // DataItem deleted
        }
    }
    invalidate();
}
 
開發者ID:rashikaranpuria,項目名稱:ubiquitous,代碼行數:20,代碼來源:MyWatchFace.java

示例2: populateConfigurations

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
/**
 * This method read the UART configurations from the DataApi and populates the adapter with them.
 */
private void populateConfigurations() {
	if (mGoogleApiClient.isConnected()) {
		final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX);
		results.setResultCallback(new ResultCallback<DataItemBuffer>() {
			@Override
			public void onResult(final DataItemBuffer dataItems) {
				final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount());
				for (int i = 0; i < dataItems.getCount(); ++i) {
					final DataItem item = dataItems.get(i);
					final long id = ContentUris.parseId(item.getUri());
					final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
					final UartConfiguration configuration = new UartConfiguration(dataMap, id);
					configurations.add(configuration);
				}
				mAdapter.setConfigurations(configurations);
				dataItems.release();
			}
		});
	}
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:24,代碼來源:UARTConfigurationsActivity.java

示例3: onDataChanged

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

    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            if (item.getUri().getPath().compareTo("/SHAKEINTENSITY") == 0) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

                Log.e("Data Event", "value->"+dataMap.getString(SHAKE_INTENSITY_KEY));
                LocalStoreUtils.setShakeIntensity(dataMap.getString(SHAKE_INTENSITY_KEY), this);
            }
        }
    }

}
 
開發者ID:squareboat,項目名稱:Excuser,代碼行數:19,代碼來源:DataLayerListenerService.java

示例4: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的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

示例5: processData

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
private void processData(DataItem item) {
    if (START_ACTIVITY_PATH.equals(item.getUri().getPath())) {
        DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

        if (dataMap.containsKey("max")) {
            mWatchMaxTemp = dataMap.getString("max");
        }

        if (dataMap.containsKey("min")) {
            mWatchMinTemp = dataMap.getString("min");
        }
        if (dataMap.containsKey("id")) {
            int resid=getArtResourceForWeatherCondition(dataMap.getInt("id"));
            mWatchBitmap=  BitmapFactory.decodeResource(getResources(), resid);
            mWatchBitmap=Bitmap.createScaledBitmap(mWatchBitmap, (int) mTextPaint.getTextSize(), (int)mTextPaint.getTextSize(), false);
        }
        mWatchTemp=mWatchMaxTemp+" "+mWatchMinTemp;
    }
}
 
開發者ID:oscarbujinkan,項目名稱:Go-Ubiquitous,代碼行數:20,代碼來源:SunshineWatchFace.java

示例6: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的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

示例7: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的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

示例8: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    Log.d(LOG_TAG, "Weather data has been changed!");
    for (DataEvent event : dataEventBuffer) {
        DataItem item = event.getDataItem();
        if (WEATHER_DATA_PATH.equals(item.getUri().getPath())) {
            DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
            double high = dataMap.getDouble(WEATHER_DATA_HIGH);
            double low = dataMap.getDouble(WEATHER_DATA_LOW);
            long id = dataMap.getLong(WEATHER_DATA_ID);

            mWeather = (int) Math.round(high) + "/" +  (int) Math.round(low);
            mWeatherId = (int) id;

            loadIconForWeatherId();

            SharedPreferences preferences = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putString(KEY_WEATHER, mWeather);
            editor.putInt(KEY_WEATHER_ID, mWeatherId);
            editor.apply();
        }
    }
}
 
開發者ID:DmitryMalkovich,項目名稱:go-ubiquitous,代碼行數:25,代碼來源:SunshineWatchFace.java

示例9: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(LOG_TAG, "onDataChanged" );
    for (DataEvent dataEvent : dataEvents) {
        if (DataEvent.TYPE_CHANGED == dataEvent.getType()) {
            DataItem dataItem = dataEvent.getDataItem();
            DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();

            String path = dataEvent.getDataItem().getUri().getPath();
            if (path.equals(WEATHER_PATH)) {
                Log.d(LOG_TAG, "/weather id=" + dataMap.getString(KEY_UUID));
                SunshineSyncAdapter.syncImmediately(this);
            }
        }
    }
}
 
開發者ID:jenniferlimtan,項目名稱:UdacityProject6,代碼行數:17,代碼來源:WatchFaceService.java

示例10: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
/**
 * Called whenever a new message sent by the Wearable.
 *
 * @param dataEvents buffer with transmitted data
 */
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    Log.i(TAG, "onDataChanged()");

    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
            DataItem dataItem = dataEvent.getDataItem();
            Uri uri = dataItem.getUri();
            String path = uri.getPath();

            if (path.startsWith("/sensors/")) {
                if (SmartWatch.getInstance() != null) {
                    SmartWatch.getInstance().unpackSensorData(DataMapItem.fromDataItem(dataItem).getDataMap());
                }
            }
        }
    }
}
 
開發者ID:gradlman,項目名稱:SensorLib,代碼行數:25,代碼來源:SmartWatchListener.java

示例11: onDataChanged

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.i("DEV", "Wear: MainActivity.onDataChangeListener");
    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            if (item.getUri().getPath().compareTo("/stayawhile/queue") == 0) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
                queueUpdated(dataMap.getString(QUEUE_KEY));
            }
        } else if (event.getType() == DataEvent.TYPE_DELETED) {
            // DataItem deleted
        }
    }
}
 
開發者ID:MVK16,項目名稱:stayawhile-android,代碼行數:17,代碼來源:MainActivity.java

示例12: deleteSingleIgcFile

import com.google.android.gms.wearable.DataItem; //導入依賴的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

示例13: getExceptionFromWear

import com.google.android.gms.wearable.DataItem; //導入依賴的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

示例14: getAllAvailableDataItems

import com.google.android.gms.wearable.DataItem; //導入依賴的package包/類
private void getAllAvailableDataItems() {
    PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient);
    results.setResultCallback(new ResultCallback<DataItemBuffer>() {
        @Override
        public void onResult(@NonNull DataItemBuffer dataItems) {
            if (dataItems.getCount() != 0) {
                for (DataItem item : dataItems) {
                    if (item.getUri().getPath().contains(Statics.DATAIGC)) {
                        getStringFromAsset(item);
                    }
                    if (item.getUri().getPath().contains(Statics.DATATHROWABLE)) {
                        getExceptionFromWear(item);
                    }
                    if (item.getUri().getPath().contains(Statics.DATABTFAILED)) {
                        getBTFailed(item);
                    }
                }
            }
            dataItems.release();
        }
    });
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:23,代碼來源:MainActivity.java

示例15: getBTFailed

import com.google.android.gms.wearable.DataItem; //導入依賴的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


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