The present disclosure relates to the technical field of multimedia, in particularly, to a method and an electronic device for controlling a focus box.
An Android UI system operating on a television platform takes controls as basic display units. Each control has one attribute: focus, and two states: with or without focus. Controls with focus are the same as those without focus in appearance by default. In order to indicate which control has a focus at present, a focus box is required to display to a user. Therefore, when the focus is transferred, the focus box must appear as soon as possible on the control newly obtaining the focus.
An Android slide control RecyclerView in the Android UI system can easily realize one-dimensional and two-dimensional list layout, set spacing between cellintervals, make focus transferring rules, etc. However, when a focus box selecting key is pressed continuously or pressed fast and continually, a phenomenon of losing a focus box possibly occurs. For example, two fixed controls A and B exist in the upper left corner of a screen shown in
A method for controlling a focus box is provided in an embodiment of the present disclosure. The method includes: at an electronic device, monitoring slide events of a recycler view; freezing the focus box in a current position when monitoring a beginning of slide of the recycler view; calculating an item of the recycler view corresponding to the current position of the focus box when monitoring an end of the slide; and setting the item of the recycler view in the position covered by the focus box such that the item covered by the focus box obtains a focus.
An electronic device is provided in another embodiment of the present disclosure. The electronic device includes at least one processor and a memory communicably connected with the at least one processor for storing instructions executable by the at least one processor, wherein execution of the instructions by the at least one processor causes the at least one processor to:
monitor slide events of a recycler view;
freeze the focus box in a current position when monitoring a beginning of slide of the recycler view;
calculate an item of the recycler view corresponding to the current position of the focus box when monitoring an end of the slide; and
set the item of the recycler view in the position covered by the focus box such that the item covered by the focus box obtains a focus.
A non-transitory computer-readable storage medium is provided in still another embodiment of the present disclosure. The non-transitory computer-readable storage medium stores executable instructions, wherein when executed by an electronic device, causes the electronic device to:
monitor slide events of a recycler view;
freeze the focus box in a current position when monitoring a beginning of slide of the recycler view;
calculate an item of the recycler view corresponding to the current position of the focus box when monitoring an end of the slide; and
set the item of the recycler view in the position covered by the focus box such that the item covered by the focus box obtains a focus.
One or more embodiments are illustrated by way of example, and not by limitation, in the figures of the accompanying drawings, wherein elements having the same reference numeral designations represent like elements throughout. The drawings are not to scale, unless otherwise disclosed.
In order to make the objective, technical solution and advantages of the present disclosure more clearly understood, the present disclosure is further explained in details by combining with embodiments with reference to the drawings.
It should be noted that all the expressions “first” and “second” in the embodiments of the present disclosure are intended to differentiate two non-identical entities with an identical name or two non-identical parameters with an identical name. As can be seen, “first” and “second” are only for the convenience of expression, and should not be understood as limitations to the embodiments of the present disclosure, which will not be explained again in the subsequent embodiments.
As shown in
In Step 101: monitoring slide events, including beginning and end of slide, of a recycler view;
Wherein a monitoring module can be set to monitor the slide events of the recycler view in specific applications;
In Step 102: freezing a focus box in a current position when monitoring the beginning of the slide of the recycler view;
In Step 103: calculating an item of the recycler view corresponding to the current position of the focus box when monitoring the end of the slide;
In Step 104: setting the item of the recycler view in the position covered by the focus box such that the item covered by the focus box obtains the focus.
In some exemplary embodiments, a monitoring module is set; the focus box has moved to the edge of a screen (on an item 4 shown in
In other words, after the focus is transferred according to the existing focus transferring rules (the focus is transferred to the fifth item from the fourth item of the recycler view, and then to the fixed list items A and B when the rightward sliding key is continuously pressed), the focus is transferred once again to a control at which the focus should arrive (the calculated item of the recycler view corresponding to the current position of the focus box) according to a specific service scenario (for example, the recycler view continues to move); in actual use, the focus box stores the position information of the item that should obtain the focus after sliding; afterward, the focus is correctly recovered according to the information, and the wrong focus search result is given up; the final result that the focus box and the focus are on the same item is obtained, and misplacement and loss of the focus box are avoided.
Further, the step of calculating an item of the recycler view corresponding to the current position of the focus box in Step 103 includes:
In Step 103a: obtaining coordinates of four angles of the focus box and a coordinate of a center point of each item in the recycler view;
In Step 103b: performing containing judgment using the coordinates of the four angles of the focus box and the coordinate of the center point of each item in the recycler view; and
In Step 103c: determining that, if a rectangle region formed by the coordinates of the four angles of the focus box contains the center point of an item in the recycler view, the item is the item of the recycler view corresponding to the current position of the focus box.
The coordinates of the four angles of the focus box are defined as (a, i), (a, j), (b, i), (b, j), and the coordinates of the center points of the items in the recycler view are defined as (x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5), (x6, y6) . . . ; take a center point (x3, y3) of one of the items in the recycler view for example, when x3ε(a, b) and y3ε(i, j), the rectangle region formed by the coordinates of the four angles of the focus box contains the center point (x3, y3) of one of the items in the recycler view, and it is determined that the item, the coordinate of the center point of which is (x3, y3), is the item of the recycler view corresponding to the current position of the focus box.
The size of the focus box is the same as that of an individual item of the recycler view. When the user releases the rightward selecting key, the recycler view stops sliding. The item of the recycler view displayed below the focus box may be some complete item or parts of two adjacent items. In the manner of performing containing judgment using the coordinates of the four angles of the focus box and the coordinate of the center point of each item in the recycler view, the item with the center point in the focus box is selected as the item corresponding to the current position of the focus box. Wrong selection of the focus when some contents of the two items are displayed in the focus box at the same time is avoided, and the item corresponding to the focus box is correctly selected.
In some exemplary embodiments, the step of calculating an item of the recycler view corresponding to the current position of the focus box in the step 103 as shown in
In Step 103d: obtaining coordinates of four angles of the focus box and those of four angles of each item in the recycler view;
In Step 103e: comparing the coordinates of the four angles of the focus box with those of the four angles of each item in the recycler view respectively;
In Step 103f: determining that, if coordinates of four angles of an item in the recycler view are the same as those of the four angles of the focus box (the focus box displays some complete item), the item in the recycler view is the item of the recycler view corresponding to the focus box; and
In Step 103g: determining that an item in a slide direction is the item of the recycler view corresponding to the current position of the focus box when adjacent angle coordinates of two items simultaneously fall within the coordinate range of the four angles of the focus box.
After the item corresponding to the focus box is determined, the corresponding item in the recycler view is placed in the position covered by the focus box such that the item covered by the focus box obtains the focus. For example, as shown in
The coordinates of the four angles of the focus box are compared with those of four angles of each item in the recycler view respectively. When adjacent angle coordinates of two items simultaneously fall within the coordinate range of the four angles of the focus box (the focus box displays partially two adjacent items 6 and 7). It is determined that an item in a slide direction is the item of the recycler view corresponding to the current position of the focus box, thereby improving visual smoothness and enhancing user experience.
Further, after the focus is obtained in Step 104, the method further includes:
In Step 105: unfreezing the focus box, receiving a focus moving instruction, and moving the focus box in an instruction direction.
In some exemplary embodiments, freezing a focus box in a current position includes: disconnecting focus monitoring of the focus box and keeping the position of the focus box unchanged; and unfreezing the focus box includes: reconnecting the focus monitoring of the focus box and canceling the operation of keeping the position of the focus box unchanged.
According to the method for controlling a focus box provided by the embodiments of the present disclosure, a monitoring module is provided; after the monitoring module monitors the beginning of the slide of the recycler view, the system freezes the focus box in the current position; after the user releases the key and the monitoring module monitors the end of the slide of the recycler view, the item of the recycler view under the focus box is calculated according to the position of the focus box; the item is set in the position covered by the focus box to obtain the focus; the final result that the focus box and the focus are on the same item is obtained; the problem that the focus box is misplaced and the item newly sliding into the screen accidentally loses the focus when keeping on pressing the focus box selecting key is solved in a simple and effective way.
Taking an Android system for an example, a method for controlling a focus box provided by an embodiment of the present disclosure is applied to an Android TV system and includes:
In Step 101: monitoring slide events, including beginning and end of sliding, of a RecyclerView;
wherein a monitoring module can be set to monitor the slide events of the RecyclerView in specific application;
In Step 102: freezing a focus box in a current position when monitoring the beginning of the slide of the RecyclerView;
wherein the step of freezing a focus box in a current position includes: monitoring a focus of the focus box and keeping the position of the focus box unchanged;
In Step 103: calculating an item of the RecyclerView corresponding to the current position of the focus box when monitoring the end of the slide;
wherein the step of calculating an item of the RecyclerView corresponding to the current position of the focus box includes:
In Step 103a: obtaining coordinates of four angles of the focus box and a coordinate of a center point of each item in the RecyclerView;
In Step 103b: performing containing judgment using the coordinates of the four angles of the focus box and the coordinate of the center point of each item in the RecyclerView; and
In Step 103c: determining that, if a rectangle region formed by the coordinates of the four angles of the focus box contains the center point of an item in the RecyclerView, the item is the item of the RecyclerView corresponding to the current position of the focus box;
wherein the coordinates of the four angles of the focus box are defined as (a, i) (a, j) (b, i) (b, j) and the coordinates of the center points of the items in the RecyclerView are defined as (x1, y1) (x2, y2) (x3, y3) (x4, y4) (x5, y5) (x6, y6) . . . ; take a center point (x3, y3) of one of the items in the recycler view for example, when x3ε(a, b) and y3ε(i, j), the rectangle region formed by the coordinates of the four angles of the focus box contains the center point (x3, y3) of one of the items in the recycler view, and it is determined that the item, the coordinate of the center point of which is (x3, y3), is the item of the recycler view corresponding to the current position of the focus box;
In Step 104: setting the item of the RecyclerView in the position covered by the focus box such that the item covered by the focus box obtains the focus.
The method further includes:
In Step 105: unfreezing the focus box, receiving a focus moving instruction, and moving the focus box in an instruction direction; and
wherein the step of unfreezing the focus box includes: reconnecting the focus monitoring of the focus box and canceling the operation of keeping the position of the focus box unchanged.
In another aspect, as shown in
a monitoring module 201 for monitoring slide events of a recycler view;
a focus box control module 202 for freezing a focus box in a current position when the monitoring module monitors the beginning of slide of the recycler view;
a focus box corresponding item calculating module 203 for calculating an item of the recycler view corresponding to the current position of the focus box when the monitoring module monitors the end of the slide; and
a focus obtaining module 204 for setting the item of the recycler view in the position covered by the focus box such that the item covered by the focus box obtains the focus.
In the embodiments of the present disclosure, the slide monitoring module 201 is set; the focus box has moved to the edge of a screen (on an item 4 shown in
In other words, after the system transfers the focus according to the existing focus transferring rules (the focus is transferred to the fixed list item A or B from the fourth item of the recycler view when the rightward sliding key is continuously pressed), the focus box control module 202 transfers the focus once again to a control at which the focus should arrive (the calculated item of the recycler view corresponding to the current position of the focus box) according to a specific service scenario (for example, the RecyclerView continues to move in an AndroidUI system); in actual use, the focus box is used to store the position information of the item that should obtain the focus after sliding; afterward, the focus obtaining module 204 correctly recovers the focus according to the information, and the wrong focus search result of the system is given up; the final result that the focus box and the focus are on the same item is obtained, and misplacement and loss of the focus box is avoided.
Further, the focus box corresponding item calculating module 203 includes:
a first coordinate obtaining unit 203a for obtaining coordinates of four angles of the focus box and a coordinate of a center point of each item in the recycler view;
a first coordinate comparing unit 203b for performing containing judgment using the coordinates of the four angles of the focus box and the coordinate of the center point of each item in the recycler view; and
an item determining unit 203c for determining that, if a rectangle region formed by the coordinates of the four angles of the focus box contains a center point of an item in the recycler view, the item is the item of the recycler view corresponding to the current position of the focus box.
The size of the focus box is the same as that of an individual item of the recycler view. When the user releases the rightward selecting key, the recycler view stops sliding. The item of the recycler view displayed below the focus box may be some complete item or parts of two adjacent items. In the manner of performing containing judgment using the coordinates of the four angles of the focus box and the coordinate of a center point of each item in the recycler view through the coordinate comparing unit 203b, the item determining unit 203c selects the item with the center point in the focus box as the item corresponding to the current position of the focus box. Wrong selection of the focus when some contents of the two items are displayed in the focus box at the same time is avoided, and the item corresponding to the focus box is correctly selected.
In another embodiment of an apparatus 20 for controlling a focus box provided by the present disclosure, the focus box corresponding item calculating module 203 includes:
a second coordinate obtaining unit 203d for obtaining coordinates of four angles of the focus box and those of four angles of each item in the recycler view;
a second coordinate comparing unit 203e for comparing the coordinates of the four angles of the focus box with those of the four angles of each item in the recycler view respectively; and
a second item determining unit 203f for determining that, if coordinates of four angles of an item in the recycler view are the same as those of the four angles of the focus box, the item in the recycler view is the item of the recycler view corresponding to the focus box;
wherein the second item determining unit 203f is further configured for determining that an item in a slide direction is the item of the recycler view corresponding to the current position of the focus box when adjacent angle coordinates of two items simultaneously fall within the coordinate range of the four angles of the focus box.
After the item corresponding to the focus box is determined, the focus obtaining module 204 sets the corresponding item in the recycler view in the position covered by the focus box such that the item covered by the focus box obtains the focus. For example, as shown in
The second coordinate comparing unit 203e compares the coordinates of the four angles of the focus box with those of four angles of each item in the recycler view respectively. When the second item determining unit 203f determines that adjacent angle coordinates of two items simultaneously fall within the coordinate range of the four angles of the focus box (the focus box displays partially two adjacent items 6 and 7), it is determined that an item in a slide direction is the item of the recycler view corresponding to the current position of the focus box, thereby improving visual smoothness and enhancing user experience.
Further, the focus box control module 203 is further configured for unfreezing the focus box on an item after the item obtains the focus, receiving a focus moving instruction, and moving the focus box in an instruction direction.
The focus box control module 203 is configured for disconnecting focus monitoring of the focus box and keeping the position of the focus box unchanged when the focus box needs freezing; and it is further configured for reconnecting the focus monitoring of the focus box and canceling the operation of keeping the position of the focus box unchanged when the focus box is unfrozen.
According to the method and apparatus for controlling a focus box provided by the embodiments of the present disclosure, the monitoring module 201 is provide; after the monitoring module monitors the beginning of the sliding of the recycler view, the focus box control module 202 freezes the focus box in the current position; when the user releases the key and the monitoring module 201 monitors the end of the sliding of the recycler view, the focus box corresponding item calculating module 203 calculates the item of the recycler view below the focus box according to the position of the focus box; the item is set in the position of the covered by the focus box and obtains the focus by the focus obtaining module 204; a final result that the focus box and the focus are on the same item is obtained, and the problem that the focus box is misplaced and the item newly sliding into the screen accidentally loses the focus when keeping on pressing the focus box selecting key is solved in a simple and effective way. Meanwhile, the second item determining unit 203f is arranged in the focus box corresponding item calculating module 203 and is configured for determining that the item of the recycler view is the item of the recycler view corresponding to the focus box if the coordinates of four angles of one of items in the recycler view are the same as those of the four angles of the focus box, thereby improving visual smoothness and enhancing user experience.
In another aspect, the present disclosure further provides a smart terminal.
As illustrated in
The memory 11 is configured for storing executable programs;
The at least one processor 12 is caused to execute the executable programs stored in the memory 11, thereby monitoring slide events of a recycler view, freezing a focus box in a current position when monitoring the beginning of slide of the recycler view, calculating an item of the recycler view corresponding to the current position of the focus box when monitoring the end of the slide, and setting the item of the recycler view in the position covered by the focus box such that the item covered by the focus box obtains a focus;
The display device 13 is configured for displaying a graphic user interface.
The memory 11 of the smart terminal 10 can be a non-transitory computer-readable memory medium, useful for storing a computer-executable instruction. When the instruction is processed by one or more central processing units, for example, it can make the central processing units to execute Steps 101-104 of
The processor 12 can be a central processing unit (CPU for short). The processor 12 can also be other general processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic device, discrete hardware component, etc. The general processor can be a microprocessor or the processor can be any conventional processor.
Direct or indirect communications connection between the processor and the memory can be realized in any proper manner in the related art to accomplish data transmission, and it includes, but is not limited to, physical bus system connection and other invisible network connection. The bus system can include power bus, control bus, state signal bus, etc.
The smart terminal 10 provided in the embodiment solves the problem that the focus box is misplaced and the item newly sliding into the screen accidentally loses the focus when keeping on pressing the focus box selecting key in a simple and effective way.
Moreover, the focus box corresponding item calculating module includes a second item determining unit for determining that the item in the sliding direction is the item of the recycler view corresponding to the current position of the focus box when adjacent angle coordinates of two items simultaneously fall within the coordinate range of the four angles of the focus box, thereby improving visual smoothness and enhancing user experience.
Those ordinary skilled in the art should realize: the units and algorithm steps in each example described in the embodiments disclosed in the present application can be performed by electronic hardware, computer software or a combination thereof. To clarify the interchangeability of hardware and software, the constitution and steps in each example have been generally described in the above explanations according to functions. Whether these function are executed by hardware or software depends on the specific applications of the technical solution and the design constraint conditions. As for each specific application, those ordinary skilled in the art can achieve the described functions in different methods, but the achievement should not be deemed to go beyond the scope of the present disclosure. The computer software can be stored in the computer-readable memory medium. During execution, the program can include the flow of the embodiments of the above methods. The memory medium can be disk, optical disk, read-only memory, random memory, and so on.
Those ordinary skilled in the art should understand: the discussion on any of the above embodiments is merely exemplary, without intention to imply that the scope of the present disclosure (including the claims) is limited to those embodiments; consistent with the thought of the present disclosure, combinations of the technical features in one or more of the above embodiments are feasible, and many other changes in different aspects of the present disclosure exist; for conciseness, these combinations and changes are not presented in details. Therefore, any omission, modification, equivalent replacement, improvements among others within the spirit and principle of the present disclosure should be contained within the protection scope of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
201610166662.5 | Mar 2016 | CN | national |
The present disclosure is a continuation application of PCT International patent application No. PCT/CN2016/089323, filed on Jul. 8, 2016, which claims priority to Chinese Patent Application No. 201610166662.5, filed with the Chinese Patent Office on Mar. 22, 2016, both of which are herein incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2016/089323 | Jul 2016 | US |
Child | 15245614 | US |