Android – callback to identify problems when loading usertimeline using tweettimelinelistadapter
I am trying to use usertimeline and tweettimelinelistadapter to get timeline, because here can be found in the structure document. If I use my open n / W and provide the correct download speed, I can load the timeline correctly. I display ProgressDialog when I initially load the timeline
Question:
If I'm in the company's office, or my 2G / 3G n / W is too slow / intermittent, I don't know how to determine when it really timeout, so I'm not sure when to fire ProgressDialog
Question:
Is there any callback that is connected to the tweettimelinelistadapter or something like that so that I can get any errors, timeouts, etc. when trying to load the timeline
My approach is at best:
I can use datasetobserver and check whether the timeline has been loaded and unloaded. However, if there are any errors or timeout problems during loading, I can't find anything
adapter.registerDataSetObserver(mTwitterDatasetObsv);
DataSetObserver mTwitterDatasetObsv = new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
// dismiss progress dialog
}
@Override
public void onInvalidated() {
super.onInvalidated();
// dismiss progress dialog
}
};
If I need more information, please let me know
resolvent:
So I finally figured out myself and answered my own questions in case anyone was interested
I initially relied on the following lines of code. There was some abstract time to load the twitter timeline, and my activity was blank. In order to deal with the delay, I showed ProgressDialog. But as mentioned above, I need to know where to terminate the conversation
final UserTimeline userTimeline = new UserTimeline.Builder().screenName(brandScreenName).build();
// create custom TimeLine adapter object
adapter = new TweetTimelinelistadapter(this, userTimeline);
I found that we can actually call the following APIs available for usertimeline to get callbacks for successful and failed methods
// trigger userTimeline manually to get latest tweets
userTimeline.prevIoUs(null, new Callback<TimelineResult<Tweet>>() {
@Override
public void success(Result<TimelineResult<Tweet>> result) {
}
@Override
public void failure(TwitterException exception) {
}
});
However, only the above does not solve my problem, because the first success (result < timelineresult < tweet > > result) calls the appropriate result, and it does not refresh the listview by notifying the adapter. To solve this problem, I created a class customtimelineadapter, extended tweettimelinelistadapter and overridden methods, such as getitem, getcount and getview, Get tweets from the ArrayList inside the successful callback mentioned above