Disclosure of Invention
In view of the above problems, embodiments of the present invention are proposed to provide a resource data processing method of an application and a resource data processing apparatus of a corresponding application, which overcome or at least partially solve the above problems.
In order to solve the above problem, an embodiment of the present invention discloses a method for processing resource data of an application program, including:
acquiring resource configuration information of an application program; the resource configuration information comprises a service name of the resource data;
downloading the resource data according to the resource configuration information;
respectively storing the resource data according to the service names of the resource data;
acquiring a business name and a resource name corresponding to resource data to be loaded by an application program;
and loading the resource data matched with the corresponding service name and resource name of the resource data to be loaded from the stored resource data.
Optionally, the respectively storing the resource data according to the service names of the resource data includes:
and storing the resource data into a directory which takes the service name as a directory name in a preset storage space.
Optionally, the loading, from the stored resource data, the resource data matched with the service name and the resource name corresponding to the resource data to be loaded includes:
judging whether a directory corresponding to the service name exists in a preset storage space and the directory has resource data corresponding to the resource name;
if a directory corresponding to the business name exists in the preset storage space and the directory has resource data corresponding to the resource name, loading the resource data matched with the resource name in the directory corresponding to the business name;
and if the directory corresponding to the business name does not exist in the preset storage space and the directory has the resource data corresponding to the resource name, loading the resource data matched with the resource name from the application package of the application program.
Optionally, the downloading the resource data includes:
downloading a compressed file of the resource data;
the storing the resource data into a directory in a preset storage space with the service name as a directory name includes:
and decompressing and storing the compressed file of the resource data to a directory which takes the service name as a directory name in a preset storage space.
Optionally, the method further comprises:
and deleting the resource data which does not correspond to the resource configuration information in the resource data of the preset storage space.
Optionally, the resource configuration information further includes: a resource data unique identifier; deleting the resource data which is not corresponding to the resource configuration information in the resource data of the preset storage space, including:
and deleting the resource data which does not correspond to the unique resource data identifier in the resource configuration information from all the resource data in the preset storage space.
The embodiment of the invention also discloses a resource data processing device of the application program, which comprises:
the resource configuration information acquisition module is used for acquiring the resource configuration information of the application program; the resource configuration information comprises a service name of the resource data;
the resource data downloading module is used for downloading the resource data according to the resource configuration information;
the resource data storage module is used for respectively storing the resource data according to the service names of the resource data;
the name acquisition module is used for acquiring a business name and a resource name corresponding to resource data to be loaded by an application program;
and the resource data loading module is used for loading the resource data matched with the corresponding service name and resource name of the resource data to be loaded from the stored resource data.
Optionally, the resource data storage module includes:
and the directory storage submodule is used for storing the resource data into a directory which takes the service name as a directory name in a preset storage space.
Optionally, the resource data downloaded according to the resource configuration information is updated resource data, and the resource data loading module includes:
and the resource data loading sub-module is used for loading updated resource data which are matched with the corresponding service name and resource name of the resource data to be loaded in the preset storage space, or loading assets resource data which are matched with the resource name in an application packet of the application program.
Optionally, the resource data loading sub-module includes:
the name judging unit is used for judging whether a directory corresponding to the business name exists in a preset storage space and the directory has resource data corresponding to the resource name;
the first loading unit is used for loading the resource data matched with the resource name in the directory corresponding to the service name if the directory corresponding to the service name exists in the preset storage space and the directory has the resource data corresponding to the resource name;
and the second loading unit is used for loading the resource data matched with the resource name in the application package of the application program if the directory corresponding to the service name does not exist in the preset storage space and the directory has the resource data corresponding to the resource name.
Optionally, the resource data downloading module includes:
the compressed file downloading submodule is used for downloading a compressed file of the resource data;
the directory storage sub-module includes:
and the directory storage unit is used for decompressing and storing the compressed file of the resource data to a directory which takes the service name as a directory name in a preset storage space.
Optionally, the method further comprises:
and the resource data deleting module is used for deleting the resource data which does not correspond to the resource configuration information in the resource data of the preset storage space.
Optionally, the resource configuration information further includes: a resource data unique identifier; the resource data deletion module comprises:
and the resource data deleting submodule is used for deleting the resource data which does not correspond to the unique resource data identifier in the resource configuration information in all the resource data of the preset storage space.
The embodiment of the invention also discloses a device, which comprises: a processor, a memory and a computer program stored on the memory and capable of running on the processor, which computer program, when executed by the processor, implements the steps of the resource data processing method of an application program as described above.
The embodiment of the invention also discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the steps of the resource data processing method of the application program are realized.
The embodiment of the invention has the following advantages:
in the embodiment of the invention, the resource data is divided by taking the service as the granularity, and the service name is introduced into the updating process and the loading process of the resource data. When the resource data is updated, only the resource data related to the service is required to be downloaded, and other additional data is not required to be downloaded, so that the resource data is updated more flexibly, and the flow consumption of the updated resource data is reduced. When the resource data is loaded, the corresponding resource data can be loaded according to the service.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
The embodiment of the invention provides a resource data division mode with service as granularity, wherein the service is a more abstract division standard for the resource data. The application program can realize various functions, provide various services for users, and divide services according to functions, services and the like. The business division can be generally responsible for developers or operators of the application programs, and various businesses can be divided from the application programs according to needs.
For example, for an application installed in a vehicle-mounted terminal, which may provide a home page, a search page, a setting page, and the like, one of the provided pages may be used as one of services. If the main page provides a plurality of sub-pages, one sub-page can be used as one service, and one main page can be divided into a plurality of services.
For a certain page, the resource data required to be used by the page may be pictures, texts required to be displayed on the page, videos required to be played, audios and the like.
Referring to fig. 1, a flowchart illustrating a first step of a first embodiment of a method for processing resource data of an application program according to the present invention is shown, where the method specifically includes the following steps:
step 101, acquiring resource configuration information of an application program; the resource configuration information includes a service name of the resource data.
In a specific implementation, the embodiments of the present invention may be applied to terminals, such as a vehicle-mounted terminal, a mobile phone, a tablet computer, a personal digital assistant, and the like. The operating system of the terminal may include Android (Android), IOS, Windows Phone, Windows, and the like.
The resource configuration information records information of resource data needing to be updated, and may include information of a service name configured for the resource data, an update record ID, a resource data version, an android application version, a resource download address, a timestamp for creating a record, a timestamp for updating a record, and the like. The resource configuration information of the application program may be acquired when the application program is started.
The service name may be an identifier for dividing the service for the application program, and may be set by a developer or an operator of the application program. In the embodiment of the invention, the resource data are divided according to the service, and the service name is introduced into the updating and loading process of the resource data.
And 102, downloading the resource data according to the resource configuration information.
The resource data specified in the resource configuration information refers to updated resource data.
The resource data required to be loaded by the application program can be divided into two types according to the storage mode, one type is asset resource data which is stored in the application package, and under the asset directory stored in the application package, the types of data media are not distinguished, namely pictures, texts, music and the like are not distinguished.
The other is updating resource data, which is resources stored outside the application package, and the updating resource data can be continuously updated. All the updated resource data have data corresponding to the resource names in the assets resource data, and the data media types are not distinguished. It should be noted that not all asset data has updated asset data with corresponding names.
The assets resource data and the updated resource data are resource data which can be loaded by the application program, generally speaking, the updated resource data is a new resource which needs to be pushed, the application program can preferentially load the updated resource data, and the assets resource data can be loaded only if the updated resource data does not exist.
The following describes a process of an application acquiring resource configuration information and downloading resource data, taking an android application as an example.
Referring to FIG. 2, a schematic diagram of an android application communicating with an update configuration system and a static file system. The updating configuration system is a system for adding or deleting resource configuration and storing resource configuration, is a manually operated system, and is used for managing the resource configuration by an administrator and providing resource configuration information for android applications. The update configuration system can comprise a query module, a storage module and an operation module. The query module provides an HTTP interface for obtaining the updated resource data for the android application program, and the requested updated resource data can be obtained from the storage module. The storage module stores all information of the updated resource data, including the business name, the ID of the updated record, the version of the resource data, the version of the android application, the download address of the resource, the timestamp of the created record, the timestamp of the updated record and the like. And providing data for the query module and storing the data for the operation module. And the operation module stores the updated resource record viewed and entered by the background administrator through the storage module.
The static file system is a system for storing updated resource data, is a manually operated system, and is managed by an administrator to update the resource data and provide the updated resource data for android applications.
After the android application program is started, resource configuration information can be requested through an HTTP interface of the updating configuration system. After the resource configuration information is obtained, the resource data can be downloaded from the static file system according to the resource downloading address in the resource configuration information.
In one example, provided in the static file system is a compressed package of resource data, and the step of downloading the resource data may include: and downloading the compressed file of the resource data.
And 103, respectively storing the resource data according to the service names of the resource data.
In the embodiment of the invention, the resource data can be respectively stored according to the service names of the resource data. The resource data of the same service name can be stored together, and the resource data of different service names are stored separately. Therefore, when the resource data is loaded, the resource data under the service name can be searched according to the service name.
In this embodiment of the present invention, the step of respectively storing the resource data according to the service name of the resource data may include: and storing the resource data into a directory which takes the service name as a directory name in a preset storage space.
The preset storage space may be an application storage space for storing data related to the application. An update directory can be created in the preset storage space, the update directory is used for storing update resource data of all services, and the update resource data of a single service is stored in the service resource directory named by the service name. For example, the business resource directory name may be: res _ + service name ".
In one example, the step of storing the resource data into a directory with the service name as a directory name in a preset storage space may include: and decompressing and storing the compressed file of the resource data to a directory which takes the service name as a directory name in a preset storage space.
All the updated resource data have corresponding assets resource data, and the media types of the files are not distinguished.
For example: the assets directory has files: home.png, setting.txt, start.mp 3.
Png is a picture to be displayed in a home page (home), and the divided service is the home. Txt is a text that needs to be shown on a setting page (setting), and the divided service can be setting. Mp3 is the audio that needs to be played at the start page (start), and the divided service may be the start page start.
The service home and setting have update resources: res _ home/home.png, res _ setting/setting.txt, respectively. The res _ home is a directory with "res _ home" as a name, and the res _ setting is a directory with "res _ setting" as a name.
In this embodiment of the present invention, after the resource data are respectively stored in the preset storage spaces, the resource data that are not needed in the preset storage spaces may be deleted, and the method in this embodiment of the present invention may further include: and deleting the resource data which does not correspond to the resource configuration information in the resource data of the preset storage space.
The resource configuration information records information of resource data which is needed to be used by the application program at present, the resource data which is used in advance is stored in the preset storage space, and after new resource configuration information is obtained, a part of the resource data does not need to be used, so that the resource data corresponding to the resource configuration information can be omitted, and the data storage space is saved.
In this embodiment of the present invention, the resource configuration information may further include: a resource data unique identifier; the step of deleting resource data that does not correspond to the resource configuration information in the resource data of the preset storage space may include: and deleting the resource data which does not correspond to the unique resource data identifier in the resource configuration information from all the resource data in the preset storage space.
The resource data unique identifier may be formed by a plurality of pieces of information in the resource configuration information, for example, an update record ID, a resource data version, a time stamp of the update record, and the like in the resource configuration information may be used as the unique identifier of the resource data.
And 104, acquiring a business name and a resource name corresponding to the resource data to be loaded by the application program.
When the application program needs to load the resource data, the business name and the resource name corresponding to the resource data to be loaded are obtained.
Specifically, when the application program needs to load the resource data, the preset loading resource interface may be called to load the resource data. Transmitting a service name and a resource name of resource data to be loaded through a loading resource interface; and returning the resource data matched with the business name and the resource name through the loading resource interface.
In one example, the load resource interface may be optimized from the open interface method of AssetManager of the android system.
The original interface method comprises the following steps:
inputStream open(String fileName)
filiname is asset name
inputStream is the returned assets resource data
The optimized interface method comprises the following steps:
inputStream open(String type,String fileName)
type is a business name
filiename is resource name
And inputStream is the returned assets resource data or the updated resource data.
And 105, loading the resource data matched with the corresponding service name and resource name of the resource data to be loaded from the stored resource data.
All resource data under the service name of the resource data to be recorded can be searched; and then searching the resource data matched with the resource name of the resource data to be recorded in the resource data.
In this embodiment of the present invention, the step of loading, from the stored resource data, the resource data that matches the service name and the resource name corresponding to the resource data to be loaded may include: and loading updated resource data matched with the corresponding service name and resource name of the resource data to be loaded in the preset storage space, or loading assets resource data matched with the resource name in an application packet of the application program.
The resource names are the asset resource data and the file identifiers of the updated resource data, and in the embodiment of the invention, all the updated resource data have the asset resource data with the same corresponding resource name. The application program can choose to load the updated asset data or the assets resource data.
In this embodiment of the present invention, the step of loading updated resource data in the preset storage space, which is matched with the service name and the resource name corresponding to the resource data to be loaded, or loading assets resource data in an application package of the application program, which is matched with the resource name, may further include the following sub-steps:
and a substep S11, determining whether a directory corresponding to the service name exists in a preset storage space and the directory has resource data corresponding to the resource name.
And a substep S12, if a directory corresponding to the service name exists in the preset storage space and the directory has the resource data corresponding to the resource name, loading the resource data matching the resource name in the directory corresponding to the service name.
Specifically, the "updated resource name" may be constructed by the "service name" and the "resource name". For example, "update resource name" ═ res _ + service name "+/+" resource name ". And judging whether resource data corresponding to the updated resource name exists in the preset storage space.
The application program preferentially considers loading the updated resource data, and if the updated resource data corresponding to the updated resource name exists in the preset storage space, the updated resource data is loaded.
And a substep S13, if there is no directory corresponding to the service name in the preset storage space and the directory has the resource data corresponding to the resource name, loading the resource data matching the resource name in the application package of the application program.
The method comprises the steps that asset resource data are stored in an application package of an application program, and if updated resource data corresponding to an updated resource name do not exist in a preset storage space, the resource data matched with the resource name are loaded from the asset resource data in the application package.
In order to enable a person skilled in the art to better understand the embodiments of the present invention, the following description is given by way of an example:
the application program of the embodiment of the invention can comprise a resource loading module, a resource storage module, an updated resource downloading module and an updated resource acquisition module
A resource loading module: receiving two parameters of a service name and a resource name, and controlling whether an application program loads and updates resource data or assets resource data; when the updated resource data is loaded, the resources are loaded from the resource storage module.
A resource storage module: the loading module is responsible for managing the updated resource data, providing the updated resource data for the loading module and providing the file storage capacity for the updated resource downloading module.
Updating the resource downloading module: and the device is responsible for downloading the compression package of the update file from the static file system, decompressing and storing the compression package through the storage module and providing downloading capacity for the update resource acquisition module.
An update resource acquisition module: and the system is responsible for acquiring resource configuration information from the update configuration system and downloading resource data by using the update resource downloading module when the application is started.
In the embodiment of the invention, the resource data is divided by taking the service as the granularity, and the service name is introduced into the updating process and the loading process of the resource data. When the resource data is updated, only the resource data related to the service is required to be downloaded, and other additional data is not required to be downloaded, so that the resource data is updated more flexibly, and the flow consumption of the updated resource data is reduced. When the resource data is loaded, the corresponding resource data can be loaded according to the service.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 3, a block diagram of an embodiment of a resource data processing apparatus for an application according to the present invention is shown, which may specifically include the following modules:
a resource allocation information obtaining module 301, configured to obtain resource allocation information of an application; the resource configuration information comprises a service name of the resource data;
a resource data downloading module 302, configured to download the resource data according to the resource configuration information;
a resource data storage module 303, configured to store the resource data according to service names of the resource data;
a name obtaining module 304, configured to obtain a service name and a resource name corresponding to resource data to be loaded by an application;
a resource data loading module 305, configured to load, from the stored resource data, resource data that matches the service name and the resource name corresponding to the resource data to be loaded.
In this embodiment of the present invention, the resource data storage module 303 may include:
and the directory storage submodule is used for storing the resource data into a directory which takes the service name as a directory name in a preset storage space.
In this embodiment of the present invention, the resource data downloaded according to the resource configuration information is updated resource data, and the resource data loading module 305 may include:
and the resource data loading sub-module is used for loading updated resource data which are matched with the corresponding service name and resource name of the resource data to be loaded in the preset storage space, or loading assets resource data which are matched with the resource name in an application packet of the application program.
In this embodiment of the present invention, the resource data loading sub-module may include:
the name judgment submodule is used for judging whether a directory corresponding to the business name exists in a preset storage space and the directory has resource data corresponding to the resource name;
the first loading submodule is used for loading the resource data matched with the resource name in the directory corresponding to the service name if the directory corresponding to the service name exists in the preset storage space and the directory has the resource data corresponding to the resource name;
and the second loading submodule is used for loading the resource data matched with the resource name from the application package of the application program if the directory corresponding to the service name does not exist in the preset storage space and the directory has the resource data corresponding to the resource name.
In this embodiment of the present invention, the resource data downloading module 302 may include:
the compressed file downloading submodule is used for downloading a compressed file of the resource data;
the directory storage sub-module includes:
and the directory storage unit is used for decompressing and storing the compressed file of the resource data to a directory which takes the service name as a directory name in a preset storage space.
In an embodiment of the present invention, the apparatus further includes:
and the resource data deleting module is used for deleting the resource data which does not correspond to the resource configuration information in the resource data of the preset storage space.
In this embodiment of the present invention, the resource configuration information further includes: a resource data unique identifier; the resource data deletion module may include:
and the resource data deleting submodule is used for deleting the resource data which does not correspond to the unique resource data identifier in the resource configuration information in all the resource data of the preset storage space.
In the embodiment of the invention, the resource data is divided by taking the service as the granularity, and the service name is introduced into the updating process and the loading process of the resource data. When the resource data is updated, only the resource data related to the service is required to be downloaded, and other additional data is not required to be downloaded, so that the resource data is updated more flexibly, and the flow consumption of the updated resource data is reduced. When the resource data is loaded, the corresponding resource data can be loaded according to the service.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
An embodiment of the present invention further provides an apparatus, including:
the resource data processing method comprises a processor, a memory and a computer program which is stored in the memory and can run on the processor, wherein when the computer program is executed by the processor, each process of the resource data processing method embodiment of the application program is realized, the same technical effect can be achieved, and the details are not repeated here to avoid repetition.
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 being executed by a processor, the computer program implements each process of the resource data processing method embodiment of the application program, and can achieve the same technical effect, and in order to avoid repetition, the detailed description is omitted here.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The foregoing detailed description is provided for a resource data processing method of an application program and a resource data processing apparatus of an application program, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the foregoing examples are only used to help understand the method and the core ideas of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.