Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
According to the page returning method provided by the embodiment of the invention, the page returning operation can be finished directly by receiving the pressing and sliding operation input by the user on the current page and according to the pressing and sliding operation, a returning key does not need to be additionally arranged on a screen or an application program page, the time for the user to search the returning key is saved, the page returning operation is more convenient and efficient, and the user experience is better.
Fig. 1 is a flowchart of an implementation of a page returning method according to an embodiment of the present invention, and as shown in fig. 1, the page returning method is applied to a terminal installed with an android system, where the terminal may be a mobile phone or a tablet computer, and the method includes the following steps:
in step S101, a press and slide operation of the user on the current page is received.
In step S102, it is determined whether the area currently pressed by the user is a preset side area based on the pressing operation.
For example, as shown in fig. 2, the predetermined side area may be a partial area a cut out from the WeChat chat page based on the center point, and the remaining peripheral area B.
In the embodiment of the invention, whether the area currently pressed by the user is the area B is determined based on the pressing operation of the user on the current page.
In step S103, if yes, a current moving direction is determined according to the sliding operation, and the current page moves along the moving direction.
In the embodiment of the present invention, the current moving direction includes left, right, up, and down. Taking the current moving direction as leftward sliding as an example, when it is detected that the moving direction of the sliding operation input on the current page by the user is leftward sliding, the current page is moved leftward accordingly, so that the dynamic sense of the page is increased, the user can feel the returning process of the page in real time, and the experience degree of the user is improved.
In step S104, when it is detected that the displacement or the final speed of the current page movement satisfies a preset page end condition, the current page is ended.
In the embodiment of the disclosure, by receiving the pressing and sliding operations of the user on the current page and determining whether the current pressing area of the user is a preset side area based on the pressing operations, if so, determining the current moving direction according to the sliding operations, so that the current page can move along with the moving direction, and the physical feeling of the user on the page movement is increased; meanwhile, when the displacement or the final speed of the current page movement is detected to meet the preset page ending condition, the current page is ended, namely the pressing operation and the sliding operation which are input on the current page by a user are directly received, the page returning operation can be completed according to the pressing operation and the sliding operation, a returning key does not need to be additionally arranged on a screen or an application program page, the time for the user to search the returning key is saved, the page returning operation is more convenient and efficient, and the user experience is better.
Fig. 3 is a flowchart of implementing a page returning method according to a second embodiment of the present invention, as shown in fig. 3, the second embodiment is basically the same as the first embodiment, and is different in that a step S201 is further included before the step S101.
In step S201, all interfaces of the currently opened application are rendered, where the interfaces include the current page.
Taking the microblog application program as an example, when a user clicks the microblog application program and clicks a plurality of microblog browsing pages, the background program can render the plurality of microblog browsing pages.
In the embodiment of the invention, all interfaces of the currently opened application program can be rendered in an application software mode, and the specific rendering mode can refer to the existing android application program interface rendering technology.
In the embodiment of the present invention, taking rendering an interface as an example, when the interface is rendered, the status bar of the interface and the theme color of the interface are made to be consistent, specifically, the interface may be set as an immersive APP interface picture extending to the status bar, and the application itself is immersed in the status bar, so if the third party software does not allocate a picture to the status bar, the status bar is naturally black. The top status bar and the underlying virtual keys are hidden and are drawn from the edge when needed.
In actual applications, the status bar is set differently for different SDKs (Software Development Kit (SDK) which are typically some sets of Development tools used by Software engineers to build application Software for a specific Software package, Software framework, hardware platform, operating system, etc.). For example, if the SDK is less than 19, the status bar is not set to be in the transparent state, and the SDK24 and above support the open mode.
After the status bar transitions to transparent, the adjustResize of the input method may be invalidated. At this time, the layout change of the DecorView (top page, i.e. current page) can be monitored, and when the layout change is monitored, the height of the sub-View is dynamically adjusted to be the visible part of the DecorView.
Fig. 4 is a flowchart of an implementation of a page returning method according to a third embodiment of the present invention, and as shown in fig. 4, this embodiment is basically the same as the first embodiment, except that step S102 is replaced with step S301.
In step S301, based on the pressing operation, a position of an area currently pressed by the user is determined, and it is determined whether the position is within a preset range of the side area.
In the embodiment of the present invention, it is determined whether the pressed area is a side edge in the ACTION _ DOWN event of the displatcouche (the displatcouche handles touch event distribution, and the event (in most cases) starts from the displatcouche of Activity), and the pressed area is marked.
Illustratively, as shown in fig. 4, in combination with the example of the first embodiment, it is assumed that the area pressed by the user is located at a point C on the current page, the point C is marked, where marking the point C may be recording position coordinates of the point C, and determining, according to the position coordinates of the point C, a position of the point C relative to the current page, and determining whether the point C is located in the area B.
Fig. 5 is a flowchart of an implementation of a page returning method according to a fourth embodiment of the present invention, which is substantially the same as the first embodiment, except that step S103 is replaced with step S401 and step S402.
In step S401, if yes, it is determined whether the current moving direction is a lateral movement according to the sliding operation.
In step S402, if yes, the current page moves along with the horizontal direction.
In an embodiment of the invention, the lateral movement is horizontal left or right.
In the embodiment of the invention, the current page moves along with the horizontal direction, specifically, an offset value is set for setTranslationX called by a parent container of ContentView, so that the current page moves along with the horizontal direction.
When the current pressing area of the user is determined to be the preset side area and the moving direction of the current pressing area is determined to be the transverse movement, setTranslationX is called to the parent container of ContentView in real time to set an offset value, so that the user can sense that the current page moves along with the sliding operation of the user in real time, and the sensory feeling of the user using the application program is improved.
As an embodiment of the present invention, the step S104 specifically includes: and when the displacement of the current page movement is detected to meet a preset threshold value, ending the current page.
The preset threshold may be that the displacement of the current page movement exceeds half or three-quarters of the lateral width of the current page, and may be specifically set according to an actual situation.
As another embodiment of the present invention, the step S104 is specifically: and when the fact that the moving final speed of the current page meets a preset threshold value is detected, ending the current page.
As a preferred embodiment of the present invention, the step S104 may further include: and when detecting that the displacement and the final speed of the current page movement both meet the preset threshold value, ending the current page. Thus, whether the current page needs to be ended or not can be more accurately judged.
Fig. 6 is a flowchart of an implementation of a page returning method according to a fifth embodiment of the present invention, which is substantially the same as the first embodiment, except that step S501 is replaced with step S104.
In step S501, when it is detected that the displacement or the final speed of the current page movement satisfies a preset page end condition, the current page is converted into a layer in a transparent state.
In the embodiment of the present invention, when it is detected that the displacement or the final speed of the current page movement meets the preset page ending condition, a class object of a transparent conversion callback class is obtained according to the Activity object, then a Method object is obtained through a get cleared Method ("get Activity operations"), the current page is converted into a layer in a transparent state, and the background of the current page is removed. At this time, the Activity of the lower layer (Activity is an interactive interface which is full of the whole window or suspended on other windows) can be seen through, and the user can see the page at the lower layer, that is, the page at the upper layer is finished at this time.
As a preferred embodiment of the present invention, the step S104 specifically includes: and when detecting that the displacement or the final speed of the current page movement meets a preset page ending condition, converting the current page into a layer in a transparent state based on a reflection calling method.
It should be noted that, when using the method of this embodiment, android needs to be preset under SDK21(android5.0), because below SDK21(android5.0), the reflection call method can only convert a window converted from opaque to transparent, but cannot convert an originally opaque window to transparent.
The implementation of the page returning function provided by the above embodiment can be opened in a method form for calling by an external class.
Specifically, BaseActivity may be created within the project design, and then a tool class may be invoked to implement the page return function described above.
And each interface Activity inherits the BaseActivity, and inherits the page returning function by default.
In addition, if the page is controlled whether to inherit the page return function, the flexible control of the transmission value of the parent class method can be called.
Fig. 7 is a schematic structural diagram of a page returning apparatus according to an embodiment of the present invention, and for convenience of description, only the parts related to the embodiment of the present invention are shown in the diagram, which is detailed as follows:
as shown in fig. 7, a page returning apparatus is applied to a terminal, which may be a mobile phone or a tablet computer, and includes: a receiving unit 10, a determining unit 20, a moving unit 30 and an end-of-page unit 40.
And the receiving unit 10 is used for receiving the pressing and sliding operation of the user on the current page.
A determining unit 20, configured to determine whether the area currently pressed by the user is a preset side area based on the pressing operation.
For example, as shown in fig. 2, the predetermined side area may be a partial area a cut out from the WeChat chat page based on the center point, and the remaining peripheral area B.
In the embodiment of the present invention, the determination unit 20 determines whether the area currently pressed by the user is the area B based on the pressing operation of the user on the current page.
And a moving unit 30, configured to determine a current moving direction according to the sliding operation if the current page is moved along the moving direction.
In the embodiment of the present invention, the current moving direction includes left, right, up, and down. Taking the current moving direction as leftward sliding as an example, when the moving unit 30 detects that the moving direction of the sliding operation entered on the current page by the user is leftward sliding, the current page is moved leftward, so that the dynamic sense of the page is increased, the user can feel the returning process of the page in real time, and the experience of the user is improved.
And a page ending unit 40, configured to end the current page when detecting that the displacement or the final speed of the current page movement meets a preset page ending condition.
According to the page returning device, the pressing operation and the sliding operation of the user on the current page are received, whether the area pressed by the user at present is the preset side area or not is determined based on the pressing operation, if yes, the current moving direction is determined according to the sliding operation, so that the current page can move along with the moving direction, and the physical feeling of the user on the page moving is increased; meanwhile, when the displacement or the final speed of the current page movement is detected to meet the preset page ending condition, the current page is ended, namely the pressing operation and the sliding operation which are input on the current page by a user are directly received, the page returning operation can be completed according to the pressing operation and the sliding operation, a returning key does not need to be additionally arranged on a screen or an application program page, the time for the user to search the returning key is saved, the page returning operation is more convenient and efficient, and the user experience is better.
Fig. 8 is a schematic structural diagram of another page returning apparatus provided in an embodiment of the present invention, and for convenience of description, only the parts related to the embodiment of the present invention are shown in the diagram, which is detailed as follows:
in the page return apparatus of the present disclosure, an interface rendering unit 50 is further included.
And the interface rendering unit 50 is configured to render all interfaces of the currently opened application program, where the interfaces include the current page.
Taking the microblog application program as an example, when a user clicks the microblog application program and clicks a plurality of microblog browsing pages, the background program can render the plurality of microblog browsing pages.
In the embodiment of the present invention, taking rendering an interface as an example, when the interface is rendered, the status bar of the interface and the theme color of the interface are made to be consistent, specifically, the interface may be set as an immersive APP interface picture extending to the status bar, and the application itself is immersed in the status bar, so if the third party software does not allocate a picture to the status bar, the status bar is naturally black. The top status bar and the underlying virtual keys are hidden and are drawn from the edge when needed.
In actual applications, the status bar is set differently for different SDKs (Software Development Kit (SDK) which are typically some sets of Development tools used by Software engineers to build application Software for a specific Software package, Software framework, hardware platform, operating system, etc.). For example, if the SDK is less than 19, the status bar is not set to be in the transparent state, and the SDK24 and above support the open mode.
After the status bar transitions to transparent, the adjustResize of the input method may be invalidated. At this time, the layout change of the DecorView (top page, i.e. current page) can be monitored, and when the layout change is monitored, the height of the sub-View is dynamically adjusted to be the visible part of the DecorView.
As an embodiment of the present invention, the determining unit 20 is specifically configured to: and determining the position of the area currently pressed by the user based on the pressing operation, and judging whether the position is in a preset side area range.
In the embodiment of the present invention, the determining unit 20 determines whether the pressed area is a side edge in an ACTION _ DOWN event of a displatcouche (the displatcouche is to handle touch event distribution, and an event (in most cases) is started from the displatcouche of Activity), and marks the pressed area.
Illustratively, as shown in fig. 4, in combination with the example of the first embodiment, it is assumed that the area pressed by the user is located at a point C on the current page, the point C is marked, where marking the point C may be recording position coordinates of the point C, and determining, according to the position coordinates of the point C, a position of the point C relative to the current page, and determining whether the point C is located in the area B.
As another embodiment of the present invention, the mobile unit 30 includes a determination module and a moving module.
And the determining module is used for determining whether the current moving direction is transverse movement or not according to the sliding operation if the current moving direction is transverse movement.
And the moving module is used for moving the current page along with the transverse direction if the current page moves along with the transverse direction.
In an embodiment of the invention, the lateral movement is horizontal left or right.
In the embodiment of the invention, the current page moves along with the horizontal direction, specifically, an offset value is set for setTranslationX called by a parent container of ContentView, so that the current page moves along with the horizontal direction.
When the determining unit 20 determines that the current pressing area of the user is a preset side area and the determining module determines that the moving direction of the current pressing area is horizontal movement, the moving module calls a setTranslationX to a parent container of ContentView in real time to set an offset value, so that the current page moves horizontally, the user can sense that the current page moves along with own sliding operation in real time, and the sensory experience of the user using the application program is improved.
As an embodiment of the present invention, the page ending unit 40 is specifically configured to: and when the displacement of the current page movement is detected to meet a preset threshold value, ending the current page.
The preset threshold may be that the displacement of the current page movement exceeds half or three-quarters of the lateral width of the current page, and may be specifically set according to an actual situation.
As another embodiment of the present invention, the page ending unit 40 is specifically configured to: and when the fact that the moving final speed of the current page meets a preset threshold value is detected, ending the current page.
As another embodiment of the present invention, the page ending unit 40 is further specifically configured to: and when detecting that the displacement and the final speed of the current page movement both meet the preset threshold value, ending the current page. Thus, whether the current page needs to be ended or not can be more accurately judged.
As a preferred embodiment of the present invention, the page ending unit 40 is specifically configured to: and when detecting that the displacement or the final speed of the current page movement meets a preset page ending condition, converting the current page into a layer in a transparent state.
In the embodiment of the present invention, when it is detected that the displacement or the final speed of the current page movement meets the preset page ending condition, a class object of a transparent conversion callback class is obtained according to the Activity object, then a Method object is obtained through a get cleared Method ("get Activity operations"), the current page is converted into a layer in a transparent state, and the background of the current page is removed. At this time, the Activity of the lower layer (Activity is an interactive interface which is full of the whole window or suspended on other windows) can be seen through, and the user can see the page at the lower layer, that is, the page at the upper layer is finished at this time.
As a preferred embodiment of the present invention, the step S104 specifically includes: and when detecting that the displacement or the final speed of the current page movement meets a preset page ending condition, converting the current page into a layer in a transparent state based on a reflection calling method.
It should be noted that, when using the method of this embodiment, android needs to be preset under SDK21(android5.0), because below SDK21(android5.0), the reflection call method can only convert a window converted from opaque to transparent, but cannot convert an originally opaque window to transparent.
The implementation of the page returning function provided by the above embodiment can be opened in a method form for calling by an external class.
Specifically, BaseActivity may be created within the project design, and then a tool class may be invoked to implement the page return function described above.
And each interface Activity inherits the BaseActivity, and inherits the page returning function by default.
In addition, if the page is controlled whether to inherit the page return function, the flexible control of the transmission value of the parent class method can be called.
The embodiment of the invention also provides a computer device, which comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the page returning method.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the processor is enabled to execute the steps of the page returning method.
Illustratively, a computer program can be partitioned into one or more modules, which are stored in memory and executed by a processor to implement the present invention. One or more of the modules may be a sequence of computer program instruction segments for describing the execution of a computer program in a computer device that is capable of performing certain functions. For example, the computer program may be divided into the steps of the page return method provided by the various method embodiments described above and executed by a processor.
Those skilled in the art will appreciate that the above description of a computer apparatus is by way of example only and is not intended to be limiting of computer apparatus, and that the apparatus may include more or less components than those described, or some of the components may be combined, or different components may be included, such as input output devices, network access devices, buses, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like, which is the control center of the computer apparatus and connects the various parts of the overall user terminal using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The modules/units integrated by the computer device may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.