public void FlexibleViewLayoutManagerOffsetChildrenVertical()
        {
            tlog.Debug(tag, $"FlexibleViewLayoutManagerOffsetChildrenVertical START");

            var testingTarget = GetVerticalFlexibleView();

            testingTarget.Padding = new Extents(20, 20, 120, 20);

            try
            {
                verticalLayoutManager.OffsetChildrenVertical(0, true);
                verticalLayoutManager.OffsetChildrenVertical(30, true);
                verticalLayoutManager.OffsetChildrenVertical(30, false);

                verticalLayoutManager.StopScroll(true);
                verticalFlexibleView = null;
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception : Failed!");
            }

            tlog.Debug(tag, $"FlexibleViewLayoutManagerOffsetChildrenVertical END (OK)");
        }
            public override void OnFocusChange(FlexibleView flexibleView, int previousFocus, int currentFocus)
            {
                FlexibleViewViewHolder previousFocusView = flexibleView.FindViewHolderForAdapterPosition(previousFocus);

                if (previousFocusView != null)
                {
                    //Console.WriteLine($"previousFocus {previousFocus.AdapterPosition}");
                    if (previousFocusView.AdapterPosition % 2 == 0)
                    {
                        previousFocusView.ItemView.BackgroundColor = Color.Cyan;
                    }
                    else
                    {
                        previousFocusView.ItemView.BackgroundColor = Color.Yellow;
                    }
                    //previousFocus.SizeWidth = 150;
                    //previousFocus.SizeHeight = 60;
                    //NotifyItemChanged(previousFocus.AdapterPosition);
                }
                FlexibleViewViewHolder currentFocusView = flexibleView.FindViewHolderForAdapterPosition(currentFocus);

                if (currentFocusView != null)
                {
                    //Console.WriteLine($"currentFocus {currentFocus.AdapterPosition}");
                    currentFocusView.ItemView.BackgroundColor = Color.Magenta;
                    //currentFocus.SizeWidth = 200;
                    //currentFocus.SizeHeight = 100;
                    //NotifyItemChanged(currentFocus.AdapterPosition);
                }
            }
Exemplo n.º 3
0
        public void FlexibleViewRecyclerSetViewCacheSize()
        {
            tlog.Debug(tag, $"FlexibleViewRecyclerSetViewCacheSize START");

            using (FlexibleView recyclerView = new FlexibleView()
            {
                Padding = new Extents(10, 10, 10, 10)
            })
            {
                var testingTarget = new FlexibleViewRecycler(recyclerView);
                Assert.IsNotNull(testingTarget, "should be not null");
                Assert.IsInstanceOf <FlexibleViewRecycler>(testingTarget, "should be an instance of testing target class!");

                try
                {
                    testingTarget.SetViewCacheSize(5);
                }
                catch (Exception e)
                {
                    tlog.Debug(tag, e.Message.ToString());
                    Assert.Fail("Caught Exception : Failed!");
                }
            }

            tlog.Debug(tag, $"FlexibleViewRecyclerSetViewCacheSize END (OK)");
        }
Exemplo n.º 4
0
        private bool ProcessKey(FlexibleView flexibleView, Key key)
        {
            if (key.State == Key.StateType.Down)
            {
                if (key.KeyPressedName == "Up")
                {
                    flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Up);
                }
                else if (key.KeyPressedName == "Down")
                {
                    flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Down);
                }
                if (key.KeyPressedName == "Left")
                {
                    flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Left);
                }
                else if (key.KeyPressedName == "Right")
                {
                    flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Right);
                }
                else if (key.KeyPressedName == "0")
                {
                    if (flexibleView == flexibleView1)
                    {
                        FocusManager.Instance.SetCurrentFocusView(flexibleView2);
                    }
                    else if (flexibleView == flexibleView2)
                    {
                        FocusManager.Instance.SetCurrentFocusView(flexibleView1);
                    }
                }
                else if (key.KeyPressedName == "1")
                {
                    adapter.InsertData(1);
                }
                else if (key.KeyPressedName == "2")
                {
                    adapter.RemoveData(1);
                }
                else if (key.KeyPressedName == "8")
                {
                    flexibleView.FocusedItemIndex = 0;
                }
                else if (key.KeyPressedName == "9")
                {
                    flexibleView.FocusedItemIndex = 15;
                }
                else if (key.KeyPressedName == "7")
                {
                }
            }

            return(false);
        }
        /// <summary>
        /// UIControls Sample Application initialisation.
        /// </summary>
        public void Initialize()
        {
            // Create Background view.
            backGroundView = CreateBackGroundView();
            backGroundView.BackgroundColor = Color.Black;
            //Add logo
            logo                    = new ImageView(logo_path);
            logo.Name               = "LOGO_IMAGE";
            logo.PivotPoint         = PivotPoint.TopCenter;
            logo.ParentOrigin       = new Position(0.5f, 0.1f, 0.5f);
            logo.PivotPoint         = PivotPoint.TopLeft;
            logo.ParentOrigin       = ParentOrigin.TopLeft;
            logo.Position2D         = new Position2D(0, 0);
            logo.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
            logo.WidthResizePolicy  = ResizePolicyType.UseNaturalSize;
            //The logo should appear on top of everything.
            logo.DrawMode = DrawModeType.Normal;
            backGroundView.Add(logo);
            // Scrollview occupying the majority of the screen
            scrollView = new FlexibleView();
            scrollView.PositionUsesPivotPoint = true;
            scrollView.PivotPoint             = PivotPoint.BottomCenter;
            scrollView.ParentOrigin           = new Vector3(0.5f, 1.0f - 0.05f, 0.5f);
            scrollView.WidthResizePolicy      = ResizePolicyType.FillToParent;
            scrollView.HeightResizePolicy     = ResizePolicyType.SizeRelativeToParent;
            scrollView.SizeModeFactor         = new Vector3(0.0f, 0.6f, 0.0f);
            ushort buttonsPageMargin = (ushort)((1.0f - TABLE_RELATIVE_SIZE.X) * 0.5f * Window.Instance.Size.Width);

            scrollView.Padding = new Extents(buttonsPageMargin, buttonsPageMargin, 0, 0);
            backGroundView.Add(scrollView);

            // Add scroll view effect and setup constraints on pages.
            ApplyScrollViewEffect();

            // Add pages and tiles.
            Populate();

            // Set initial orientation
            uint degree = 0;

            Rotate(degree);

            Window.Instance.KeyEvent += InstanceKey;
            Tizen.Log.Fatal("NUI", "MainSample");
            defaultFocusIndicatorView = new ImageView();
            defaultFocusIndicatorView.HeightResizePolicy     = ResizePolicyType.FillToParent;
            defaultFocusIndicatorView.WidthResizePolicy      = ResizePolicyType.FillToParent;
            defaultFocusIndicatorView.PositionUsesPivotPoint = true;
            defaultFocusIndicatorView.PivotPoint             = PivotPoint.Center;
            defaultFocusIndicatorView.ParentOrigin           = ParentOrigin.Center;
            Tizen.Log.Fatal("NUI", "MainSample");
            Activate();
        }
Exemplo n.º 6
0
        public static FlexibleView CreateGridFlexibleView(Vector2 scrnSize, int orientation, int itemCount)
        {
            var flexibleView = new FlexibleView();

            Assert.IsNotNull(flexibleView, "should be not null");
            Assert.IsInstanceOf <FlexibleView>(flexibleView, "should be an instance of testing target class!");

            Assert.IsNotNull(flexibleView.Padding, "should be not null");

            flexibleView.OnRelayout(scrnSize, null);

            flexibleView.Name = "RecyclerView1";
            flexibleView.WidthSpecification  = 400;
            flexibleView.HeightSpecification = 450;
            flexibleView.Padding             = new Extents(10, 10, 10, 10);
            flexibleView.BackgroundColor     = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            flexibleView.FocusedItemIndex = -1;
            flexibleView.FocusedItemIndex = 0;

            List <ListItemData> dataList = new List <ListItemData>();

            for (int i = 0; i < itemCount; ++i)
            {
                dataList.Add(new ListItemData(i));
            }

            var adapter = new ListBridge(dataList);

            flexibleView.SetAdapter(null);
            flexibleView.SetAdapter(adapter);
            flexibleView.OnRelayout(scrnSize, null);

            var layoutManager = new GridLayoutManager(3, orientation);

            flexibleView.SetLayoutManager(null);
            flexibleView.SetLayoutManager(layoutManager);
            flexibleView.OnRelayout(scrnSize, null);

            flexibleView.Focusable = true;

            return(flexibleView);
        }
        private FlexibleView GetHorizontalFlexibleView()
        {
            if (null == horizontalFlexibleView)
            {
                horizontalFlexibleView = new FlexibleView();

                Assert.IsNotNull(horizontalFlexibleView, "should be not null");
                Assert.IsInstanceOf <FlexibleView>(horizontalFlexibleView, "should be an instance of testing target class!");

                horizontalFlexibleView = new FlexibleView();
                horizontalFlexibleView.OnRelayout(scrnSize, null);

                horizontalFlexibleView.Name = "RecyclerView1";
                horizontalFlexibleView.WidthSpecification  = 400;
                horizontalFlexibleView.HeightSpecification = 450;
                horizontalFlexibleView.Padding             = new Extents(10, 10, 10, 10);
                horizontalFlexibleView.BackgroundColor     = new Color(0.0f, 0.0f, 0.0f, 0.4f);

                List <ListItemData> dataList = new List <ListItemData>();
                for (int i = 0; i < 4; ++i)
                {
                    dataList.Add(new ListItemData(i));
                }
                adapter = new ListBridge(dataList);
                horizontalFlexibleView.SetAdapter(adapter);
                horizontalFlexibleView.OnRelayout(scrnSize, null);

                horizontalLayoutManager = new LinearLayoutManager(LinearLayoutManager.HORIZONTAL);
                horizontalFlexibleView.SetLayoutManager(horizontalLayoutManager);
                horizontalFlexibleView.OnRelayout(scrnSize, null);

                horizontalFlexibleView.Focusable = true;

                horizontalFlexibleView.KeyEvent    += RecyclerView_KeyEvent;
                horizontalFlexibleView.FocusGained += FlexibleView_FocusGained;
                horizontalFlexibleView.FocusLost   += FlexibleView_FocusLost;
            }

            return(horizontalFlexibleView);
        }
Exemplo n.º 8
0
            public override void OnFocusChange(FlexibleView flexibleView, int previousFocus, int currentFocus)
            {
                FlexibleViewViewHolder previousFocusView = flexibleView.FindViewHolderForAdapterPosition(previousFocus);

                if (previousFocusView != null)
                {
                    if (previousFocusView.AdapterPosition % 2 == 0)
                    {
                        previousFocusView.ItemView.BackgroundColor = Color.Cyan;
                    }
                    else
                    {
                        previousFocusView.ItemView.BackgroundColor = Color.Yellow;
                    }
                }
                FlexibleViewViewHolder currentFocusView = flexibleView.FindViewHolderForAdapterPosition(currentFocus);

                if (currentFocusView != null)
                {
                    currentFocusView.ItemView.BackgroundColor = Color.Magenta;
                }
            }
        public void FlexibleViewLayoutManagerScrollVerticallyBy()
        {
            tlog.Debug(tag, $"FlexibleViewLayoutManagerScrollVerticallyBy START");

            var testingTarget = new FlexibleViewLayoutManagerImpl();

            Assert.IsNotNull(testingTarget, "should be not null");
            Assert.IsInstanceOf <FlexibleViewLayoutManager>(testingTarget, "should be an instance of testing target class!");

            using (FlexibleView view = new FlexibleView()
            {
                Padding = new Extents(10, 10, 10, 10)
            })
            {
                FlexibleViewRecycler recycler = new FlexibleViewRecycler(view);
                var result = testingTarget.ScrollVerticallyBy(1.0f, recycler, false);
                tlog.Debug(tag, "ScrollVerticallyBy : " + result);
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"FlexibleViewLayoutManagerScrollVerticallyBy END (OK)");
        }
Exemplo n.º 10
0
        private bool RecyclerView_KeyEvent(object source, View.KeyEventArgs e)
        {
            FlexibleView flexibleView = source as FlexibleView;

            return(ProcessKey(flexibleView, e.Key));
        }
Exemplo n.º 11
0
        public void Activate()
        {
            Window window = Window.Instance;

            flexibleView1                 = new FlexibleView();
            flexibleView1.Name            = "RecyclerView";
            flexibleView1.Position2D      = new Position2D(500, 200);
            flexibleView1.Size2D          = new Size2D(400, 450);
            flexibleView1.Padding         = new Extents(10, 10, 10, 10);
            flexibleView1.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            List <ListItemData> dataList = new List <ListItemData>();

            for (int i = 0; i < 131; ++i)
            {
                dataList.Add(new ListItemData(i));
            }
            adapter = new ListBridge(dataList);
            flexibleView1.SetAdapter(adapter);

            LinearLayoutManager layoutManager1 = new LinearLayoutManager(LinearLayoutManager.VERTICAL);

            //GridLayoutManager layoutManager1 = new GridLayoutManager(3, LinearLayoutManager.VERTICAL);
            flexibleView1.SetLayoutManager(layoutManager1);

            flexibleView1.FocusedItemIndex = 0;

            window.Add(flexibleView1);

            flexibleView1.Focusable = true;

            flexibleView1.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView1.FocusGained += FlexibleView_FocusGained;
            flexibleView1.FocusLost   += FlexibleView_FocusLost;

            scrollBar1            = new ScrollBar();
            scrollBar1.Direction  = ScrollBar.DirectionType.Vertical;
            scrollBar1.Position2D = new Position2D(394, 2);
            scrollBar1.Size2D     = new Size2D(4, 446);
            scrollBar1.Style.Track.BackgroundColor = Color.Green;
            scrollBar1.Style.Thumb.Size            = new Size(4, 30);
            scrollBar1.Style.Thumb.BackgroundColor = Color.Yellow;
            scrollBar1.Style.Track.ResourceUrl     = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView1.AttachScrollBar(scrollBar1);


            flexibleView2                 = new FlexibleView();
            flexibleView2.Name            = "RecyclerView";
            flexibleView2.Position2D      = new Position2D(500, 800);
            flexibleView2.Size2D          = new Size2D(700, 200);
            flexibleView2.Padding         = new Extents(10, 10, 10, 10);
            flexibleView2.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            flexibleView2.SetAdapter(adapter);

            GridLayoutManager layoutManager2 = new GridLayoutManager(3, LinearLayoutManager.HORIZONTAL);

            flexibleView2.SetLayoutManager(layoutManager2);

            flexibleView2.FocusedItemIndex = 0;

            window.Add(flexibleView2);

            flexibleView2.Focusable = true;

            flexibleView2.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView2.FocusGained += FlexibleView_FocusGained;
            flexibleView2.FocusLost   += FlexibleView_FocusLost;

            scrollBar2            = new ScrollBar();
            scrollBar2.Position2D = new Position2D(2, 194);
            scrollBar2.Size2D     = new Size2D(696, 4);
            scrollBar2.Style.Track.BackgroundColor = Color.Green;
            scrollBar2.Style.Thumb.Size            = new Size(30, 4);
            scrollBar2.Style.Thumb.BackgroundColor = Color.Yellow;
            scrollBar2.Style.Track.ResourceUrl     = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView2.AttachScrollBar(scrollBar2);


            FocusManager.Instance.SetCurrentFocusView(flexibleView1);
        }
Exemplo n.º 12
0
        private bool RecyclerView_KeyEvent(object source, View.KeyEventArgs e)
        {
            FlexibleView flexibleView = source as FlexibleView;

            return(true);
        }
Exemplo n.º 13
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            root = new View()
            {
                Size            = new Size(1920, 1080),
                BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
            };
            window.Add(root);

            parent = new View()
            {
                Position = new Position(300, 300),
                Size     = new Size(1150, 450)
            };
            parent.Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Horizontal,
                LinearAlignment   = LinearLayout.Alignment.Bottom,
                CellPadding       = new Size(50, 50)
            };
            root.Add(parent);

            // Create vertical flexibleView
            flexibleView1      = new FlexibleView();
            flexibleView1.Name = "RecyclerView1";
            flexibleView1.WidthSpecification  = 400;
            flexibleView1.HeightSpecification = 450;
            flexibleView1.Padding             = new Extents(10, 10, 10, 10);
            flexibleView1.BackgroundColor     = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            List <ListItemData> dataList = new List <ListItemData>();

            for (int i = 0; i < 131; ++i)
            {
                dataList.Add(new ListItemData(i));
            }
            adapter = new ListBridge(dataList);
            flexibleView1.SetAdapter(adapter);

            LinearLayoutManager layoutManager1 = new LinearLayoutManager(LinearLayoutManager.VERTICAL);

            flexibleView1.SetLayoutManager(layoutManager1);

            flexibleView1.FocusedItemIndex = 0;

            parent.Add(flexibleView1);

            flexibleView1.Focusable = true;

            flexibleView1.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView1.FocusGained += FlexibleView_FocusGained;
            flexibleView1.FocusLost   += FlexibleView_FocusLost;

            scrollBar1                     = new ScrollBar();
            scrollBar1.Direction           = ScrollBar.DirectionType.Vertical;
            scrollBar1.Position            = new Position(394, 2);
            scrollBar1.WidthSpecification  = 4;
            scrollBar1.HeightSpecification = 446;
            scrollBar1.TrackColor          = Color.Green;
            scrollBar1.ThumbSize           = new Size(4, 30);
            scrollBar1.ThumbColor          = Color.Yellow;
            scrollBar1.TrackImageURL       = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView1.AttachScrollBar(scrollBar1);

            // Create horizontal flexibleView
            flexibleView2      = new FlexibleView();
            flexibleView2.Name = "RecyclerView2";
            flexibleView2.WidthSpecification  = 700;
            flexibleView2.HeightSpecification = 200;
            flexibleView2.Padding             = new Extents(10, 10, 10, 10);
            flexibleView2.BackgroundColor     = new Color(0.0f, 0.0f, 0.0f, 0.4f);

            flexibleView2.SetAdapter(adapter);

            GridLayoutManager layoutManager2 = new GridLayoutManager(3, LinearLayoutManager.HORIZONTAL);

            flexibleView2.SetLayoutManager(layoutManager2);

            flexibleView2.FocusedItemIndex = 0;

            parent.Add(flexibleView2);

            flexibleView2.Focusable = true;

            flexibleView2.KeyEvent    += RecyclerView_KeyEvent;
            flexibleView2.FocusGained += FlexibleView_FocusGained;
            flexibleView2.FocusLost   += FlexibleView_FocusLost;

            scrollBar2                     = new ScrollBar();
            scrollBar2.Direction           = ScrollBar.DirectionType.Horizontal;
            scrollBar2.Position            = new Position(2, 194);
            scrollBar2.WidthSpecification  = 696;
            scrollBar2.HeightSpecification = 4;
            scrollBar2.TrackColor          = Color.Green;
            scrollBar2.ThumbSize           = new Size(30, 4);
            scrollBar2.ThumbColor          = Color.Yellow;
            scrollBar2.TrackImageURL       = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
            flexibleView2.AttachScrollBar(scrollBar2);

            FocusManager.Instance.SetCurrentFocusView(flexibleView1);
            FocusManager.Instance.PreFocusChange += onPreFocusChange;
        }