Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.my_sensors);
            Titlenew         = FindViewById <TextView>(Resource.Id.title_my_sensors);
            linearLayout     = FindViewById <LinearLayout>(Resource.Id.my_sensors_layout);
            my_sensors       = FindViewById <ListView>(Resource.Id.my_sensors_listView);
            barLayout        = FindViewById <BarLayout>(Resource.Id.appBarLayout);
            pref             = GetSharedPreferences("sensors", FileCreationMode.Private);
            background_color = GetSharedPreferences("backgroundColor_textColor", FileCreationMode.Private);
            text_color       = background_color.GetString("textColor", "Black");
            background       = background_color.GetString("background", "White");

            objects = pref.GetStringSet("sensor", null);
            if (objects != null)
            {
                result = objects.ToList();
                MyListView1 mylist = new MyListView1(this, result, Color.ParseColor(text_color));
                my_sensors.Adapter        = mylist;
                my_sensors.ItemLongClick += My_sensors_ItemLongClick;
            }
            else
            {
                Titlenew.Text = "Нет подключённых устройств";
            }
            linearLayout.SetBackgroundColor(Color.ParseColor(background));
            my_sensors.SetBackgroundColor(Color.ParseColor(background));
            Titlenew.SetTextColor(Color.ParseColor(text_color));
        }
Ejemplo n.º 2
0
        protected override void OnViewModelSet()
        {
            System.Diagnostics.Debug.WriteLine("ViewItemActivity.OnViewModelSet()");

            // Layout
            SetContentView(Resource.Layout.activity_view_item);

            // Status Bar
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

            // Linking up
            appbar    = FindViewById <Android.Support.Design.Widget.AppBarLayout>(Resource.Id.viewitem_appbar);
            imageView = FindViewById <ImageViewAsync>(Resource.Id.viewItem_imageView);

            // Display Image
            if (!string.IsNullOrEmpty(ViewModel.Item.ImageFilename))
            {
                imageFile = new Java.IO.File(AndroidHelper._dir, ViewModel.Item.ImageFilename);

                // Display
                RunOnUiThread(() => {
                    ImageService.Instance.LoadFile(imageFile.Path).Into(imageView);
                });
            }
            else
            {
                // Hide container
                Android.Support.Design.Widget.CoordinatorLayout.LayoutParams lp =
                    (Android.Support.Design.Widget.CoordinatorLayout.LayoutParams)appbar.LayoutParameters;

                lp.Height = 0;

                appbar.LayoutParameters = lp;
            }

            container = FindViewById <LinearLayout>(Resource.Id.activity_view_item_container);

            // Get "rows"
            for (int i = 0; i < container.ChildCount; i++)
            {
                // Get imageview for row and paint it
                LinearLayout row   = ((LinearLayout)container.GetChildAt(i));
                ImageView    image = (ImageView)row.GetChildAt(0);
                image.SetColorFilter(Color.ParseColor(Application.Context.Resources.GetString(Resource.Color.accent)));
            }
        }