sPFApp/src/main/java/it/polimi/spf/app/fragments/profile/ProfileFragment.java
@Override
    public Loader<ProfileFieldContainer> onCreateLoader(int id, Bundle args) {
        switch (id) {
            case LoadersConfig.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 LoadersConfig.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);
        }
    }
@Override
    public Loader<ProfileFieldContainer> onCreateLoader(int id, Bundle args) {
        switch (id) {
            case LoadersConfig.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 LoadersConfig.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);
        }
    }
@ Override public Loader < ProfileFieldContainer > onCreateLoader ( int id , Bundle args ) { switch ( id ) { case LoadersConfig . 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 LoadersConfig . 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 ) ; } }
/*
LOADERS - Used to load and save profile data.
/ * LOADERS - Used to load and save profile data .