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


Java DataMap.fromBundle方法代碼示例

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


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

示例1: onReceive

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    final PowerManager.WakeLock wl = JoH.getWakeLock("circle-message-receiver", 60000);
    try {
        DataMap dataMap;
        Bundle bundle = intent.getBundleExtra("msg");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            String msg = dataMap.getString("msg", "");
            int length = dataMap.getInt("length", 0);
            JoH.static_toast(xdrip.getAppContext(), msg, length);
        }
        bundle = intent.getBundleExtra("steps");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
                mStepsCount = dataMap.getInt("steps", 0);
                mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
            }
        }
        bundle = intent.getBundleExtra("data");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            setSgvLevel((int) dataMap.getLong("sgvLevel"));
            Log.d(TAG, "CircleWatchface sgv level : " + getSgvLevel());
            setSgvString(dataMap.getString("sgvString"));
            Log.d(TAG, "CircleWatchface sgv string : " + getSgvString());
            setRawString(dataMap.getString("rawString"));
            setDelta(dataMap.getString("delta"));
            setDatetime(dataMap.getDouble("timestamp"));
            mExtraStatusLine = dataMap.getString("extra_status_line");
            addToWatchSet(dataMap);


            //start animation?
            // dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
            if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (getSgvString().equals("100") || getSgvString().equals("5.5") || getSgvString().equals("5,5"))) {
                startAnimation();
            }

            prepareLayout();
            prepareDrawTime();
            invalidate();
        }
        //status
        bundle = intent.getBundleExtra("status");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            setStatusString(dataMap.getString("externalStatusString"));

            prepareLayout();
            prepareDrawTime();
            invalidate();
        }
    } finally {
        JoH.releaseWakeLock(wl);
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:59,代碼來源:CircleWatchface.java

示例2: onCreate

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mActivity = this;
    setContentView(R.layout.activity_mega_status);
    JoH.fixActionBar(this);

    sectionList.clear();
    sectionTitles.clear();
    populateSectionList();

    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // switch to last used position if it exists
    int saved_position = (int) PersistentStore.getLong("mega-status-last-page");

    // if triggered from pending intent, flip to named section if we can
    final String action = getIntent().getAction();
    if ((action != null) && (action.length() > 0)) {
        int action_position = sectionList.indexOf(action);
        if (action_position > -1) saved_position = action_position;
    }

    if ((saved_position > 0) && (saved_position < sectionList.size())) {
        currentPage = saved_position;
        mViewPager.setCurrentItem(saved_position);
        autoStart = true; // run once activity becomes visible
    }
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            UserError.Log.d(TAG, "Page selected: " + position);
            runnableView = null;
            currentPage = position;
            startAutoFresh();
            PersistentStore.setLong("mega-status-last-page", currentPage);
        }
    });

    // streamed data from android wear
    requestWearCollectorStatus();
    serviceDataReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context ctx, Intent intent) {
            final String action = intent.getAction();
            //final String msg = intent.getStringExtra("data");
            Bundle bundle = intent.getBundleExtra("data");
            if (bundle != null) {
                DataMap dataMap = DataMap.fromBundle(bundle);
                String lastState = dataMap.getString("lastState", "");
                long last_timestamp = dataMap.getLong("timestamp", 0);
                UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp);
                switch (action) {
                    case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE:
                        switch (DexCollectionType.getDexCollectionType()) {
                            case DexcomG5:
                                // as this is fairly lightweight just write the data to both G5 collectors
                                G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                Ob1G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                break;
                            case DexcomShare:
                                if (lastState != null && !lastState.isEmpty()) {
                                    //setConnectionStatus(lastState);//TODO set System Status page connection_status.setText to lastState for non-G5 Services?
                                }
                                break;
                            default:
                                DexCollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                if (lastState != null && !lastState.isEmpty()) {
                                    //setConnectionStatus(lastState);//TODO set System Status page connection_status.setText to lastState for non-G5 Services?
                                }
                                break;
                        }
                        break;
                }
            }
        }
    };
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:82,代碼來源:MegaStatus.java

示例3: onCreateView

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    //Injectors.getMicroStatusComponent().inject(this);
    requestWearCollectorStatus();
    serviceDataReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context ctx, Intent intent) {
            final String action = intent.getAction();
            //final String msg = intent.getStringExtra("data");
            Bundle bundle = intent.getBundleExtra("data");
            if (bundle != null) {
                DataMap dataMap = DataMap.fromBundle(bundle);
                String lastState = dataMap.getString("lastState", "");
                long last_timestamp = dataMap.getLong("timestamp", 0);
                UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp);
                switch (action) {
                    case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE:
                        switch (DexCollectionType.getDexCollectionType()) {
                            case DexcomG5:
                                G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                break;
                            case DexcomShare:
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);//TODO getLastState() in non-G5 Services
                                }
                                break;
                            default:
                                DexCollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);
                                }
                                break;
                        }
                        break;
                }
            }
        }
    };
    final ActivitySystemStatusBinding binding = DataBindingUtil.inflate(
            inflater, R.layout.activity_system_status, container, false);
    microStatus = new MicroStatusImpl();
    binding.setMs(microStatus);
    return binding.getRoot();
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:47,代碼來源:SystemStatusFragment.java


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