1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 #include "higv_cextfile.h"
16 #include "sample_utils.h"
17 #include "hi_gv_parser.h"
18 
19 #ifdef __cplusplus
20 #if __cplusplus
21 extern "C" {
22 #endif
23 #endif /*  __cplusplus  */
24 
25 #define  TIMER_SPEED          (3000)
26 
27 static HI_U32 g_timerId = 4;
28 static HI_U32 g_itemSeq = 0;
29 
OnViewMoveListener(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)30 HI_S32 OnViewMoveListener(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
31 {
32     HIGV_UNUSED(widget);
33     HIGV_UNUSED(wParam);
34     HIGV_UNUSED(lParam);
35     return HIGV_PROC_GOON;
36 }
37 
SCROLLVIEW_WIN_Onhide(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)38 HI_S32 SCROLLVIEW_WIN_Onhide(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
39 {
40     HI_U32 ret;
41     HIGV_UNUSED(wParam);
42     HIGV_UNUSED(lParam);
43 
44     ret = (HI_U32)HI_GV_Timer_Stop(widget, g_timerId);
45     ret |= (HI_U32)HI_GV_Timer_Destroy(widget, g_timerId);
46 
47     HIGV_CHECK("HI_GV_Timer_Destory", ret);
48 
49     g_itemSeq = 0;
50 
51     return HIGV_PROC_GOON;
52 }
53 
SCROLLVIEW_WIN_Onshow(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)54 HI_S32 SCROLLVIEW_WIN_Onshow(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
55 {
56     HI_S32 ret;
57     HIGV_UNUSED(widget);
58     HIGV_UNUSED(wParam);
59     HIGV_UNUSED(lParam);
60 
61     ret = HI_GV_Widget_Active(CHILDBUTTON_01);
62 
63     HIGV_CHECK("HI_GV_Widget_Active", ret);
64 
65     return HIGV_PROC_GOON;
66 }
67 
SCROLLVIEW_WIN_Onrefresh(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)68 HI_S32 SCROLLVIEW_WIN_Onrefresh(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
69 {
70     HI_S32 ret;
71     HIGV_UNUSED(wParam);
72     HIGV_UNUSED(lParam);
73 
74     ret = HI_GV_Timer_Create(widget, g_timerId, TIMER_SPEED);
75     HIGV_CHECK("HI_GV_Timer_Create", ret);
76 
77     ret = HI_GV_Timer_Start(widget, g_timerId);
78     HIGV_CHECK("HI_GV_Timer_Start", ret);
79 
80     return HIGV_PROC_GOON;
81 }
82 
SCROLLVIEW_WIN_Ontimer(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)83 HI_S32 SCROLLVIEW_WIN_Ontimer(HIGV_HANDLE widget, HI_PARAM wParam, HI_PARAM lParam)
84 {
85     HI_S32 ret;
86     HIGV_UNUSED(wParam);
87     HIGV_UNUSED(lParam);
88 
89     if (g_itemSeq == 0) {
90         ret = HI_GV_Widget_Active(CHILDBUTTON_02);
91         HIGV_CHECK("HI_GV_Widget_Active", ret);
92 
93         g_itemSeq++;
94 
95         ret = HI_GV_Timer_Reset(widget, g_timerId);
96         HIGV_CHECK("HI_GV_Timer_Reset", ret);
97     } else if (g_itemSeq == 1) { /* 1:item seq index */
98         ret = HI_GV_Widget_Active(CHILDBUTTON_03);
99         HIGV_CHECK("HI_GV_Widget_Active", ret);
100 
101         g_itemSeq++;
102 
103         ret = HI_GV_Timer_Reset(widget, g_timerId);
104         HIGV_CHECK("HI_GV_Timer_Reset", ret);
105     } else if (g_itemSeq == 2) { /* 2:item seq index */
106         ret = HI_GV_Widget_Active(CHILDBUTTON_04);
107         HIGV_CHECK("HI_GV_Widget_Active", ret);
108 
109         g_itemSeq++;
110 
111         ret = HI_GV_Timer_Reset(widget, g_timerId);
112         HIGV_CHECK("HI_GV_Timer_Reset", ret);
113     } else if (g_itemSeq == 3) { /* 3:item seq index */
114         ret = HI_GV_Widget_Active(CHILDBUTTON_05);
115         HIGV_CHECK("HI_GV_Widget_Active", ret);
116 
117         g_itemSeq++;
118 
119         ret = HI_GV_Timer_Reset(widget, g_timerId);
120         HIGV_CHECK("HI_GV_Timer_Reset", ret);
121     } else {
122         HI_U32 ret = (HI_U32)HI_GV_PARSER_LoadViewById(BUTTON_WIN);
123         ret |= (HI_U32)HI_GV_Widget_Show(BUTTON_WIN);
124         ret |= (HI_U32)HI_GV_Widget_Active(BUTTON_WIN);
125         ret |= (HI_U32)HI_GV_Widget_Hide(SCROLLVIEW_WIN);
126         HIGV_CHECK("HI_GV_Timer else branch", ret);
127     }
128 
129     return HIGV_PROC_GOON;
130 }
131 
132 #ifdef __cplusplus
133 #if __cplusplus
134 }
135 #endif
136 #endif /*  __cplusplus  */
137 
138