コード例 #1
0
 //  public NavigationAdapter(Context context, WearableNavigationDrawer mWearableNavigationDrawer1, WearableActionDrawer mWearableActionDrawer1)
 public NavigationAdapter(Context context, FragmentManager fragmentManager, WearableNavigationDrawer wnavDwe, WearableActionDrawer wActionDwr, Communicator objCommunicator)
 {
     mContext                  = context;
     _fragmentManager          = fragmentManager;
     mWearableNavigationDrawer = wnavDwe;
     mWearableActionDrawer     = wActionDwr;
     _Communicator             = objCommunicator;
 }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_main2);


            #region NVD
            mWearableNavigationDrawer = (WearableNavigationDrawer)FindViewById(Resource.Id.top_navigation_drawer);
            //mWearableNavigationDrawer.SetAdapter(new NavigationAdapter(this, mWearableNavigationDrawer, mWearableActionDrawer));

            #endregion
            SectionFragment f = new SectionFragment();
            objCommunicator = new Communicator(this);
            Device device = new Device();
            device.Initialize(objCommunicator);
            device.AdvertiseMyself(true);

            objCommunicator.MessageReceived += delegate
            {
                string isVibrate = "";
                try
                {
                    Vibration.Vibrate();
                    var duration = TimeSpan.FromSeconds(20);
                    Vibration.Vibrate(duration);
                    isVibrate = "Success";
                }
                catch (FeatureNotSupportedException ex)
                {
                    isVibrate = "Not Supported";
                }
                catch (System.Exception ex)
                {
                    isVibrate = "Error";
                }
                // var v = CrossVibrate.Current;
                //v.Vibration(TimeSpan.FromSeconds(1)); // 1 second vibration
            };

            SectionFragment sectionFragment = f.GetSection(DEFAULT_SECTION);
            var             sFFB            = this.FragmentManager.BeginTransaction();
            sectionFragment.OnClick(f.View);
            sFFB.Replace(Resource.Id.fragment_container, sectionFragment);
            sFFB.Commit();

            mWearableActionDrawer = (WearableActionDrawer)FindViewById(Resource.Id.bottom_action_drawer);
            mWearableNavigationDrawer.SetAdapter(new NavigationAdapter(this, this.FragmentManager, mWearableNavigationDrawer, mWearableActionDrawer, objCommunicator));
            mWearableActionDrawer.MenuItemClick += (m, arg) =>
            {
                mWearableActionDrawer.CloseDrawer();
                //switch (arg.Item.ItemId)
                // {
                //case Resource.Id.action_edit:
                // Toast.MakeText(this, Resource.String.action_edit_todo, ToastLength.Short).Show();
                //return true;
                // break;
                // case Resource.Id.action_share:
                // Toast.MakeText(this, Resource.String.action_share_todo, ToastLength.Short).Show();
                // return true;
                //  break;
                // }

                // return false;
            };
            SetAmbientEnabled();
        }