Java 类android.app.LoaderManager.LoaderCallbacks 实例源码

项目:easyfilemanager    文件:RecentsCreateFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Context context = getActivity();

    mAdapter = new DocumentStackAdapter();
    mListView.setAdapter(mAdapter);

    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) getActivity()).getDisplayState();

    mCallbacks = new LoaderCallbacks<List<DocumentStack>>() {
        @Override
        public Loader<List<DocumentStack>> onCreateLoader(int id, Bundle args) {
            return new RecentsCreateLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(
                Loader<List<DocumentStack>> loader, List<DocumentStack> data) {
            mAdapter.swapStacks(data);

            if (isResumed()) {
                setListShown(true);
            } else {
                setListShownNoAnimation(true);
            }
            // When launched into empty recents, show drawer
            if (mAdapter.isEmpty() && !state.stackTouched) {
                ((BaseActivity) context).setRootsDrawerOpen(true);
            }
        }

        @Override
        public void onLoaderReset(Loader<List<DocumentStack>> loader) {
            mAdapter.swapStacks(null);
        }
    };

    setListAdapter(mAdapter);
    setListShown(false);
    getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks);
}
项目:easyfilemanager    文件:RootsFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if(null != savedInstanceState) {
        group_size = savedInstanceState.getInt(GROUP_SIZE, 0);
        expandedIds = (ArrayList<Long>) savedInstanceState.getSerializable(GROUP_IDS);
    }

    final Context context = getActivity();
    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) context).getDisplayState();

    mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() {
        @Override
        public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) {
            return new RootsLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(
                Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) {
            if (!isAdded()) return;

            final Intent includeApps = getArguments().getParcelable(EXTRA_INCLUDE_APPS);

            if (mAdapter == null) {
                mAdapter = new RootsExpandableAdapter(context, result, includeApps);
                Parcelable state = mList.onSaveInstanceState();
                mList.setAdapter(mAdapter);
                mList.onRestoreInstanceState(state);
            } else {
                mAdapter.setData(result);
            }

            int groupCount = mAdapter.getGroupCount();
            if(group_size != 0 && group_size == groupCount){
                if (expandedIds != null) {
                    restoreExpandedState(expandedIds);
                }
            } else {
                group_size = groupCount;
                for (int i = 0; i < group_size; i++) {
                    mList.expandGroup(i);
                }
                expandedIds = getExpandedIds();
                mList.setOnGroupExpandListener(mOnGroupExpandListener);
                mList.setOnGroupCollapseListener(mOnGroupCollapseListener);
            }
        }

        @Override
        public void onLoaderReset(Loader<Collection<RootInfo>> loader) {
            mAdapter = null;
            mList.setAdapter((RootsExpandableAdapter)null);
        }
    };
}
项目:FireFiles    文件:RecentsCreateFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Context context = getActivity();

    mAdapter = new DocumentStackAdapter();
    mListView.setAdapter(mAdapter);

    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) getActivity()).getDisplayState();

    mCallbacks = new LoaderCallbacks<List<DocumentStack>>() {
        @Override
        public Loader<List<DocumentStack>> onCreateLoader(int id, Bundle args) {
            return new RecentsCreateLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(
                Loader<List<DocumentStack>> loader, List<DocumentStack> data) {
            mAdapter.swapStacks(data);

            if (isResumed()) {
                setListShown(true);
            } else {
                setListShownNoAnimation(true);
            }
            // When launched into empty recents, show drawer
            if (mAdapter.isEmpty() && !state.stackTouched) {
                ((BaseActivity) context).setRootsDrawerOpen(true);
            }
        }

        @Override
        public void onLoaderReset(Loader<List<DocumentStack>> loader) {
            mAdapter.swapStacks(null);
        }
    };

    setListAdapter(mAdapter);
    setListShown(false);
    getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks);
}
项目:FireFiles    文件:RootsFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if(null != savedInstanceState) {
        group_size = savedInstanceState.getInt(GROUP_SIZE, 0);
        expandedIds = (ArrayList<Long>) savedInstanceState.getSerializable(GROUP_IDS);
    }

    final Context context = getActivity();
    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) context).getDisplayState();

    mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() {
        @Override
        public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) {
            return new RootsLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(
                Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) {
            if (!isAdded()) return;

            final Intent includeApps = getArguments().getParcelable(EXTRA_INCLUDE_APPS);

            if (mAdapter == null) {
                mAdapter = new RootsExpandableAdapter(context, result, includeApps);
                Parcelable state = mList.onSaveInstanceState();
                mList.setAdapter(mAdapter);
                mList.onRestoreInstanceState(state);
            } else {
                mAdapter.setData(result);
            }

            int groupCount = mAdapter.getGroupCount();
            if(group_size != 0 && group_size == groupCount){
                if (expandedIds != null) {
                    restoreExpandedState(expandedIds);
                }
            } else {
                group_size = groupCount;
                for (int i = 0; i < group_size; i++) {
                    mList.expandGroup(i);
                }
                expandedIds = getExpandedIds();
                mList.setOnGroupExpandListener(mOnGroupExpandListener);
                mList.setOnGroupCollapseListener(mOnGroupCollapseListener);
            }
        }

        @Override
        public void onLoaderReset(Loader<Collection<RootInfo>> loader) {
            mAdapter = null;
            mList.setAdapter((RootsExpandableAdapter)null);
        }
    };
}
项目:simple-share-android    文件:RecentsCreateFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Context context = getActivity();

    mAdapter = new DocumentStackAdapter();
    mListView.setAdapter(mAdapter);

    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) getActivity()).getDisplayState();

    mCallbacks = new LoaderCallbacks<List<DocumentStack>>() {
        @Override
        public Loader<List<DocumentStack>> onCreateLoader(int id, Bundle args) {
            return new RecentsCreateLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(
                Loader<List<DocumentStack>> loader, List<DocumentStack> data) {
            mAdapter.swapStacks(data);

            if (isResumed()) {
                setListShown(true);
            } else {
                setListShownNoAnimation(true);
            }
            // When launched into empty recents, show drawer
            if (mAdapter.isEmpty() && !state.stackTouched) {
                ((BaseActivity) context).setRootsDrawerOpen(true);
            }
        }

        @Override
        public void onLoaderReset(Loader<List<DocumentStack>> loader) {
            mAdapter.swapStacks(null);
        }
    };

    setListAdapter(mAdapter);
    setListShown(false);
    getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks);
}
项目:simple-share-android    文件:RootsFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if(null != savedInstanceState) {
        group_size = savedInstanceState.getInt(GROUP_SIZE, 0);
        expandedIds = (ArrayList<Long>) savedInstanceState.getSerializable(GROUP_IDS);
    }

    final Context context = getActivity();
    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) context).getDisplayState();

    mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() {
        @Override
        public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) {
            return new RootsLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(
                Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) {
            if (!isAdded()) return;

            final Intent includeApps = getArguments().getParcelable(EXTRA_INCLUDE_APPS);

            if (mAdapter == null) {
                mAdapter = new RootsExpandableAdapter(context, result, includeApps);
                Parcelable state = mList.onSaveInstanceState();
                mList.setAdapter(mAdapter);
                mList.onRestoreInstanceState(state);
            } else {
                mAdapter.setData(result);
            }

            int groupCount = mAdapter.getGroupCount();
            if(group_size != 0 && group_size == groupCount){
                if (expandedIds != null) {
                    restoreExpandedState(expandedIds);
                }
            } else {
                group_size = groupCount;
                for (int i = 0; i < group_size; i++) {
                    mList.expandGroup(i);
                }
                expandedIds = getExpandedIds();
                mList.setOnGroupExpandListener(mOnGroupExpandListener);
                mList.setOnGroupCollapseListener(mOnGroupCollapseListener);
            }
        }

        @Override
        public void onLoaderReset(Loader<Collection<RootInfo>> loader) {
            mAdapter = null;
            mList.setAdapter((RootsExpandableAdapter)null);
        }
    };
}
项目:Secure-App-Generator    文件:MainActivity.java   
private void initialiseExistingFormList() {
    FormAdapter adapter = new FormAdapter(this.getApplicationContext(), null, this);
    setListAdapter(adapter);
    getLoaderManager().initLoader(0, null, (LoaderCallbacks<Cursor>) this);
}
项目:arca-android    文件:ModernRequestDispatcher.java   
@Override
public void execute(final Query request, final QueryListener listener) {
    final LoaderCallbacks<?> callbacks = new QueryLoaderCallbacks(listener);
    execute(request, callbacks);
}
项目:arca-android    文件:ModernRequestDispatcher.java   
@Override
public void execute(final Update request, final UpdateListener listener) {
    final LoaderCallbacks<?> callbacks = new UpdateLoaderCallbacks(listener);
    execute(request, callbacks);
}
项目:arca-android    文件:ModernRequestDispatcher.java   
@Override
public void execute(final Insert request, final InsertListener listener) {
    final LoaderCallbacks<?> callbacks = new InsertLoaderCallbacks(listener);
    execute(request, callbacks);
}
项目:arca-android    文件:ModernRequestDispatcher.java   
@Override
public void execute(final Delete request, final DeleteListener listener) {
    final LoaderCallbacks<?> callbacks = new DeleteLoaderCallbacks(listener);
    execute(request, callbacks);
}
项目:arca-android    文件:ModernRequestDispatcher.java   
@Override
public void execute(final Batch request, final BatchListener listener) {
    final LoaderCallbacks<?> callbacks = new BatchLoaderCallbacks(listener);
    execute(request, callbacks);
}
项目:arca-android    文件:ModernRequestDispatcher.java   
private void execute(final Request<?> request, final LoaderCallbacks<?> callbacks) {
    final int identifier = request.getIdentifier();
    final Bundle bundle = createRequestBundle(request);
    mLoaderManager.restartLoader(identifier, bundle, callbacks);
}