android app development, when there are lots of activity, each activity requires basic requests to the server, you want to get access to the data. And time-consuming requests from the network are large, so these operations can not be done in the main thread, you need to open another thread, and Handler in conjunction. My steps are: 1 open thread 2 requests a path to get json return value 3 parse json and get the return object 4 notification handler is complete, so do the subsequent processing handler But now there is a problem, every activity, every time request the network will need to do this same procedure, different paths only request the network, calling different methods parse json, and return different Entity. I think there is no kind of way, this thread can be extracted, so that all activity shared, we only need to pass Entity appropriate path and want to get or what kind of value, you can get what we want. Which God is great way to help me explain, thank you
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: Write a parent class, inherit his every activity, or you can get hold public class Reply:
Well, I was this idea that my activity have a common parent, also need to inherit him, which is more manageable. I need to know is how to extract such a public class. Because the parameters passed in a path I can do, but returned entity, how can I go to write? Because I need to resolve in the thread inside json, for example, I need to get this request entity classes A, B another request on the need to return to the entity classes, how to do? Reply: Ask for rescue, if there is a way to achieve, pointing at me. If you do not realize the way, or you want to solve this issue, you can help me top. We are all hard to force programmers, Thanks Reply: Entity A and B have no associated entities? Reply:
No association For example: when I could log in, you need to request the network, an entity back to my user information. For example, when I get the news list, you need to get another entity, or List etc. Reply:
The man on the package network please block this function code, the results returned by each sub-activity to resolve. . Reply:
Entity A and B have no associated entities?
No association For example: when I could log in, you need to request the network, an entity back to my user information. For example, when I get the news list, you need to get another entity, or List, etc.
The man on the package network please block this function code, the results returned by each sub-activity to resolve. .
Well yes, I can only request the network this package, you can get a return json, but some json will be very complicated, or a larger amount of data, analysis will be very time consuming, so I just want to resolve this one, too package into Reply:
Entity A and B have no associated entities?
No association For example: when I could log in, you need to request the network, an entity back to my user information. For example, when I get the news list, you need to get another entity, or List, etc.
The man on the package network please block this function code, the results returned by each sub-activity to resolve. .
But now it seems that I can not do Reply: I think so: You create a Handler in the main thread object, put your so-called "thread class" draw to make a MyThread, then MyThread constructor, passing ("the appropriate path", "want to get the Entity", "just Hanlder object "is created), then after json back again after you received the UI thread to process through Handler ~ Reply: My idea is to put a network request to open a thread class which regards access to resources such as processing initialization parameters in the constructorResolved in another class Put your various returns such as the definition of a base class horse of God ResultThen returns the result of various different inheritance AResult BResult ... Then define the return type of the agreement to return the body plus keywords such as resul-type = A This way you get an A on parsing by definition AResult this class to parse (different results call different analytical methods) and with resolve to instantiate a value is returned to the requesting activity AResult Reply:
I think so: You create a Handler in the main thread object, put your so-called "thread class" draw to make a MyThread, then MyThread constructor, passing ("the appropriate path", "want to get the Entity", "just Hanlder object "is created), then after json back again after you received the UI thread to process through Handler ~
My idea is to put a network request to open a thread class which regards access to resources such as initialization parameters in the constructor in processing Resolved in another class Put your various returns such as the definition of a base class horse of God ResultThen returns the result of various different inheritance AResult BResult ... Then define the return type of the agreement to return the body plus keywords such as resul-type = A This way you get an A on parsing by definition AResult this class to parse (different results call different analytical methods) and with resolve to instantiate a AResult value returned to the requesting activity
My thoughts on why should parse json purebred where did it because sometimes we need to parse the data volume is large, or complex is relatively high, so if placed UI thread to do, probably because of time-consuming the emergence of serious problems, so I want to do analytical method into thread. Reply:
I think so: You create a Handler in the main thread object, put your so-called "thread class" draw to make a MyThread, then MyThread constructor, passing ("the appropriate path", "want to get the Entity", "just Hanlder object "is created), then after json back again after you received the UI thread to process through Handler ~
My idea is to put a network request to open a thread class which regards access to resources such as initialization parameters in the constructor in processing Resolved in another class Put your various returns such as the definition of a base class horse of God ResultThen returns the result of various different inheritance AResult BResult ... Then define the return type of the agreement to return the body plus keywords such as resul-type = A This way you get an A on parsing by definition AResult this class to parse (different results call different analytical methods) and with resolve to instantiate a AResult value returned to the requesting activity
My thoughts on why should parse json purebred where did it because sometimes we need to parse the data volume is large, or complex is relatively high, so if placed UI thread to do, probably because of time-consuming the emergence of serious problems, so I want to do analytical method into thread.
Ah you do not affect the resolve not to resolve a separate thread to open and download together also possible Reply: The time-consuming to get all the child thread, Reply:
the child threads are time-consuming to get,
I resolved, write your own callback function, thank you for help. ! ! ! Reply:
The time-consuming to get all the child thread,
I resolved, write your own callback function, thank you for help. ! ! !
LZ V5 Reply: Write a class devoted to public access to the data network link, and then return the results in a different Activity which can resolve it. Reply:
write a public class dedicated link for data processing network, and then return the results in a different Activity which can resolve it.
Yes, this idea is correct, but this result is not what I want, but if you parse than the larger case, if done in the UI thread, it may be time consuming, so I need a public class, is In sub-thread should resolve to do. Reply: Write an analytic data interfaces, each entity class needs to resolve its own data to implement this interface, because there are different Entity, consider using generics. The main thread unfit to handle large data screwdriver to another thread, but the results must request a callback function to handle, otherwise it will cause this App hanging dead unresponsive phenomenon. Reply:
write an analytic data interfaces, each entity class needs to resolve its own data to implement this interface, because there are different Entity, consider using generics. The main thread unfit to handle large data screwdriver to another thread, but the results must request a callback function to handle, otherwise it will cause this App hanging dead unresponsive phenomenon.
Well, I did, but do not require the use of generics, because the child thread exists Entity is no practical usefulness. Thank you
No comments:
Post a Comment