Android 4.2.1 text message session List and Information List page data loading

Source: Internet
Author: User

Long-winded: I found my blog was reposted, but I didn't specify the source. It felt a little painful and happy. Here we formally declare: reprinted, please indicate the source, thank you. If you have commercial purposes, please be sure to inform me.

 

 

Today, I looked at the MMS session List interface and the SMS list interface to read database data.
Start with the session List interface. When you enter the oncreate () method, the previous code is a registration event. The session List interface inherits from listactivity and has the listview declaration. It can be used directly for convenience. Enter initlistadapter (). Here the adapter is obtained and used. The Code is as follows:

    private void initListAdapter() {        mListAdapter = new ConversationListAdapter(this, null);        mListAdapter.setOnContentChangedListener(mContentChangedListener);        setListAdapter(mListAdapter);        getListView().setRecyclerListener(mListAdapter);    }

However, the cursor in the input adapter constructor is empty. This is strange. Based on experience, search for the location where the mlistadapter appears on this interface. You can see that there is mlistadapter. changecursor in an onquerycomplete () callback method, which is also available in the Stop method, but can be excluded. Now we understand that the adapter data is changed or provided after each asynchronous query based on the callback.
Next, you can see where to call the query method of this anonymous internal class. Based on the object declared by this anonymous internal class, you can view its call location in startasyncquery () the call is displayed in the method. Next, let's take a look at the execution location of this method, which has been executed in the onstart () method. This ends the data loading process on the session List interface. Here is a tip. We have seen mlistadapter. changecursor (null) in the onstop method. Generally, the corresponding loading will be performed in the onstart method.

Next, let's look at the text message list interface. Here there are many codes. We can directly search for mmsglistadapter to see where to construct it. The Code is as follows:

        mMsgListAdapter = new MessageListAdapter(this, null, mMsgListView, true, highlight);        mMsgListAdapter.setOnDataSetChangedListener(mDataSetChangedListener);        mMsgListAdapter.setMsgListItemHandler(mMessageListItemHandler);

The imported cursor is still empty. With the previous experience, search for mmsglistadapter. changecursor and find it in a callback method. When the query code is closed, the query code is called. This time, we can directly query mbackgroundqueryhandler. startquery based on previous experience and where to execute it. Find the startmsglistquery () method and check where the method is called. Find the method in the following order: onstart ()-> loadmessagesanddraft ()-> loadmessagecontent ()
-> Startmsglistquery ().
In the actual debugging process, if you find the query statement, you can also print the call stack method based on the breakpoint debugging or log to quickly sort out the code execution process. Add a new trick. Based on the method call time map obtained by traceview, you can quickly find the call process by searching start. It is really necessary to take the time to make a serious summary.

Related Article

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.