From facaf86885f8153ac21e12de93bbe00eaacf7867 Mon Sep 17 00:00:00 2001 From: jaehyun0cho Date: Wed, 24 Jun 2020 20:53:42 +0900 Subject: [PATCH] [NUI] Add public types to replace nested types (CA1034 of StyleCop) (#1692) Renamed public types are added outside of the class to replace public nested types (CA1034 of StyleCop) in Tizen.NUI.Components and Tizen.NUI.Wearable. This patch is done for types which have not been publicly opened. The newly added event and EventArgs names follow the C# naming rules. To identify the nested types from other types, the class name is prepended to the nested type names if it is required. e.g. FlexibleView.ItemClickEventArgs -> FlexibleViewItemClickedEventArgs Co-authored-by: Jaehyun Cho --- .../Controls/FlexibleView/FlexibleView.Adapter.cs | 301 ------- .../Controls/FlexibleView/FlexibleView.Helper.cs | 45 +- .../FlexibleView/FlexibleView.LayoutManager.cs | 899 --------------------- .../Controls/FlexibleView/FlexibleView.Recycler.cs | 166 ---- .../FlexibleView/FlexibleView.ViewHolder.cs | 245 ------ .../Controls/FlexibleView/FlexibleView.cs | 164 ++-- .../Controls/FlexibleView/FlexibleViewAdapter.cs | 277 +++++++ .../FlexibleView/FlexibleViewLayoutManager.cs | 860 ++++++++++++++++++++ .../Controls/FlexibleView/FlexibleViewRecycler.cs | 156 ++++ .../FlexibleView/FlexibleViewViewHolder.cs | 231 ++++++ .../Controls/FlexibleView/GridLayoutManager.cs | 25 +- .../FlexibleView/LinearLayoutManager.Internal.cs | 72 +- .../Controls/FlexibleView/LinearLayoutManager.cs | 59 +- .../Controls/FlexibleView/OrientationHelper.cs | 52 +- src/Tizen.NUI.Components/Controls/RadioButton.cs | 3 +- .../Controls/RecyclerView/RecyclerView.cs | 6 +- .../Controls/ScrollableBase.cs | 105 ++- src/Tizen.NUI.Components/Controls/SelectButton.cs | 42 +- src/Tizen.NUI.Components/Controls/SelectGroup.cs | 34 +- .../src/public/CircularSlider.cs | 42 +- src/Tizen.NUI.Wearable/src/public/WearableList.cs | 8 +- .../Samples/CubeTransitionEffectSample.cs | 12 +- .../Samples/FlexibleViewSample.cs | 26 +- 23 files changed, 1861 insertions(+), 1969 deletions(-) delete mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Adapter.cs delete mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.LayoutManager.cs delete mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Recycler.cs delete mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.ViewHolder.cs create mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewAdapter.cs create mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewLayoutManager.cs create mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewRecycler.cs create mode 100755 src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewViewHolder.cs diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Adapter.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Adapter.cs deleted file mode 100755 index 75234b0..0000000 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Adapter.cs +++ /dev/null @@ -1,301 +0,0 @@ -using System; -using System.ComponentModel; - -namespace Tizen.NUI.Components -{ - public partial class FlexibleView - { - /// - /// Adapters provide a binding from an app-specific data set to views that are displayed within a FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract class Adapter - { - private EventHandler itemEventHandlers; - - internal event EventHandler ItemEvent - { - add - { - itemEventHandlers += value; - } - - remove - { - itemEventHandlers -= value; - } - } - - internal enum ItemEventType - { - Insert = 0, - Remove, - Move, - Change - } - - /// - /// Called when FlexibleView needs a new FlexibleView.ViewHolder of the given type to represent an item. - /// - /// The view type of the new View - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract ViewHolder OnCreateViewHolder(int viewType); - - /// - /// Called by FlexibleView to display the data at the specified position. - /// - /// The ViewHolder which should be updated to represent the contents of the item at the given position in the data set. - /// The position of the item within the adapter's data set. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract void OnBindViewHolder(ViewHolder holder, int position); - - /// - /// Called when a ViewHolder is never used. - /// - /// The ViewHolder which need to be disposed - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract void OnDestroyViewHolder(ViewHolder holder); - - /// - /// Returns the total number of items in the data set held by the adapter. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract int GetItemCount(); - - /// - /// Return the view type of the item at position for the purposes of view recycling. - /// - /// The position of the item within the adapter's data set. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual int GetItemViewType(int position) - { - return 0; - } - - /// - /// Called by FlexibleView when it starts observing this Adapter. - /// Keep in mind that same adapter may be observed by multiple FlexibleView. - /// - /// The FlexibleView instance which started observing this adapter. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnAttachedToRecyclerView(FlexibleView flexibleView) - { - } - - /// - /// Called by FlexibleView when it stops observing this Adapter. - /// - /// The FlexibleView instance which stopped observing this adapter. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnDetachedFromRecyclerView(FlexibleView flexibleView) - { - } - - /// - /// Called when FlexibleView focus changed. - /// - /// The FlexibleView into which the focus ViewHolder changed. - /// The position of previous focus - /// The position of current focus - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnFocusChange(FlexibleView flexibleView, int previousFocus, int currentFocus) - { - } - - /// - /// Called when a view created by this adapter has been recycled. - /// If an item view has large or expensive data bound to it such as large bitmaps, this may be a good place to release those resources - /// - /// The ViewHolder will be recycled. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnViewRecycled(ViewHolder holder) - { - } - - /// - /// Called when a view created by this adapter has been attached to a window. - /// This can be used as a reasonable signal that the view is about to be seen by the user. - /// - /// Holder of the view being attached. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnViewAttachedToWindow(ViewHolder holder) - { - } - - /// - /// Called when a view created by this adapter has been detached from its window. - /// - /// Holder of the view being detached. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnViewDetachedFromWindow(ViewHolder holder) - { - } - - /// - /// Notify any registered observers that the data set has changed. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyDataSetChanged() - { - } - - /// - /// Notify any registered observers that the data set has changed. - /// It indicates that any reflection of the data at position is out of date and should be updated. - /// - /// Position of the item that has changed - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemChanged(int position) - { - ItemEventArgs args = new ItemEventArgs - { - EventType = ItemEventType.Change, - }; - args.param[0] = position; - args.param[1] = 1; - OnItemEvent(this, args); - } - - /// - /// Notify any registered observers that the itemCount items starting at position positionStart have changed. - /// An optional payload can be passed to each changed item. - /// - /// Position of the first item that has changed - /// Number of items that have changed - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemRangeChanged(int positionStart, int itemCount) - { - } - - /// - /// Notify any registered observers that the data set has been newly inserted. - /// It indicates that any reflection of the data at position is out of date and should be updated. - /// - /// Position of the item that has been newly inserted - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemInserted(int position) - { - NotifyItemRangeInserted(position, 1); - } - - /// - /// Notify any registered observers that the itemCount items starting at position positionStart have been newly inserted. - /// - /// Position of the first item that was inserted - /// Number of items inserted - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemRangeInserted(int positionStart, int itemCount) - { - ItemEventArgs args = new ItemEventArgs - { - EventType = ItemEventType.Insert, - }; - args.param[0] = positionStart; - args.param[1] = itemCount; - OnItemEvent(this, args); - } - - /// - /// Notify any registered observers that the item previously located at position has been removed from the data set. - /// - /// Previous position of the first item that was removed - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemRemoved(int position) - { - NotifyItemRangeRemoved(position, 1); - } - - /// - /// Notify any registered observers that the itemCount items previously located at positionStart have been removed from the data set. - /// - /// Previous position of the first item that was removed - /// Number of items removed from the data set - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemRangeRemoved(int positionStart, int itemCount) - { - ItemEventArgs args = new ItemEventArgs - { - EventType = ItemEventType.Remove, - }; - args.param[0] = positionStart; - args.param[1] = itemCount; - OnItemEvent(this, args); - } - - /// - /// Notify any registered observers that the item reflected at fromPosition has been moved to toPosition. - /// - /// Previous position of the item - /// New position of the item. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void NotifyItemMoved(int fromPosition, int toPosition) - { - - } - - private void OnItemEvent(object sender, ItemEventArgs e) - { - itemEventHandlers?.Invoke(sender, e); - } - - internal class ItemEventArgs : EventArgs - { - - /// - /// Data change event parameters. - /// - public int[] param = new int[4]; - - /// - /// Data changed event type. - /// - public ItemEventType EventType - { - get; - set; - } - } - } - - } -} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Helper.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Helper.cs index a69dbb0..05ea699 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Helper.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Helper.cs @@ -11,19 +11,19 @@ namespace Tizen.NUI.Components private FlexibleView mFlexibleView; private int mMaxTypeCount = 10; - private List[] mScrap; + private List[] mScrap; public RecycledViewPool(FlexibleView flexibleView) { mFlexibleView = flexibleView; - mScrap = new List[mMaxTypeCount]; + mScrap = new List[mMaxTypeCount]; } //public void SetViewTypeCount(int typeCount) //{ //} - public ViewHolder GetRecycledView(int viewType) + public FlexibleViewViewHolder GetRecycledView(int viewType) { if (viewType >= mMaxTypeCount || mScrap[viewType] == null) { @@ -35,13 +35,13 @@ namespace Tizen.NUI.Components { return null; } - ViewHolder recycledView = mScrap[viewType][index]; + FlexibleViewViewHolder recycledView = mScrap[viewType][index]; mScrap[viewType].RemoveAt(index); return recycledView; } - public void PutRecycledView(ViewHolder view) + public void PutRecycledView(FlexibleViewViewHolder view) { int viewType = view.ItemViewType; if (viewType >= mMaxTypeCount) @@ -50,7 +50,7 @@ namespace Tizen.NUI.Components } if (mScrap[viewType] == null) { - mScrap[viewType] = new List(); + mScrap[viewType] = new List(); } view.IsBound = false; mScrap[viewType].Add(view); @@ -73,15 +73,15 @@ namespace Tizen.NUI.Components } } - private class ChildHelper + internal class ChildHelper { private FlexibleView mFlexibleView; - private List mViewList = new List(); + private List mViewList = new List(); - //private List mRemovePendingViews; + //private List mRemovePendingViews; - private Dictionary itemViewTable = new Dictionary(); + private Dictionary itemViewTable = new Dictionary(); private TapGestureDetector mTapGestureDetector; public ChildHelper(FlexibleView owner) @@ -94,7 +94,7 @@ namespace Tizen.NUI.Components public void Clear() { - foreach (ViewHolder holder in mViewList) + foreach (FlexibleViewViewHolder holder in mViewList) { mFlexibleView.Remove(holder.ItemView); @@ -103,10 +103,10 @@ namespace Tizen.NUI.Components mViewList.Clear(); } - public void ScrapViews(Recycler recycler) + public void ScrapViews(FlexibleViewRecycler recycler) { recycler.Clear(); - foreach (ViewHolder itemView in mViewList) + foreach (FlexibleViewViewHolder itemView in mViewList) { recycler.ScrapView(itemView); } @@ -114,7 +114,7 @@ namespace Tizen.NUI.Components mViewList.Clear(); } - public void AttachView(ViewHolder holder, int index) + public void AttachView(FlexibleViewViewHolder holder, int index) { if (index == -1) { @@ -132,7 +132,7 @@ namespace Tizen.NUI.Components itemViewTable[holder.ItemView.ID] = holder; } - public void AddView(ViewHolder holder, int index) + public void AddView(FlexibleViewViewHolder holder, int index) { mFlexibleView.Add(holder.ItemView); @@ -141,7 +141,7 @@ namespace Tizen.NUI.Components AttachView(holder, index); } - public bool RemoveView(ViewHolder holder) + public bool RemoveView(FlexibleViewViewHolder holder) { mFlexibleView.Remove(holder.ItemView); @@ -152,7 +152,7 @@ namespace Tizen.NUI.Components public bool RemoveViewAt(int index) { - ViewHolder itemView = mViewList[index]; + FlexibleViewViewHolder itemView = mViewList[index]; return RemoveView(itemView); } @@ -160,7 +160,7 @@ namespace Tizen.NUI.Components { for (int i = index; i < index + count; i++) { - ViewHolder holder = mViewList[i]; + FlexibleViewViewHolder holder = mViewList[i]; mFlexibleView.Remove(holder.ItemView); } mViewList.RemoveRange(index, count); @@ -172,7 +172,7 @@ namespace Tizen.NUI.Components return mViewList.Count; } - public ViewHolder GetChildAt(int index) + public FlexibleViewViewHolder GetChildAt(int index) { if (index < 0 || index >= mViewList.Count) { @@ -190,19 +190,19 @@ namespace Tizen.NUI.Components } if (itemViewTable.ContainsKey(itemView.ID)) { - ViewHolder holder = itemViewTable[itemView.ID]; + FlexibleViewViewHolder holder = itemViewTable[itemView.ID]; mFlexibleView.FocusedItemIndex = holder.AdapterPosition; mFlexibleView.DispatchItemClicked(holder); } } - private bool OnTouchEvent(object source, TouchEventArgs e) + private bool OnTouchEvent(object source, View.TouchEventArgs e) { View itemView = source as View; if (itemView != null && itemViewTable.ContainsKey(itemView.ID)) { - ViewHolder holder = itemViewTable[itemView.ID]; + FlexibleViewViewHolder holder = itemViewTable[itemView.ID]; mFlexibleView.DispatchItemTouched(holder, e.Touch); return true; @@ -358,6 +358,5 @@ namespace Tizen.NUI.Components set; } } - } } diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.LayoutManager.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.LayoutManager.cs deleted file mode 100755 index 8122078..0000000 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.LayoutManager.cs +++ /dev/null @@ -1,899 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.Components -{ - public partial class FlexibleView - { - /// - /// A LayoutManager is responsible for measuring and positioning item views within a FlexibleView - /// as well as determining the policy for when to recycle item views that are no longer visible to the user. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract class LayoutManager - { - /// - /// Direction - /// - public enum Direction - { - /// - /// Left - /// - Left, - - /// - /// Right - /// - Right, - - /// - /// Up - /// - Up, - - /// - /// Down - /// - Down - } - - private readonly int SCROLL_ANIMATION_DURATION = 500; - - private FlexibleView mFlexibleView; - private ChildHelper mChildHelper; - - private List mPendingRecycleViews = new List(); - - private Animation mScrollAni; - - /// - /// Layout all relevant child views from the given adapter. - /// - /// Recycler to use for fetching potentially cached views for a position - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract void OnLayoutChildren(Recycler recycler); - - /// - /// Called after a full layout calculation is finished. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnLayoutCompleted() - { - } - - /// - /// Gets the current focus position in adapter. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int FocusPosition - { - get - { - return mFlexibleView.mFocusedItemIndex; - } - } - - /// - /// Gets the datas count in data sets. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int ItemCount - { - get - { - Adapter b = mFlexibleView != null ? mFlexibleView.mAdapter : null; - - return b != null ? b.GetItemCount() : 0; - } - } - - /// - /// Query if horizontal scrolling is currently supported. The default implementation returns false. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual bool CanScrollHorizontally() - { - return false; - } - - /// - /// Query if vertical scrolling is currently supported. The default implementation returns false. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual bool CanScrollVertically() - { - return false; - } - - /// - /// Scroll horizontally by dy pixels in screen coordinates. - /// - /// distance to scroll in pixels. Y increases as scroll position approaches the top. - /// Recycler to use for fetching potentially cached views for a position - /// Specify if the scroll need animation - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual float ScrollHorizontallyBy(float dy, Recycler recycler, bool immediate) - { - return 0; - } - - /// - /// Scroll vertically by dy pixels in screen coordinates. - /// - /// distance to scroll in pixels. Y increases as scroll position approaches the top. - /// Recycler to use for fetching potentially cached views for a position - /// Specify if the scroll need animation - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual float ScrollVerticallyBy(float dy, Recycler recycler, bool immediate) - { - return 0; - } - - /// - /// Compute the extent of the scrollbar's thumb within the range. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual float ComputeScrollExtent() - { - return 0; - } - - /// - /// Compute the offset of the scrollbar's thumb within the range. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual float ComputeScrollOffset() - { - return 0; - } - - /// - /// Compute the range that the scrollbar represents. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual float ComputeScrollRange() - { - return 0; - } - - /// - /// Scroll the FlexibleView to make the position visible. - /// - /// Scroll to this adapter position - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void ScrollToPosition(int position) - { - - } - - /// - /// Scroll to the specified adapter position with the given offset from resolved layout start. - /// - /// Scroll to this adapter position - /// The distance (in pixels) between the start edge of the item view and start edge of the FlexibleView. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void ScrollToPositionWithOffset(int position, int offset) - { - - } - - internal void MoveFocus(FlexibleView.LayoutManager.Direction direction, Recycler recycler) - { - int prevFocusPosition = FocusPosition; - int nextFocusPosition = GetNextPosition(FocusPosition, direction); - if (nextFocusPosition == NO_POSITION) - { - return; - } - - FlexibleView.ViewHolder nextFocusChild = FindItemViewByPosition(nextFocusPosition); - if (nextFocusChild == null) - { - nextFocusChild = OnFocusSearchFailed(null, direction, recycler); - } - - if (nextFocusChild != null) - { - RequestChildRectangleOnScreen(mFlexibleView, nextFocusChild, recycler, false); - - ChangeFocus(nextFocusPosition); - } - } - - /** - * Requests that the given child of the RecyclerView be positioned onto the screen. This - * method can be called for both unfocusable and focusable child views. For unfocusable - * child views, focusedChildVisible is typically true in which case, layout manager - * makes the child view visible only if the currently focused child stays in-bounds of RV. - * @param parent The parent RecyclerView. - * @param child The direct child making the request. - * @param rect The rectangle in the child's coordinates the child - * wishes to be on the screen. - * @param immediate True to forbid animated or delayed scrolling, - * false otherwise - * @param focusedChildVisible Whether the currently focused view must stay visible. - * @return Whether the group scrolled to handle the operation - */ - internal bool RequestChildRectangleOnScreen(FlexibleView parent, FlexibleView.ViewHolder child, Recycler recycler, bool immediate) - { - Vector2 scrollAmount = GetChildRectangleOnScreenScrollAmount(parent, child); - float dx = scrollAmount[0]; - float dy = scrollAmount[1]; - if (dx != 0 || dy != 0) - { - if (dx != 0 && CanScrollHorizontally()) - { - ScrollHorizontallyBy(dx, recycler, immediate); - } - else if (dy != 0 && CanScrollVertically()) - { - ScrollVerticallyBy(dy, recycler, immediate); - } - return true; - } - return false; - } - - /// - /// Calls {@code FlexibleView#RelayoutRequest} on the underlying FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void RelayoutRequest() - { - if (mFlexibleView != null) - { - mFlexibleView.RelayoutRequest(); - } - } - - /// - /// Lay out the given child view within the FlexibleView using coordinates that include view margins. - /// - /// Child to lay out - /// Left edge, with item view left margin included - /// Top edge, with item view top margin included - /// Width, with item view left and right margin included - /// Height, with item view top and bottom margin included - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void LayoutChild(ViewHolder child, float left, float top, float width, float height) - { - if (null == child) return; - View itemView = child.ItemView; - itemView.SizeWidth = width - itemView.Margin.Start - itemView.Margin.End; - itemView.SizeHeight = height - itemView.Margin.Top - itemView.Margin.Bottom; - itemView.PositionX = left + itemView.Margin.Start; - itemView.PositionY = top + itemView.Margin.Top; - } - - /// - /// Change the ViewHolder with focusPosition to focus. - /// - /// the newly focus position - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void ChangeFocus(int focusPosition) - { - if (mFlexibleView != null) - { - mFlexibleView.DispatchFocusChanged(focusPosition); - } - } - - /// - /// Return the current number of child views attached to the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int ChildCount - { - get - { - return mChildHelper != null ? mChildHelper.GetChildCount() : 0; - } - } - - /// - /// Return the child view at the given index. - /// - /// child index - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder GetChildAt(int index) - { - return mChildHelper != null ? mChildHelper.GetChildAt(index) : null; - } - - /// - /// Finds the view which represents the given adapter position. - /// - /// adapter position - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder FindItemViewByPosition(int position) - { - return mFlexibleView.FindViewHolderForLayoutPosition(position); - } - - /// - /// Offset all child views attached to the parent FlexibleView by dx pixels along the horizontal axis. - /// - /// Pixels to offset by - /// specify if the offset need animation - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void OffsetChildrenHorizontal(float dx, bool immediate) - { - if (mChildHelper == null) - { - return; - } - - if (dx == 0) - { - return; - } - - int childCount = mChildHelper.GetChildCount(); - if (immediate == true) - { - for (int i = childCount - 1; i >= 0; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - v.ItemView.PositionX += dx; - } - } - else - { - if (mScrollAni == null) - { - mScrollAni = new Animation(); - mScrollAni.Duration = SCROLL_ANIMATION_DURATION; - mScrollAni.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSquare); - } - - // avoid out of boundary of flexibleview. delta value might be used for shadow. - // this must be done before animation clear. - if (childCount > 0) - { - ViewHolder vh = mChildHelper.GetChildAt(0); - if (vh.LayoutPosition == 0) - { - if ((int)(vh.Left + dx) > 0) - { - dx = 0 - vh.Left; - } - } - - vh = mChildHelper.GetChildAt(childCount - 1); - if (vh.LayoutPosition == ItemCount - 1) - { - if ((int)(vh.Right + dx) < (int)Width + PaddingRight) - { - dx = Width + PaddingRight - vh.Right; - } - } - } - - // save position before animation clear. - float[] childrenPositon = new float[childCount]; - for (int i = childCount - 1; i >= 0; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - childrenPositon[i] = v.ItemView.PositionX; - } - - mScrollAni.Clear(); - mScrollAni.Finished += OnScrollAnimationFinished; - - for (int i = childCount - 1; i >= 0; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - // set position again because position might be changed after animation clear. - v.ItemView.PositionX = childrenPositon[i]; - mScrollAni.AnimateTo(v.ItemView, "PositionX", v.ItemView.PositionX + dx); - } - mScrollAni.Play(); - } - } - - /// - /// Offset all child views attached to the parent FlexibleView by dy pixels along the vertical axis. - /// - /// Pixels to offset by - /// specify if the offset need animation - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void OffsetChildrenVertical(float dy, bool immediate) - { - if (mChildHelper == null) - { - return; - } - - if (dy == 0) - { - return; - } - - int childCount = mChildHelper.GetChildCount(); - if (immediate == true) - { - for (int i = childCount - 1; i >= 0; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - v.ItemView.PositionY += dy; - } - } - else - { - if (mScrollAni == null) - { - mScrollAni = new Animation(); - mScrollAni.Duration = SCROLL_ANIMATION_DURATION; - mScrollAni.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSquare); - } - - // avoid out of boundary of flexibleview. delta value might be used for shadow. - // this must be done before animation clear. - if (childCount > 0) - { - ViewHolder vh = mChildHelper.GetChildAt(0); - if (vh.LayoutPosition == 0) - { - if ((int)(vh.Top + dy) > 0) - { - dy = 0 - vh.Top; - } - } - - vh = mChildHelper.GetChildAt(childCount - 1); - if (vh.LayoutPosition == ItemCount - 1) - { - if ((int)(vh.Bottom + dy) < (int)Height + PaddingBottom) - { - dy = Height + PaddingBottom - vh.Bottom; - } - } - } - - // save position before animation clear. - float[] childPositon = new float[childCount]; - for (int i = childCount - 1; i >= 0; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - childPositon[i] = v.ItemView.PositionY; - } - - mScrollAni.Clear(); - mScrollAni.Finished += OnScrollAnimationFinished; - - for (int i = childCount - 1; i >= 0; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - // set position again because position might be changed after animation clear. - v.ItemView.PositionY = childPositon[i]; - mScrollAni.AnimateTo(v.ItemView, "PositionY", v.ItemView.PositionY + dy); - } - mScrollAni.Play(); - } - } - - /// - /// Return the width of the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public float Width - { - get - { - return mFlexibleView != null ? mFlexibleView.SizeWidth : 0; - } - } - - /// - /// Return the height of the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public float Height - { - get - { - return mFlexibleView != null ? mFlexibleView.SizeHeight : 0; - } - } - - /// - /// Return the left padding of the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int PaddingLeft - { - get - { - return mFlexibleView?.Padding?.Start ?? 0; - } - } - - /// - /// Return the top padding of the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int PaddingTop - { - get - { - return mFlexibleView?.Padding?.Top ?? 0; - } - } - - /// - /// Return the right padding of the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int PaddingRight - { - get - { - return mFlexibleView?.Padding?.End ?? 0; - } - } - - /// - /// Return the bottom padding of the parent FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int PaddingBottom - { - get - { - return mFlexibleView?.Padding?.Bottom ?? 0; - } - } - - /// - /// Add a view to the currently attached FlexibleView if needed.
- /// LayoutManagers should use this method to add views obtained from a FlexibleView.Recycler using getViewForPosition(int).
- ///
- /// view to add - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void AddView(ViewHolder holder) - { - AddView(holder, -1); - } - - /// - /// Add a view to the currently attached FlexibleView if needed.
- /// LayoutManagers should use this method to add views obtained from a FlexibleView.Recycler using getViewForPosition(int).
- ///
- /// view to add - /// index to add child at - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void AddView(ViewHolder holder, int index) - { - AddViewInternal(holder, index, false); - } - - /// - /// Temporarily detach and scrap all currently attached child views. - /// Views will be scrapped into the given Recycler. - /// The Recycler may prefer to reuse scrap views before other views that were previously recycled. - /// - /// Recycler to scrap views into - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void ScrapAttachedViews(Recycler recycler) - { - if (null == mChildHelper || null == recycler) - { - return; - } - - recycler.Clear(); - - mChildHelper.ScrapViews(recycler); - } - - /** - * Remove a child view and recycle it using the given Recycler. - * - * @param index Index of child to remove and recycle - * @param recycler Recycler to use to recycle child - */ - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void RemoveAndRecycleViewAt(int index, Recycler recycler) - { - if (null == recycler) return; - ViewHolder v = mChildHelper.GetChildAt(index); - mChildHelper.RemoveViewAt(index); - recycler.RecycleView(v); - } - - /// - /// ecycles children between given indices.. - /// - /// Recycler to recycle views into - /// inclusive - /// exclusive - /// recycle immediately or add to pending list and recycle later. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void RecycleChildren(FlexibleView.Recycler recycler, int startIndex, int endIndex, bool immediate) - { - if (startIndex == endIndex) - { - return; - } - if (endIndex > startIndex) - { - for (int i = startIndex; i < endIndex; i++) - { - ViewHolder v = mChildHelper.GetChildAt(i); - if (v.PendingRecycle == false) - { - v.PendingRecycle = true; - mPendingRecycleViews.Add(v); - } - } - } - else - { - for (int i = startIndex; i > endIndex; i--) - { - ViewHolder v = mChildHelper.GetChildAt(i); - if (v.PendingRecycle == false) - { - v.PendingRecycle = true; - mPendingRecycleViews.Add(v); - } - } - } - if (immediate == true) - { - RecycleChildrenInt(recycler); - } - } - - /// - /// Retrieves a position that neighbor to current position by direction. - /// - /// The anchor adapter position - /// The direction. - /// 6 - /// 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 abstract int GetNextPosition(int position, FlexibleView.LayoutManager.Direction direction); - - /// - /// Retrieves the first visible item view. - /// - /// 6 - /// 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 virtual ViewHolder FindFirstVisibleItemView() - { - return null; - } - - /// - /// Retrieves the last visible item view. - /// - /// 6 - /// 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 virtual ViewHolder FindLastVisibleItemView() - { - return null; - } - - internal virtual ViewHolder OnFocusSearchFailed(FlexibleView.ViewHolder focused, LayoutManager.Direction direction, Recycler recycler) - { - return null; - } - - internal void SetRecyclerView(FlexibleView recyclerView) - { - mFlexibleView = recyclerView; - mChildHelper = recyclerView.mChildHelper; - } - - internal void StopScroll(bool doSomethingAfterAnimationStopped) - { - if (mScrollAni != null && mScrollAni.State == Animation.States.Playing) - { - mScrollAni.Finished -= OnScrollAnimationFinished; - mScrollAni.Stop(); - - if (doSomethingAfterAnimationStopped) - { - OnScrollAnimationFinished(mScrollAni, null); - } - } - } - - /** - * Returns the scroll amount that brings the given rect in child's coordinate system within - * the padded area of RecyclerView. - * @param parent The parent RecyclerView. - * @param child The direct child making the request. - * @param rect The rectangle in the child's coordinates the child - * wishes to be on the screen. - * @param immediate True to forbid animated or delayed scrolling, - * false otherwise - * @return The array containing the scroll amount in x and y directions that brings the - * given rect into RV's padded area. - */ - private Vector2 GetChildRectangleOnScreenScrollAmount(FlexibleView parent, FlexibleView.ViewHolder child) - { - Vector2 ret = new Vector2(0, 0); - int parentLeft = PaddingLeft; - int parentTop = PaddingTop; - int parentRight = (int)Width - PaddingRight; - int parentBottom = (int)Height - PaddingBottom; - int childLeft = (int)child.Left; - int childTop = (int)child.Top; - int childRight = (int)child.Right; - int childBottom = (int)child.Bottom; - - int offScreenLeft = Math.Min(0, childLeft - parentLeft); - int offScreenTop = Math.Min(0, childTop - parentTop); - int offScreenRight = Math.Max(0, childRight - parentRight); - int offScreenBottom = Math.Max(0, childBottom - parentBottom); - - // Favor the "start" layout direction over the end when bringing one side or the other - // of a large rect into view. If we decide to bring in end because start is already - // visible, limit the scroll such that start won't go out of bounds. - int dx = offScreenLeft != 0 ? offScreenLeft - : Math.Min(childLeft - parentLeft, offScreenRight); - - // Favor bringing the top into view over the bottom. If top is already visible and - // we should scroll to make bottom visible, make sure top does not go out of bounds. - int dy = offScreenTop != 0 ? offScreenTop - : Math.Min(childTop - parentTop, offScreenBottom); - - ret.X = -dx; - ret.Y = -dy; - - return ret; - } - - private void OnScrollAnimationFinished(object sender, EventArgs e) - { - foreach (ViewHolder holder in mPendingRecycleViews) - { - holder.PendingRecycle = false; - } - mPendingRecycleViews.Clear(); - - int start = NO_POSITION; - ViewHolder firstItemView = FindFirstVisibleItemView(); - if (firstItemView != null) - start = firstItemView.LayoutPosition; - else - start = 0; - - int itemCount = ChildCount; - - int end = NO_POSITION; - ViewHolder lastItemView = FindLastVisibleItemView(); - if (lastItemView != null) - end = lastItemView.LayoutPosition; - else - end = itemCount - 1; - - List removedViewList = new List(); - for (int i = 0; i < itemCount; i++) - { - ViewHolder v = GetChildAt(i); - - //if item view of holder is visible, it should not be recycled. - if (v.LayoutPosition >= start && v.LayoutPosition <= end) - continue; - - removedViewList.Add(v); - } - - for (int i = 0; i < removedViewList.Count; i++) - { - ViewHolder v = removedViewList[i]; - v.PendingRecycle = false; - mFlexibleView.mRecycler.RecycleView(v); - mChildHelper.RemoveView(v); - } - - // relayout - } - - private void AddViewInternal(ViewHolder holder, int index, bool disappearing) - { - if (null == holder) return; - if (holder.IsScrap()) - { - holder.Unscrap(); - mChildHelper.AttachView(holder, index); - } - else - { - mChildHelper.AddView(holder, index); - } - } - - private void RecycleChildrenInt(FlexibleView.Recycler recycler) - { - if (null == recycler) return; - foreach (ViewHolder holder in mPendingRecycleViews) - { - holder.PendingRecycle = false; - recycler.RecycleView(holder); - mChildHelper.RemoveView(holder); - } - mPendingRecycleViews.Clear(); - } - - private void ScrapOrRecycleView(Recycler recycler, ViewHolder itemView) - { - recycler.ScrapView(itemView); - } - - } - } -} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Recycler.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Recycler.cs deleted file mode 100755 index c23e5e2..0000000 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.Recycler.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel; - -namespace Tizen.NUI.Components -{ - public partial class FlexibleView - { - /// - /// A Recycler is responsible for managing scrapped or detached item views for reuse. - /// A "scrapped" view is a view that is still attached to its parent FlexibleView but that has been marked for removal or reuse. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class Recycler - { - private FlexibleView mFlexibleView; - private RecycledViewPool mRecyclerPool; - - private List mAttachedScrap = new List(); - private List mChangedScrap = null; - //private List mCachedViews = new List(); - - //private List mUnmodifiableAttachedScrap; - - private int mCacheSizeMax = 2; - - /// - /// Recycler constructor. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public Recycler(FlexibleView recyclerView) - { - mFlexibleView = recyclerView; - } - - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void SetViewCacheSize(int viewCount) - { - mCacheSizeMax = viewCount; - } - - /// - /// Obtain a view initialized for the given position. - /// - /// Position to obtain a view for - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder GetViewForPosition(int position) - { - Adapter b = mFlexibleView != null ? mFlexibleView.mAdapter : null; - if (b == null) - { - return null; - } - if (position < 0 || position >= b.GetItemCount()) - { - return null; - } - - int type = b.GetItemViewType(position); - ViewHolder itemView = null; - for (int i = 0; i < mAttachedScrap.Count; i++) - { - if (mAttachedScrap[i].LayoutPosition == position && mAttachedScrap[i].ItemViewType == type) - { - itemView = mAttachedScrap[i]; - break; - } - } - if (itemView == null) - { - itemView = mRecyclerPool.GetRecycledView(type); - if (itemView == null) - { - itemView = b.OnCreateViewHolder(type); - } - - if (!itemView.IsBound) - { - b.OnBindViewHolder(itemView, position); - itemView.IsBound = true; - } - - itemView.AdapterPosition = position; - itemView.ItemViewType = type; - } - - return itemView; - } - - /// - /// Recycle a detached view. - /// - /// Removed holder for recycling - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void RecycleView(ViewHolder itemView) - { - if (null == itemView) return; - itemView.ScrapContainer = null; - mRecyclerPool.PutRecycledView(itemView); - } - - /// - /// Returns the count in scrap list. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int GetScrapCount() - { - return mAttachedScrap.Count; - } - - /// - /// Gets the scrap view at index. - /// - /// index - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder GetScrapViewAt(int index) - { - return mAttachedScrap[index]; - } - - /// - /// Clear scrap views out of this recycler. Detached views contained within a recycled view pool will remain. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public void Clear() - { - mAttachedScrap.Clear(); - if (mChangedScrap != null) - { - mChangedScrap.Clear(); - } - } - - internal void ScrapView(ViewHolder itemView) - { - mAttachedScrap.Add(itemView); - itemView.ScrapContainer = this; - } - - internal void UnscrapView(ViewHolder itemView) - { - mAttachedScrap.Remove(itemView); - itemView.ScrapContainer = null; - } - - internal void SetRecycledViewPool(RecycledViewPool pool) - { - mRecyclerPool = pool; - } - } - } -} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.ViewHolder.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.ViewHolder.cs deleted file mode 100755 index bf37ef1..0000000 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.ViewHolder.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.ComponentModel; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.Components -{ - public partial class FlexibleView - { - /// - /// A ViewHolder describes an item view and metadata about its place within the FlexibleView. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class ViewHolder - { - // This ViewHolder has been bound to a position; AdapterPosition, mItemId and mItemViewType - // are all valid. - //static readonly int FLAG_BOUND = 1 << 0; - - // The data this ViewHolder's view reflects is stale and needs to be rebound - // by the adapter. AdapterPosition and mItemId are consistent. - //static readonly int FLAG_UPDATE = 1 << 1; - - // This ViewHolder's data is invalid. The identity implied by AdapterPosition and mItemId - // are not to be trusted and may no longer match the item view type. - // This ViewHolder must be fully rebound to different data. - //static readonly int FLAG_INVALID = 1 << 2; - - // This ViewHolder points at data that represents an item previously removed from the - // data set. Its view may still be used for things like outgoing animations. - //static readonly int FLAG_REMOVED = 1 << 3; - - // This ViewHolder should not be recycled. This flag is set via setIsRecyclable() - // and is intended to keep views around during animations. - //static readonly int FLAG_NOT_RECYCLABLE = 1 << 4; - - // This ViewHolder is returned from scrap which means we are expecting an addView call - // for this itemView. When returned from scrap, ViewHolder stays in the scrap list until - // the end of the layout pass and then recycled by RecyclerView if it is not added back to - // the RecyclerView. - //static readonly int FLAG_RETURNED_FROM_SCRAP = 1 << 5; - - // This ViewHolder is fully managed by the LayoutManager. We do not scrap, recycle or remove - // it unless LayoutManager is replaced. - // It is still fully visible to the LayoutManager. - //static readonly int FLAG_IGNORE = 1 << 7; - - private int mFlags; - private int mPreLayoutPosition = NO_POSITION; - - /// - /// ViewHolder constructor. - /// - /// View - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder(View itemView) - { - if (itemView == null) - { - throw new ArgumentNullException("itemView may not be null"); - } - this.ItemView = itemView; - } - - /// - /// Returns the view. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public View ItemView { get; } - - /// - /// Returns the left edge includes the view left margin. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public float Left - { - get - { - return ItemView.PositionX - ItemView.Margin.Start; - } - } - - /// - /// Returns the right edge includes the view right margin. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public float Right - { - get - { - return ItemView.PositionX + ItemView.SizeWidth + ItemView.Margin.End; - } - } - - /// - /// Returns the top edge includes the view top margin. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public float Top - { - get - { - return ItemView.PositionY - ItemView.Margin.Top; - } - } - - /// - /// Returns the bottom edge includes the view bottom margin. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public float Bottom - { - get - { - return ItemView.PositionY + ItemView.SizeHeight + ItemView.Margin.Bottom; - } - } - - /// - /// Returns the position of the ViewHolder in terms of the latest layout pass. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int LayoutPosition - { - get - { - return mPreLayoutPosition == NO_POSITION ? AdapterPosition : mPreLayoutPosition; - } - } - - /// - /// Returns the Adapter position of the item represented by this ViewHolder. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int AdapterPosition { get; internal set; } = NO_POSITION; - - /// - /// Get old position of item view. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int OldPosition { get; private set; } = NO_POSITION; - - /// - /// Gets or sets item view type. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int ItemViewType { get; set; } = INVALID_TYPE; - - internal bool IsBound - { - get; - set; - } - - internal Recycler ScrapContainer { get; set; } - - internal bool PendingRecycle - { - get; - set; - } = false; - - - internal bool IsScrap() - { - return ScrapContainer != null; - } - - internal void Unscrap() - { - ScrapContainer.UnscrapView(this); - } - - - internal void FlagRemovedAndOffsetPosition(int mNewPosition, int offset, bool applyToPreLayout) - { - //AddFlags(ViewHolder.FLAG_REMOVED); - OffsetPosition(offset, applyToPreLayout); - AdapterPosition = mNewPosition; - } - - internal void OffsetPosition(int offset, bool applyToPreLayout) - { - if (OldPosition == NO_POSITION) - { - OldPosition = AdapterPosition; - } - if (mPreLayoutPosition == NO_POSITION) - { - mPreLayoutPosition = AdapterPosition; - } - if (applyToPreLayout) - { - mPreLayoutPosition += offset; - } - AdapterPosition += offset; - } - - internal void ClearOldPosition() - { - OldPosition = NO_POSITION; - mPreLayoutPosition = NO_POSITION; - } - - internal void SaveOldPosition() - { - if (OldPosition == NO_POSITION) - { - OldPosition = AdapterPosition; - } - } - - private void SetFlags(int flags, int mask) - { - mFlags = (mFlags & ~mask) | (flags & mask); - } - - private void AddFlags(int flags) - { - mFlags |= flags; - } - } - } -} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs index c0062c1..87ac2b2 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleView.cs @@ -22,6 +22,36 @@ using Tizen.NUI.BaseComponents; namespace Tizen.NUI.Components { /// + /// FlexibleView ItemClick Event Arguments. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class FlexibleViewItemClickedEventArgs : EventArgs + { + /// + /// The clicked FlexibleViewViewHolder. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder ClickedView { get; set; } + } + + /// + /// FlexibleView ItemTouch Event Arguments. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class FlexibleViewItemTouchEventArgs : View.TouchEventArgs + { + /// + /// The touched FlexibleViewViewHolder. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder TouchedView { get; set; } + } + + /// /// A flexible view for providing a limited window into a large data set. /// /// 6 @@ -44,9 +74,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly int INVALID_TYPE = -1; - private Adapter mAdapter; - private LayoutManager mLayout; - private Recycler mRecycler; + private FlexibleViewAdapter mAdapter; + private FlexibleViewLayoutManager mLayout; + private FlexibleViewRecycler mRecycler; private RecycledViewPool mRecyclerPool; private ChildHelper mChildHelper; @@ -59,8 +89,8 @@ namespace Tizen.NUI.Components private ScrollBar mScrollBar = null; private Timer mScrollBarShowTimer = null; - private EventHandler clickEventHandlers; - private EventHandler touchEventHandlers; + private EventHandler clickEventHandlers; + private EventHandler touchEventHandlers; private EventHandler styleChangedEventHandlers; /// @@ -73,7 +103,7 @@ namespace Tizen.NUI.Components { mRecyclerPool = new RecycledViewPool(this); - mRecycler = new Recycler(this); + mRecycler = new FlexibleViewRecycler(this); mRecycler.SetRecycledViewPool(mRecyclerPool); mChildHelper = new ChildHelper(this); @@ -90,10 +120,9 @@ namespace Tizen.NUI.Components /// /// Item click event. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler ItemClickEvent + public event EventHandler ItemClicked { add { @@ -110,10 +139,9 @@ namespace Tizen.NUI.Components /// /// Item touch event. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler ItemTouchEvent + public event EventHandler ItemTouch { add { @@ -215,7 +243,7 @@ namespace Tizen.NUI.Components return; } - ViewHolder nextFocusView = FindViewHolderForAdapterPosition(value); + FlexibleViewViewHolder nextFocusView = FindViewHolderForAdapterPosition(value); if (nextFocusView == null) { mLayout.ScrollToPosition(value); @@ -231,10 +259,9 @@ namespace Tizen.NUI.Components /// /// Set a new adapter to provide child views on demand. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public void SetAdapter(Adapter adapter) + public void SetAdapter(FlexibleViewAdapter adapter) { if (adapter == null) { @@ -248,21 +275,19 @@ namespace Tizen.NUI.Components /// /// Retrieves the previously set adapter or null if no adapter is set. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public Adapter GetAdapter() + public FlexibleViewAdapter GetAdapter() { return mAdapter; } /// - /// Set the FlexibleView.LayoutManager that this FlexibleView will use. + /// Set the FlexibleViewLayoutManager that this FlexibleView will use. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public void SetLayoutManager(LayoutManager layoutManager) + public void SetLayoutManager(FlexibleViewLayoutManager layoutManager) { if (null == layoutManager) return; mLayout = layoutManager; @@ -280,12 +305,11 @@ namespace Tizen.NUI.Components } /// - /// Return the FlexibleView.LayoutManager currently responsible for layout policy for this FlexibleView. + /// Return the FlexibleViewLayoutManager currently responsible for layout policy for this FlexibleView. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public LayoutManager GetLayoutManager() + public FlexibleViewLayoutManager GetLayoutManager() { return mLayout; } @@ -308,10 +332,9 @@ namespace Tizen.NUI.Components /// Move focus by direction. /// /// Direction. Should be "Left", "Right", "Up" or "Down" - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public void MoveFocus(FlexibleView.LayoutManager.Direction direction) + public void MoveFocus(FlexibleViewLayoutManager.Direction direction) { mLayout.MoveFocus(direction, mRecycler); } @@ -350,19 +373,18 @@ namespace Tizen.NUI.Components } /// - /// Return the ViewHolder for the item in the given position of the data set as of the latest layout pass. - /// This method checks only the children of RecyclerView. If the item at the given position is not laid out, it will not create a new one. + /// Return the FlexibleViewViewHolder for the item in the given position of the data set as of the latest layout pass. + /// This method checks only the children of FlexibleViewRecyclerView. If the item at the given position is not laid out, it will not create a new one. /// /// The position of the item in the data set of the adapter - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder FindViewHolderForLayoutPosition(int position) + public FlexibleViewViewHolder FindViewHolderForLayoutPosition(int position) { int childCount = mChildHelper.GetChildCount(); for (int i = 0; i < childCount; i++) { - if (mChildHelper.GetChildAt(i) is ViewHolder holder) + if (mChildHelper.GetChildAt(i) is FlexibleViewViewHolder holder) { if (holder.LayoutPosition == position) { @@ -375,19 +397,18 @@ namespace Tizen.NUI.Components } /// - /// Return the ViewHolder for the item in the given position of the data set. - /// This method checks only the children of RecyclerView. If the item at the given position is not laid out, it will not create a new one. + /// Return the FlexibleViewViewHolder for the item in the given position of the data set. + /// This method checks only the children of FlexibleViewRecyclerView. If the item at the given position is not laid out, it will not create a new one. /// /// The position of the item in the data set of the adapter - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder FindViewHolderForAdapterPosition(int position) + public FlexibleViewViewHolder FindViewHolderForAdapterPosition(int position) { int childCount = mChildHelper.GetChildCount(); for (int i = 0; i < childCount; i++) { - if (mChildHelper.GetChildAt(i) is ViewHolder holder) + if (mChildHelper.GetChildAt(i) is FlexibleViewViewHolder holder) { if (holder.AdapterPosition == position) { @@ -402,10 +423,9 @@ namespace Tizen.NUI.Components /// /// Return the recycler instance. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public Recycler GetRecycler() + public FlexibleViewRecycler GetRecycler() { return mRecycler; } @@ -539,7 +559,7 @@ namespace Tizen.NUI.Components int childCount = mChildHelper.GetChildCount(); for (int i = 0; i < childCount; i++) { - ViewHolder holder = mChildHelper.GetChildAt(i); + FlexibleViewViewHolder holder = mChildHelper.GetChildAt(i); if (holder != null && holder.AdapterPosition >= positionStart) { holder.OffsetPosition(itemCount, false); @@ -558,7 +578,7 @@ namespace Tizen.NUI.Components int childCount = mChildHelper.GetChildCount(); for (int i = 0; i < childCount; i++) { - ViewHolder holder = mChildHelper.GetChildAt(i); + FlexibleViewViewHolder holder = mChildHelper.GetChildAt(i); if (holder != null) { if (holder.AdapterPosition >= positionEnd) @@ -591,7 +611,7 @@ namespace Tizen.NUI.Components int childCount = mChildHelper.GetChildCount(); for (int i = 0; i < childCount; i++) { - ViewHolder holder = mChildHelper.GetChildAt(i); + FlexibleViewViewHolder holder = mChildHelper.GetChildAt(i); holder.SaveOldPosition(); } } @@ -601,7 +621,7 @@ namespace Tizen.NUI.Components int childCount = mChildHelper.GetChildCount(); for (int i = 0; i < childCount; i++) { - ViewHolder holder = mChildHelper.GetChildAt(i); + FlexibleViewViewHolder holder = mChildHelper.GetChildAt(i); holder.ClearOldPosition(); } } @@ -611,7 +631,7 @@ namespace Tizen.NUI.Components int scrapCount = mRecycler.GetScrapCount(); for (int i = 0; i < scrapCount; i++) { - ViewHolder scrap = mRecycler.GetScrapViewAt(i); + FlexibleViewViewHolder scrap = mRecycler.GetScrapViewAt(i); mChildHelper.RemoveView(scrap); mRecycler.RecycleView(scrap); } @@ -686,7 +706,7 @@ namespace Tizen.NUI.Components return false; } - private void DispatchFocusChanged(int nextFocusPosition) + internal void DispatchFocusChanged(int nextFocusPosition) { mAdapter.OnFocusChange(this, mFocusedItemIndex, nextFocusPosition); @@ -695,7 +715,7 @@ namespace Tizen.NUI.Components ShowScrollBar(); } - private void DispatchChildAttached(ViewHolder holder) + private void DispatchChildAttached(FlexibleViewViewHolder holder) { if (mAdapter != null && holder != null) { @@ -703,7 +723,7 @@ namespace Tizen.NUI.Components } } - private void DispatchChildDetached(ViewHolder holder) + private void DispatchChildDetached(FlexibleViewViewHolder holder) { if (mAdapter != null && holder != null) { @@ -711,7 +731,7 @@ namespace Tizen.NUI.Components } } - private void DispatchChildDestroyed(ViewHolder holder) + private void DispatchChildDestroyed(FlexibleViewViewHolder holder) { if (mAdapter != null && holder != null) { @@ -719,16 +739,16 @@ namespace Tizen.NUI.Components } } - private void DispatchItemClicked(ViewHolder clickedHolder) + private void DispatchItemClicked(FlexibleViewViewHolder clickedHolder) { - ItemClickEventArgs args = new ItemClickEventArgs(); + FlexibleViewItemClickedEventArgs args = new FlexibleViewItemClickedEventArgs(); args.ClickedView = clickedHolder; OnClickEvent(this, args); } - private void DispatchItemTouched(ViewHolder touchedHolder, Touch touchEvent) + private void DispatchItemTouched(FlexibleViewViewHolder touchedHolder, Touch touchEvent) { - ItemTouchEventArgs args = new ItemTouchEventArgs(); + FlexibleViewItemTouchEventArgs args = new FlexibleViewItemTouchEventArgs(); args.TouchedView = touchedHolder; args.Touch = touchEvent; OnTouchEvent(this, args); @@ -767,21 +787,21 @@ namespace Tizen.NUI.Components } } - private void OnItemEvent(object sender, Adapter.ItemEventArgs e) + private void OnItemEvent(object sender, FlexibleViewAdapter.ItemEventArgs e) { switch (e.EventType) { - case Adapter.ItemEventType.Insert: + case FlexibleViewAdapter.ItemEventType.Insert: mAdapteHelper.OnItemRangeInserted(e.param[0], e.param[1]); ShowScrollBar(); break; - case Adapter.ItemEventType.Remove: + case FlexibleViewAdapter.ItemEventType.Remove: mAdapteHelper.OnItemRangeRemoved(e.param[0], e.param[1]); ShowScrollBar(); break; - case Adapter.ItemEventType.Move: + case FlexibleViewAdapter.ItemEventType.Move: break; - case Adapter.ItemEventType.Change: + case FlexibleViewAdapter.ItemEventType.Change: break; default: return; @@ -790,48 +810,24 @@ namespace Tizen.NUI.Components } - private void OnClickEvent(object sender, ItemClickEventArgs e) + private void OnClickEvent(object sender, FlexibleViewItemClickedEventArgs e) { clickEventHandlers?.Invoke(sender, e); } - private void OnTouchEvent(object sender, ItemTouchEventArgs e) + private void OnTouchEvent(object sender, FlexibleViewItemTouchEventArgs e) { touchEventHandlers?.Invoke(sender, e); } - /// - /// ItemClick Event Arguments. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class ItemClickEventArgs : EventArgs + internal void LayoutManagerRelayoutRequest() { - /// - /// The clicked ViewHolder. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder ClickedView { get; set; } + RelayoutRequest(); } - /// - /// ItemTouch Event Arguments. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class ItemTouchEventArgs : TouchEventArgs - { - /// - /// The touched ViewHolder. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewHolder TouchedView { get; set; } + internal ChildHelper GetChildHelper() + { + return mChildHelper; } } } diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewAdapter.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewAdapter.cs new file mode 100755 index 0000000..e56cbed --- /dev/null +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewAdapter.cs @@ -0,0 +1,277 @@ +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Components +{ + /// + /// FlexibleViewAdapters provide a binding from an app-specific data set to views that are displayed within a FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract class FlexibleViewAdapter + { + private EventHandler itemEventHandlers; + + internal event EventHandler ItemEvent + { + add + { + itemEventHandlers += value; + } + + remove + { + itemEventHandlers -= value; + } + } + + internal enum ItemEventType + { + Insert = 0, + Remove, + Move, + Change + } + + /// + /// Called when FlexibleView needs a new FlexibleViewViewHolder of the given type to represent an item. + /// + /// The view type of the new View + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract FlexibleViewViewHolder OnCreateViewHolder(int viewType); + + /// + /// Called by FlexibleView to display the data at the specified position. + /// + /// The FlexibleViewViewHolder which should be updated to represent the contents of the item at the given position in the data set. + /// The position of the item within the adapter's data set. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract void OnBindViewHolder(FlexibleViewViewHolder holder, int position); + + /// + /// Called when a FlexibleViewViewHolder is never used. + /// + /// The FlexibleViewViewHolder which need to be disposed + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract void OnDestroyViewHolder(FlexibleViewViewHolder holder); + + /// + /// Returns the total number of items in the data set held by the adapter. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract int GetItemCount(); + + /// + /// Return the view type of the item at position for the purposes of view recycling. + /// + /// The position of the item within the adapter's data set. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual int GetItemViewType(int position) + { + return 0; + } + + /// + /// Called by FlexibleView when it starts observing this FlexibleViewAdapter. + /// Keep in mind that same adapter may be observed by multiple FlexibleView. + /// + /// The FlexibleView instance which started observing this adapter. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnAttachedToRecyclerView(FlexibleView flexibleView) + { + } + + /// + /// Called by FlexibleView when it stops observing this FlexibleViewAdapter. + /// + /// The FlexibleView instance which stopped observing this adapter. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnDetachedFromRecyclerView(FlexibleView flexibleView) + { + } + + /// + /// Called when FlexibleView focus changed. + /// + /// The FlexibleView into which the focus FlexibleViewViewHolder changed. + /// The position of previous focus + /// The position of current focus + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnFocusChange(FlexibleView flexibleView, int previousFocus, int currentFocus) + { + } + + /// + /// Called when a view created by this adapter has been recycled. + /// If an item view has large or expensive data bound to it such as large bitmaps, this may be a good place to release those resources + /// + /// The FlexibleViewViewHolder will be recycled. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnViewRecycled(FlexibleViewViewHolder holder) + { + } + + /// + /// Called when a view created by this adapter has been attached to a window. + /// This can be used as a reasonable signal that the view is about to be seen by the user. + /// + /// Holder of the view being attached. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnViewAttachedToWindow(FlexibleViewViewHolder holder) + { + } + + /// + /// Called when a view created by this adapter has been detached from its window. + /// + /// Holder of the view being detached. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnViewDetachedFromWindow(FlexibleViewViewHolder holder) + { + } + + /// + /// Notify any registered observers that the data set has changed. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyDataSetChanged() + { + } + + /// + /// Notify any registered observers that the data set has changed. + /// It indicates that any reflection of the data at position is out of date and should be updated. + /// + /// Position of the item that has changed + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemChanged(int position) + { + ItemEventArgs args = new ItemEventArgs + { + EventType = ItemEventType.Change, + }; + args.param[0] = position; + args.param[1] = 1; + OnItemEvent(this, args); + } + + /// + /// Notify any registered observers that the itemCount items starting at position positionStart have changed. + /// An optional payload can be passed to each changed item. + /// + /// Position of the first item that has changed + /// Number of items that have changed + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemRangeChanged(int positionStart, int itemCount) + { + } + + /// + /// Notify any registered observers that the data set has been newly inserted. + /// It indicates that any reflection of the data at position is out of date and should be updated. + /// + /// Position of the item that has been newly inserted + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemInserted(int position) + { + NotifyItemRangeInserted(position, 1); + } + + /// + /// Notify any registered observers that the itemCount items starting at position positionStart have been newly inserted. + /// + /// Position of the first item that was inserted + /// Number of items inserted + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemRangeInserted(int positionStart, int itemCount) + { + ItemEventArgs args = new ItemEventArgs + { + EventType = ItemEventType.Insert, + }; + args.param[0] = positionStart; + args.param[1] = itemCount; + OnItemEvent(this, args); + } + + /// + /// Notify any registered observers that the item previously located at position has been removed from the data set. + /// + /// Previous position of the first item that was removed + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemRemoved(int position) + { + NotifyItemRangeRemoved(position, 1); + } + + /// + /// Notify any registered observers that the itemCount items previously located at positionStart have been removed from the data set. + /// + /// Previous position of the first item that was removed + /// Number of items removed from the data set + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemRangeRemoved(int positionStart, int itemCount) + { + ItemEventArgs args = new ItemEventArgs + { + EventType = ItemEventType.Remove, + }; + args.param[0] = positionStart; + args.param[1] = itemCount; + OnItemEvent(this, args); + } + + /// + /// Notify any registered observers that the item reflected at fromPosition has been moved to toPosition. + /// + /// Previous position of the item + /// New position of the item. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void NotifyItemMoved(int fromPosition, int toPosition) + { + + } + + private void OnItemEvent(object sender, ItemEventArgs e) + { + itemEventHandlers?.Invoke(sender, e); + } + + internal class ItemEventArgs : EventArgs + { + + /// + /// Data change event parameters. + /// + public int[] param = new int[4]; + + /// + /// Data changed event type. + /// + public ItemEventType EventType + { + get; + set; + } + } + } +} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewLayoutManager.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewLayoutManager.cs new file mode 100755 index 0000000..5b23922 --- /dev/null +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewLayoutManager.cs @@ -0,0 +1,860 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Components +{ + /// + /// A FlexibleViewLayoutManager is responsible for measuring and positioning item views within a FlexibleView + /// as well as determining the policy for when to recycle item views that are no longer visible to the user. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract class FlexibleViewLayoutManager + { + /// + /// Direction + /// + public enum Direction + { + /// + /// Left + /// + Left, + + /// + /// Right + /// + Right, + + /// + /// Up + /// + Up, + + /// + /// Down + /// + Down + } + + private readonly int SCROLL_ANIMATION_DURATION = 500; + + private FlexibleView mFlexibleView; + private FlexibleView.ChildHelper mChildHelper; + + private List mPendingRecycleViews = new List(); + + private Animation mScrollAni; + + /// + /// Layout all relevant child views from the given adapter. + /// + /// Recycler to use for fetching potentially cached views for a position + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract void OnLayoutChildren(FlexibleViewRecycler recycler); + + /// + /// Called after a full layout calculation is finished. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void OnLayoutCompleted() + { + } + + /// + /// Gets the current focus position in adapter. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int FocusPosition + { + get + { + return mFlexibleView.FocusedItemIndex; + } + } + + /// + /// Gets the datas count in data sets. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int ItemCount + { + get + { + FlexibleViewAdapter b = mFlexibleView != null ? mFlexibleView.GetAdapter() : null; + + return b != null ? b.GetItemCount() : 0; + } + } + + /// + /// Query if horizontal scrolling is currently supported. The default implementation returns false. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual bool CanScrollHorizontally() + { + return false; + } + + /// + /// Query if vertical scrolling is currently supported. The default implementation returns false. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual bool CanScrollVertically() + { + return false; + } + + /// + /// Scroll horizontally by dy pixels in screen coordinates. + /// + /// distance to scroll in pixels. Y increases as scroll position approaches the top. + /// Recycler to use for fetching potentially cached views for a position + /// Specify if the scroll need animation + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual float ScrollHorizontallyBy(float dy, FlexibleViewRecycler recycler, bool immediate) + { + return 0; + } + + /// + /// Scroll vertically by dy pixels in screen coordinates. + /// + /// distance to scroll in pixels. Y increases as scroll position approaches the top. + /// Recycler to use for fetching potentially cached views for a position + /// Specify if the scroll need animation + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual float ScrollVerticallyBy(float dy, FlexibleViewRecycler recycler, bool immediate) + { + return 0; + } + + /// + /// Compute the extent of the scrollbar's thumb within the range. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual float ComputeScrollExtent() + { + return 0; + } + + /// + /// Compute the offset of the scrollbar's thumb within the range. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual float ComputeScrollOffset() + { + return 0; + } + + /// + /// Compute the range that the scrollbar represents. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual float ComputeScrollRange() + { + return 0; + } + + /// + /// Scroll the FlexibleView to make the position visible. + /// + /// Scroll to this adapter position + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void ScrollToPosition(int position) + { + + } + + /// + /// Scroll to the specified adapter position with the given offset from resolved layout start. + /// + /// Scroll to this adapter position + /// The distance (in pixels) between the start edge of the item view and start edge of the FlexibleView. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void ScrollToPositionWithOffset(int position, int offset) + { + + } + + internal void MoveFocus(FlexibleViewLayoutManager.Direction direction, FlexibleViewRecycler recycler) + { + int prevFocusPosition = FocusPosition; + int nextFocusPosition = GetNextPosition(FocusPosition, direction); + if (nextFocusPosition == FlexibleView.NO_POSITION) + { + return; + } + + FlexibleViewViewHolder nextFocusChild = FindItemViewByPosition(nextFocusPosition); + if (nextFocusChild == null) + { + nextFocusChild = OnFocusSearchFailed(null, direction, recycler); + } + + if (nextFocusChild != null) + { + RequestChildRectangleOnScreen(mFlexibleView, nextFocusChild, recycler, false); + + ChangeFocus(nextFocusPosition); + } + } + + /** + * Requests that the given child of the FlexibleViewRecyclerView be positioned onto the screen. This + * method can be called for both unfocusable and focusable child views. For unfocusable + * child views, focusedChildVisible is typically true in which case, layout manager + * makes the child view visible only if the currently focused child stays in-bounds of RV. + * @param parent The parent FlexibleViewRecyclerView. + * @param child The direct child making the request. + * @param rect The rectangle in the child's coordinates the child + * wishes to be on the screen. + * @param immediate True to forbid animated or delayed scrolling, + * false otherwise + * @param focusedChildVisible Whether the currently focused view must stay visible. + * @return Whether the group scrolled to handle the operation + */ + internal bool RequestChildRectangleOnScreen(FlexibleView parent, FlexibleViewViewHolder child, FlexibleViewRecycler recycler, bool immediate) + { + Vector2 scrollAmount = GetChildRectangleOnScreenScrollAmount(parent, child); + float dx = scrollAmount[0]; + float dy = scrollAmount[1]; + if (dx != 0 || dy != 0) + { + if (dx != 0 && CanScrollHorizontally()) + { + ScrollHorizontallyBy(dx, recycler, immediate); + } + else if (dy != 0 && CanScrollVertically()) + { + ScrollVerticallyBy(dy, recycler, immediate); + } + return true; + } + return false; + } + + /// + /// Calls {@code FlexibleView#RelayoutRequest} on the underlying FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void RelayoutRequest() + { + if (mFlexibleView != null) + { + mFlexibleView.LayoutManagerRelayoutRequest(); + } + } + + /// + /// Lay out the given child view within the FlexibleView using coordinates that include view margins. + /// + /// Child to lay out + /// Left edge, with item view left margin included + /// Top edge, with item view top margin included + /// Width, with item view left and right margin included + /// Height, with item view top and bottom margin included + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void LayoutChild(FlexibleViewViewHolder child, float left, float top, float width, float height) + { + if (null == child) return; + View itemView = child.ItemView; + itemView.SizeWidth = width - itemView.Margin.Start - itemView.Margin.End; + itemView.SizeHeight = height - itemView.Margin.Top - itemView.Margin.Bottom; + itemView.PositionX = left + itemView.Margin.Start; + itemView.PositionY = top + itemView.Margin.Top; + } + + /// + /// Change the FlexibleViewViewHolder with focusPosition to focus. + /// + /// the newly focus position + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void ChangeFocus(int focusPosition) + { + if (mFlexibleView != null) + { + mFlexibleView.DispatchFocusChanged(focusPosition); + } + } + + /// + /// Return the current number of child views attached to the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int ChildCount + { + get + { + return mChildHelper != null ? mChildHelper.GetChildCount() : 0; + } + } + + /// + /// Return the child view at the given index. + /// + /// child index + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder GetChildAt(int index) + { + return mChildHelper != null ? mChildHelper.GetChildAt(index) : null; + } + + /// + /// Finds the view which represents the given adapter position. + /// + /// adapter position + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder FindItemViewByPosition(int position) + { + return mFlexibleView.FindViewHolderForLayoutPosition(position); + } + + /// + /// Offset all child views attached to the parent FlexibleView by dx pixels along the horizontal axis. + /// + /// Pixels to offset by + /// specify if the offset need animation + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void OffsetChildrenHorizontal(float dx, bool immediate) + { + if (mChildHelper == null) + { + return; + } + + if (dx == 0) + { + return; + } + + int childCount = mChildHelper.GetChildCount(); + if (immediate == true) + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + v.ItemView.PositionX += dx; + } + } + else + { + if (mScrollAni == null) + { + mScrollAni = new Animation(); + mScrollAni.Duration = SCROLL_ANIMATION_DURATION; + mScrollAni.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSquare); + } + + // avoid out of boundary of flexibleview. delta value might be used for shadow. + // this must be done before animation clear. + if (childCount > 0) + { + FlexibleViewViewHolder vh = mChildHelper.GetChildAt(0); + if (vh.LayoutPosition == 0) + { + if ((int)(vh.Left + dx) > 0) + { + dx = 0 - vh.Left; + } + } + + vh = mChildHelper.GetChildAt(childCount - 1); + if (vh.LayoutPosition == ItemCount - 1) + { + if ((int)(vh.Right + dx) < (int)Width + PaddingRight) + { + dx = Width + PaddingRight - vh.Right; + } + } + } + + // save position before animation clear. + float[] childrenPositon = new float[childCount]; + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + childrenPositon[i] = v.ItemView.PositionX; + } + + mScrollAni.Clear(); + mScrollAni.Finished += OnScrollAnimationFinished; + + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + // set position again because position might be changed after animation clear. + v.ItemView.PositionX = childrenPositon[i]; + mScrollAni.AnimateTo(v.ItemView, "PositionX", v.ItemView.PositionX + dx); + } + mScrollAni.Play(); + } + } + + /// + /// Offset all child views attached to the parent FlexibleView by dy pixels along the vertical axis. + /// + /// Pixels to offset by + /// specify if the offset need animation + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void OffsetChildrenVertical(float dy, bool immediate) + { + if (mChildHelper == null) + { + return; + } + + if (dy == 0) + { + return; + } + + int childCount = mChildHelper.GetChildCount(); + if (immediate == true) + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + v.ItemView.PositionY += dy; + } + } + else + { + if (mScrollAni == null) + { + mScrollAni = new Animation(); + mScrollAni.Duration = SCROLL_ANIMATION_DURATION; + mScrollAni.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSquare); + } + + // avoid out of boundary of flexibleview. delta value might be used for shadow. + // this must be done before animation clear. + if (childCount > 0) + { + FlexibleViewViewHolder vh = mChildHelper.GetChildAt(0); + if (vh.LayoutPosition == 0) + { + if ((int)(vh.Top + dy) > 0) + { + dy = 0 - vh.Top; + } + } + + vh = mChildHelper.GetChildAt(childCount - 1); + if (vh.LayoutPosition == ItemCount - 1) + { + if ((int)(vh.Bottom + dy) < (int)Height + PaddingBottom) + { + dy = Height + PaddingBottom - vh.Bottom; + } + } + } + + // save position before animation clear. + float[] childPositon = new float[childCount]; + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + childPositon[i] = v.ItemView.PositionY; + } + + mScrollAni.Clear(); + mScrollAni.Finished += OnScrollAnimationFinished; + + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + // set position again because position might be changed after animation clear. + v.ItemView.PositionY = childPositon[i]; + mScrollAni.AnimateTo(v.ItemView, "PositionY", v.ItemView.PositionY + dy); + } + mScrollAni.Play(); + } + } + + /// + /// Return the width of the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public float Width + { + get + { + return mFlexibleView != null ? mFlexibleView.SizeWidth : 0; + } + } + + /// + /// Return the height of the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public float Height + { + get + { + return mFlexibleView != null ? mFlexibleView.SizeHeight : 0; + } + } + + /// + /// Return the left padding of the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int PaddingLeft + { + get + { + return mFlexibleView?.Padding?.Start ?? 0; + } + } + + /// + /// Return the top padding of the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int PaddingTop + { + get + { + return mFlexibleView?.Padding?.Top ?? 0; + } + } + + /// + /// Return the right padding of the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int PaddingRight + { + get + { + return mFlexibleView?.Padding?.End ?? 0; + } + } + + /// + /// Return the bottom padding of the parent FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int PaddingBottom + { + get + { + return mFlexibleView?.Padding?.Bottom ?? 0; + } + } + + /// + /// Add a view to the currently attached FlexibleView if needed.
+ /// FlexibleViewLayoutManagers should use this method to add views obtained from a FlexibleViewRecycler using getViewForPosition(int).
+ ///
+ /// view to add + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddView(FlexibleViewViewHolder holder) + { + AddView(holder, -1); + } + + /// + /// Add a view to the currently attached FlexibleView if needed.
+ /// FlexibleViewLayoutManagers should use this method to add views obtained from a FlexibleViewRecycler using getViewForPosition(int).
+ ///
+ /// view to add + /// index to add child at + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddView(FlexibleViewViewHolder holder, int index) + { + AddViewInternal(holder, index, false); + } + + /// + /// Temporarily detach and scrap all currently attached child views. + /// Views will be scrapped into the given FlexibleViewRecycler. + /// The FlexibleViewRecycler may prefer to reuse scrap views before other views that were previously recycled. + /// + /// Recycler to scrap views into + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void ScrapAttachedViews(FlexibleViewRecycler recycler) + { + if (null == mChildHelper || null == recycler) + { + return; + } + + recycler.Clear(); + + mChildHelper.ScrapViews(recycler); + } + + /** + * Remove a child view and recycle it using the given FlexibleViewRecycler. + * + * @param index Index of child to remove and recycle + * @param recycler FlexibleViewRecycler to use to recycle child + */ + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveAndRecycleViewAt(int index, FlexibleViewRecycler recycler) + { + if (null == recycler) return; + FlexibleViewViewHolder v = mChildHelper.GetChildAt(index); + mChildHelper.RemoveViewAt(index); + recycler.RecycleView(v); + } + + /// + /// ecycles children between given indices.. + /// + /// Recycler to recycle views into + /// inclusive + /// exclusive + /// recycle immediately or add to pending list and recycle later. + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void RecycleChildren(FlexibleViewRecycler recycler, int startIndex, int endIndex, bool immediate) + { + if (startIndex == endIndex) + { + return; + } + if (endIndex > startIndex) + { + for (int i = startIndex; i < endIndex; i++) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + if (v.PendingRecycle == false) + { + v.PendingRecycle = true; + mPendingRecycleViews.Add(v); + } + } + } + else + { + for (int i = startIndex; i > endIndex; i--) + { + FlexibleViewViewHolder v = mChildHelper.GetChildAt(i); + if (v.PendingRecycle == false) + { + v.PendingRecycle = true; + mPendingRecycleViews.Add(v); + } + } + } + if (immediate == true) + { + RecycleChildrenInt(recycler); + } + } + + /// + /// Retrieves a position that neighbor to current position by direction. + /// + /// The anchor adapter position + /// The direction. + /// 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 abstract int GetNextPosition(int position, FlexibleViewLayoutManager.Direction direction); + + /// + /// Retrieves the first visible item view. + /// + /// 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 virtual FlexibleViewViewHolder FindFirstVisibleItemView() + { + return null; + } + + /// + /// Retrieves the last visible item view. + /// + /// 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 virtual FlexibleViewViewHolder FindLastVisibleItemView() + { + return null; + } + + internal virtual FlexibleViewViewHolder OnFocusSearchFailed(FlexibleViewViewHolder focused, FlexibleViewLayoutManager.Direction direction, FlexibleViewRecycler recycler) + { + return null; + } + + internal void SetRecyclerView(FlexibleView recyclerView) + { + mFlexibleView = recyclerView; + mChildHelper = recyclerView.GetChildHelper(); + } + + internal void StopScroll(bool doSomethingAfterAnimationStopped) + { + if (mScrollAni != null && mScrollAni.State == Animation.States.Playing) + { + mScrollAni.Finished -= OnScrollAnimationFinished; + mScrollAni.Stop(); + + if (doSomethingAfterAnimationStopped) + { + OnScrollAnimationFinished(mScrollAni, null); + } + } + } + + /** + * Returns the scroll amount that brings the given rect in child's coordinate system within + * the padded area of FlexibleViewRecyclerView. + * @param parent The parent FlexibleViewRecyclerView. + * @param child The direct child making the request. + * @param rect The rectangle in the child's coordinates the child + * wishes to be on the screen. + * @param immediate True to forbid animated or delayed scrolling, + * false otherwise + * @return The array containing the scroll amount in x and y directions that brings the + * given rect into RV's padded area. + */ + private Vector2 GetChildRectangleOnScreenScrollAmount(FlexibleView parent, FlexibleViewViewHolder child) + { + Vector2 ret = new Vector2(0, 0); + int parentLeft = PaddingLeft; + int parentTop = PaddingTop; + int parentRight = (int)Width - PaddingRight; + int parentBottom = (int)Height - PaddingBottom; + int childLeft = (int)child.Left; + int childTop = (int)child.Top; + int childRight = (int)child.Right; + int childBottom = (int)child.Bottom; + + int offScreenLeft = Math.Min(0, childLeft - parentLeft); + int offScreenTop = Math.Min(0, childTop - parentTop); + int offScreenRight = Math.Max(0, childRight - parentRight); + int offScreenBottom = Math.Max(0, childBottom - parentBottom); + + // Favor the "start" layout direction over the end when bringing one side or the other + // of a large rect into view. If we decide to bring in end because start is already + // visible, limit the scroll such that start won't go out of bounds. + int dx = offScreenLeft != 0 ? offScreenLeft + : Math.Min(childLeft - parentLeft, offScreenRight); + + // Favor bringing the top into view over the bottom. If top is already visible and + // we should scroll to make bottom visible, make sure top does not go out of bounds. + int dy = offScreenTop != 0 ? offScreenTop + : Math.Min(childTop - parentTop, offScreenBottom); + + ret.X = -dx; + ret.Y = -dy; + + return ret; + } + + private void OnScrollAnimationFinished(object sender, EventArgs e) + { + foreach (FlexibleViewViewHolder holder in mPendingRecycleViews) + { + holder.PendingRecycle = false; + } + mPendingRecycleViews.Clear(); + + int start = FlexibleView.NO_POSITION; + FlexibleViewViewHolder firstItemView = FindFirstVisibleItemView(); + if (firstItemView != null) + start = firstItemView.LayoutPosition; + else + start = 0; + + int itemCount = ChildCount; + + int end = FlexibleView.NO_POSITION; + FlexibleViewViewHolder lastItemView = FindLastVisibleItemView(); + if (lastItemView != null) + end = lastItemView.LayoutPosition; + else + end = itemCount - 1; + + List removedViewList = new List(); + for (int i = 0; i < itemCount; i++) + { + FlexibleViewViewHolder v = GetChildAt(i); + + //if item view of holder is visible, it should not be recycled. + if (v.LayoutPosition >= start && v.LayoutPosition <= end) + continue; + + removedViewList.Add(v); + } + + for (int i = 0; i < removedViewList.Count; i++) + { + FlexibleViewViewHolder v = removedViewList[i]; + v.PendingRecycle = false; + mFlexibleView.GetRecycler().RecycleView(v); + mChildHelper.RemoveView(v); + } + + // relayout + } + + private void AddViewInternal(FlexibleViewViewHolder holder, int index, bool disappearing) + { + if (null == holder) return; + if (holder.IsScrap()) + { + holder.Unscrap(); + mChildHelper.AttachView(holder, index); + } + else + { + mChildHelper.AddView(holder, index); + } + } + + private void RecycleChildrenInt(FlexibleViewRecycler recycler) + { + if (null == recycler) return; + foreach (FlexibleViewViewHolder holder in mPendingRecycleViews) + { + holder.PendingRecycle = false; + recycler.RecycleView(holder); + mChildHelper.RemoveView(holder); + } + mPendingRecycleViews.Clear(); + } + + private void ScrapOrRecycleView(FlexibleViewRecycler recycler, FlexibleViewViewHolder itemView) + { + recycler.ScrapView(itemView); + } + } +} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewRecycler.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewRecycler.cs new file mode 100755 index 0000000..8c3a7c5 --- /dev/null +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewRecycler.cs @@ -0,0 +1,156 @@ +using System.Collections.Generic; +using System.ComponentModel; + +namespace Tizen.NUI.Components +{ + /// + /// A FlexibleViewRecycler is responsible for managing scrapped or detached item views for reuse. + /// A "scrapped" view is a view that is still attached to its parent FlexibleView but that has been marked for removal or reuse. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class FlexibleViewRecycler + { + private FlexibleView mFlexibleView; + private FlexibleView.RecycledViewPool mRecyclerPool; + + private List mAttachedScrap = new List(); + private List mChangedScrap = null; + //private List mCachedViews = new List(); + + //private List mUnmodifiableAttachedScrap; + + private int mCacheSizeMax = 2; + + /// + /// FlexibleViewRecycler constructor. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewRecycler(FlexibleView recyclerView) + { + mFlexibleView = recyclerView; + } + + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetViewCacheSize(int viewCount) + { + mCacheSizeMax = viewCount; + } + + /// + /// Obtain a view initialized for the given position. + /// + /// Position to obtain a view for + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder GetViewForPosition(int position) + { + FlexibleViewAdapter b = mFlexibleView != null ? mFlexibleView.GetAdapter() : null; + if (b == null) + { + return null; + } + if (position < 0 || position >= b.GetItemCount()) + { + return null; + } + + int type = b.GetItemViewType(position); + FlexibleViewViewHolder itemView = null; + for (int i = 0; i < mAttachedScrap.Count; i++) + { + if (mAttachedScrap[i].LayoutPosition == position && mAttachedScrap[i].ItemViewType == type) + { + itemView = mAttachedScrap[i]; + break; + } + } + if (itemView == null) + { + itemView = mRecyclerPool.GetRecycledView(type); + if (itemView == null) + { + itemView = b.OnCreateViewHolder(type); + } + + if (!itemView.IsBound) + { + b.OnBindViewHolder(itemView, position); + itemView.IsBound = true; + } + + itemView.AdapterPosition = position; + itemView.ItemViewType = type; + } + + return itemView; + } + + /// + /// Recycle a detached view. + /// + /// Removed holder for recycling + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void RecycleView(FlexibleViewViewHolder itemView) + { + if (null == itemView) return; + itemView.ScrapContainer = null; + mRecyclerPool.PutRecycledView(itemView); + } + + /// + /// Returns the count in scrap list. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int GetScrapCount() + { + return mAttachedScrap.Count; + } + + /// + /// Gets the scrap view at index. + /// + /// index + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder GetScrapViewAt(int index) + { + return mAttachedScrap[index]; + } + + /// + /// Clear scrap views out of this recycler. Detached views contained within a recycled view pool will remain. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void Clear() + { + mAttachedScrap.Clear(); + if (mChangedScrap != null) + { + mChangedScrap.Clear(); + } + } + + internal void ScrapView(FlexibleViewViewHolder itemView) + { + mAttachedScrap.Add(itemView); + itemView.ScrapContainer = this; + } + + internal void UnscrapView(FlexibleViewViewHolder itemView) + { + mAttachedScrap.Remove(itemView); + itemView.ScrapContainer = null; + } + + internal void SetRecycledViewPool(FlexibleView.RecycledViewPool pool) + { + mRecyclerPool = pool; + } + } +} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewViewHolder.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewViewHolder.cs new file mode 100755 index 0000000..b5bd325 --- /dev/null +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/FlexibleViewViewHolder.cs @@ -0,0 +1,231 @@ +using System; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Components +{ + /// + /// A FlexibleViewViewHolder describes an item view and metadata about its place within the FlexibleView. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class FlexibleViewViewHolder + { + // This FlexibleViewViewHolder has been bound to a position; AdapterPosition, mItemId and mItemViewType + // are all valid. + //static readonly int FLAG_BOUND = 1 << 0; + + // The data this FlexibleViewViewHolder's view reflects is stale and needs to be rebound + // by the adapter. AdapterPosition and mItemId are consistent. + //static readonly int FLAG_UPDATE = 1 << 1; + + // This FlexibleViewViewHolder's data is invalid. The identity implied by AdapterPosition and mItemId + // are not to be trusted and may no longer match the item view type. + // This FlexibleViewViewHolder must be fully rebound to different data. + //static readonly int FLAG_INVALID = 1 << 2; + + // This FlexibleViewViewHolder points at data that represents an item previously removed from the + // data set. Its view may still be used for things like outgoing animations. + //static readonly int FLAG_REMOVED = 1 << 3; + + // This FlexibleViewViewHolder should not be recycled. This flag is set via setIsRecyclable() + // and is intended to keep views around during animations. + //static readonly int FLAG_NOT_RECYCLABLE = 1 << 4; + + // This FlexibleViewViewHolder is returned from scrap which means we are expecting an addView call + // for this itemView. When returned from scrap, FlexibleViewViewHolder stays in the scrap list until + // the end of the layout pass and then recycled by FlexibleViewRecyclerView if it is not added back to + // the FlexibleViewRecyclerView. + //static readonly int FLAG_RETURNED_FROM_SCRAP = 1 << 5; + + // This FlexibleViewViewHolder is fully managed by the FlexibleViewLayoutManager. We do not scrap, recycle or remove + // it unless FlexibleViewLayoutManager is replaced. + // It is still fully visible to the FlexibleViewLayoutManager. + //static readonly int FLAG_IGNORE = 1 << 7; + + private int mFlags; + private int mPreLayoutPosition = FlexibleView.NO_POSITION; + + /// + /// FlexibleViewViewHolder constructor. + /// + /// View + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public FlexibleViewViewHolder(View itemView) + { + if (itemView == null) + { + throw new ArgumentNullException("itemView may not be null"); + } + this.ItemView = itemView; + } + + /// + /// Returns the view. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public View ItemView { get; } + + /// + /// Returns the left edge includes the view left margin. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public float Left + { + get + { + return ItemView.PositionX - ItemView.Margin.Start; + } + } + + /// + /// Returns the right edge includes the view right margin. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public float Right + { + get + { + return ItemView.PositionX + ItemView.SizeWidth + ItemView.Margin.End; + } + } + + /// + /// Returns the top edge includes the view top margin. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public float Top + { + get + { + return ItemView.PositionY - ItemView.Margin.Top; + } + } + + /// + /// Returns the bottom edge includes the view bottom margin. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public float Bottom + { + get + { + return ItemView.PositionY + ItemView.SizeHeight + ItemView.Margin.Bottom; + } + } + + /// + /// Returns the position of the FlexibleViewViewHolder in terms of the latest layout pass. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int LayoutPosition + { + get + { + return mPreLayoutPosition == FlexibleView.NO_POSITION ? AdapterPosition : mPreLayoutPosition; + } + } + + /// + /// Returns the FlexibleViewAdapter position of the item represented by this FlexibleViewViewHolder. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int AdapterPosition { get; internal set; } = FlexibleView.NO_POSITION; + + /// + /// Get old position of item view. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int OldPosition { get; private set; } = FlexibleView.NO_POSITION; + + /// + /// Gets or sets item view type. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int ItemViewType { get; set; } = FlexibleView.INVALID_TYPE; + + internal bool IsBound + { + get; + set; + } + + internal FlexibleViewRecycler ScrapContainer { get; set; } + + internal bool PendingRecycle + { + get; + set; + } = false; + + + internal bool IsScrap() + { + return ScrapContainer != null; + } + + internal void Unscrap() + { + ScrapContainer.UnscrapView(this); + } + + + internal void FlagRemovedAndOffsetPosition(int mNewPosition, int offset, bool applyToPreLayout) + { + //AddFlags(FlexibleViewViewHolder.FLAG_REMOVED); + OffsetPosition(offset, applyToPreLayout); + AdapterPosition = mNewPosition; + } + + internal void OffsetPosition(int offset, bool applyToPreLayout) + { + if (OldPosition == FlexibleView.NO_POSITION) + { + OldPosition = AdapterPosition; + } + if (mPreLayoutPosition == FlexibleView.NO_POSITION) + { + mPreLayoutPosition = AdapterPosition; + } + if (applyToPreLayout) + { + mPreLayoutPosition += offset; + } + AdapterPosition += offset; + } + + internal void ClearOldPosition() + { + OldPosition = FlexibleView.NO_POSITION; + mPreLayoutPosition = FlexibleView.NO_POSITION; + } + + internal void SaveOldPosition() + { + if (OldPosition == FlexibleView.NO_POSITION) + { + OldPosition = AdapterPosition; + } + } + + private void SetFlags(int flags, int mask) + { + mFlags = (mFlags & ~mask) | (flags & mask); + } + + private void AddFlags(int flags) + { + mFlags |= flags; + } + } +} diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/GridLayoutManager.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/GridLayoutManager.cs index a0e415c..330561c 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/GridLayoutManager.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/GridLayoutManager.cs @@ -43,7 +43,7 @@ namespace Tizen.NUI.Components mSpanCount = spanCount; } - internal override void EnsureAnchorReady(FlexibleView.Recycler recycler, AnchorInfo anchorInfo, int itemDirection) + internal override void EnsureAnchorReady(FlexibleViewRecycler recycler, AnchorInfo anchorInfo, int itemDirection) { bool layingOutInPrimaryDirection = (itemDirection == LayoutState.ITEM_DIRECTION_TAIL); int span = anchorInfo.Position % mSpanCount; @@ -84,34 +84,33 @@ namespace Tizen.NUI.Components /// /// The anchor adapter position /// The direction. - /// 6 /// 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 override int GetNextPosition(int position, FlexibleView.LayoutManager.Direction direction) + protected override int GetNextPosition(int position, FlexibleViewLayoutManager.Direction direction) { if (mOrientation == HORIZONTAL) { switch (direction) { - case FlexibleView.LayoutManager.Direction.Left: + case FlexibleViewLayoutManager.Direction.Left: if (position >= mSpanCount) { return position - mSpanCount; } break; - case FlexibleView.LayoutManager.Direction.Right: + case FlexibleViewLayoutManager.Direction.Right: if (position < ItemCount - mSpanCount) { return position + mSpanCount; } break; - case FlexibleView.LayoutManager.Direction.Up: + case FlexibleViewLayoutManager.Direction.Up: if (position % mSpanCount > 0) { return position - 1; } break; - case FlexibleView.LayoutManager.Direction.Down: + case FlexibleViewLayoutManager.Direction.Down: if (position < ItemCount - 1 && (position % mSpanCount < mSpanCount - 1)) { return position + 1; @@ -123,25 +122,25 @@ namespace Tizen.NUI.Components { switch (direction) { - case FlexibleView.LayoutManager.Direction.Left: + case FlexibleViewLayoutManager.Direction.Left: if (position % mSpanCount > 0) { return position - 1; } break; - case FlexibleView.LayoutManager.Direction.Right: + case FlexibleViewLayoutManager.Direction.Right: if (position < ItemCount - 1 && (position % mSpanCount < mSpanCount - 1)) { return position + 1; } break; - case FlexibleView.LayoutManager.Direction.Up: + case FlexibleViewLayoutManager.Direction.Up: if (position >= mSpanCount) { return position - mSpanCount; } break; - case FlexibleView.LayoutManager.Direction.Down: + case FlexibleViewLayoutManager.Direction.Down: if (position < ItemCount - mSpanCount) { return position + mSpanCount; @@ -153,7 +152,7 @@ namespace Tizen.NUI.Components return NO_POSITION; } - internal override void LayoutChunk(FlexibleView.Recycler recycler, + internal override void LayoutChunk(FlexibleViewRecycler recycler, LayoutState layoutState, LayoutChunkResult result) { bool layingOutInPrimaryDirection = @@ -162,7 +161,7 @@ namespace Tizen.NUI.Components int count = mSpanCount; for (int i = 0; i < count; i++) { - FlexibleView.ViewHolder holder = layoutState.Next(recycler); + FlexibleViewViewHolder holder = layoutState.Next(recycler); if (holder == null) { result.Finished = true; diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.Internal.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.Internal.cs index dfb5c3c..d10bc14 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.Internal.cs @@ -6,10 +6,10 @@ namespace Tizen.NUI.Components { public partial class LinearLayoutManager { - internal virtual void LayoutChunk(FlexibleView.Recycler recycler, + internal virtual void LayoutChunk(FlexibleViewRecycler recycler, LayoutState layoutState, LayoutChunkResult result) { - FlexibleView.ViewHolder holder = layoutState.Next(recycler); + FlexibleViewViewHolder holder = layoutState.Next(recycler); if (holder == null) { // if we are laying out views in scrap, this may return null which means there is @@ -60,7 +60,7 @@ namespace Tizen.NUI.Components result.Focusable = true; } - internal override FlexibleView.ViewHolder OnFocusSearchFailed(FlexibleView.ViewHolder focused, FlexibleView.LayoutManager.Direction direction, FlexibleView.Recycler recycler) + internal override FlexibleViewViewHolder OnFocusSearchFailed(FlexibleViewViewHolder focused, FlexibleViewLayoutManager.Direction direction, FlexibleViewRecycler recycler) { if (ChildCount == 0) { @@ -77,7 +77,7 @@ namespace Tizen.NUI.Components mLayoutState.Recycle = false; Fill(recycler, mLayoutState, true, true); - FlexibleView.ViewHolder nextFocus; + FlexibleViewViewHolder nextFocus; if (layoutDir == LayoutState.LAYOUT_START) { nextFocus = GetChildAt(0); @@ -89,7 +89,7 @@ namespace Tizen.NUI.Components return nextFocus; } - private void UpdateAnchorInfoForLayout(FlexibleView.Recycler recycler, AnchorInfo anchorInfo) + private void UpdateAnchorInfoForLayout(FlexibleViewRecycler recycler, AnchorInfo anchorInfo) { if (UpdateAnchorFromPendingData(anchorInfo)) { @@ -148,14 +148,14 @@ namespace Tizen.NUI.Components // Finds an anchor child from existing Views. Most of the time, this is the view closest to // start or end that has a valid position (e.g. not removed). // If a child has focus, it is given priority. - private bool UpdateAnchorFromChildren(FlexibleView.Recycler recycler, AnchorInfo anchorInfo) + private bool UpdateAnchorFromChildren(FlexibleViewRecycler recycler, AnchorInfo anchorInfo) { if (ChildCount == 0) { return false; } - FlexibleView.ViewHolder anchorChild = FindFirstVisibleItemView(); + FlexibleViewViewHolder anchorChild = FindFirstVisibleItemView(); if (anchorChild == null) { Log.Error("flexibleview", $"exception occurs when updating anchor information!"); @@ -175,20 +175,20 @@ namespace Tizen.NUI.Components // or 0 for not applicable // @return {@link LayoutState#LAYOUT_START} or {@link LayoutState#LAYOUT_END} if focus direction // is applicable to current state, {@link LayoutState#INVALID_LAYOUT} otherwise. - private int ConvertFocusDirectionToLayoutDirection(FlexibleView.LayoutManager.Direction focusDirection) + private int ConvertFocusDirectionToLayoutDirection(FlexibleViewLayoutManager.Direction focusDirection) { switch (focusDirection) { - case FlexibleView.LayoutManager.Direction.Up: + case FlexibleViewLayoutManager.Direction.Up: return mOrientation == VERTICAL ? LayoutState.LAYOUT_START : LayoutState.INVALID_LAYOUT; - case FlexibleView.LayoutManager.Direction.Down: + case FlexibleViewLayoutManager.Direction.Down: return mOrientation == VERTICAL ? LayoutState.LAYOUT_END : LayoutState.INVALID_LAYOUT; - case FlexibleView.LayoutManager.Direction.Left: + case FlexibleViewLayoutManager.Direction.Left: return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_START : LayoutState.INVALID_LAYOUT; - case FlexibleView.LayoutManager.Direction.Right: + case FlexibleViewLayoutManager.Direction.Right: return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_END : LayoutState.INVALID_LAYOUT; default: @@ -198,7 +198,7 @@ namespace Tizen.NUI.Components } - private float Fill(FlexibleView.Recycler recycler, LayoutState layoutState, bool stopOnFocusable, bool immediate) + private float Fill(FlexibleViewRecycler recycler, LayoutState layoutState, bool stopOnFocusable, bool immediate) { float start = layoutState.Available; @@ -262,12 +262,12 @@ namespace Tizen.NUI.Components return start - layoutState.Available; } - private void Cache(FlexibleView.Recycler recycler, LayoutState layoutState, bool immediate, float scrolled = 0) + private void Cache(FlexibleViewRecycler recycler, LayoutState layoutState, bool immediate, float scrolled = 0) { if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) { // get the first child in the direction we are going - FlexibleView.ViewHolder child = GetChildClosestToEnd(); + FlexibleViewViewHolder child = GetChildClosestToEnd(); if (child != null) { if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderEnd(child) + scrolled < mOrientationHelper.GetEnd()) @@ -282,7 +282,7 @@ namespace Tizen.NUI.Components } else { - FlexibleView.ViewHolder child = GetChildClosestToStart(); + FlexibleViewViewHolder child = GetChildClosestToStart(); if (child != null) { if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderStart(child) + scrolled > 0) @@ -297,7 +297,7 @@ namespace Tizen.NUI.Components } } - private void RecycleByLayoutState(FlexibleView.Recycler recycler, LayoutState layoutState, bool immediate) + private void RecycleByLayoutState(FlexibleViewRecycler recycler, LayoutState layoutState, bool immediate) { if (!layoutState.Recycle) { @@ -313,7 +313,7 @@ namespace Tizen.NUI.Components } } - private void RecycleViewsFromStart(FlexibleView.Recycler recycler, float dt, bool immediate) + private void RecycleViewsFromStart(FlexibleViewRecycler recycler, float dt, bool immediate) { if (dt < 0) { @@ -326,7 +326,7 @@ namespace Tizen.NUI.Components { for (int i = childCount - 1; i >= 0; i--) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); if (mOrientationHelper.GetViewHolderEnd(child) > limit) { // stop here @@ -339,7 +339,7 @@ namespace Tizen.NUI.Components { for (int i = 0; i < childCount; i++) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); if (mOrientationHelper.GetViewHolderEnd(child) > limit) { // stop here @@ -350,7 +350,7 @@ namespace Tizen.NUI.Components } } - private void RecycleViewsFromEnd(FlexibleView.Recycler recycler, float dt, bool immediate) + private void RecycleViewsFromEnd(FlexibleViewRecycler recycler, float dt, bool immediate) { if (dt < 0) { @@ -362,7 +362,7 @@ namespace Tizen.NUI.Components { for (int i = 0; i < childCount; i++) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); if (mOrientationHelper.GetViewHolderStart(child) < limit) { // stop here @@ -375,7 +375,7 @@ namespace Tizen.NUI.Components { for (int i = childCount - 1; i >= 0; i--) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); if (mOrientationHelper.GetViewHolderStart(child) < limit) { // stop here @@ -386,7 +386,7 @@ namespace Tizen.NUI.Components } } - private float ScrollBy(float dy, FlexibleView.Recycler recycler, bool immediate) + private float ScrollBy(float dy, FlexibleViewRecycler recycler, bool immediate) { if (ChildCount == 0 || dy == 0) { @@ -423,7 +423,7 @@ namespace Tizen.NUI.Components { mLayoutState.Extra += mOrientationHelper.GetEndPadding(); // get the first child in the direction we are going - FlexibleView.ViewHolder child = GetChildClosestToEnd(); + FlexibleViewViewHolder child = GetChildClosestToEnd(); if (child != null) { // the direction in which we are traversing children @@ -440,7 +440,7 @@ namespace Tizen.NUI.Components else { mLayoutState.Extra += mOrientationHelper.GetStartAfterPadding(); - FlexibleView.ViewHolder child = GetChildClosestToStart(); + FlexibleViewViewHolder child = GetChildClosestToStart(); if (child != null) { mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL @@ -463,7 +463,7 @@ namespace Tizen.NUI.Components // children. // // @return The child closes to start of the layout from user's perspective. - private FlexibleView.ViewHolder GetChildClosestToStart() + private FlexibleViewViewHolder GetChildClosestToStart() { return GetChildAt(mShouldReverseLayout ? ChildCount - 1 : 0); } @@ -472,7 +472,7 @@ namespace Tizen.NUI.Components // children. // // @return The child closes to end of the layout from user's perspective. - private FlexibleView.ViewHolder GetChildClosestToEnd() + private FlexibleViewViewHolder GetChildClosestToEnd() { return GetChildAt(mShouldReverseLayout ? 0 : ChildCount - 1); } @@ -502,14 +502,14 @@ namespace Tizen.NUI.Components mLayoutState.Extra = mOrientationHelper.GetStartAfterPadding(); } - private FlexibleView.ViewHolder FindFirstCompleteVisibleItemView() + private FlexibleViewViewHolder FindFirstCompleteVisibleItemView() { int childCount = ChildCount; if (mShouldReverseLayout == false) { for (int i = 0; i < childCount; i++) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); int start = (int)mOrientationHelper.GetViewHolderStart(child); if (start > 0 && start < (int)mOrientationHelper.GetEnd()) { @@ -521,7 +521,7 @@ namespace Tizen.NUI.Components { for (int i = childCount - 1; i >= 0; i--) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); int start = (int)mOrientationHelper.GetViewHolderStart(child); if (start > 0 && start < (int)mOrientationHelper.GetEnd()) { @@ -532,14 +532,14 @@ namespace Tizen.NUI.Components return null; } - private FlexibleView.ViewHolder FindLastCompleteVisibleItemView() + private FlexibleViewViewHolder FindLastCompleteVisibleItemView() { int childCount = ChildCount; if (mShouldReverseLayout == false) { for (int i = childCount - 1; i >= 0; i--) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); if ((int)mOrientationHelper.GetViewHolderEnd(child) < (int)mOrientationHelper.GetEnd()) { return child; @@ -550,7 +550,7 @@ namespace Tizen.NUI.Components { for (int i = 0; i < childCount; i++) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); if ((int)mOrientationHelper.GetViewHolderEnd(child) < (int)mOrientationHelper.GetEnd()) { return child; @@ -615,9 +615,9 @@ namespace Tizen.NUI.Components // Also updates current item index to the next item, based on {@link #mItemDirection} // // @return The next element that we should layout. - public FlexibleView.ViewHolder Next(FlexibleView.Recycler recycler) + public FlexibleViewViewHolder Next(FlexibleViewRecycler recycler) { - FlexibleView.ViewHolder itemView = recycler.GetViewForPosition(CurrentPosition); + FlexibleViewViewHolder itemView = recycler.GetViewForPosition(CurrentPosition); CurrentPosition += ItemDirection; return itemView; diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.cs index e7b1e79..ba6eba0 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/LinearLayoutManager.cs @@ -22,10 +22,9 @@ namespace Tizen.NUI.Components /// /// Layout collection of views horizontally/vertically. /// - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public partial class LinearLayoutManager : FlexibleView.LayoutManager + public partial class LinearLayoutManager : FlexibleViewLayoutManager { /// /// Constant value: 0. @@ -110,7 +109,7 @@ namespace Tizen.NUI.Components { get { - FlexibleView.ViewHolder child = FindFirstVisibleItemView(); + FlexibleViewViewHolder child = FindFirstVisibleItemView(); return child == null ? NO_POSITION : child.LayoutPosition; } } @@ -125,7 +124,7 @@ namespace Tizen.NUI.Components { get { - FlexibleView.ViewHolder child = FindFirstCompleteVisibleItemView(); + FlexibleViewViewHolder child = FindFirstCompleteVisibleItemView(); return child == null ? NO_POSITION : child.LayoutPosition; } } @@ -140,7 +139,7 @@ namespace Tizen.NUI.Components { get { - FlexibleView.ViewHolder child = FindLastVisibleItemView(); + FlexibleViewViewHolder child = FindLastVisibleItemView(); return child == null ? NO_POSITION : child.LayoutPosition; } } @@ -155,7 +154,7 @@ namespace Tizen.NUI.Components { get { - FlexibleView.ViewHolder child = FindLastCompleteVisibleItemView(); + FlexibleViewViewHolder child = FindLastCompleteVisibleItemView(); return child == null ? NO_POSITION : child.LayoutPosition; } } @@ -186,10 +185,9 @@ namespace Tizen.NUI.Components /// Lay out all relevant child views from the given adapter. /// /// Recycler to use for fetching potentially cached views for a position - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public override void OnLayoutChildren(FlexibleView.Recycler recycler) + public override void OnLayoutChildren(FlexibleViewRecycler recycler) { mLayoutState.Recycle = false; if (!mAnchorInfo.Valid || mPendingScrollPosition != NO_POSITION) @@ -247,10 +245,9 @@ namespace Tizen.NUI.Components /// distance to scroll in pixels. Y increases as scroll position approaches the top. /// Recycler to use for fetching potentially cached views for a position /// Specify if the scroll need animation - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public override float ScrollHorizontallyBy(float dx, FlexibleView.Recycler recycler, bool immediate) + public override float ScrollHorizontallyBy(float dx, FlexibleViewRecycler recycler, bool immediate) { if (mOrientation == VERTICAL) { @@ -265,10 +262,9 @@ namespace Tizen.NUI.Components /// distance to scroll in pixels. Y increases as scroll position approaches the top. /// Recycler to use for fetching potentially cached views for a position /// Specify if the scroll need animation - /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public override float ScrollVerticallyBy(float dy, FlexibleView.Recycler recycler, bool immediate) + public override float ScrollVerticallyBy(float dy, FlexibleViewRecycler recycler, bool immediate) { if (mOrientation == HORIZONTAL) { @@ -285,8 +281,8 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public override float ComputeScrollOffset() { - FlexibleView.ViewHolder startChild = FindFirstVisibleItemView(); - FlexibleView.ViewHolder endChild = FindLastVisibleItemView(); + FlexibleViewViewHolder startChild = FindFirstVisibleItemView(); + FlexibleViewViewHolder endChild = FindLastVisibleItemView(); if (ChildCount == 0 || startChild == null || endChild == null) { return 0; @@ -314,8 +310,8 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public override float ComputeScrollExtent() { - FlexibleView.ViewHolder startChild = FindFirstVisibleItemView(); - FlexibleView.ViewHolder endChild = FindLastVisibleItemView(); + FlexibleViewViewHolder startChild = FindFirstVisibleItemView(); + FlexibleViewViewHolder endChild = FindLastVisibleItemView(); if (ChildCount == 0 || startChild == null || endChild == null) { return 0; @@ -333,8 +329,8 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public override float ComputeScrollRange() { - FlexibleView.ViewHolder startChild = FindFirstVisibleItemView(); - FlexibleView.ViewHolder endChild = FindLastVisibleItemView(); + FlexibleViewViewHolder startChild = FindFirstVisibleItemView(); + FlexibleViewViewHolder endChild = FindLastVisibleItemView(); if (ChildCount == 0 || startChild == null || endChild == null) { return 0; @@ -395,7 +391,7 @@ namespace Tizen.NUI.Components mAnchorInfo.Reset(); } - internal virtual void EnsureAnchorReady(FlexibleView.Recycler recycler, AnchorInfo anchorInfo, int itemDirection) + internal virtual void EnsureAnchorReady(FlexibleViewRecycler recycler, AnchorInfo anchorInfo, int itemDirection) { } @@ -406,22 +402,21 @@ namespace Tizen.NUI.Components /// /// The anchor adapter position /// The direction. - /// 6 /// 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 override int GetNextPosition(int position, FlexibleView.LayoutManager.Direction direction) + protected override int GetNextPosition(int position, FlexibleViewLayoutManager.Direction direction) { if (mOrientation == HORIZONTAL) { switch (direction) { - case FlexibleView.LayoutManager.Direction.Left: + case FlexibleViewLayoutManager.Direction.Left: if (position > 0) { return position - 1; } break; - case FlexibleView.LayoutManager.Direction.Right: + case FlexibleViewLayoutManager.Direction.Right: if (position < ItemCount - 1) { return position + 1; @@ -433,13 +428,13 @@ namespace Tizen.NUI.Components { switch (direction) { - case FlexibleView.LayoutManager.Direction.Up: + case FlexibleViewLayoutManager.Direction.Up: if (position > 0) { return position - 1; } break; - case FlexibleView.LayoutManager.Direction.Down: + case FlexibleViewLayoutManager.Direction.Down: if (position < ItemCount - 1) { return position + 1; @@ -454,17 +449,16 @@ namespace Tizen.NUI.Components /// /// Retrieves the first visible item view. /// - /// 6 /// 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 override FlexibleView.ViewHolder FindFirstVisibleItemView() + protected override FlexibleViewViewHolder FindFirstVisibleItemView() { int childCount = ChildCount; if (mShouldReverseLayout == false) { for (int i = 0; i < childCount; i++) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); int end = (int)mOrientationHelper.GetViewHolderEnd(child); if (end >= 0 && end < (int)mOrientationHelper.GetEnd()) { @@ -476,7 +470,7 @@ namespace Tizen.NUI.Components { for (int i = childCount - 1; i >= 0; i--) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); int end = (int)mOrientationHelper.GetViewHolderEnd(child); if (end >= 0 && end < (int)mOrientationHelper.GetEnd()) { @@ -490,17 +484,16 @@ namespace Tizen.NUI.Components /// /// Retrieves the last visible item view. /// - /// 6 /// 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 override FlexibleView.ViewHolder FindLastVisibleItemView() + protected override FlexibleViewViewHolder FindLastVisibleItemView() { int childCount = ChildCount; if (mShouldReverseLayout == false) { for (int i = childCount - 1; i >= 0; i--) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); int start = (int)mOrientationHelper.GetViewHolderStart(child); if (start > 0 && start < (int)mOrientationHelper.GetEnd()) { @@ -512,7 +505,7 @@ namespace Tizen.NUI.Components { for (int i = 0; i < childCount; i++) { - FlexibleView.ViewHolder child = GetChildAt(i); + FlexibleViewViewHolder child = GetChildAt(i); int start = (int)mOrientationHelper.GetViewHolderStart(child); if (start > 0 && start < (int)mOrientationHelper.GetEnd()) { diff --git a/src/Tizen.NUI.Components/Controls/FlexibleView/OrientationHelper.cs b/src/Tizen.NUI.Components/Controls/FlexibleView/OrientationHelper.cs index 2b76fc5..20f9059 100755 --- a/src/Tizen.NUI.Components/Controls/FlexibleView/OrientationHelper.cs +++ b/src/Tizen.NUI.Components/Controls/FlexibleView/OrientationHelper.cs @@ -23,8 +23,8 @@ namespace Tizen.NUI.Components // can also be used to abstract calls around view bounds and child measurements with margins and // decorations. // - // @see #createHorizontalHelper(RecyclerView.LayoutManager) - // @see #createVerticalHelper(RecyclerView.LayoutManager) + // @see #createHorizontalHelper(FlexibleViewRecyclerView.LayoutManager) + // @see #createVerticalHelper(FlexibleViewRecyclerView.LayoutManager) internal abstract class OrientationHelper { public const int HORIZONTAL = 0; @@ -32,11 +32,11 @@ namespace Tizen.NUI.Components private const int INVALID_SIZE = -1; - protected FlexibleView.LayoutManager mLayoutManager; + protected FlexibleViewLayoutManager mLayoutManager; private float mLastTotalSpace = INVALID_SIZE; - public OrientationHelper(FlexibleView.LayoutManager layoutManager) + public OrientationHelper(FlexibleViewLayoutManager layoutManager) { mLayoutManager = layoutManager; } @@ -51,8 +51,8 @@ namespace Tizen.NUI.Components // Returns the layout space change between the previous layout pass and current layout pass. // Make sure you call {@link #onLayoutComplete()} at the end of your LayoutManager's - // {@link RecyclerView.LayoutManager#onLayoutChildren(RecyclerView.Recycler, - // RecyclerView.State)} method. + // {@link FlexibleViewRecyclerView.LayoutManager#onLayoutChildren(FlexibleViewRecyclerView.Recycler, + // FlexibleViewRecyclerView.State)} method. // // @return The difference between the current total space and previous layout's total space. // @see #onLayoutComplete() @@ -68,7 +68,7 @@ namespace Tizen.NUI.Components // @param view The view element to check // @return The first pixel of the element // @see #getDecoratedEnd(android.view.View) - public abstract float GetViewHolderStart(FlexibleView.ViewHolder holder); + public abstract float GetViewHolderStart(FlexibleViewViewHolder holder); // Returns the end of the view including its decoration and margin. // For example, for the horizontal helper, if a View's right is at pixel 200, has 2px right @@ -77,7 +77,7 @@ namespace Tizen.NUI.Components // @param view The view element to check // @return The last pixel of the element // @see #getDecoratedStart(android.view.View) - public abstract float GetViewHolderEnd(FlexibleView.ViewHolder holder); + public abstract float GetViewHolderEnd(FlexibleViewViewHolder holder); // Returns the space occupied by this View in the current orientation including decorations and // margins. @@ -86,7 +86,7 @@ namespace Tizen.NUI.Components // @return Total space occupied by this view // @see #getDecoratedMeasurementInOther(View) - public abstract float GetViewHolderMeasurement(FlexibleView.ViewHolder holder); + public abstract float GetViewHolderMeasurement(FlexibleViewViewHolder holder); // Returns the space occupied by this View in the perpendicular orientation including // decorations and margins. @@ -94,7 +94,7 @@ namespace Tizen.NUI.Components // @param view The view element to check // @return Total space occupied by this view in the perpendicular orientation to current one // @see #getDecoratedMeasurement(View) - public abstract float GetViewHolderMeasurementInOther(FlexibleView.ViewHolder holder); + public abstract float GetViewHolderMeasurementInOther(FlexibleViewViewHolder holder); // Returns the start position of the layout after the start padding is added. // @@ -126,7 +126,7 @@ namespace Tizen.NUI.Components // // @param view View to offset // @param offset offset amount - internal abstract void OffsetChild(FlexibleView.ViewHolder holder, int offset); + internal abstract void OffsetChild(FlexibleViewViewHolder holder, int offset); // Returns the padding at the end of the layout. For horizontal helper, this is the right // padding and for vertical helper, this is the bottom padding. This method does not check @@ -141,7 +141,7 @@ namespace Tizen.NUI.Components // @param orientation Desired orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL} // @return A new OrientationHelper public static OrientationHelper CreateOrientationHelper( - FlexibleView.LayoutManager layoutManager, int orientation) + FlexibleViewLayoutManager layoutManager, int orientation) { if (orientation == HORIZONTAL) { @@ -160,7 +160,7 @@ namespace Tizen.NUI.Components // // @param layoutManager The LayoutManager to attach to. // @return A new OrientationHelper - public static OrientationHelper CreateHorizontalHelper(FlexibleView.LayoutManager layoutManager) + public static OrientationHelper CreateHorizontalHelper(FlexibleViewLayoutManager layoutManager) { return new HorizontalHelper(layoutManager); @@ -170,7 +170,7 @@ namespace Tizen.NUI.Components // // @param layoutManager The LayoutManager to attach to. // @return A new OrientationHelper - public static OrientationHelper CreateVerticalHelper(FlexibleView.LayoutManager layoutManager) + public static OrientationHelper CreateVerticalHelper(FlexibleViewLayoutManager layoutManager) { return new VerticalHelper(layoutManager); } @@ -178,7 +178,7 @@ namespace Tizen.NUI.Components internal class HorizontalHelper : OrientationHelper { - public HorizontalHelper(FlexibleView.LayoutManager layoutManager): base(layoutManager) + public HorizontalHelper(FlexibleViewLayoutManager layoutManager): base(layoutManager) { } @@ -204,22 +204,22 @@ namespace Tizen.NUI.Components return mLayoutManager.PaddingLeft; } - public override float GetViewHolderMeasurement(FlexibleView.ViewHolder holder) + public override float GetViewHolderMeasurement(FlexibleViewViewHolder holder) { return holder.Right - holder.Left; } - public override float GetViewHolderMeasurementInOther(FlexibleView.ViewHolder holder) + public override float GetViewHolderMeasurementInOther(FlexibleViewViewHolder holder) { return holder.Bottom - holder.Top; } - public override float GetViewHolderEnd(FlexibleView.ViewHolder holder) + public override float GetViewHolderEnd(FlexibleViewViewHolder holder) { return holder.Right; } - public override float GetViewHolderStart(FlexibleView.ViewHolder holder) + public override float GetViewHolderStart(FlexibleViewViewHolder holder) { return holder.Left; } @@ -230,7 +230,7 @@ namespace Tizen.NUI.Components - mLayoutManager.PaddingRight; } - internal override void OffsetChild(FlexibleView.ViewHolder holder, int offset) + internal override void OffsetChild(FlexibleViewViewHolder holder, int offset) { //holder.offsetLeftAndRight(offset); } @@ -244,7 +244,7 @@ namespace Tizen.NUI.Components internal class VerticalHelper : OrientationHelper { - public VerticalHelper(FlexibleView.LayoutManager layoutManager) : base(layoutManager) + public VerticalHelper(FlexibleViewLayoutManager layoutManager) : base(layoutManager) { } @@ -269,22 +269,22 @@ namespace Tizen.NUI.Components return mLayoutManager.PaddingTop; } - public override float GetViewHolderMeasurement(FlexibleView.ViewHolder holder) + public override float GetViewHolderMeasurement(FlexibleViewViewHolder holder) { return holder.Bottom - holder.Top; } - public override float GetViewHolderMeasurementInOther(FlexibleView.ViewHolder holder) + public override float GetViewHolderMeasurementInOther(FlexibleViewViewHolder holder) { return holder.Right - holder.Left; } - public override float GetViewHolderEnd(FlexibleView.ViewHolder holder) + public override float GetViewHolderEnd(FlexibleViewViewHolder holder) { return holder.Bottom; } - public override float GetViewHolderStart(FlexibleView.ViewHolder holder) + public override float GetViewHolderStart(FlexibleViewViewHolder holder) { return holder.Top; } @@ -295,7 +295,7 @@ namespace Tizen.NUI.Components - mLayoutManager.PaddingBottom; } - internal override void OffsetChild(FlexibleView.ViewHolder holder, int offset) + internal override void OffsetChild(FlexibleViewViewHolder holder, int offset) { //holder.offsetTopAndBottom(offset); } diff --git a/src/Tizen.NUI.Components/Controls/RadioButton.cs b/src/Tizen.NUI.Components/Controls/RadioButton.cs index ee69f22..d1cf8ca 100755 --- a/src/Tizen.NUI.Components/Controls/RadioButton.cs +++ b/src/Tizen.NUI.Components/Controls/RadioButton.cs @@ -80,10 +80,9 @@ namespace Tizen.NUI.Components /// /// Set CheckState to true after selecting RadioButton. /// - /// 6 /// 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 override void OnSelected() + protected override void OnSelectedChanged() { if (!IsSelected) { diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs index 6462254..ac592cd 100644 --- a/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs @@ -53,7 +53,7 @@ namespace Tizen.NUI.Components private void Initialize(RecycleAdapter adapter, RecycleLayoutManager layoutManager) { - ScrollEvent += OnScroll; + Scrolling += OnScrolling; mAdapter = adapter; mAdapter.OnDataChanged += OnAdapterDataChanged; @@ -193,7 +193,7 @@ namespace Tizen.NUI.Components } } - private void OnScroll(object source, ScrollableBase.ScrollEventArgs args) + private void OnScrolling(object source, ScrollEventArgs args) { mLayoutManager.Layout(ScrollingDirection == Direction.Horizontal ? args.Position.X : args.Position.Y); List recycledItemList = mLayoutManager.Recycle(ScrollingDirection == Direction.Horizontal ? args.Position.X : args.Position.Y); @@ -245,4 +245,4 @@ namespace Tizen.NUI.Components return mLayoutManager.CalculateCandidateScrollPosition(position); } } -} \ No newline at end of file +} diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index aa44760..9470275 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -22,6 +22,39 @@ using System.Diagnostics; namespace Tizen.NUI.Components { /// + /// ScrollEventArgs is a class to record scroll event arguments which will sent to user. + /// + /// 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 class ScrollEventArgs : EventArgs + { + Position position; + + /// + /// Default constructor. + /// + /// Current scroll position + /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API + public ScrollEventArgs(Position position) + { + this.position = position; + } + + /// + /// [Draft] Current scroll position. + /// + /// 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 Position Position + { + get + { + return position; + } + } + } + + /// /// [Draft] This class provides a View that can scroll a single View with a layout. This View can be a nest of Views. /// /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -276,52 +309,18 @@ namespace Tizen.NUI.Components public Vector2 ScrollAvailableArea { set; get; } /// - /// ScrollEventArgs is a class to record scroll event arguments which will sent to user. - /// - /// 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 class ScrollEventArgs : EventArgs - { - Position position; - - /// - /// Default constructor. - /// - /// Current scroll position - /// 6 - /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API - public ScrollEventArgs(Position position) - { - this.position = position; - } - - /// - /// [Draft] Current scroll position. - /// - /// 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 Position Position - { - get - { - return position; - } - } - } - - /// /// An event emitted when user starts dragging ScrollableBase, user can subscribe or unsubscribe to this event handler.
///
/// 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 event EventHandler ScrollDragStartEvent; + public event EventHandler ScrollDragStarted; /// /// An event emitted when user stops dragging ScrollableBase, user can subscribe or unsubscribe to this event handler.
///
/// 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 event EventHandler ScrollDragEndEvent; + public event EventHandler ScrollDragEnded; /// @@ -329,14 +328,14 @@ namespace Tizen.NUI.Components /// /// 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 event EventHandler ScrollAnimationStartEvent; + public event EventHandler ScrollAnimationStarted; /// /// An event emitted when the scrolling slide animation ends, user can subscribe or unsubscribe to this event handler.
///
/// 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 event EventHandler ScrollAnimationEndEvent; + public event EventHandler ScrollAnimationEnded; /// @@ -344,7 +343,7 @@ namespace Tizen.NUI.Components /// /// 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 event EventHandler ScrollEvent; + public event EventHandler Scrolling; /// @@ -604,28 +603,28 @@ namespace Tizen.NUI.Components AnimateChildTo(ScrollDuration, -targetPosition); } - private void OnScrollDragStart() + private void OnScrollDragStarted() { ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition); - ScrollDragStartEvent?.Invoke(this, eventArgs); + ScrollDragStarted?.Invoke(this, eventArgs); } - private void OnScrollDragEnd() + private void OnScrollDragEnded() { ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition); - ScrollDragEndEvent?.Invoke(this, eventArgs); + ScrollDragEnded?.Invoke(this, eventArgs); } - private void OnScrollAnimationStart() + private void OnScrollAnimationStarted() { ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition); - ScrollAnimationStartEvent?.Invoke(this, eventArgs); + ScrollAnimationStarted?.Invoke(this, eventArgs); } - private void OnScrollAnimationEnd() + private void OnScrollAnimationEnded() { ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition); - ScrollAnimationEndEvent?.Invoke(this, eventArgs); + ScrollAnimationEnded?.Invoke(this, eventArgs); } private bool readyToNotice = false; @@ -637,7 +636,7 @@ namespace Tizen.NUI.Components private void OnScroll() { ScrollEventArgs eventArgs = new ScrollEventArgs(ContentContainer.CurrentPosition); - ScrollEvent?.Invoke(this, eventArgs); + Scrolling?.Invoke(this, eventArgs); bool isHorizontal = ScrollingDirection == Direction.Horizontal; float contentLength = isHorizontal ? ContentContainer.Size.Width : ContentContainer.Size.Height; @@ -679,7 +678,7 @@ namespace Tizen.NUI.Components { Debug.WriteLineIf(LayoutDebugScrollableBase, "StopScroll Animation Playing"); scrollAnimation.Stop(Animation.EndActions.Cancel); - OnScrollAnimationEnd(); + OnScrollAnimationEnded(); } scrollAnimation.Clear(); } @@ -715,7 +714,7 @@ namespace Tizen.NUI.Components scrollAnimation.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine); scrollAnimation.AnimateTo(ContentContainer, (ScrollingDirection == Direction.Horizontal) ? "PositionX" : "PositionY", axisPosition); scrolling = true; - OnScrollAnimationStart(); + OnScrollAnimationStarted(); scrollAnimation.Play(); } @@ -955,7 +954,7 @@ namespace Tizen.NUI.Components StopScroll(); } totalDisplacementForPan = 0.0f; - OnScrollDragStart(); + OnScrollDragStarted(); } else if (e.PanGesture.State == Gesture.StateType.Continuing) { @@ -977,7 +976,7 @@ namespace Tizen.NUI.Components float flickDisplacement = CalculateDisplacementFromVelocity(axisVelocity); Debug.WriteLineIf(LayoutDebugScrollableBase, "FlickDisplacement:" + flickDisplacement + "TotalDisplacementForPan:" + totalDisplacementForPan); - OnScrollDragEnd(); + OnScrollDragEnded(); if (flickDisplacement > 0 | flickDisplacement < 0)// Flick detected { @@ -1018,7 +1017,7 @@ namespace Tizen.NUI.Components { scrolling = false; CheckPreReachedTargetPosition(); - OnScrollAnimationEnd(); + OnScrollAnimationEnded(); } /// diff --git a/src/Tizen.NUI.Components/Controls/SelectButton.cs b/src/Tizen.NUI.Components/Controls/SelectButton.cs index 4c4bde6..0a41b99 100755 --- a/src/Tizen.NUI.Components/Controls/SelectButton.cs +++ b/src/Tizen.NUI.Components/Controls/SelectButton.cs @@ -21,6 +21,19 @@ using System.ComponentModel; namespace Tizen.NUI.Components { /// + /// SelectedChangedEventArgs is a class to record item selected arguments which will sent to user. + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class SelectedChangedEventArgs : EventArgs + { + /// Select state of SelectButton + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public bool IsSelected { get; set; } + } + + /// /// SelectButton is base class of CheckBox and RadioButton. /// It can be used as selector and add into group for single-choice or multiple-choice . /// User can handle Navigation by adding/inserting/deleting NavigationItem. @@ -80,10 +93,9 @@ namespace Tizen.NUI.Components /// /// An event for the item selected signal which can be used to subscribe or unsubscribe the event handler provided by the user.
///
- /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler SelectedEvent; + public event EventHandler SelectedChanged; /// /// Index of selection in selection group. If selection is not in the group, return -1; @@ -183,10 +195,9 @@ namespace Tizen.NUI.Components /// /// Overrides this method if want to handle behavior after pressing return key by user. /// - /// 6 /// 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 virtual void OnSelected() + protected virtual void OnSelectedChanged() { } @@ -198,29 +209,14 @@ namespace Tizen.NUI.Components private void OnSelect() { - OnSelected(); + OnSelectedChanged(); - if (SelectedEvent != null) + if (SelectedChanged != null) { - SelectEventArgs eventArgs = new SelectEventArgs(); + SelectedChangedEventArgs eventArgs = new SelectedChangedEventArgs(); eventArgs.IsSelected = IsSelected; - SelectedEvent(this, eventArgs); + SelectedChanged(this, eventArgs); } } - - /// - /// SelectEventArgs is a class to record item selected arguments which will sent to user. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class SelectEventArgs : EventArgs - { - /// Select state of SelectButton - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsSelected { get; set; } - } } } diff --git a/src/Tizen.NUI.Components/Controls/SelectGroup.cs b/src/Tizen.NUI.Components/Controls/SelectGroup.cs index 9f0e270..9b39097 100755 --- a/src/Tizen.NUI.Components/Controls/SelectGroup.cs +++ b/src/Tizen.NUI.Components/Controls/SelectGroup.cs @@ -21,6 +21,19 @@ using System.ComponentModel; namespace Tizen.NUI.Components { /// + /// Selection group event arguments + /// + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class GroupSelectedChangedEventArgs : EventArgs + { + /// The index of selected item + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public int SelectedIndex { get; set; } + } + + /// /// SelectionGroup is the base class of CheckBoxGroup and RadioButtonGroup. /// It defines a group that is set of selections and enables the user to choose one or multiple selection. /// @@ -108,7 +121,7 @@ namespace Tizen.NUI.Components return; } ItemGroup.Add(selection); - selection.SelectedEvent += OnSelectedEvent; + selection.SelectedChanged += OnSelectedChanged; } /// @@ -124,7 +137,7 @@ namespace Tizen.NUI.Components { return; } - selection.SelectedEvent -= OnSelectedEvent; + selection.SelectedChanged -= OnSelectedChanged; ItemGroup.Remove(selection); } @@ -139,7 +152,7 @@ namespace Tizen.NUI.Components { } - private void OnSelectedEvent(object sender, SelectButton.SelectEventArgs args) + private void OnSelectedChanged(object sender, SelectedChangedEventArgs args) { SelectButton selection = sender as SelectButton; if (selection != null) @@ -151,20 +164,5 @@ namespace Tizen.NUI.Components } } } - - /// - /// Selection group event arguments - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class SelectGroupEventArgs : EventArgs - { - /// The index of selected item - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int SelectedIndex { get; set; } - } } } diff --git a/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs b/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs index 793d0be..44d45c6 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs @@ -23,6 +23,25 @@ using System.ComponentModel; namespace Tizen.NUI.Wearable { /// + /// Value Changed event data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class CircularSliderValueChangedEventArgs : EventArgs + { + private float currentValue = 0.0f; + + /// + /// Current value + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float CurrentValue + { + get { return currentValue; } + set { currentValue = value; } + } + } + + /// /// The CircularSlider class of Wearable is used to let users select a value from a continuous or discrete range of values by moving the slider thumb. /// CircularSlider shows the current value with the length of the line. /// @@ -197,25 +216,6 @@ namespace Tizen.NUI.Wearable private Animation sweepAngleAnimation; private Animation thumbAnimation; - /// - /// Value Changed event data. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public class ValueChangedEventArgs : EventArgs - { - private float currentValue = 0.0f; - - /// - /// Current value - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public float CurrentValue - { - get { return currentValue; } - set { currentValue = value; } - } - } - #endregion Fields @@ -249,7 +249,7 @@ namespace Tizen.NUI.Wearable /// The value changed event handler. /// [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler ValueChanged; + public event EventHandler ValueChanged; #endregion Events @@ -616,7 +616,7 @@ namespace Tizen.NUI.Wearable thumbAnimation.Play(); } - ValueChanged?.Invoke(this, new ValueChangedEventArgs() { CurrentValue = currentValue }); + ValueChanged?.Invoke(this, new CircularSliderValueChangedEventArgs() { CurrentValue = currentValue }); } private void UpdateTrackVisualColor(Color trackColor) diff --git a/src/Tizen.NUI.Wearable/src/public/WearableList.cs b/src/Tizen.NUI.Wearable/src/public/WearableList.cs index 4d0b0f5..dd07bdf 100644 --- a/src/Tizen.NUI.Wearable/src/public/WearableList.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableList.cs @@ -41,8 +41,8 @@ namespace Tizen.NUI.Wearable { ScrollingDirection = ScrollableBase.Direction.Vertical; - ScrollDragStartEvent += OnScrollDragStart; - ScrollAnimationEndEvent += OnAnimationEnd; + ScrollDragStarted += OnScrollDragStarted; + ScrollAnimationEnded += OnAnimationEnded; ContentContainer.PositionUsesPivotPoint = true; ContentContainer.ParentOrigin = Tizen.NUI.ParentOrigin.Center; @@ -108,7 +108,7 @@ namespace Tizen.NUI.Wearable } } - private void OnAnimationEnd(object source, ScrollableBase.ScrollEventArgs args) + private void OnAnimationEnded(object source, ScrollEventArgs args) { } @@ -135,7 +135,7 @@ namespace Tizen.NUI.Wearable } } - private void OnScrollDragStart(object source, ScrollableBase.ScrollEventArgs args) + private void OnScrollDragStarted(object source, ScrollEventArgs args) { RecycleItem prevFocusedItem = FocusedItem; prevFocusedItem?.OnFocusLost(); diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs index 0a1df5a..6c2b9ad 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CubeTransitionEffectSample.cs @@ -161,9 +161,9 @@ namespace Tizen.NUI.Samples radioStyle = radios[2].Style; radioStyle.Icon.BackgroundImage = new Selector() { Normal = EFFECT_FOLD_IMAGE, Selected = EFFECT_FOLD_IMAGE_SELECTED }; radios[2].ApplyStyle(radioStyle); - radios[0].SelectedEvent += OnWaveClicked; - radios[1].SelectedEvent += OnCrossClicked; - radios[2].SelectedEvent += OnFoldClicked; + radios[0].SelectedChanged += OnWaveClicked; + radios[1].SelectedChanged += OnCrossClicked; + radios[2].SelectedChanged += OnFoldClicked; radios[0].IsSelected = true; // load image mCurrentTexture = LoadStageFillingTexture(IMAGES[mIndex]); @@ -251,9 +251,9 @@ namespace Tizen.NUI.Samples { if (radios[i]) { - if ( 0 == i) radios[0].SelectedEvent -= OnWaveClicked; - if ( 1 == i) radios[1].SelectedEvent -= OnCrossClicked; - if ( 2 == i) radios[2].SelectedEvent -= OnFoldClicked; + if ( 0 == i) radios[0].SelectedChanged -= OnWaveClicked; + if ( 1 == i) radios[1].SelectedChanged -= OnCrossClicked; + if ( 2 == i) radios[2].SelectedChanged -= OnFoldClicked; radiosParent.Remove(radios[i]); radios[i].Dispose(); radios[i] = null; diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs index 2c437c3..7eb33a5 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/FlexibleViewSample.cs @@ -52,7 +52,7 @@ namespace Tizen.NUI.Samples } } - public class ListBridge : FlexibleView.Adapter + public class ListBridge : FlexibleViewAdapter { private List mDatas; @@ -73,15 +73,15 @@ namespace Tizen.NUI.Samples NotifyItemRemoved(position); } - public override FlexibleView.ViewHolder OnCreateViewHolder(int viewType) + public override FlexibleViewViewHolder OnCreateViewHolder(int viewType) { - FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new ListItemView()); + FlexibleViewViewHolder viewHolder = new FlexibleViewViewHolder(new ListItemView()); //Console.WriteLine($"OnCreateViewHolder... viewType: {viewType} viewID: {viewHolder.ItemView.ID}"); return viewHolder; } - public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position) + public override void OnBindViewHolder(FlexibleViewViewHolder holder, int position) { //Console.WriteLine($"OnBindItemView... position: {position}"); ListItemData listItemData = mDatas[position]; @@ -102,7 +102,7 @@ namespace Tizen.NUI.Samples listItemView.BackgroundColor = Color.Yellow; } - public override void OnDestroyViewHolder(FlexibleView.ViewHolder holder) + public override void OnDestroyViewHolder(FlexibleViewViewHolder holder) { //Console.WriteLine($"OnDestroyViewHolder... viewID: {holder.ItemView?.ID}"); if (holder.ItemView != null) @@ -118,7 +118,7 @@ namespace Tizen.NUI.Samples public override void OnFocusChange(FlexibleView flexibleView, int previousFocus, int currentFocus) { - FlexibleView.ViewHolder previousFocusView = flexibleView.FindViewHolderForAdapterPosition(previousFocus); + FlexibleViewViewHolder previousFocusView = flexibleView.FindViewHolderForAdapterPosition(previousFocus); if (previousFocusView != null) { //Console.WriteLine($"previousFocus {previousFocus.AdapterPosition}"); @@ -130,7 +130,7 @@ namespace Tizen.NUI.Samples //previousFocus.SizeHeight = 60; //NotifyItemChanged(previousFocus.AdapterPosition); } - FlexibleView.ViewHolder currentFocusView = flexibleView.FindViewHolderForAdapterPosition(currentFocus); + FlexibleViewViewHolder currentFocusView = flexibleView.FindViewHolderForAdapterPosition(currentFocus); if (currentFocusView != null) { //Console.WriteLine($"currentFocus {currentFocus.AdapterPosition}"); @@ -141,12 +141,12 @@ namespace Tizen.NUI.Samples } } - public override void OnViewAttachedToWindow(FlexibleView.ViewHolder holder) + public override void OnViewAttachedToWindow(FlexibleViewViewHolder holder) { //Console.WriteLine($"+Attached: {holder.AdapterPosition}"); } - public override void OnViewDetachedFromWindow(FlexibleView.ViewHolder holder) + public override void OnViewDetachedFromWindow(FlexibleViewViewHolder holder) { //Console.WriteLine($" --Detached: {holder.AdapterPosition}"); } @@ -301,19 +301,19 @@ namespace Tizen.NUI.Samples { if (key.KeyPressedName == "Up") { - flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Up); + flexibleView.MoveFocus(FlexibleViewLayoutManager.Direction.Up); } else if (key.KeyPressedName == "Down") { - flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Down); + flexibleView.MoveFocus(FlexibleViewLayoutManager.Direction.Down); } if (key.KeyPressedName == "Left") { - flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Left); + flexibleView.MoveFocus(FlexibleViewLayoutManager.Direction.Left); } else if (key.KeyPressedName == "Right") { - flexibleView.MoveFocus(FlexibleView.LayoutManager.Direction.Right); + flexibleView.MoveFocus(FlexibleViewLayoutManager.Direction.Right); } else if (key.KeyPressedName == "0") { -- 2.7.4