The call process of the Xutils source code file download method. The xutils source code

Source: Internet
Author: User

The call process of the Xutils source code file download method. The xutils source code

// I'm mainly curious about the callback onLoading () of Xutils. I haven't found it for a long time. If it's hard to find it, write it down.

Preface:

1. Only summarize the main code lines and provide a general process

2. For ease of understanding, the variable name in this article is different from the source code variable name, but the camper method of the class name. For example, in the source code: WorkRunnable mWorker

3. Check the Xutils source code to reduce the difficulty of reading the Xutils source code.


Code trunk:

HttpFragment:

// HttpFragment is a class in the Xutils built-in example.
HttpUtils = new HttpUtils ();
HttpUtils. send (mthord, url, params, callback {onStart (), onLoading (), onSuccess (), onFailure ,})

HttpUtils:
HttpRequest = new HttpRequest (method, url); httpUtils. sendRequest (request, params, callback); httpHandler = new Handler <T> (httpClient, httpContext, resoponseTextCharset, callBack); httpRequest. setRequestParams (params, httphandler##httphandler.exe cuteOnExcutor (priorityExecutor, request );

PriorityAsynTask = HttpHandler:
// HttpHandler extends PriorityAsyncTask, so the following method actually calls the method in HttpHandler
// There are two types of interfaces that Thread can execute. runable () interface 2. callable interface // The difference is to call the run () and call () Open threads respectively. The latter has a return value and can cancel the job, exception can be returned // However, to call Callable using Thread, you need to use FutreTask packaging. FutureTask implements the Runable interface, and the done () method is executed after the job ends, it can be used to determine the download success or cancellation status;
// The following two lines of code are initialized, not in the execution sequence: workRunnable {call () {return postResult (doInBackground (parmas) }}; futureTask = new FutureTask <Result> (workRunnable) {done (postResultIfNotInvoke ())};
WorkRunnable. mParams = params?priorityexecutor.exe cute (new PriorityRunnable (priority, futureTask ));
PriorityExecutor: // use the thread pool to open the thread threadpoolexecutor.exe cute (new PriorityRunnable (priority, futrueTask ))

PriorityRunnable:
// FutureTask is the workRunnable packaging class that calls the methods in workRunnable, that is, postResult (doInBackground (parmas );
FutrueTask. run ();

HttpHandler: // Finally, HttpHandler's doInBackground is run. doInBackground (); httpHandler. sendRequest (httpRequest); httpResponse = client.exe cute (httpRequest, context); handleResponse (httpResponse); fileDownloadHandler. handleEntity (httpEntity, httpHandler, charset );
StringDownloadHandler: // The download processing stage is reached. O (∩) O Haha ~ While (line = reader. readLine ())! = Null) {httpHandler. updateProgress (total, current, false )}
HttpHandler: httpHandler. publishProgress (UPDATE_LOADING, total, current );
// Values = new Progress [] {UPDATE_LOADING, total, current}; using Java's uncertain number of parameter mechanisms (Profress ...) // use the Handler mechanism to communicate with handler. obtainMessage (MESSAGE_POST_PROGRESS, new AsyncTaskResult <Progress> (this, values ))

// PriorityAsyncTask is httpHandlerasyncTaskResult. priorityAsyncTask. onProgressUpdate (values); // based on values [0], it is determined that requestCallBack is being downloaded. onLoading (Long. valueOf (String. valueOf (values [1]), // The total file size is Long. valueOf (String. valueOf (values [2]), // The isUploading size has been downloaded); // It will end after it is ready, the logic for other callback functions is similar to that for Starting download, downloading, and downloading failure.



How does Eclipse navigate to the source code of a method called?

The shortcut key F3 is recommended.

How to read the source code of an exe file?

The generated program cannot see the source Code, but you can see the program resources. use E-Code Explorer to decompile and debug the easy-format executable files generated by easy-language compilation and analyze the internal structure, view the data.

[Function overview]
1. Format analysis: analyze the overall structure of easy-to-format executable files and view the data of corresponding items. The analysis of the PE skeleton (PE Header) and the easy-format mycoplasma are presented with a clear tree structure and supplemented with detailed analysis tables.
2. Disassembly analysis: Quick static disassembly and easy-to-format executable files. This feature allows you to conveniently jump to and call the code preview function of the target address.
3. Form Analysis: analyzes form data contained in easy-format executable files. The subordinate structure of the form unit is clearly displayed in a tree structure. Detailed display of control properties, accurate event processing function locating, and convenient switching with the disassembly mode allow users to immediately enter the event function airspace to be debugged, avoid wasting time in the runtime space. This is required for debugging non-linear event-driven programs.
4. Symbol modifier: You can call the easy-language support library as a symbol table to modify the disassembly code. You can directly analyze the methods and operation attributes called by the function, used constants, basic data types, custom data types, and window units. This greatly improves the readability of the Code.
5. Internal data analysis: analyzes constants, API functions, services, and call support libraries used by the program.
6. Multiple Loading Methods: supports loading from files and loading disassembly directly from memory of a process. Attaching the Process List directly can avoid debugging difficulties caused by some AntiDebug operations.
7. Supports multiple formats: supports standard PE executable files, easy-to-format files, and other types of easy-to-format files. Can be analyzed correctly.
8. Easy-format captors: Easy-format executable files (such as files encapsulated by other means after shelling) of unknown shells can be easily and quickly analyzed.
9. Provides the hexadecimal File Viewing function.
10. Provides a variety of auxiliary tools to complete functions such as dump easy-to-format scripts in the memory, fix relocation information, and generate EXE files.
11. Both the analysis results and the disassembly results can be directly exported to generate a report file.
12. Supports custom disassembly and environment color for HEX display. You can select your preferred color to read the code.
13. For detailed analysis settings, you can set the most appropriate debugging environment on your own.
14. Provides the file drag-and-drop function for direct analysis or debugging.
15. You can obtain the file to be analyzed from the command line.
Other more functions are waiting for you to find ............
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.