本文整理汇总了Java中android.support.v4.app.LoaderManager类的典型用法代码示例。如果您正苦于以下问题:Java LoaderManager类的具体用法?Java LoaderManager怎么用?Java LoaderManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoaderManager类属于android.support.v4.app包,在下文中一共展示了LoaderManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CategoryController
import android.support.v4.app.LoaderManager; //导入依赖的package包/类
CategoryController(final Activity activity, LoaderManager loaderManager, View itemView) {
super(itemView);
this.activity = activity;
this.loaderManager = loaderManager;
appCardsAdapter = new AppPreviewAdapter(activity);
viewAll = (Button) itemView.findViewById(R.id.button);
viewAll.setOnClickListener(onViewAll);
heading = (TextView) itemView.findViewById(R.id.name);
image = (FeatureImage) itemView.findViewById(R.id.category_image);
background = (FrameLayout) itemView.findViewById(R.id.category_background);
RecyclerView appCards = (RecyclerView) itemView.findViewById(R.id.app_cards);
appCards.setAdapter(appCardsAdapter);
appCards.addItemDecoration(new ItemDecorator(activity));
displayImageOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.imageScaleType(ImageScaleType.NONE)
.displayer(new FadeInBitmapDisplayer(100, true, true, false))
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
}
示例2: onCreate
import android.support.v4.app.LoaderManager; //导入依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.logD(LOG_TAG, "onCreate");
mSharedPreferences = new PreferencesManagerImp(getActivity().getApplicationContext());
mLocation = mSharedPreferences.getLocation();
if (savedInstanceState != null) {
mRotation = true;
}
LoaderProvider loaderProvider = new LoaderProvider(getContext());
LoaderManager loaderManager = getLoaderManager();
Geocoder geocoder = new Geocoder(getActivity());
// loaderManager.enableDebugLogging(true);
mPresenter = new FindPresenter(mLocation, loaderManager, loaderProvider, geocoder);
setHasOptionsMenu(true);
mRecentSearchSuggestions = new SearchRecentSuggestions(getContext(),
RecentSuggestionsProvider.AUTHORITY, RecentSuggestionsProvider.MODE);
mCompositeSubscription = new CompositeSubscription();
mActivityCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinator);
mSnackCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinatorSnackContainer);
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
示例8: testGet
import android.support.v4.app.LoaderManager; //导入依赖的package包/类
@Test
public void testGet() throws Exception {
//GIVEN
FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).create().get();
Application application = RuntimeEnvironment.application;
Scope appScope = Toothpick.openScope(application);
appScope.installModules(new SmoothieApplicationModule(application));
Scope activityScope = Toothpick.openScopes(application, activity);
activityScope.installModules(new SmoothieSupportActivityModule(activity));
//WHEN
Activity injectedActivity = activityScope.getInstance(Activity.class);
FragmentManager fragmentManager = activityScope.getInstance(FragmentManager.class);
LoaderManager loaderManager = activityScope.getInstance(LoaderManager.class);
LayoutInflater layoutInflater = activityScope.getInstance(LayoutInflater.class);
//THEN
assertThat(injectedActivity, instanceOf(FragmentActivity.class));
assertThat((FragmentActivity) injectedActivity, sameInstance(activity));
assertThat(fragmentManager, notNullValue());
assertThat(loaderManager, notNullValue());
assertThat(layoutInflater, notNullValue());
}
示例9: 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);
}
示例10: 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);
}
}
}
示例11: 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);
}
}
}
示例12: 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);
}
}
}
示例13: getLoaderManager
import android.support.v4.app.LoaderManager; //导入依赖的package包/类
public LoaderManager getLoaderManager() {
if (mPlugins.isEmpty()) {
return getOriginal().super_getLoaderManager();
}
final ListIterator<FragmentPlugin> iterator = mPlugins.listIterator(mPlugins.size());
final CallFun0<LoaderManager> superCall = new CallFun0<LoaderManager>(
"getLoaderManager()") {
@Override
public LoaderManager call() {
if (iterator.hasPrevious()) {
return iterator.previous().getLoaderManager(this);
} else {
return getOriginal().super_getLoaderManager();
}
}
};
return superCall.call();
}
示例14: getLoaderManager
import android.support.v4.app.LoaderManager; //导入依赖的package包/类
public android.app.LoaderManager getLoaderManager() {
if (mPlugins.isEmpty()) {
return getOriginal().super_getLoaderManager();
}
final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size());
final CallFun0<android.app.LoaderManager> superCall
= new CallFun0<android.app.LoaderManager>("getLoaderManager()") {
@Override
public android.app.LoaderManager call() {
if (iterator.hasPrevious()) {
return iterator.previous().getLoaderManager(this);
} else {
return getOriginal().super_getLoaderManager();
}
}
};
return superCall.call();
}
示例15: getSupportLoaderManager
import android.support.v4.app.LoaderManager; //导入依赖的package包/类
public LoaderManager getSupportLoaderManager() {
if (mPlugins.isEmpty()) {
return getOriginal().super_getSupportLoaderManager();
}
final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size());
final CallFun0<LoaderManager> superCall = new CallFun0<LoaderManager>(
"getSupportLoaderManager()") {
@Override
public LoaderManager call() {
if (iterator.hasPrevious()) {
return iterator.previous().getSupportLoaderManager(this);
} else {
return getOriginal().super_getSupportLoaderManager();
}
}
};
return superCall.call();
}