Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:00:18+00:00 2026-06-15T09:00:18+00:00

I have ListFragment and AsyncTaskLoader which fetches data from internet. ListFragment is filled by

  • 0

I have ListFragment and AsyncTaskLoader which fetches data from internet. ListFragment is filled by BaseAdapter.

When data is loading, BaseAdapter fills the first row with spinning progress bar. When data is loaded and no errors occured, data is filled into ListView. But if some error occured(I have a flag in AsyncTaskLoader indicating that error), then BaseAdapter fill the first row with error message.

Problem:

When loading has errors, LoaderManager automatically tries to load data again(forceLoad() called), which is good. But what I need is to notify BaseAdapter that data is loading so BaseAdapter can change error message to spinning progress bar.

Is there any easy good way to notify fragment when LoaderManager is calling forceLoad()?

My suggestion:

ListFragment will implement the interface below and pass this ListFragment in AsyncTaskLoader’s constructor.

public interface LoadingListener {
    public void onLoadingStatusChanged(boolean isLoading);
}

Then I can call onLoadingStatusChanged(true) in loadInBackground() and onLoadingStatusChanged(false) in deliverResult(T data). I am affraid that holding reference to Fragment in AsyncTaskLoader may leak that fragment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:00:19+00:00Added an answer on June 15, 2026 at 9:00 am

    Your suggested implementation is a fine way to handle things. Although Loader already presents callbacks for OnLoadComplete and OnLoadCanceled, so a started callback is the only addition you need to make. You could also implement a custom OnLoadStart callback that triggers anytime onForceLoad() or onStartLoad() is called as opposed to loadInBackground and it would more closely mirror the existing framework callbacks.

    I would suggest that, just like the framework callbacks, you set up methods to register and unregister the listener rather than passing it in the constructor, so your Fragment can attach/remove itself as part of the normal lifecycle and the reference doesn’t leak. As you mentioned, passing it in the constructor with no way to remove it would be considered a leak.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a ListFragment that fetches some data from the net and then
What I want to achieve is having a ListFragment which displays data loaded from
I have create a listfragment and a button which looks like as follows (
I have crated a class which extends the ListFragment . I have one button
I have a ListFragment populated from a Cursor. I have the list background set
I have a ListFragment that loads stuff from an SQLite Database, and there's a
I have have a FragmentActivity with two tabs which are ListFragment s. Each ListFragment
For an ICS based application, I have created a ListFragment, which in turn uses
I have have a FragmentActivity with two tabs which are ListFragment s. Each ListFragment
I have a Fragment which extends ListFragment, this is added at runtime to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.