本文整理汇总了Java中android.support.v4.app.LoaderManager.initLoader方法的典型用法代码示例。如果您正苦于以下问题:Java LoaderManager.initLoader方法的具体用法?Java LoaderManager.initLoader怎么用?Java LoaderManager.initLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.LoaderManager
的用法示例。
在下文中一共展示了LoaderManager.initLoader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadListViewItems
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void loadListViewItems(int listPosition, boolean markSeen, boolean showProgress) {
if (!isAdded()) {
return;
}
int loaderId = 0;
ConversationsLoaderCallbacks callbacks =
new ConversationsLoaderCallbacks(getContext(), listView,
listPosition, cursorAdapter, markSeen, showProgress);
LoaderManager manager = getLoaderManager();
Loader<?> loader = manager.getLoader(loaderId);
if (loader == null) {
// init and run the items loader
manager.initLoader(loaderId, null, callbacks);
} else {
// restart loader
manager.restartLoader(loaderId, null, callbacks);
}
}
示例2: loadListViewItems
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void loadListViewItems(String itemsFilter, boolean deleteItems, int listPosition) {
if (!isAdded()) {
return;
}
int loaderId = 0;
JournalItemsLoaderCallbacks callbacks =
new JournalItemsLoaderCallbacks(getContext(), cursorAdapter,
itemsFilter, deleteItems, listView, listPosition);
LoaderManager manager = getLoaderManager();
if (manager.getLoader(loaderId) == null) {
// init and run the items loader
manager.initLoader(loaderId, null, callbacks);
} else {
// restart loader
manager.restartLoader(loaderId, null, callbacks);
}
}
示例3: loadListViewItems
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void loadListViewItems(int threadId, int unreadCount, int listPosition) {
if (!isAdded()) {
return;
}
int loaderId = 0;
ConversationLoaderCallbacks callbacks =
new ConversationLoaderCallbacks(getContext(),
threadId, unreadCount, listView, listPosition, cursorAdapter);
LoaderManager manager = getLoaderManager();
if (manager.getLoader(loaderId) == null) {
// init and run the items loader
manager.initLoader(loaderId, null, callbacks);
} else {
// restart loader
manager.restartLoader(loaderId, null, callbacks);
}
}
示例4: loadListViewItems
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void loadListViewItems(String itemsFilter, boolean deleteItems, int listPosition) {
if (!isAdded()) {
return;
}
int loaderId = 0;
ContactsLoaderCallbacks callbacks =
new ContactsLoaderCallbacks(getContext(), contactType, cursorAdapter,
itemsFilter, deleteItems, listView, listPosition);
LoaderManager manager = getLoaderManager();
if (manager.getLoader(loaderId) == null) {
// init and run the items loader
manager.initLoader(loaderId, null, callbacks);
} else {
// restart loader
manager.restartLoader(loaderId, null, callbacks);
}
}
示例5: search
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void search(EditText editText) {
mEditText = editText;
// Initialize the Loader with id '1239' and callbacks.
// If the loader doesn't already exist, one is created. Otherwise,
// the already created Loader is reused. In either case, the
// LoaderManager will manage the Loader across the Activity/Fragment
// lifecycle, will receive any new loads once they have completed,
// and will report this new data back via callbacks.
LoaderManager lm = getSupportLoaderManager();
//close any loader that is already running
lm.destroyLoader(LOADER_ID);
//init new loader
lm.initLoader(LOADER_ID, null, this);
}
示例6: onActivityCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Activity activity = getActivity();
if (activity instanceof FloatingActionButtonProvider) {
actionButton = ((FloatingActionButtonProvider) activity).getActionButton();
if (actionButton != null) {
actionButton.setOnClickListener(actionButtonClickListener);
}
}
// Ensure the actionButton is initialized before creating the options menu
setHasOptionsMenu(true);
LoaderManager loaderManager = getLoaderManager();
loaderManager.initLoader(BOOKMARK_STATUS_LOADER_ID, null, bookmarkStatusLoaderCallbacks);
loaderManager.initLoader(EVENT_DETAILS_LOADER_ID, null, eventDetailsLoaderCallbacks);
}
示例7: startSearch
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void startSearch(String terms, String tags, int page){
noResults.setVisibility(View.GONE);
Bundle args = new Bundle();
args.putString(SearchActivity.TERMS, terms);
args.putString(SearchActivity.TAGS, tags);
args.putInt(SearchActivity.PAGE, page);
LoaderManager lm = getLoaderManager();
Loader l = lm.getLoader(page);
if (l == null){
lm.initLoader(page, args, this);
}
//Check if the terms and tags are different from what the loader has and restart if they're different
else {
RequestSearchAsyncLoader s = (RequestSearchAsyncLoader)l;
if (!s.getTerms().equalsIgnoreCase(searchTerms) || !s.getTags().equalsIgnoreCase(tags)){
lm.restartLoader(page, args, this);
}
else {
lm.initLoader(page, args, this);
}
}
}
示例8: startSearch
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void startSearch(String terms, int page){
noResults.setVisibility(View.GONE);
Bundle args = new Bundle();
args.putString(SearchActivity.TERMS, terms);
args.putInt(SearchActivity.PAGE, page);
LoaderManager lm = getLoaderManager();
Loader l = lm.getLoader(page);
if (l == null){
lm.initLoader(page, args, this);
}
//Check if the terms and tags are different from what the loader has and restart if they're different
else {
UserSearchAsyncLoader s = (UserSearchAsyncLoader)l;
if (!s.getTerms().equalsIgnoreCase(searchTerms)){
lm.restartLoader(page, args, this);
}
else {
lm.initLoader(page, args, this);
}
}
}
示例9: startSearch
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void startSearch(String terms, String tags, int page){
noResults.setVisibility(View.GONE);
Bundle args = new Bundle();
args.putString(SearchActivity.TERMS, terms);
args.putString(SearchActivity.TAGS, tags);
args.putInt(SearchActivity.PAGE, page);
LoaderManager lm = getLoaderManager();
Loader l = lm.getLoader(page);
if (l == null){
lm.initLoader(page, args, this);
}
//Check if the terms and tags are different from what the loader has and restart if they're different
else {
TorrentSearchAsyncLoader s = (TorrentSearchAsyncLoader)l;
if (!s.getTerms().equalsIgnoreCase(searchTerms) || !s.getTags().equalsIgnoreCase(tags)){
lm.restartLoader(page, args, this);
}
else {
lm.initLoader(page, args, this);
}
}
}
示例10: onActivityCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Activity activity = getActivity();
if (activity instanceof FloatingActionButtonProvider) {
actionButton = ((FloatingActionButtonProvider) activity).getActionButton();
if (actionButton != null) {
actionButton.setOnClickListener(actionButtonClickListener);
}
}
// Ensure the actionButton is initialized before creating the options menu
setHasOptionsMenu(true);
LoaderManager loaderManager = getLoaderManager();
loaderManager.initLoader(BOOKMARK_STATUS_LOADER_ID, null, bookmarkStatusLoaderCallbacks);
loaderManager.initLoader(EVENT_DETAILS_LOADER_ID, null, eventDetailsLoaderCallbacks);
}
示例11: startLoaders
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
private void startLoaders(@Nullable final Assignment assignment) {
if (assignment != null) {
// build the args used for various loaders
final Bundle args = new Bundle(3);
args.putString(ARG_GUID, mGuid);
args.putString(ARG_MINISTRY_ID, assignment.getMinistryId());
args.putString(ARG_MCC, assignment.getMcc().toString());
// start loaders
final LoaderManager manager = this.getLoaderManager();
if (assignment.getMcc() == Mcc.GCM) {
manager.initLoader(LOADER_CHURCHES, args, mLoaderCallbacksChurches);
}
if (assignment.getMcc() != Mcc.UNKNOWN) {
manager.initLoader(LOADER_TRAININGS, args, mLoaderCallbacksTraining);
}
}
}
示例12: onActivityCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mAdapter = new AltCursorAdapter(getActivity(), new int[]{R.layout.news_item}, null,
new String[]{DB.MyNews.FEED_ID, DB.News.TITLE, DB.News.PUBLISHED_DATE},
new int[]{R.id.news_feed, R.id.news_title, R.id.news_date});
mAdapter.setViewBinder(new BinderNews(getActivity()));
setListAdapter(mAdapter);
initUI();
// on screen orientation changes, the loaders will return the last result,
// without doing the background work again
LoaderManager lm = getLoaderManager();
lm.initLoader(LoaderIds.CURSOR_GET_STARRED, null, cursorCallbacks);
}
示例13: onActivityCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final LoaderManager manager = getLoaderManager();
// Initialize the search adapter
mAdapter = new SearchAdapter(getActivity());
mList.setAdapter(mAdapter);
// Create callbacks before the initial loader is started
mLoaderCallbacks = new CursorLoaderCallbacks();
// Reconnect to the loader only if present
manager.initLoader(LOADER_ID_SEARCH, null, mLoaderCallbacks);
// If there is a search term, put it in the text field
if (!TextUtils.isEmpty(mSearchTerm)) {
mSearch.setText(mSearchTerm);
mSearch.selectAll();
}
// Always start with an empty filter
filter("");
}
示例14: onActivityCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mMessageHelper = MessageHelper.getInstance(getActivity());
initializeMessageList();
// This needs to be done before initializing the cursor loader below
initializeSortSettings();
mLoaderJustInitialized = true;
LoaderManager loaderManager = getLoaderManager();
int len = mAccountUuids.length;
mCursors = new Cursor[len];
mCursorValid = new boolean[len];
for (int i = 0; i < len; i++) {
loaderManager.initLoader(i, null, this);
mCursorValid[i] = false;
}
}
示例15: onCreate
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
// Check for a Item ID as an argument, and find the item
Bundle args = getArguments();
if (args != null) {
long itemId = args.getLong(ARG_ITEM_ID, -1);
if (itemId != -1) {
LoaderManager lm = getLoaderManager();
lm.initLoader(R.id.item_detail_fragment, args, new ItemLoaderCallbacks());
}
}
}