本文整理汇总了Java中android.support.v4.app.LoaderManager.getLoader方法的典型用法代码示例。如果您正苦于以下问题:Java LoaderManager.getLoader方法的具体用法?Java LoaderManager.getLoader怎么用?Java LoaderManager.getLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.LoaderManager
的用法示例。
在下文中一共展示了LoaderManager.getLoader方法的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: 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);
}
}
}
示例6: 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);
}
}
}
示例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 {
TorrentSearchAsyncLoader s = (TorrentSearchAsyncLoader)l;
if (!s.getTerms().equalsIgnoreCase(searchTerms) || !s.getTags().equalsIgnoreCase(tags)){
lm.restartLoader(page, args, this);
}
else {
lm.initLoader(page, args, this);
}
}
}
示例8: initStartedLoaders
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
/**
* Initialize already started loaders.
*/
void initStartedLoaders() {
LoaderManager lm = operatorContext.loaderManager;
SparseArray<LoaderCookies> listenersMap = this.listenersMap;
int count = listenersMap.size();
for (int i = 0; i < count; i++) {
int loaderId = listenersMap.keyAt(i);
Loader<?> loader = lm.getLoader(loaderId);
if (loader != null && loader.isStarted()) {
LoaderCookies cookies = listenersMap.valueAt(i);
boolean notInit = (cookies.options & LoaderCookies.ALREADY_INIT) == 0;
if (notInit) {
Utils.initLoader(
operatorContext,
loaderId,
STUB_PROVIDER,
(cookies.options & LoaderCookies.DESTROY_ON_FINISH) == LoaderCookies.DESTROY_ON_FINISH,
this
);
}
}
}
}
示例9: onCreate
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Activity activity = getActivity();
AccountManager manager = AccountManager.get(activity);
if (!User.isLoggedIn(manager)) {
activity.setResult(Activity.RESULT_CANCELED);
activity.finish();
}
LoaderManager loaders = getLoaderManager();
if (loaders.getLoader(LOAD_AUTH_TOKEN) != null) {
loaders.initLoader(LOAD_AUTH_TOKEN, null, mLoadAuthTokenCallbacks);
}
}
示例10: onActivityCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
PlansAdapter adapter = new PlansAdapter(getActivity(), now);
setListAdapter(adapter);
getListView().setOnItemLongClickListener(this);
LoaderManager lm = getLoaderManager();
if (lm.getLoader(uid) != null) {
getLoaderManager().initLoader(uid, null, this);
} else if (doDummy && now < 0L) {
doDummy = false;
getLoaderManager().initLoader(UID_DUMMY, null, this);
}
}
示例11: reLaunchOperations
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public void reLaunchOperations(int loaderId) {
AppCompatActivity activity = (AppCompatActivity)this.getContext();
if (activity != null) {
LoaderManager supportLoaderManager = activity.getSupportLoaderManager();
if (supportLoaderManager.getLoader(loaderId) != null) {
this.launchOperation();
}
}
}
示例12: onViewCreated
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final FragmentActivity activity = getActivity();
AbsListView list = ButterKnife.findById(view,android.R.id.list);
list.setEmptyView(view.findViewById(android.R.id.empty));
adapter = new MyPointsAdapter(activity, null);
(list).setAdapter(adapter);
LoaderManager loaderManager = activity.getSupportLoaderManager();
if (loaderManager.getLoader(POINT_HISTORY_ID) == null) {
loaderManager.initLoader(POINT_HISTORY_ID, null, this);
} else {
loaderManager.restartLoader(POINT_HISTORY_ID, null, this);
}
/**
* убрал условие запроса не чаще, чем раз в PointsManger.isExpired(context)
* пользователь не всегда догадыватеся сам обновить историю
* полагает, что баллы не начислены и пишет в техподдержку
*/
PointsManager.refreshPointHistory((BaseActivity) activity, new Response.Listener<Object>() {
@Override
public void onResponse(Object o) {
processTitleBalance();
processStatus();
processPoints();
processPointUnits();
}
}, null);
processTitleBalance();
processStatus();
processPoints();
processPointUnits();
}
示例13: attachProgressCallback
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public static <TData, TProgress> void attachProgressCallback(LoaderManager loaderManager, int id, @NonNull ProgressPromiseLoaderCallbacks<TData, TProgress> loaderCallbacks) {
final Loader<Result<TData>> loader = loaderManager.getLoader(id);
if (loader == null) {
return;
}
@SuppressWarnings("unchecked") final ProgressPromiseLoader<TData, TProgress> promiseLoader = (ProgressPromiseLoader<TData, TProgress>) loader;
promiseLoader.attachLoaderCallbacks(loaderCallbacks);
}
示例14: detachProgressCallback
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public static <TData, TProgress> void detachProgressCallback(LoaderManager loaderManager, int id, @NonNull ProgressPromiseLoaderCallbacks<TData, TProgress> loaderCallbacks) {
final Loader<Result<TData>> loader = loaderManager.getLoader(id);
if (loader == null) {
return;
}
@SuppressWarnings("unchecked") final ProgressPromiseLoader<TData, TProgress> promiseLoader = (ProgressPromiseLoader<TData, TProgress>) loader;
promiseLoader.detachLoaderCallbacks(loaderCallbacks);
}
示例15: cancelLoader
import android.support.v4.app.LoaderManager; //导入方法依赖的package包/类
public static void cancelLoader(LoaderManager loaderManager, int id) {
final Loader<?> loader = loaderManager.getLoader(id);
if (loader == null) {
return;
}
loader.cancelLoad();
}