Follow formatting NUI
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / RecyclerView / RecycleAdapter.cs
1 /* Copyright (c) 2020 Samsung Electronics Co., Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  */
16 using System;
17 using System.Collections.Generic;
18 using System.ComponentModel;
19
20 namespace Tizen.NUI.Components
21 {
22     /// <summary>
23     /// [Draft] Defalt adapter for RecyclerView.
24     /// Managing RecycleItem and Data for RecyclerView.
25     /// </summary>
26     /// <since_tizen> 8 </since_tizen>
27     /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class RecycleAdapter
30     {
31         private List<object> mData = new List<object>();
32
33         /// <summary>
34         /// Create recycle item for RecyclerView.
35         /// RecyclerView will make its children using this api.
36         /// </summary>
37         /// <returns>Item for RecyclerView</returns>
38         /// <since_tizen> 8 </since_tizen>
39         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
40         [EditorBrowsable(EditorBrowsableState.Never)]
41         public virtual RecycleItem CreateRecycleItem()
42         {
43             return new RecycleItem();
44         }
45
46         /// <summary>
47         /// Bind data with recycler item.
48         /// This function is called when RecyclerItem is used again with new data.
49         /// Can update content of recycle item with new data at DataIndex of item. 
50         /// </summary>
51         /// <param name="item">Reused RecycleItem which needs data binding.</param>
52         /// <since_tizen> 8 </since_tizen>
53         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
54         [EditorBrowsable(EditorBrowsableState.Never)]
55         public virtual void BindData(RecycleItem item)
56         {
57
58         }
59
60         /// <summary>
61         /// Notify when data of adapter is changed.
62         /// </summary>
63         /// <since_tizen> 8 </since_tizen>
64         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
65         [EditorBrowsable(EditorBrowsableState.Never)]
66         public void Notify()
67         {
68             OnDataChanged?.Invoke(this, new EventArgs());
69         }
70
71         /// <summary>
72         /// Triggered when user called Notify().
73         /// </summary>
74         /// <since_tizen> 8 </since_tizen>
75         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
76         [EditorBrowsable(EditorBrowsableState.Never)]
77         public event EventHandler<EventArgs> OnDataChanged;
78
79         /// <summary>
80         /// Triggered when user called Notify().
81         /// </summary>
82         /// <since_tizen> 8 </since_tizen>
83         /// This may be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public List<object> Data
86         {
87             get
88             {
89                 return mData;
90             }
91             set
92             {
93                 mData = value;
94                 Notify();
95             }
96         }
97     }
98 }