WO2023035942A1 - 一种显示用户界面的方法及终端设备 - Google Patents

一种显示用户界面的方法及终端设备 Download PDF

Info

Publication number
WO2023035942A1
WO2023035942A1 PCT/CN2022/114450 CN2022114450W WO2023035942A1 WO 2023035942 A1 WO2023035942 A1 WO 2023035942A1 CN 2022114450 W CN2022114450 W CN 2022114450W WO 2023035942 A1 WO2023035942 A1 WO 2023035942A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
user interface
parsing
target list
displayed
Prior art date
Application number
PCT/CN2022/114450
Other languages
English (en)
French (fr)
Inventor
谢信奇
张泽宇
Original Assignee
北京字节跳动网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Publication of WO2023035942A1 publication Critical patent/WO2023035942A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Definitions

  • the present disclosure relates to the field of display technologies, and in particular, to a method for displaying a user interface and a terminal device.
  • UI User Interface
  • multimedia resources such as videos often need to be displayed in the form of a list, so that the user can select the multimedia information to be played.
  • the original data of the table items in the list is generally data in Json format downloaded from the server. After the terminal device obtains the original data of the table items in the list, it needs to parse all the original data of the table items into corresponding data objects locally on the terminal device, and After parsing the original data of all table items, the user interface is rendered and displayed according to the data object obtained by parsing the original data of the table items.
  • the user interface containing the list can only be output after the original data of all the items in the list are parsed, so the delay in outputting the user interface will increase with the number of items in the list in the user interface. However, when there are many items in the list in the user interface, the delay in outputting the user interface will be longer, which will affect the user experience.
  • the present disclosure provides a method for displaying a user interface and a terminal device, which are used to solve the problem of a longer delay in outputting the user interface when there are many items in the list in the user interface.
  • an embodiment of the present disclosure provides a method for displaying a user interface, which is applied to a terminal device, and the method includes:
  • the target quantity is the number of entries in the target list displayed by the terminal device in the initial state when the terminal device displays the user interface to be displayed;
  • An initial user interface is generated and displayed based on the first parsing result.
  • the method further includes:
  • Parsing the remaining original data to obtain a second parsing result includes the original entries of the target list not displayed by the terminal device in the initial state when the terminal device displays the user interface to be displayed data;
  • the determination of the target quantity includes:
  • the number of targets is determined according to the position information of the view control of the target list, the item size of the target list, and the screen properties of the terminal device.
  • the sequential parsing of the original data of the target number of items in the target list according to the arrangement order of the items in the target list includes:
  • the first type adapter is used to read the target number of pieces of data to be parsed for parsing when the incoming data to be parsed is data that implements the first data interface, and skip the following The data to be parsed is parsed.
  • the method further includes:
  • An identifier for identifying that there is unparsed original data after the first parsing result is added to the first parsing result.
  • the parsing of the remaining original data includes:
  • the incoming data to be parsed is data that implements the second data interface
  • the to-be-parsed data according to the first parsing result Data to determine the data to be parsed belonging to the remaining original data, and analyze the data to be parsed belonging to the remaining raw data based on a preset parsing method to obtain the second parsing result.
  • the analyzing the data to be analyzed belonging to the remaining original data based on a preset analysis method, and obtaining the second analysis result includes:
  • the generating and displaying the user interface to be displayed based on the first parsing result and the second parsing result includes:
  • an embodiment of the present disclosure provides a terminal device, including:
  • An acquisition unit configured to acquire raw data of each item of the target list in the user interface to be displayed
  • a processing unit configured to determine a target number, where the target number is the number of entries in the target list displayed by the terminal device in an initial state when the terminal device displays the user interface to be displayed;
  • a parsing unit configured to sequentially parse the original data of the target number of entries in the target list according to the order in which the items in the target list are arranged, and obtain a first parsing result
  • a display unit configured to generate and display an initial user interface based on the first parsing result.
  • the parsing unit is further configured to parse the remaining original data to obtain a second parsing result after generating and displaying the initial user interface based on the first parsing result; the remaining raw data includes displaying the user interface to be displayed through the terminal device interface, the original data of the entry of the target list not displayed by the terminal device in the initial state;
  • the display unit is further configured to generate and display the user interface to be displayed based on the first parsing result and the second parsing result.
  • the processing unit is specifically configured to acquire the position information of the view control of the target list, the item size of the target list, and the screen properties of the terminal device;
  • the number of targets is determined according to the position information of the view control of the target list, the item size of the target list, and the screen properties of the terminal device.
  • the parsing unit is specifically configured to enable the original data of each entry in the target list to implement the first data interface, and register the first type of adapter into the Gson object ;
  • the first type adapter is used to read the target number of pieces of data to be parsed for parsing when the incoming data to be parsed is data that implements the first data interface, and skip the following The data to be parsed is parsed.
  • the parsing unit is further configured to add an identifier for identifying unparsed raw data after the first parsing result to the first parsing result .
  • the parsing unit is specifically configured to enable the original data of each entry in the target list to implement a second data interface; after the first parsing result is determined, there is If the original data has not been parsed, and the incoming data to be parsed is the data that implements the second data interface, determine the remaining raw data from the data to be parsed according to the first parsing result Parse the data, and analyze the data to be parsed belonging to the remaining original data based on a preset parsing method to obtain the second parsing result.
  • the parsing unit is specifically configured to inject an asynchronous parsing task into a second-type adapter built into the Gson object; parse the remaining primitives through the second-type adapter Data to be parsed; calling the asynchronous parsing task to obtain the second parsing result.
  • the display unit is specifically configured to splice the first analysis result and the second analysis result to obtain a splicing result; generate the splicing result according to the splicing result.
  • an embodiment of the present disclosure provides an electronic device, including: a memory and a processor, the memory is used to store a computer program; the processor is used to enable the electronic device to implement any of the above-mentioned The method for displaying a user interface described in the implementation manner.
  • an embodiment of the present disclosure provides a computer-readable storage medium.
  • the computing device implements the method for displaying a user interface described in any one of the foregoing implementation manners.
  • the embodiments of the present disclosure provide a computer program product, which, when the computer program product is run on a computer, enables the computer to implement the method for displaying a user interface described in any one of the foregoing implementation manners.
  • the method for displaying a user interface After obtaining the original data of each entry including the target list in the user interface to be displayed, first determine that when the user interface to be displayed is displayed by the terminal device, in the initial state The number of entries in the target list displayed by the terminal device, and then only parse the raw data of the target number to obtain a first parsing result, and then generate and display an initial user interface based on the first parsing result.
  • the embodiments of the present disclosure can generate and display the initial user interface after parsing the original data of the entries displayed by the terminal device in the initial state, compared to displaying the user interface after parsing the raw data of all entries interface, the embodiments of the present disclosure can shorten the delay in displaying the user interface to the user when there are many items in the list, and improve user experience.
  • FIG. 1 is one of the flowcharts of steps of a method for displaying a user interface provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic diagram of an initial state provided by an embodiment of the present disclosure
  • FIG. 3 is the second flowchart of steps of the method for displaying a user interface provided by an embodiment of the present disclosure
  • FIG. 4 is the third flowchart of steps of the method for displaying a user interface provided by an embodiment of the present disclosure
  • FIG. 5 is the fifth flowchart of steps of a method for displaying a user interface provided by an embodiment of the present disclosure
  • FIG. 6 is a schematic structural diagram of a terminal device provided by an embodiment of the present disclosure.
  • FIG. 7 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present disclosure.
  • words such as “exemplary” or “for example” are used as examples, illustrations or illustrations. Any embodiment or design described as “exemplary” or “for example” in the embodiments of the present disclosure shall not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as “exemplary” or “such as” is intended to present related concepts in a concrete manner.
  • the meaning of "plurality” refers to two or more.
  • An embodiment of the present disclosure provides a method for displaying a user interface applied to a terminal device. Referring to FIG. 1, the method includes the following steps:
  • the manner of obtaining the original data of each entry of the target list may include: sending request information for requesting display data of the user interface to be displayed to the server, and receiving the user interface to be displayed sent by the server
  • the display data of the interface is to extract the original data of each entry of the target list from the display data of the user interface to be displayed.
  • each entry of the target list corresponds to a unique piece of original data
  • each piece of original data also uniquely corresponds to an entry of the target list .
  • the original data of the entry of the target list may include data in Json (JavaScript Object Notation) format. This disclosure is not limited in this regard.
  • the target number is the number of entries in the target list displayed by the terminal device in an initial state when the terminal device displays the user interface to be displayed.
  • the initial state in the embodiments of the present disclosure may refer to a state before the user switches the display content on the screen of the terminal device when the user interface to be displayed is displayed through the terminal device.
  • the items of the target list 21 in the user interface to be displayed include: item 1, item 2, item 3, item 4, and item 5, and the terminal device displays the
  • the target list 21 displayed by the terminal device in the initial state includes three entries, namely: entry 1, entry 2, and entry 3; the terminal device does not display
  • the obtained target list 21 includes two items, which are respectively: item 4 and item 5, so it can be determined that the number of targets is 3.
  • the number of entries displayed by the terminal device in the initial state must be less than or equal to the total number of entries in the target list, and when the number of targets is equal to the total number of entries in the target list, the terminal device in the initial state can display All the items in the target list are displayed, and the target list has fewer items, and it will not take a long time to parse the original data of all the items in the target list.
  • the original data is analyzed, and the user interface is displayed according to the analysis result.
  • the first parsing result is obtained by parsing the raw data of the previous target number of entries in the target list.
  • the number of targets is 3, and the total number of original data in the original data set is 5, so the original data of table item 1, table item 2, and table item 3 are analyzed to obtain the first analysis result .
  • the first analysis result is sent to the user interface layer, so that the user interface renders the initial user interface according to the first analysis result, and outputs the initial user interface.
  • the implementation of sending the first parsing result to the user interface layer may include:
  • the first parsing result is sent to the user interface layer by using a visual object (Observable) in the RxJava library.
  • the first analysis result can also be sent to the user interface layer in other ways, for example: sending the first analysis result to the user interface layer through Kotlin Flow, Jetpack Live Data, etc., the present disclosure
  • the embodiment does not limit this, and it shall prevail that the first parsing result can be sent to the user interface layer.
  • the method for displaying a user interface After obtaining the original data of each entry including the target list in the user interface to be displayed, first determine that when the user interface to be displayed is displayed by the terminal device, in the initial state The number of entries in the target list displayed by the terminal device, and then only parse the raw data of the target number to obtain a first parsing result, and then generate and display an initial user interface based on the first parsing result.
  • the embodiments of the present disclosure can generate and display the initial user interface after parsing the original data of the entries displayed by the terminal device in the initial state, compared to displaying the user interface after parsing the raw data of all entries interface, the embodiments of the present disclosure can shorten the delay in displaying the user interface to the user when there are many items in the list, and improve user experience.
  • the embodiment of the present disclosure provides another method for displaying a user interface.
  • the method for displaying a user interface includes the following steps:
  • the original data of each entry in the target list may be acquired by sending request information to the server.
  • the position information of the view control of the target list in the embodiment of the present disclosure specifically refers to the position of the view control (view) used to display the target list in the user interface to be displayed.
  • the screen attributes may specifically include information such as screen resolution and screen size of the terminal device.
  • the sizes of the items in the target list may all be the same or different.
  • the sizes of the items in the target list are different Next, when obtaining the item size of the target list, obtain the size of each item.
  • S33 Determine the number of targets according to the position information of the view control of the target list, the item size of the target list, and the screen properties of the terminal device.
  • the implementation of determining the number of targets may include the following steps a and step b:
  • Step a according to the position information of the view control of the target list and the screen properties of the terminal device, determine the target displayed by the terminal device in the initial state when the user interface to be displayed is displayed by the terminal device The list view control dimensions.
  • Step b Calculate the number of targets according to the view control size of the target list and the item size of the target list displayed by the terminal device in an initial state.
  • the view control size of the target list displayed by the terminal device is 15 twips (twips), and the size of each entry in the target list is the same and is 5 twips, then it can be determined that in the initial state
  • the target list displayed by the terminal device described below includes 3 entries, so it can be determined that the number of targets is 3.
  • the size of the view control of the target list displayed by the terminal device is 20 twips
  • the size of the first entry in the target list is 5 twips
  • the second list of the target list The size of the item is 6 twips
  • the size of the third entry in the target list is 5 twips
  • the size of the fourth entry in the target list and the entries after the fourth entry are all 7 twips
  • the implementation of the above step S34 (according to the arrangement order of the entries of the target list, sequentially parse the original data of the target number of entries of the target list) Can include:
  • the first type adapter is used to read the target number of pieces of data to be parsed for parsing when the incoming data to be parsed is data that implements the first data interface, and skip the following The data to be parsed is parsed.
  • the principle of the above embodiment includes: after the original data of each entry of the target list realizes the first data interface, the original data of each entry of the target list is the data to be parsed to realize the first data interface, and the first type
  • the adapter is configured to use a custom method (read the target number of data to be parsed for parsing, and skip parsing the subsequent data to be parsed) to parse the data to be parsed that implements the first data interface , so when the data to be parsed is passed in (it may be the original data of each entry in the target list that implements the first data interface, or it may be other data to be parsed), the parser will first determine whether the incoming data to be parsed is Realized the first data interface; If realized the first data interface, then use self-defining method (read the described data to be parsed of described target quantity bar to analyze by first type adapter, and skip to follow-up described pending parsing the data to be parsed) parsing the incoming data to be parsed, so as to realize that
  • the first type adapter can be registered in the Gson object through the registerTypeAdapter() method provided by Gson.
  • the first data interface and the first type adapter (Type Adapter) for parsing the data to be parsed that implements the first data interface can be pre-defined, and the first type adapter is injected and registered in the Gson object in advance .
  • the first type adapter is injected and registered in the Gson object in advance .
  • the internal implementation of the terminal device parses the target quantity sequentially according to the order in which the items in the target list are arranged.
  • the process of the original data of the table items of the target list includes performing the following steps after registering the first type adapter to the Gson object and making the original data of each table item of the target list realize the first data interface:
  • step S43 if the data to be analyzed implements the first data interface, the following step S44 is performed; and if the data to be analyzed does not implement the first data interface, the following step S45 is performed.
  • the method for displaying a user interface further includes:
  • An identifier for identifying that there is unparsed original data after the first parsing result is added to the first parsing result.
  • the value of the field of the last parsing object in the first parsing result used to indicate whether there is unparsed original data after the last parsing object can be set to "yes" to identify the first parsing result There is said raw data unparsed afterwards.
  • step S34 (according to the arrangement order of the items in the target list, sequentially analyze the original data of the target number of items in the target list, and obtain the first parsing result), the display provided by the embodiment of the present disclosure
  • the user interface method continues to execute the following step S35.
  • the remaining original data includes original data of entries in the target list that are not displayed by the terminal device in an initial state when the terminal device displays the user interface to be displayed.
  • the remaining original data includes: original data of entry 4 and original data of entry 5 .
  • the target list includes 10 entries, and each entry corresponds to a piece of original data.
  • the original data of the target number of entries in the target list are sequentially parsed. For data, after analyzing the original data of entry 1 to entry 3, the remaining original data is the original data of entry 4 to entry 10.
  • the parsing of the remaining original data includes:
  • the incoming data to be parsed is data that implements the second data interface
  • the to-be-parsed data according to the first parsing result Data to determine the data to be parsed belonging to the remaining original data, and analyze the data to be parsed belonging to the remaining raw data based on a preset parsing method to obtain the second parsing result.
  • the analyzing the data to be analyzed belonging to the remaining original data based on the preset analysis method, and obtaining the second analysis result includes:
  • the second data interface may be preset, and if the second data interface is implemented, it indicates that the data type of the second data interface has original data that needs to be parsed. After obtaining the original data of each entry in the target list, write the original data of each entry in the target list into the object of the second data interface, so that the original data of each entry in the target list realizes the second data interface.
  • the terminal device when the original data is data in Json format and a second data interface is defined, and the first parsing result is sent to the user interface layer as a visual object in RxJava for display, the terminal device internal
  • the process of implementing the parsing of the remaining raw data includes:
  • a creation task may be defined in the application program to which the user interface to be displayed belongs, and when the application program to which the user interface to be displayed belongs is started, a Gson instance for parsing the remaining original data is created.
  • step S54 If it is determined that there is unparsed raw data after the first parsing result and the second data interface is implemented, perform the following step S54, and if it is determined that there is no unparsed said original data after the first parsing result If the original data and/or the second data interface is not implemented, the method flow of the embodiment of the present disclosure ends.
  • S54 Intercept the data to be parsed that implements the second data interface through the first function, and parse the data to be parsed that implements the second data interface using a custom analysis method.
  • the custom parsing method includes: obtaining the incoming data to be parsed, injecting an asynchronous parsing task Callable into the incoming data object, using the built-in Gson object to completely deserialize the incoming data to be parsed and return complete list. After the custom parsing method returns, obtain the asynchronous parsing task Callable in the processed data object, and use the Observable.fromCallable() method to call asynchronously to generate a new visualization object.
  • step S36 (generating and displaying the user interface to be displayed based on the first parsing result and the second parsing result) may include one of the following steps a stepc:
  • Step a splicing the first parsing result and the second parsing result to obtain a splicing result.
  • the visualization object obtained in step S34 and the visualization object obtained in step S35 are merged into one visualization object.
  • Step b Generate the user interface to be displayed according to the splicing result.
  • the embodiment of the present disclosure does not limit the implementation manner of sending the splicing result to the user interface layer, and the implementation manner of sending the splicing result to the user interface layer may be the same as the implementation manner of sending the first parsing result to the user interface layer.
  • Step c updating and displaying the initial user interface as the user interface to be displayed.
  • the remaining original data is further analyzed to obtain the second analysis result, and the user interface to be displayed is generated and displayed based on the first analysis result and the second analysis result, so the above implementation
  • This example can further ensure the normal display of the user interface to be displayed, and avoid the problem that the user cannot browse normally when browsing down the target list.
  • the embodiment of the present disclosure also provides a terminal device.
  • the embodiment of the terminal device corresponds to the foregoing method embodiment.
  • the details in the above will be described one by one, but it should be clear that the terminal device in this embodiment can correspondingly implement all the content in the foregoing method embodiments.
  • FIG. 6 is a schematic structural diagram of the terminal device. As shown in FIG. 6 , the terminal device 600 includes:
  • An acquisition unit 61 configured to acquire the original data of each entry of the target list in the user interface to be displayed;
  • the processing unit 62 is configured to determine a target number, where the target number is the number of entries in the target list displayed by the terminal device in an initial state when the terminal device displays the user interface to be displayed;
  • the parsing unit 63 is configured to sequentially parse the original data of the target number of entries in the target list according to the order in which the entries in the target list are arranged, and obtain a first parsing result;
  • the display unit 64 is configured to generate and display an initial user interface based on the first parsing result.
  • the parsing unit 63 is further configured to parse the remaining original data after generating and displaying the initial user interface based on the first parsing result to obtain a second parsing result;
  • the remaining raw data includes raw data of items in the target list that are not displayed by the terminal device in the initial state when the user interface to be displayed is displayed by the terminal device;
  • the display unit 64 is also configured to The first analysis result and the second analysis result generate and display the user interface to be displayed.
  • the processing unit 62 may be configured to acquire the position information of the view control of the target list, the item size of the target list, and the screen properties of the terminal device ; Determine the number of targets according to the position information of the view control of the target list, the item size of the target list, and the screen properties of the terminal device.
  • the parsing unit 63 may be configured to enable the original data of each entry in the target list to implement the first data interface, and register the first type of adapter to the Gson object In; wherein, the first type of adapter is used to read the target number of pieces of data to be parsed for parsing when the incoming data to be parsed is data that implements the first data interface, and skip Parse the subsequent data to be parsed.
  • the parsing unit 63 may also be configured to add, to the first parsing result, the raw data used to identify that there is unparsed after the first parsing result logo.
  • the parsing unit 63 may be configured to enable the original data of each entry in the target list to implement a second data interface; after determining the first parsing result When there is unparsed raw data, and the incoming data to be parsed is the data that implements the second data interface, determine from the data to be parsed which belongs to the remaining raw data according to the first parsing result data to be parsed, and analyze the data to be parsed belonging to the remaining original data based on a preset parsing method to obtain the second parsing result.
  • the parsing unit 63 can be used to inject an asynchronous parsing task into the second type adapter built into the Gson object; Data to be parsed of the original data; calling the asynchronous parsing task to obtain the second parsing result.
  • the display unit 64 may be configured to splice the first analysis result and the second analysis result to obtain a splicing result; generate the splicing result according to the splicing result. Describe the user interface to be displayed; update and display the initial user interface as the user interface to be displayed.
  • the terminal device provided in this embodiment can execute the method for displaying a user interface provided in the above method embodiment, and its implementation principle and technical effect are similar, and will not be repeated here.
  • FIG. 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure.
  • the electronic device provided by this embodiment includes: a memory 701 and a processor 702, the memory 701 is used to store computer programs; the processing The device 702 is configured to execute the method for displaying a user interface provided in the above embodiments when executing a computer program.
  • an embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computing device implements the above-mentioned embodiment Provides methods for displaying the user interface.
  • an embodiment of the present disclosure further provides a computer program product, which enables the computing device to implement the method for displaying a user interface provided in the foregoing embodiments when the computer program product is run on a computer.
  • the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Accordingly, the present disclosure can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therein.
  • the processor can be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • Memory may include non-permanent storage in computer readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read only memory (ROM) or flash RAM.
  • RAM random access memory
  • ROM read only memory
  • flash RAM flash random access memory
  • Computer-readable media includes both volatile and non-volatile, removable and non-removable storage media.
  • the storage medium may implement information storage by any method or technology, and the information may be computer-readable instructions, data structures, program modules, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, A magnetic tape cartridge, disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer readable media excludes transitory computer readable media, such as modulated data signals and carrier waves.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

本公开实施例提供了一种显示用户界面的方法及终端设备,涉及显示技术领域。该方法包括:获取待显示用户界面中的目标列表的各个表项的原始数据;确定目标数量,所述目标数量为通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量;按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果;基于所述第一解析结果生成并显示初始用户界面。本公开实施例用于缩短输出用户界面的延迟。

Description

一种显示用户界面的方法及终端设备
本申请要求于2021年9月10日提交中国国家知识产权局、申请号为202111064190.X、申请名称为“一种显示用户界面的方法及终端设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本公开涉及显示技术领域,尤其涉及一种显示用户界面的方法及终端设备。
背景技术
目前,终端设备上常常需要输出包含列表的用户界面(User Interface,UI)。例如:在一些应用程序的用户界面中常常需要将诸如视频等多媒体资源以列表的形式展示出来,以供用户选择想要播放的多媒体信息。
列表的表项的原始数据一般为从服务器下载的Json格式的数据,终端设备得到列表的表项的原始数据后,需要在终端设备本地将表项的原始数据全部解析为相应的数据对象,并在解析完所有表项的原始数据后,根据解析表项的原始数据得到的数据对象渲染用户界面并显示。如上所述,现有技术中只有将列表的所有表项的原始数据全部解析完后,才能输出包含列表的用户界面,因此输出用户界面的延迟会随着用户界面中的列表的表项的增多而增加,当用户界面中的列表的表项较多时,输出用户界面的延迟会较长,影响用户的使用体验。
发明内容
有鉴于此,本公开提供了一种显示用户界面的方法及终端设备,用于解决当用户界面中的列表的表项较多时,输出用户界面的延迟会较长的问题。
为了实现上述目的,本公开实施例提供技术方案如下:
第一方面,本公开的实施例提供了一种显示用户界面的方法,应用于终端设备,所述方法包括:
获取待显示用户界面中的目标列表的各个表项的原始数据;
确定目标数量,所述目标数量为通过所述终端设备显示所述待显示用户界 面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量;
按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果;
基于所述第一解析结果生成并显示初始用户界面。
作为本公开实施例一种可选的实施方式,在基于所述第一解析结果生成并显示初始用户界面之后,所述方法还包括:
解析剩余原始数据,获取第二解析结果;所述剩余原始数据包括通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备未显示出的所述目标列表的表项的原始数据;
基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面。
作为本公开实施例一种可选的实施方式,所述确定目标数量,包括:
获取所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性;
根据所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性,确定所述目标数量。
作为本公开实施例一种可选的实施方式,所述按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,包括:
使所述目标列表的各个表项的原始数据实现第一数据接口,并将第一类型适配器注册到Gson对象中;
其中,所述第一类型适配器用于在传入的待解析数据为实现了所述第一数据接口的数据时,读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析。
作为本公开实施例一种可选的实施方式,所述方法还包括:
在所述第一解析结果中添加用于标识所述第一解析结果之后存在未解析的所述原始数据的标识。
作为本公开实施例一种可选的实施方式,所述解析剩余原始数据,包括:
使所述目标列表的各个表项的原始数据实现第二数据接口;
在确定所述第一解析结果之后存在未解析的所述原始数据,且传入的待解析数据为实现了所述第二数据接口的数据时,根据所述第一解析结果从所述待解析数据确定属于所述剩余原始数据的待解析数据,并基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果。
作为本公开实施例一种可选的实施方式,所述基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果,包括:
向Gson对象中内置的第二类型适配器注入异步解析任务;
通过所述第二类型适配器解析属于所述剩余原始数据的待解析数据;
调用所述异步解析任务获取所述第二解析结果。
作为本公开实施例一种可选的实施方式,所述基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面,包括:
对所述第一解析结果和所述第二解析结果进行拼接,获取拼接结果;
根据所述拼接结果生成所述待显示用户界面;
将所述初始用户界面更新显示为所述待显示用户界面。
第二方面,本公开的实施例提供了一种终端设备,包括:
获取单元,用于获取待显示用户界面中的目标列表的各个表项的原始数据;
处理单元,用于确定目标数量,所述目标数量为通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量;
解析单元,用于按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果;
显示单元,用于基于所述第一解析结果生成并显示初始用户界面。
作为本公开实施例一种可选的实施方式,
所述解析单元,还用于在基于所述第一解析结果生成并显示初始用户界面之后,解析剩余原始数据,获取第二解析结果;所述剩余原始数据包括通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备未显示出的所 述目标列表的表项的原始数据;
所述显示单元,还用于基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面。
作为本公开实施例一种可选的实施方式,所述处理单元,具体用于获取所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性;根据所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性,确定所述目标数量。
作为本公开实施例一种可选的实施方式,所述解析单元,具体用于使所述目标列表的各个表项的原始数据实现第一数据接口,并将第一类型适配器注册到Gson对象中;
其中,所述第一类型适配器用于在传入的待解析数据为实现了所述第一数据接口的数据时,读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析。
作为本公开实施例一种可选的实施方式,所述解析单元,还用于在所述第一解析结果中添加用于标识所述第一解析结果之后存在未解析的所述原始数据的标识。
作为本公开实施例一种可选的实施方式,所述解析单元,具体用于在使所述目标列表的各个表项的原始数据实现第二数据接口;在确定所述第一解析结果之后存在未解析的所述原始数据,且传入的待解析数据为实现了所述第二数据接口的数据时,根据所述第一解析结果从所述待解析数据确定属于所述剩余原始数据的待解析数据,并基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果。
作为本公开实施例一种可选的实施方式,所述解析单元,具体用于在向Gson对象中内置的第二类型适配器注入异步解析任务;通过所述第二类型适配器解析属于所述剩余原始数据的待解析数据;调用所述异步解析任务获取所述第二解析结果。
作为本公开实施例一种可选的实施方式,所述显示单元,具体用于对所述 第一解析结果和所述第二解析结果进行拼接,获取拼接结果;根据所述拼接结果生成所述待显示用户界面;将所述初始用户界面更新显示为所述待显示用户界面。
第三方面,本公开实施例提供一种电子设备,包括:存储器和处理器,所述存储器用于存储计算机程序;所述处理器用于在执行计算机程序时,使得所述电子设备实现上述任一实施方式所述的显示用户界面的方法。
第四方面,本公开实施例提供一种计算机可读存储介质,当所述计算机程序被计算设备执行时,使得所述计算设备实现上述任一实施方式所述的显示用户界面的方法。
第五方面,本公开实施例提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机实现上述任一实施方式所述的显示用户界面的方法。
本公开实施例提供的显示用户界面的方法在获取包括待显示用户界面中的目标列表的各个表项的原始数据后,先确定通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量,然后仅解析目标数量条原始数据并获取第一解析结果,再基于所述第一解析结果生成并显示初始用户界面。由于本公开实施例在解析完初始状态下所述终端设备显示出的表项的原始数据后,即可生成并显示初始用户界面,因此相比于解析完所有表项的原始数据后再显示用户界面,本公开实施例可以在列表的表项较多时,缩短向用户展示用户界面的延迟,提升用户体验。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本公开实施例提供的显示用户界面的方法的步骤流程图之一;
图2为本公开实施例提供的初始状态示意图;
图3为本公开实施例提供的显示用户界面的方法的步骤流程图之二;
图4为本公开实施例提供的显示用户界面的方法的步骤流程图之三;
图5为本公开实施例提供的显示用户界面的方法的步骤流程图之五;
图6为本公开实施例提供的终端设备的结构示意示意图;
图7为本公开实施例提供的电子设备的硬件结构示意图。
具体实施方式
为了能够更清楚地理解本公开的上述目的、特征和优点,下面将对本公开的方案进行进一步描述。需要说明的是,在不冲突的情况下,本公开的实施例及实施例中的特征可以相互组合。
在下面的描述中阐述了很多具体细节以便于充分理解本公开,但本公开还可以采用其他不同于在此描述的方式来实施;显然,说明书中的实施例只是本公开的一部分实施例,而不是全部的实施例。
在本公开实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本公开实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。此外,在本公开实施例的描述中,除非另有说明,“多个”的含义是指两个或两个以上。
本公开实施例提供了一种应用于终端设备的显示用户界面的方法,参照图1所示,该方法包括如下步骤:
S11、获取待显示用户界面中的目标列表的各个表项的原始数据。
示例性的,获取所述目标列表的各个表项的原始数据的方式可以包括:向服务器发送用于请求所述待显示用户界面的显示数据的请求信息,并接收服务器发送的所述待显示用户界面的显示数据,从待显示用户界面的显示数据中提取目标列表的各个表项的原始数据。
需要说明的是,本公开实施例中目标列表的表项与原始数据是一一对应的,目标列表的每一个表项唯一对应一条原始数据,每一条原始数据也唯一对应目标列表的一个表项。
示例性的,目标列表的表项的原始数据可以包括Json(JavaScript Object Notation)格式的数据。本公开不对此进行限制。
S12、确定目标数量。
其中,所述目标数量为通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量。
具体的,本公开实施例中的初始状态可以指:通过终端设备显示出待显示用户界面时,用户对终端设备的屏幕中的显示内容进行切换前的状态。
示例性的,参照图2所示,待显示用户界面中的目标列表21的表项包括:表项1、表项2、表项3、表项4以及表项5,通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表21的表项包括三个,分别为:表项1、表项2以及表项3;所述终端设备未显示出的所述目标列表21的表项包括两个,分别为:表项4和表项5,因此可以确定出目标数量为3。
需要说明的是,终端设备初始状态下显示出的表项数量必然小于或等于目标列表的表项的总数,且当目标数量等于目标列表的表项的总数时,初始状态下终端设备即可将目标列表的所有表项显示出来,目标列表的表项较少,解析完目标列表的所有表项的原始数据也不会耗费较长时间,因此这种情况下可以直接对原始数据集合中的全部原始数据进行解析,并根据解析结果显示用户界面即可。
S13、按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果。
即,解析目标列表的表项中的前目标数量个表项的原始数据获取第一解析结果。
承图2所示实例,目标数量为3,原始数据集合中的原始数据的总数为5, 因此对表项1、表项2、表项3的原始数据进行解析,获取所述第一解析结果。
S14、基于所述第一解析结果生成并显示初始用户界面。
即,将第一解析结果发至用户界面层,以便于用户界面根据所述第一解析结果渲染所述初始用户界面,并输出所述初始用户界面。
可选的,将第一解析结果发至用户界面层的实现方式可以包括:
使用RxJava库中的可视化对象(Observable)将所述第一解析结果发至用户界面层。
需要说明的是,本公开实施例中还可以通过其它方式将第一解析结果发至用户界面层,例如:通过Kotlin Flow、Jetpack Live Data等方式将第一解析结果发至用户界面层,本公开实施例对此不做限定,以能够将第一解析结果发送至用户界面层为准。
本公开实施例提供的显示用户界面的方法在获取包括待显示用户界面中的目标列表的各个表项的原始数据后,先确定通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量,然后仅解析目标数量条原始数据并获取第一解析结果,再基于所述第一解析结果生成并显示初始用户界面。由于本公开实施例在解析完初始状态下所述终端设备显示出的表项的原始数据后,即可生成并显示初始用户界面,因此相比于解析完所有表项的原始数据后再显示用户界面,本公开实施例可以在列表的表项较多时,缩短向用户展示用户界面的延迟,提升用户体验。
本公开实施例提供了另一种显示用户界面的方法,参照图3所示,该显示用户界面的方法包括如下步骤:
S31、获取待显示用户界面中的目标列表的各个表项的原始数据。
同样,可以通过向服务器发送请求信息以获取所述目标列表的各个表项的原始数据。
S32、获取所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性(Display Metrics)。
本公开实施例中的目标列表的视图控件的位置信息具体是指用于显示目 标列表的视图控件(view)在待显示用户界面中的位置。
本公开实施例中屏幕属性具体可以包括终端设备的屏幕分辨率、屏幕尺寸等信息。
需要说明的是,目标列表的各个表项的尺寸可以全部相同,也可以为各不相同。在目标列表的各个表项的尺寸全部相同的情况下,获取目标列表的表项尺寸时,只需要获取其中一个表项的尺寸即可,在目标列表的各个表项的尺寸各不相同的情况下,获取目标列表的表项尺寸时,获取每一个表项的尺寸。
S33、根据所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性,确定所述目标数量。
在一些实施例中,根据所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性,确定所述目标数量的实现方式可以包括如下步骤a和步骤b:
步骤a、根据所述目标列表的视图控件的位置信息和所述终端设备的屏幕属性,确定通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的视图控件尺寸。
步骤b、根据初始状态下所述终端设备显示出的所述目标列表的视图控件尺寸和所述目标列表的表项尺寸,计算所述目标数量。
例如:初始状态下所述终端设备显示出的所述目标列表的视图控件尺寸为15缇(twips),所述目标列表的各个表项的尺寸相同且均为5缇,则可以确定在初始状态下所述终端设备显示出的所述目标列表的表项包括3个,因此可以确定目标数量为3。
再例如:初始状态下所述终端设备显示出的所述目标列表的视图控件尺寸为20缇,所述目标列表的第一个表项的尺寸为5缇,所述目标列表的第二个表项的尺寸为6缇、所述目标列表的第三个表项的尺寸为5缇、所述目标列表的第四个表项以及第四个表项之后的表项的尺寸均为7缇,则可以确定在初始状态下所述终端设备显示出的所述目标列表的表项包括:第一个表项、第二个表项、第三个表项以及第四个表项,因此确定目标数量为4。
S34、按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果。
作为本公开实施例一种可选的实施方式,上述步骤S34(按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据)的实现方式可以包括:
使所述目标列表的各个表项的原始数据实现第一数据接口,并将第一类型适配器注册到Gson对象中。其中,所述第一类型适配器用于在传入的待解析数据为实现了所述第一数据接口的数据时,读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析。
上述实施例的原理包括:使所述目标列表的各个表项的原始数据实现第一数据接口后,目标列表的各个表项的原始数据为实现第一数据接口的待解析数据,而第一类型适配器被配置使用自定义方法(读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析)对实现了第一数据接口的待解析数据进行解析,因此当有待解析数据传入时(可能是实现了第一数据接口的目标列表的各个表项的原始数据,也可能是其它待解析数据),解析器会先判断传入的待解析数据是否实现了第一数据接口;若实现了第一数据接口,则通过第一类型适配器使用自定义方法(读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析)对传入的待解析数据进行解析,从而实现按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,且不影响除所述目标列表的表项的原始数据以外的其它待解析数据的正常解析。
示例性的,可以通过Gson提供的registerTypeAdapter()方法,将第一类型适配器注册到Gson对象中。
具体的,可以预先定义第一数据接口以及用于对实现了所述第一数据接口的待解析数据进行解析的第一类型适配器(Type Adapter),预先将第一类型适配器注入注册到Gson对象中。当开始对待解析数据进行解析时,先判断待解析数据是否实现了所述第一数据接口,若待解析数据实现了所述第一数据接口, 则读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析;而若待解析数据未实现所述第一数据接口,则根据待解析数据所属数据类型的调用相应的类型适配器对待解析数据进行完全解析。
示例性的,参照图4所示,当原始数据为Json格式的数据、并且定义有第一数据接口时,终端设备内部实现按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据的过程包括在将第一类型适配器注册到Gson对象且使所述目标列表的各个表项的原始数据实现第一数据接口后执行如下步骤:
S41、通过调用Gson.fromJson()函数发起对Json格式的待解析数据的解析。
S42、通过getTypeToken()函数获取传入的待解析数据的数据类型。
S43、根据待解析数据的数据类型判断待解析数据是否实现了所述第一数据接口。
在上述步骤S43中,若待解析数据实现了所述第一数据接口,则执行如下步骤S44;而若待解析数据未实现所述第一数据接口,则执行如下步骤S45。
S44、顺序读取目标数量条待解析数据进行解析,获取所述第一解析结果,并跳过对后续的所述待解析数据进行解析。
S45、通过待解析数据的数据类型对应的类型适配器进行解析。
作为本公开实施例一种可选的实施方式,本公开实施例提供的显示用户界面的方法还包括:
在所述第一解析结果中添加用于标识所述第一解析结果之后存在未解析的所述原始数据的标识。
示例性的,可以将第一解析结果中的最后一个解析对象的用于表征最后一个解析对象之后是否存在未解析的原始数据的字段的值设置为“是”,以标识所述第一解析结果之后存在未解析的所述原始数据。
在上述步骤S34(按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果)之后,本公开实施例提供的显示用户界面的方法继续执行如下步骤S35。
S35、解析剩余原始数据,获取第二解析结果。
所述剩余原始数据包括通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备未显示出的所述目标列表的表项的原始数据。
参照图2所示,在图2所示场景中,剩余原始数据包括:表项4原始数据和表项5的原始数据。
示例性的,目标列表包括10个表项,每一个表项对应一条原始数据,在按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据时,解析了表项1至表项3的原始数据,则剩余原始数据为表项4至表项10的原始数据。
作为本公开实施例一种可选的实施方式,所述解析剩余原始数据,包括:
使所述目标列表的各个表项的原始数据实现第二数据接口;
在确定所述第一解析结果之后存在未解析的所述原始数据,且传入的待解析数据为实现了所述第二数据接口的数据时,根据所述第一解析结果从所述待解析数据确定属于所述剩余原始数据的待解析数据,并基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果。
进一步的,所述基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果,包括:
向Gson对象中内置的第二类型适配器注入异步解析任务;
通过所述第二类型适配器解析属于所述剩余原始数据的待解析数据;
调用所述异步解析任务获取所述第二解析结果。
具体的,可以预先设定第二数据接口,若第二数据接口被实现,则表明第二数据接口的数据类型存在需要解析的原始数据。在获取目标列表的各个表项的原始数据后,将目标列表的各个表项的原始数据写入第二数据接口的对象中,以使所述目标列表的各个表项的原始数据实现第二数据接口。
示例性的,参照图5所示,当原始数据为Json格式的数据、定义有第二数据接口时,且第一解析结果以RxJava中的可视化对象发送到用户界面层进行展示时,终端设备内部实现解析剩余原始数据的过程包括:
S51、创建用于解析剩余原始数据的Gson实例。
具体的,可以在待显示用户界面所属应用程序中定义一个创建任务,在待显示用户界面所属应用程序启动时,创建用于解析剩余原始数据的Gson实例。
S52、判断所述第一解析结果之后是否存在未解析的所述原始数据。
S53、是否实现了所述第二数据接口。
若确定所述第一解析结果之后存在未解析的所述原始数据且实现了所述第二数据接口,则执行如下步骤S54,而若确定所述第一解析结果之后不存在未解析的所述原始数据和/或未实现第二数据接口,则结束本公开实施例的方法流程。
S54、通过第一函数拦截实现了第二数据接口的待解析数据,使用自定义解析方法对实现了第二数据接口的待解析数据进行解析。
其中,自定义解析方法包括:获取传入的待解析数据,向传入的数据对象中注入一个异步解析任务Callable,使用内置的Gson对象对传入的待解析数据进行完整的反序列化并返回完整的列表。在自定义解析方法返回后,获取处理后的数据对象中的异步解析任务Callable,并使用Observable.fromCallable()方法异步调用,生成一个新的可视化对象。
S36、基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面。
作为本公开实施例一种可选的实施方式,上述步骤S36(基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面)的实现方式可以包括如下步骤a之步骤c:
步骤a、对所述第一解析结果和所述第二解析结果进行拼接,获取拼接结果。
即,将步骤S34中得到的可视化对象和步骤S35中得到的可视化对象合并为一个可视化对象。
步骤b、根据所述拼接结果生成所述待显示用户界面。
本公开实施例中不限定将拼接结果发至用户界面层的实现方式进行限定, 将拼接结果发至用户界面层的实现方式可以与将第一解析结果发送至用户界面层的实现方式相同。
步骤c、将所述初始用户界面更新显示为所述待显示用户界面。
上述实施例在生成并显示初始用户界面后进一步解析剩余原始数据获取第二解析结果,并基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面,因此上述实施例可以进一步保证待显示用户界面的正常显示,避免用户向下浏览所述目标列表时无法正常浏览的问题。
基于同一发明构思,作为对上述方法的实现,本公开实施例还提供了一种终端设备,该终端设备实施例与前述方法实施例对应,为便于阅读,本实施例不再对前述方法实施例中的细节内容进行逐一赘述,但应当明确,本实施例中的终端设备能够对应实现前述方法实施例中的全部内容。
本公开实施例提供了一种终端设备,图6为该终端设备的结构示意图,如图6所示,该终端设备600包括:
获取单元61,用于获取待显示用户界面中的目标列表的各个表项的原始数据;
处理单元62,用于确定目标数量,所述目标数量为通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量;
解析单元63,用于按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果;以及
显示单元64,用于基于所述第一解析结果生成并显示初始用户界面。
作为本公开实施例一种可选的实施方式,所述解析单元63,还用于在基于所述第一解析结果生成并显示初始用户界面之后,解析剩余原始数据,获取第二解析结果;所述剩余原始数据包括通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备未显示出的所述目标列表的表项的原始数据;所述显示单元64,还用于基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面。
作为本公开实施例一种可选的实施方式,所述处理单元62,可以用于获取所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性;根据所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性,确定所述目标数量。
作为本公开实施例一种可选的实施方式,所述解析单元63,可以用于使所述目标列表的各个表项的原始数据实现第一数据接口,并将第一类型适配器注册到Gson对象中;其中,所述第一类型适配器用于在传入的待解析数据为实现了所述第一数据接口的数据时,读取所述目标数量条所述待解析数据进行解析,并跳过对后续的所述待解析数据进行解析。
作为本公开实施例一种可选的实施方式,所述解析单元63,还可以用于在所述第一解析结果中添加用于标识所述第一解析结果之后存在未解析的所述原始数据的标识。
作为本公开实施例一种可选的实施方式,所述解析单元63,可以用于在使所述目标列表的各个表项的原始数据实现第二数据接口;在确定所述第一解析结果之后存在未解析的所述原始数据,且传入的待解析数据为实现了所述第二数据接口的数据时,根据所述第一解析结果从所述待解析数据确定属于所述剩余原始数据的待解析数据,并基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果。
作为本公开实施例一种可选的实施方式,所述解析单元63,可以用于在向Gson对象中内置的第二类型适配器注入异步解析任务;通过所述第二类型适配器解析属于所述剩余原始数据的待解析数据;调用所述异步解析任务获取所述第二解析结果。
作为本公开实施例一种可选的实施方式,所述显示单元64,可以用于对所述第一解析结果和所述第二解析结果进行拼接,获取拼接结果;根据所述拼接结果生成所述待显示用户界面;将所述初始用户界面更新显示为所述待显示用户界面。
本实施例提供的终端设备可以执行上述方法实施例提供的显示用户界面 的方法,其实现原理与技术效果类似,此处不再赘述。
基于同一发明构思,本公开实施例还提供了一种电子设备。图7为本公开实施例提供的电子设备的结构示意图,如图7所示,本实施例提供的电子设备包括:存储器701和处理器702,所述存储器701用于存储计算机程序;所述处理器702用于在执行计算机程序时执行上述实施例提供的显示用户界面的方法。
基于同一发明构思,本公开实施例还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,当计算机程序被处理器执行时,使得所述计算设备实现上述实施例提供的显示用户界面的方法。
基于同一发明构思,本公开实施例还提供了一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算设备实现上述实施例提供的显示用户界面的方法。
本领域技术人员应明白,本公开的实施例可提供为方法、系统、或计算机程序产品。因此,本公开可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本公开可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质上实施的计算机程序产品的形式。
处理器可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动存储介质。存储介质可以由任何方法或技术来实现信息存储,信息可以是计算机可读指令、 数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。根据本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
最后应说明的是:以上各实施例仅用以说明本公开的技术方案,而非对其限制;尽管参照前述各实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本公开各实施例技术方案的范围。

Claims (12)

  1. 一种显示用户界面的方法,其特征在于,应用于终端设备,所述方法包括:
    获取待显示用户界面中的目标列表的各个表项的原始数据;
    确定目标数量,所述目标数量为通过所述终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量;
    按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,获取第一解析结果;
    基于所述第一解析结果生成并显示初始用户界面。
  2. 根据权利要求1所述的方法,其特征在于,在基于所述第一解析结果生成并显示初始用户界面之后,所述方法还包括:
    解析剩余原始数据,获取第二解析结果;所述剩余原始数据包括通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备未显示出的所述目标列表的表项的原始数据;
    基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面。
  3. 根据权利要求1所述的方法,其特征在于,所述确定目标数量,包括:
    获取所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性;
    根据所述目标列表的视图控件的位置信息、所述目标列表的表项尺寸以及所述终端设备的屏幕属性,确定所述目标数量。
  4. 根据权利要求1所述的方法,其特征在于,所述按照所述目标列表的表项的排列顺序,顺序解析所述目标数量个所述目标列表的表项的原始数据,包括:
    使所述目标列表的各个表项的原始数据实现第一数据接口,并将第一类型适配器注册到Gson对象中;
    其中,所述第一类型适配器用于在传入的待解析数据为实现了所述第一数据接口的数据时,读取所述目标数量条所述待解析数据进行解析,并跳过对后 续的所述待解析数据进行解析。
  5. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在所述第一解析结果中添加用于标识所述第一解析结果之后存在未解析的所述原始数据的标识。
  6. 根据权利要求2所述的方法,其特征在于,所述解析剩余原始数据,包括:
    使所述目标列表的各个表项的原始数据实现第二数据接口;
    在确定所述第一解析结果之后存在未解析的所述原始数据,且传入的待解析数据为实现了所述第二数据接口的数据时,根据所述第一解析结果从所述待解析数据确定属于所述剩余原始数据的待解析数据,并基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果。
  7. 根据权利要求6所述的方法,其特征在于,所述基于预设解析方式对属于所述剩余原始数据的待解析数据进行解析,获取所述第二解析结果,包括:
    向Gson对象中内置的第二类型适配器注入异步解析任务;
    通过所述第二类型适配器解析属于所述剩余原始数据的待解析数据;
    调用所述异步解析任务获取所述第二解析结果。
  8. 根据权利要求2所述的方法,其特征在于,所述基于所述第一解析结果和所述第二解析结果生成并显示所述待显示用户界面,包括:
    对所述第一解析结果和所述第二解析结果进行拼接,获取拼接结果;
    根据所述拼接结果生成所述待显示用户界面;
    将所述初始用户界面更新显示为所述待显示用户界面。
  9. 一种终端设备,其特征在于,包括:
    获取单元,用于获取待显示用户界面中的目标列表的各个表项的原始数据;
    处理单元,用于确定目标数量,所述目标数量为通过终端设备显示所述待显示用户界面时,在初始状态下所述终端设备显示出的所述目标列表的表项的数量;
    解析单元,用于按照所述目标列表的表项的排列顺序,顺序解析所述目标 数量个所述目标列表的表项的原始数据,获取第一解析结果;
    显示单元,用于基于所述第一解析结果生成并显示初始用户界面。
  10. 一种电子设备,其特征在于,包括:存储器和处理器,所述存储器用于存储计算机程序;所述处理器用于在执行计算机程序时,使得所述电子设备实现权利要求1-8任一项所述的显示用户界面的方法。
  11. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,当所述计算机程序被计算设备执行时,使得所述计算设备实现权利要求1-8任一项所述的显示用户界面的方法。
  12. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机实现如权利要求1-8任一项所述的显示用户界面的方法。
PCT/CN2022/114450 2021-09-10 2022-08-24 一种显示用户界面的方法及终端设备 WO2023035942A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111064190.XA CN115794267A (zh) 2021-09-10 2021-09-10 一种显示用户界面的方法及终端设备
CN202111064190.X 2021-09-10

Publications (1)

Publication Number Publication Date
WO2023035942A1 true WO2023035942A1 (zh) 2023-03-16

Family

ID=85417208

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/114450 WO2023035942A1 (zh) 2021-09-10 2022-08-24 一种显示用户界面的方法及终端设备

Country Status (2)

Country Link
CN (1) CN115794267A (zh)
WO (1) WO2023035942A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104133884A (zh) * 2014-07-28 2014-11-05 百度在线网络技术(北京)有限公司 显示网页的方法及装置
US20170169126A1 (en) * 2015-04-20 2017-06-15 Guangzhou Ucweb Computer Technology Co., Ltd. Method and device of displaying webpage
CN108733738A (zh) * 2017-04-25 2018-11-02 腾讯科技(深圳)有限公司 一种页面加载方法、系统、服务器及终端
CN108804707A (zh) * 2018-06-21 2018-11-13 腾讯科技(深圳)有限公司 一种页面处理方法、装置以及相关设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104133884A (zh) * 2014-07-28 2014-11-05 百度在线网络技术(北京)有限公司 显示网页的方法及装置
US20170169126A1 (en) * 2015-04-20 2017-06-15 Guangzhou Ucweb Computer Technology Co., Ltd. Method and device of displaying webpage
CN108733738A (zh) * 2017-04-25 2018-11-02 腾讯科技(深圳)有限公司 一种页面加载方法、系统、服务器及终端
CN108804707A (zh) * 2018-06-21 2018-11-13 腾讯科技(深圳)有限公司 一种页面处理方法、装置以及相关设备

Also Published As

Publication number Publication date
CN115794267A (zh) 2023-03-14

Similar Documents

Publication Publication Date Title
US20220385952A1 (en) Method and apparatus for displaying live broadcast data, and device and storage medium
US10372783B2 (en) Persisting the state of visual control elements in uniform resource locator (URL)-generated web pages
US9665255B2 (en) Deterministic visual indication of user data context
US20180322200A1 (en) Analytics based on pipes programming model
US10664556B2 (en) Adaptable user interface layout
US10205678B2 (en) Systems and methods for client-side dynamic information resource activation and deactivation
US9792267B2 (en) Simplifying identification of potential non-visibility of user interface components when responsive web pages are rendered by disparate devices
US20200225920A1 (en) Generating synchronous digital circuits from source code constructs that map to circuit implementations
US8732664B2 (en) Document serialization and comparison via object model
CN112711418B (zh) 多组件的前端界面布局方法、装置、电子设备和存储介质
CN110968314B (zh) 一种页面生成方法及装置
US20140280367A1 (en) Silo-aware databases
Chiarelli Beginning React: Simplify your frontend development workflow and enhance the user experience of your applications with React
WO2023035942A1 (zh) 一种显示用户界面的方法及终端设备
CN107621951B (zh) 一种视图层级优化的方法及装置
WO2023051439A1 (zh) 页面刷新的耗时优化方法、装置及终端设备
CN116166547A (zh) 代码变更范围分析方法、装置、设备、存储介质
US10108375B2 (en) Systems and/or methods for unified handling of event notifications across different model types
US8549485B2 (en) Method and system for concise expression of optional code snippets in interrepted languages
CN109190097B (zh) 用于输出信息的方法和装置
CN112395276A (zh) 一种数据比对方法及相关设备
CN111125565A (zh) 一种在应用中输入信息的方法与设备
US20240111410A1 (en) Drag and drop interactions for a browser software application
CN115118616B (zh) 展示结果测试方法、装置、计算机设备和存储介质
CN112799954B (zh) 快速构建测试环境的方法、设备及计算机可读介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22866412

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE