示例#1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            string theme = SettingsHelper.GetTheme(this);

            if (theme == "dark")
            {
                SetTheme(Resource.Style.Dark_Theme);
            }

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.services_activity);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById(Resource.Id.toolbar).JavaCast <Android.Support.V7.Widget.Toolbar>();
            toolbar.SetContentInsetsAbsolute(0, 0);
            SetSupportActionBar(toolbar);

            ImageView backButton = FindViewById <ImageView>(Resource.Id.MenuButton);

            backButton.Click += ((sender, e) =>
            {
                OnBackPressed();
            });

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            LinearLayoutManager lm = new LinearLayoutManager(this);

            recyclerView.SetLayoutManager(lm);

            ProgressDialog progress = new ProgressDialog(this, Resource.Style.MyAlertDialogStyle);

            progress.SetMessage(Resources.GetString(Resource.String.loading_services));
            progress.SetProgressStyle(ProgressDialogStyle.Spinner);
            progress.Indeterminate = true;
            progress.SetCancelable(false);
            progress.Show();

            ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(this);
            Configuration      config      = BaseContext.Resources.Configuration;
            String             lang        = preferences.GetString("locale", null);

            string token = SettingsHelper.GetToken(this);

            services = await ServiceHelper.GetServices(token);

            if (services != null)
            {
                ServicesAdapter adapter = new ServicesAdapter(services, lang);
                recyclerView.SetAdapter(adapter);
                adapter.ItemClick += Adapter_ItemClick;
            }

            progress.Dismiss();
        }
        protected void WireUpExternalHandlers()
        {
            serviceDiscoveredHandler = (object sender, EventArgs e) => {
                if (App.Current.State.SelectedDevice != null)
                {
                    this._services = App.Current.State.SelectedDevice.Services;

                    //TODO: why doens't update work? is it because i'm replacing the reference?
                    this.RunOnUiThread(() => {
                        this._listAdapter      = new ServicesAdapter(this, this._services);
                        this._listView.Adapter = this._listAdapter;
                    });
                }
            };
            App.Current.State.SelectedDevice.ServicesDiscovered += serviceDiscoveredHandler;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_service);
            services = new List <BluetoothGattService>();
            gatt     = SingleGattService.GetInstance().CurGatt;

            serviceList     = FindViewById <GridView>(Resource.Id.service_list);
            back            = FindViewById <Button>(Resource.Id.service_back);
            refreshService  = FindViewById <Button>(Resource.Id.service_refresh);
            stepintoService = FindViewById <Button>(Resource.Id.service_stepinto);

            adapter                         = new ServicesAdapter(this, services);
            serviceList.Adapter             = adapter;
            serviceList.OnItemClickListener = this;
            back.SetOnClickListener(this);
            refreshService.SetOnClickListener(this);
            stepintoService.SetOnClickListener(this);

            RefreshBluetoothDeviceService();
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// load our layout
			SetContentView (Resource.Layout.ServiceListScreen);

			// find our controls
			this._listView = FindViewById<ListView> (Resource.Id.ServiceListView);
			this._deviceNameText = FindViewById<TextView> (Resource.Id.DeviceNameText);
			this._deviceAddressText = FindViewById<TextView> (Resource.Id.DeviceAddressText);

			// set the device info
			this._deviceNameText.Text = App.Current.State.SelectedDevice.Name;
			this._deviceAddressText.Text = App.Current.State.SelectedDevice.ID.ToString();

			// create our adapter
			this._listAdapter = new ServicesAdapter (this, this._services);
			this._listView.Adapter = this._listAdapter;

			App.Current.State.SelectedDevice.DiscoverServices ();

			this.WireUpLocalHandlers ();
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // load our layout
            SetContentView(Resource.Layout.ServiceListScreen);

            // find our controls
            this._listView          = FindViewById <ListView> (Resource.Id.ServiceListView);
            this._deviceNameText    = FindViewById <TextView> (Resource.Id.DeviceNameText);
            this._deviceAddressText = FindViewById <TextView> (Resource.Id.DeviceAddressText);

            // set the device info
            this._deviceNameText.Text    = App.Current.State.SelectedDevice.Name;
            this._deviceAddressText.Text = App.Current.State.SelectedDevice.ID.ToString();

            // create our adapter
            this._listAdapter      = new ServicesAdapter(this, this._services);
            this._listView.Adapter = this._listAdapter;

            App.Current.State.SelectedDevice.DiscoverServices();

            this.WireUpLocalHandlers();
        }
示例#6
0
 static ApplicationContext()
 {
     SessionValues = new Dictionary <string, object>();
     Configuration = new ApplicationConfigurationAdapter();
     Services      = new ServicesAdapter();
 }
		protected void WireUpExternalHandlers ()
		{
			serviceDiscoveredHandler = (object sender, EventArgs e) => {
				if (App.Current.State.SelectedDevice != null) {

					this._services = App.Current.State.SelectedDevice.Services;

					//TODO: why doens't update work? is it because i'm replacing the reference?
					this.RunOnUiThread( () => {
						this._listAdapter = new ServicesAdapter (this, this._services);
						this._listView.Adapter = this._listAdapter;
					});
				}
			};
			App.Current.State.SelectedDevice.ServicesDiscovered += serviceDiscoveredHandler;
		}