当前位置: 首页>>代码示例>>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;未经允许,请勿转载。