Java 类android.content.AsyncTaskLoader 实例源码

项目:SPF    文件:ProfileFragment.java   
@Override
public Loader<ProfileFieldContainer> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<ProfileFieldContainer>(getActivity()) {
        @Override
        public ProfileFieldContainer loadInBackground() {
            ProfileFieldContainer result;
            if (SELF_IDENTIFIER.equals(mProfileIdentifier)) {
                result = mLocalProfile.getValueBulk(FIELDS);
                mLocalProfile.disconnect();
            } else {
                SPFSearch search = mSpf.getComponent(SPF.SEARCH);
                SPFPerson person = search.lookup(mProfileIdentifier);
                if (person == null) {
                    Log.w(TAG, "Person " + mProfileIdentifier + " is not available");
                    return null;
                }

                result = person.getProfile(mSpf).getProfileBulk(FIELDS);
            }

            return result;
        }
    };
}
项目:SPF    文件:PeopleFragment.java   
@Override
public Loader<List<PersonInfo>> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case LOAD_CONTACTS_LOADER:
        return new AsyncTaskLoader<List<PersonInfo>>(getActivity()) {

            @Override
            public List<PersonInfo> loadInBackground() {
                return SPF.get().getSecurityMonitor().getPersonRegistry().getAvailableContacts();
            }
        };
    case LOAD_REQUEST_LOADER:
        return new AsyncTaskLoader<List<PersonInfo>>(getActivity()) {

            @Override
            public List<PersonInfo> loadInBackground() {
                return SPF.get().getSecurityMonitor().getPersonRegistry().getPendingRequests();
            }
        };
    default:
        return null;
    }
}
项目:SPF    文件:ActivityFragment.java   
@Override
public Loader<Collection<ActivityVerb>> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case LOAD_LIST_LOADER_ID:
        return new AsyncTaskLoader<Collection<ActivityVerb>>(getActivity()) {

            @Override
            public Collection<ActivityVerb> loadInBackground() {
                return SPF.get().getServiceRegistry().getSupportedVerbs();
            }

        };

    default:
        return null;
    }
}
项目:SPF    文件:AppManagerFragment.java   
@Override
public Loader<List<AppAuth>> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case APP_LOADER:
        return new AsyncTaskLoader<List<AppAuth>>(getActivity()) {

            @Override
            public List<AppAuth> loadInBackground() {
                return SPF.get().getSecurityMonitor().getAvailableApplications();
            }
        };

    default:
        return null;
    }
}
项目:truth-android    文件:AsyncTaskLoaderSubject.java   
public static SubjectFactory<AsyncTaskLoaderSubject, AsyncTaskLoader> type() {
  return new SubjectFactory<AsyncTaskLoaderSubject, AsyncTaskLoader>() {
    @Override
    public AsyncTaskLoaderSubject getSubject(FailureStrategy fs, AsyncTaskLoader that) {
      return new AsyncTaskLoaderSubject(fs, that);
    }
  };
}
项目:SPF    文件:ConversationListFragment.java   
@Override
public Loader<List<Conversation>> onCreateLoader(int id, Bundle args) {
    switch(id){
        case CONVERSATION_LOADER:
            return new AsyncTaskLoader<List<Conversation>>(getActivity()) {
                @Override
                public List<Conversation> loadInBackground() {
                    return ChatDemoApp.get().getChatStorage().getAllConversations();
                }
            };
        default:
            return null;
    }
}
项目:SPF    文件:ConversationActivity.java   
@Override
public Loader<List<Message>> onCreateLoader(int id, Bundle args) {
    switch (id){
        case MESSAGE_LOADER_ID:
            return new AsyncTaskLoader<List<Message>>(this) {
                @Override
                public List<Message> loadInBackground() {
                    mStorage.markAsRead(mConversation);
                    return mStorage.getAllMessages(mConversation);
                }
            };
        default:
            return null;
    }
}
项目:SPF    文件:CouponManagerFragment.java   
@Override
public Loader<List<Coupon>> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<List<Coupon>>(getActivity()) {

        @Override
        public List<Coupon> loadInBackground() {
            return ProviderApplication.get().getCouponDatabase().getAllCoupons();
        }
    };
}
项目:SPF    文件:CouponDetailActivity.java   
@Override
public Loader<Coupon> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<Coupon>(CouponDetailActivity.this) {

        @Override
        public Coupon loadInBackground() {
            return ProviderApplication.get().getCouponDatabase().getCouponById(mCouponId);
        }

    };
}
项目:SPF    文件:CouponManagerFragment.java   
@Override
public Loader<List<Coupon>> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<List<Coupon>>(getActivity()) {

        @Override
        public List<Coupon> loadInBackground() {
            return ClientApplication.get().getCouponDatabase().getAllCoupons();
        }
    };
}
项目:SPF    文件:CouponDetailActivity.java   
@Override
public Loader<Coupon> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<Coupon>(CouponDetailActivity.this) {

        @Override
        public Coupon loadInBackground() {
            return ClientApplication.get().getCouponDatabase().getCouponById(mCouponId);
        }

    };
}
项目:SPF    文件:NotificationFragment.java   
@Override
public Loader<List<NotificationMessage>> onCreateLoader(int id, final Bundle args) {
    switch (id) {
    case MESSAGE_LOADER_ID:
        return new AsyncTaskLoader<List<NotificationMessage>>(getActivity()) {

            @Override
            public List<NotificationMessage> loadInBackground() {
                return SPF.get().getNotificationManager().getAvailableNotifications();
            }
        };
    case MESSAGE_DELETER_ID:
        return new AsyncTaskLoader<List<NotificationMessage>>(getActivity()) {

            @Override
            public List<NotificationMessage> loadInBackground() {
                if(args == null){
                    SPF.get().getNotificationManager().deleteAllNotifications();
                } else {
                    long msgId = args.getLong(EXTRA_MESSAGE_ID);
                    SPF.get().getNotificationManager().deleteNotification(msgId);
                }
                return SPF.get().getNotificationManager().getAvailableNotifications();
            }
        };

    default:
        return null;
    }
}
项目:alogger    文件:LogFragment.java   
@Override
public Loader<ArrayList<LogEntry>> onCreateLoader(int arg0, Bundle arg1) {

       AsyncTaskLoader<ArrayList<LogEntry>> loader = new AsyncTaskLoader<ArrayList<LogEntry>>(getActivity()) {

        @Override
        public ArrayList<LogEntry> loadInBackground() {
            return JSONLogReader.getLogsFromFile(logger.getLogFile().getPath());
        }
       };

       loader.forceLoad();

    return loader;
}
项目:wear-notify-for-reddit    文件:ViewImageActivity.java   
@Override public Loader<Bitmap> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<Bitmap>(this) {

        @Override protected void onStartLoading() {
            forceLoad();
        }

        @Override public Bitmap loadInBackground() {
            return readBitmapFromDisk(mImageName);
        }
    };
}
项目:truth-android    文件:AsyncTaskLoaderSubject.java   
protected AsyncTaskLoaderSubject(FailureStrategy failureStrategy, AsyncTaskLoader subject) {
  super(failureStrategy, subject);
}
项目:GeoSMS-Release    文件:ConversationListLoader.java   
public ConversationsContentObserver(AsyncTaskLoader<ArrayList<Conversation>> conversationLoader) {
    super(null);
    this.conversationLoader = conversationLoader;
    final Uri uri = Uri.parse("content://mms-sms/conversations?simple=true");
    conversationLoader.getContext().getContentResolver().registerContentObserver(uri, true, this);
}
项目:SPF    文件:ProfileFragment.java   
@Override
public Loader<ProfileFieldContainer> onCreateLoader(int id, Bundle args) {
    switch (id) {
    case LOAD_PROFILE_LOADER_ID:
        return new AsyncTaskLoader<ProfileFieldContainer>(getActivity()) {

            @Override
            public ProfileFieldContainer loadInBackground() {
                if (mMode == Mode.SELF || mMode == Mode.EDIT) {
                    return SPF.get().getProfileManager().getProfileFieldBulk(mCurrentPersona, ProfilePagerAdapter.DEFAULT_FIELDS);
                } else {
                    SPFRemoteInstance instance = SPF.get().getPeopleManager().getPerson(mPersonIdentifier);
                    if (instance == null) {
                        throw new IllegalStateException("Person " + mPersonIdentifier + " not found in proximity");
                    } else {
                        String app = getActivity().getCallingPackage();
                        app = app == null ? "it.polimi.spf.app" : app;
                        return instance.getProfileBulk(ProfileField.toIdentifierList(ProfilePagerAdapter.DEFAULT_FIELDS), app);
                    }
                }
            }
        };

    case SAVE_PROFILE_LOADER_ID:
        if (mMode != Mode.EDIT) {
            Log.e(TAG, "SAVE_PROFILE_LOADER initialized in mode " + mMode);
        }

        return new AsyncTaskLoader<ProfileFieldContainer>(getActivity()) {

            @Override
            public ProfileFieldContainer loadInBackground() {
                SPF.get().getProfileManager().setProfileFieldBulk(mContainer, mCurrentPersona);
                return null;
            }
        };

    default:
        throw new IllegalArgumentException("No loader for id " + id);
    }
}
项目:assertj-android    文件:AsyncTaskLoaderAssert.java   
public AsyncTaskLoaderAssert(AsyncTaskLoader actual) {
  super(actual, AsyncTaskLoaderAssert.class);
}