android.app.LoaderManager.LoaderCallbacks Java Examples

The following examples show how to use android.app.LoaderManager.LoaderCallbacks. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecentsCreateFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #2
Source File: RootsFragment.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@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);
        }
    };
}
 
Example #3
Source File: RecentsCreateFragment.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #4
Source File: RootsFragment.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@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);
        }
    };
}
 
Example #5
Source File: RecentsCreateFragment.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #6
Source File: RootsFragment.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
@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);
        }
    };
}
 
Example #7
Source File: ModernRequestDispatcher.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void execute(final Query request, final QueryListener listener) {
	final LoaderCallbacks<?> callbacks = new QueryLoaderCallbacks(listener);
	execute(request, callbacks);
}
 
Example #8
Source File: ModernRequestDispatcher.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void execute(final Update request, final UpdateListener listener) {
	final LoaderCallbacks<?> callbacks = new UpdateLoaderCallbacks(listener);
	execute(request, callbacks);
}
 
Example #9
Source File: ModernRequestDispatcher.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void execute(final Insert request, final InsertListener listener) {
	final LoaderCallbacks<?> callbacks = new InsertLoaderCallbacks(listener);
	execute(request, callbacks);
}
 
Example #10
Source File: ModernRequestDispatcher.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void execute(final Delete request, final DeleteListener listener) {
	final LoaderCallbacks<?> callbacks = new DeleteLoaderCallbacks(listener);
	execute(request, callbacks);
}
 
Example #11
Source File: ModernRequestDispatcher.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void execute(final Batch request, final BatchListener listener) {
	final LoaderCallbacks<?> callbacks = new BatchLoaderCallbacks(listener);
	execute(request, callbacks);
}
 
Example #12
Source File: ModernRequestDispatcher.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void execute(final Request<?> request, final LoaderCallbacks<?> callbacks) {
	final int identifier = request.getIdentifier();
	final Bundle bundle = createRequestBundle(request);
	mLoaderManager.restartLoader(identifier, bundle, callbacks);
}