[EditorBrowsable(EditorBrowsableState.Never)]
protected override int GetNextPosition(int position, FlexibleViewLayoutManager.Direction direction)
{
- if (mOrientation == HORIZONTAL)
+ if (Orientation == HORIZONTAL)
{
switch (direction)
{
result.Consumed = mOrientationHelper.GetViewHolderMeasurement(holder);
float left, top, width, height;
- if (mOrientation == VERTICAL)
+ if (Orientation == VERTICAL)
{
width = (Width - PaddingLeft - PaddingRight) / count;
height = result.Consumed;
result.Consumed = mOrientationHelper.GetViewHolderMeasurement(holder);
float left, top, width, height;
- if (mOrientation == VERTICAL)
+ if (Orientation == VERTICAL)
{
width = Width - PaddingLeft - PaddingRight;
height = result.Consumed;
switch (focusDirection)
{
case FlexibleViewLayoutManager.Direction.Up:
- return mOrientation == VERTICAL ? LayoutState.LAYOUT_START
+ return Orientation == VERTICAL ? LayoutState.LAYOUT_START
: LayoutState.INVALID_LAYOUT;
case FlexibleViewLayoutManager.Direction.Down:
- return mOrientation == VERTICAL ? LayoutState.LAYOUT_END
+ return Orientation == VERTICAL ? LayoutState.LAYOUT_END
: LayoutState.INVALID_LAYOUT;
case FlexibleViewLayoutManager.Direction.Left:
- return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_START
+ return Orientation == HORIZONTAL ? LayoutState.LAYOUT_START
: LayoutState.INVALID_LAYOUT;
case FlexibleViewLayoutManager.Direction.Right:
- return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_END
+ return Orientation == HORIZONTAL ? LayoutState.LAYOUT_END
: LayoutState.INVALID_LAYOUT;
default:
return LayoutState.INVALID_LAYOUT;
private const float MAX_SCROLL_FACTOR = 1 / 3f;
- /// <summary>
- /// Current orientation.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected int mOrientation;
-
internal OrientationHelper mOrientationHelper;
private LayoutState mLayoutState;
[EditorBrowsable(EditorBrowsableState.Never)]
public LinearLayoutManager(int orientation)
{
- mOrientation = orientation;
- mOrientationHelper = OrientationHelper.CreateOrientationHelper(this, mOrientation);
+ Orientation = orientation;
+ mOrientationHelper = OrientationHelper.CreateOrientationHelper(this, Orientation);
mLayoutState = new LayoutState();
mLayoutState.Offset = mOrientationHelper.GetStartAfterPadding();
}
/// <summary>
+ /// Current orientation.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected int Orientation { get; set; }
+
+ /// <summary>
/// Retrieves the first visible item position.
/// </summary>
/// <since_tizen> 6 </since_tizen>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool CanScrollHorizontally()
{
- return mOrientation == HORIZONTAL;
+ return Orientation == HORIZONTAL;
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool CanScrollVertically()
{
- return mOrientation == VERTICAL;
+ return Orientation == VERTICAL;
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public override float ScrollHorizontallyBy(float dx, FlexibleViewRecycler recycler, bool immediate)
{
- if (mOrientation == VERTICAL)
+ if (Orientation == VERTICAL)
{
return 0;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public override float ScrollVerticallyBy(float dy, FlexibleViewRecycler recycler, bool immediate)
{
- if (mOrientation == HORIZONTAL)
+ if (Orientation == HORIZONTAL)
{
return 0;
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected override int GetNextPosition(int position, FlexibleViewLayoutManager.Direction direction)
{
- if (mOrientation == HORIZONTAL)
+ if (Orientation == HORIZONTAL)
{
switch (direction)
{
if (Container != null)
{
- Layout(mPrevScrollPosition);
+ Layout(PrevScrollPosition);
}
}
}
if (Container != null)
{
- Layout(mPrevScrollPosition);
+ Layout(PrevScrollPosition);
}
}
}
public override float CalculateLayoutOrientationSize()
{
float orientationFactor = LayoutOrientation == Orientation.Horizontal ? Rows : Columns;
- return mStepSize * (int)Math.Ceiling((double)DataCount / (double)orientationFactor);
+ return StepSize * (int)Math.Ceiling((double)DataCount / (double)orientationFactor);
}
previousItem = item;
}
- if (mStepSize == 0)
+ if (StepSize == 0)
{
- mStepSize = LayoutOrientation == Orientation.Horizontal ? ItemSize.Width : ItemSize.Height;
+ StepSize = LayoutOrientation == Orientation.Horizontal ? ItemSize.Width : ItemSize.Height;
}
}
public override List<RecycleItem> Recycle(float scrollPosition)
{
List<RecycleItem> result = new List<RecycleItem>();
- bool checkFront = (mPrevScrollPosition - scrollPosition) > 0;
+ bool checkFront = (PrevScrollPosition - scrollPosition) > 0;
int itemInGroup = LayoutOrientation == Orientation.Horizontal ? Rows : Columns;
}
- mPrevScrollPosition = scrollPosition;
+ PrevScrollPosition = scrollPosition;
return result;
}
// Tizen.Log.Error("NUI","["+item.DataIndex+"] "+item.Position.Y+" ==== \n");
}
- if(mStepSize == 0)
+ if(StepSize == 0)
{
- mStepSize = LayoutOrientation == Orientation.Horizontal?ItemSize.Width:ItemSize.Height;
+ StepSize = LayoutOrientation == Orientation.Horizontal?ItemSize.Width:ItemSize.Height;
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public override float CalculateLayoutOrientationSize()
{
- return mStepSize * DataCount;
+ return StepSize * DataCount;
}
/// <summary>
{
List<RecycleItem> result = new List<RecycleItem>();
- bool checkFront = (mPrevScrollPosition - scrollPosition) > 0;
+ bool checkFront = (PrevScrollPosition - scrollPosition) > 0;
if(checkFront)
{
}
}
- mPrevScrollPosition = scrollPosition;
+ PrevScrollPosition = scrollPosition;
return result;
}
-/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
[EditorBrowsable(EditorBrowsableState.Never)]
public class RecycleLayoutManager
{
- protected float mPrevScrollPosition = 0.0f;
- protected int mPrevFirstDataIndex = 0;
- protected float mStepSize = 0.0f;
-
/// <summary>
/// Enumeration for the direction in which the content is laid out
/// </summary>
/// <since_tizen> 8 </since_tizen>
/// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
[EditorBrowsable(EditorBrowsableState.Never)]
- public float StepSize{
- get
- {
- return mStepSize;
- }
- }
+ public float StepSize { get; protected set; }
/// <summary>
/// How far can you reach the next item.
public int DataCount{get; set;}
/// <summary>
+ /// The last scrolled position which is calculated by ScrollableBase. The value should be updated in the Recycle() method.
+ /// </summary>
+ /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected float PrevScrollPosition { get; set; }
+
+ /// <summary>
/// This is called to find out where items are lain out according to current scroll position.
/// </summary>
/// <param name="scrollPosition">Scroll position which is calculated by ScrollableBase</param>
return scrollPosition;
}
}
-}
\ No newline at end of file
+}
-/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
[EditorBrowsable(EditorBrowsableState.Never)]
public class RecyclerView : ScrollableBase
{
- protected RecycleAdapter mAdapter;
- protected View mContainer;
- protected RecycleLayoutManager mLayoutManager;
- protected int mTotalItemCount = 15;
+ private RecycleAdapter adapter;
+ private RecycleLayoutManager layoutManager;
+ private int totalItemCount = 15;
private List<PropertyNotification> notifications = new List<PropertyNotification>();
public RecyclerView() : base()
{
Scrolling += OnScrolling;
- mAdapter = adapter;
- mAdapter.OnDataChanged += OnAdapterDataChanged;
+ this.adapter = adapter;
+ this.adapter.OnDataChanged += OnAdapterDataChanged;
- mLayoutManager = layoutManager;
- mLayoutManager.Container = ContentContainer;
- mLayoutManager.ItemSize = mAdapter.CreateRecycleItem().Size;
- mLayoutManager.DataCount = mAdapter.Data.Count;
+ this.layoutManager = layoutManager;
+ this.layoutManager.Container = ContentContainer;
+ this.layoutManager.ItemSize = this.adapter.CreateRecycleItem().Size;
+ this.layoutManager.DataCount = this.adapter.Data.Count;
InitializeItems();
}
private void OnItemSizeChanged(object source, PropertyNotification.NotifyEventArgs args)
{
- mLayoutManager.Layout(ScrollingDirection == Direction.Horizontal ? ContentContainer.CurrentPosition.X : ContentContainer.CurrentPosition.Y);
+ layoutManager.Layout(ScrollingDirection == Direction.Horizontal ? ContentContainer.CurrentPosition.X : ContentContainer.CurrentPosition.Y);
}
public int TotalItemCount
{
get
{
- return mTotalItemCount;
+ return totalItemCount;
}
set
{
- mTotalItemCount = value;
+ totalItemCount = value;
InitializeItems();
}
}
notifications.RemoveAt(i);
}
- for (int i = 0; i < mTotalItemCount; i++)
+ for (int i = 0; i < totalItemCount; i++)
{
- RecycleItem item = mAdapter.CreateRecycleItem();
+ RecycleItem item = adapter.CreateRecycleItem();
item.DataIndex = i;
item.Name = "[" + i + "] recycle";
- if (i < mAdapter.Data.Count)
+ if (i < adapter.Data.Count)
{
- mAdapter.BindData(item);
+ adapter.BindData(item);
}
Add(item);
notifications.Add(noti);
}
- mLayoutManager.Layout(0.0f);
+ layoutManager.Layout(0.0f);
if (ScrollingDirection == Direction.Horizontal)
{
- ContentContainer.SizeWidth = mLayoutManager.CalculateLayoutOrientationSize();
+ ContentContainer.SizeWidth = layoutManager.CalculateLayoutOrientationSize();
}
else
{
- ContentContainer.SizeHeight = mLayoutManager.CalculateLayoutOrientationSize();
+ ContentContainer.SizeHeight = layoutManager.CalculateLayoutOrientationSize();
}
}
if (ScrollingDirection == Direction.Horizontal)
{
- ContentContainer.SizeWidth = mLayoutManager.CalculateLayoutOrientationSize();
+ ContentContainer.SizeWidth = layoutManager.CalculateLayoutOrientationSize();
}
else
{
- ContentContainer.SizeHeight = mLayoutManager.CalculateLayoutOrientationSize();
+ ContentContainer.SizeHeight = layoutManager.CalculateLayoutOrientationSize();
}
}
}
{
get
{
- return mAdapter;
+ return adapter;
}
set
{
- if(mAdapter != null)
+ if (adapter != null)
{
- mAdapter.OnDataChanged -= OnAdapterDataChanged;
+ adapter.OnDataChanged -= OnAdapterDataChanged;
}
- mAdapter = value;
- mAdapter.OnDataChanged += OnAdapterDataChanged;
- mLayoutManager.ItemSize = mAdapter.CreateRecycleItem().Size;
- mLayoutManager.DataCount = mAdapter.Data.Count;
+ adapter = value;
+ adapter.OnDataChanged += OnAdapterDataChanged;
+ layoutManager.ItemSize = adapter.CreateRecycleItem().Size;
+ layoutManager.DataCount = adapter.Data.Count;
InitializeItems();
}
}
{
get
{
- return mLayoutManager;
+ return layoutManager;
}
- set
+ protected set
{
- mLayoutManager = value;
- mLayoutManager.Container = ContentContainer;
- mLayoutManager.ItemSize = mAdapter.CreateRecycleItem().Size;
- mLayoutManager.DataCount = mAdapter.Data.Count;
+ LayoutManager = value;
+ LayoutManager.Container = ContentContainer;
+ LayoutManager.ItemSize = Adapter.CreateRecycleItem().Size;
+ LayoutManager.DataCount = Adapter.Data.Count;
InitializeItems();
}
}
private void OnScrolling(object source, ScrollEventArgs args)
{
- mLayoutManager.Layout(ScrollingDirection == Direction.Horizontal ? args.Position.X : args.Position.Y);
- List<RecycleItem> recycledItemList = mLayoutManager.Recycle(ScrollingDirection == Direction.Horizontal ? args.Position.X : args.Position.Y);
+ layoutManager.Layout(ScrollingDirection == Direction.Horizontal ? args.Position.X : args.Position.Y);
+ List<RecycleItem> recycledItemList = layoutManager.Recycle(ScrollingDirection == Direction.Horizontal ? args.Position.X : args.Position.Y);
BindData(recycledItemList);
}
{
foreach (RecycleItem item in changedData)
{
- if (item.DataIndex > -1 && item.DataIndex < mAdapter.Data.Count)
+ if (item.DataIndex > -1 && item.DataIndex < adapter.Data.Count)
{
item.Show();
item.Name = "["+item.DataIndex+"]";
- mAdapter.BindData(item);
+ adapter.BindData(item);
}
else
{
{
// Destination is depending on implementation of layout manager.
// Get destination from layout manager.
- return mLayoutManager.CalculateCandidateScrollPosition(position);
+ return layoutManager.CalculateCandidateScrollPosition(position);
}
}
}
public override float CalculateLayoutOrientationSize()
{
- return mStepSize * (DataCount-1);
+ return StepSize * (DataCount-1);
}
public override void Layout(float scrollPosition)
RecycleItem centerItem = Container.Children[FocusedIndex] as RecycleItem;
float centerItemPosition = LayoutOrientation == Orientation.Horizontal ? centerItem.Position.X : centerItem.Position.Y;
- Vector2 stepRange = new Vector2(-scrollPosition - mStepSize + 1.0f, -scrollPosition + mStepSize - 1.0f);
+ Vector2 stepRange = new Vector2(-scrollPosition - StepSize + 1.0f, -scrollPosition + StepSize - 1.0f);
Vector2 visibleRange = new Vector2(Math.Abs(scrollPosition) - 180, Math.Abs(scrollPosition) + 180);
- if (mStepSize != 0 && centerItemPosition <= stepRange.X)
+ if (StepSize != 0 && centerItemPosition <= stepRange.X)
{
FocusedIndex = Math.Min(Container.Children.Count - 1, FocusedIndex + 1);
centerItem = Container.Children[FocusedIndex] as RecycleItem;
- centerItem.Position = new Position(0.0f, Math.Abs(mStepSize * (centerItem.DataIndex)));
+ centerItem.Position = new Position(0.0f, Math.Abs(StepSize * (centerItem.DataIndex)));
centerItem.Scale = new Vector3(1.0f, 1.0f, 1.0f);
}
- else if (mStepSize != 0 && centerItemPosition >= stepRange.Y)
+ else if (StepSize != 0 && centerItemPosition >= stepRange.Y)
{
FocusedIndex = Math.Max(0, FocusedIndex - 1);
centerItem = Container.Children[FocusedIndex] as RecycleItem;
- centerItem.Position = new Position(0.0f, Math.Abs(mStepSize * (centerItem.DataIndex)));
+ centerItem.Position = new Position(0.0f, Math.Abs(StepSize * (centerItem.DataIndex)));
centerItem.Scale = new Vector3(1.0f, 1.0f, 1.0f);
}
else
}
}
- if (mStepSize == 0)
+ if (StepSize == 0)
{
if (LayoutOrientation == Orientation.Horizontal)
{
- mStepSize = Container.Children[0].Size.Width / 2.0f + Container.Children[1].Size.Width * Container.Children[1].Scale.X / 2.0f;
+ StepSize = Container.Children[0].Size.Width / 2.0f + Container.Children[1].Size.Width * Container.Children[1].Scale.X / 2.0f;
}
else
{
- mStepSize = Container.Children[0].Size.Height / 2.0f + Container.Children[1].Size.Height * Container.Children[1].Scale.X / 2.0f;
+ StepSize = Container.Children[0].Size.Height / 2.0f + Container.Children[1].Size.Height * Container.Children[1].Scale.X / 2.0f;
}
- mStepSize = float.IsNaN(mStepSize)?0:mStepSize;
+ StepSize = float.IsNaN(StepSize)?0:StepSize;
}
}
{
List<RecycleItem> result = new List<RecycleItem>();
- bool isBack = scrollPosition - mPrevScrollPosition < 0;
+ bool isBack = scrollPosition - PrevScrollPosition < 0;
int previousFocusIndex = FocusedIndex;
FocusedIndex--;
}
- mPrevScrollPosition = scrollPosition;
+ PrevScrollPosition = scrollPosition;
return result;
}
public override float CalculateCandidateScrollPosition(float scrollPosition)
{
- int value = (int)(Math.Abs(scrollPosition) / mStepSize);
- float remain = Math.Abs(scrollPosition) % mStepSize;
+ int value = (int)(Math.Abs(scrollPosition) / StepSize);
+ float remain = Math.Abs(scrollPosition) % StepSize;
- int newValue = remain > mStepSize / 2.0f ? value + 1 : value;
+ int newValue = remain > StepSize / 2.0f ? value + 1 : value;
CurrentFocusedIndex = newValue;
- return -newValue * mStepSize;
+ return -newValue * StepSize;
}
}
}
\ No newline at end of file
-/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
FocusedItem = item;
FocusedItem.OnFocusGained();
- ScrollTo(item.DataIndex * mLayoutManager.StepSize, animated);
+ ScrollTo(item.DataIndex * LayoutManager.StepSize, animated);
}
}
}
/// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
protected override void OnPreReachedTargetPosition(float targetPosition)
{
- int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / mLayoutManager.StepSize);
+ int targetDataIndex = (int)Math.Round(Math.Abs(targetPosition) / LayoutManager.StepSize);
for (int i = 0; i < Children.Count; i++)
{