List of usage examples for android.support.v4.app LoaderManager initLoader
public abstract <D> Loader<D> initLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback);
From source file:org.aweture.wonk.substitutions.Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This Activity is in every case the landing activity. But that doesn't mean that the // users should be shown this Activity. Maybe they should be redirected to the // landing Activity. if (shouldDisplayLanding()) { displayLandingActivity();/*ww w.ja v a2 s.c o m*/ return; } // Set content view and toolbar setContentView(R.layout.activity_substitutions); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); // Set up ViewPager with an adapter and tabs. adapter = new PartAdapter(); ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(adapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout); tabLayout.setupWithViewPager(viewPager); // Set up the member variables. feedbackContainer = findViewById(R.id.feedbackContainer); noDataText = findViewById(R.id.noDataText); progessBar = findViewById(R.id.progressBar); // The ProgressBar might have a color that makes it hard to distinguish. // So it is set to the primary color to make sure everything is laid out properly. int primaryColor = ContextCompat.getColor(this, R.color.primary); ((ProgressBar) progessBar).getIndeterminateDrawable().setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN); // Init the LoaderManager to load the content. LoaderManager loaderManager = getSupportLoaderManager(); loaderManager.initLoader(R.id.SUBSTITUTIONS_ACTIVTY_PLAN_LOADER, null, this); }
From source file:net.niyonkuru.koodroid.ui.UsageFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); LoaderManager loaderManager = getLoaderManager(); if (isAirtimeEnabled()) { loaderManager.initLoader(AIRTIME_TOKEN, null, this); }//w ww.j a v a2 s. c om if (isUsageEnabled()) { loaderManager.initLoader(DATA_TOKEN, null, this); loaderManager.initLoader(TEXT_TOKEN, null, this); } }
From source file:com.bangz.shotrecorder.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();/*from w w w. j av a 2 s.com*/ if (intent.getData() == null) { intent.setData(ShotRecord.ShotRecords.CONTENT_URI); } setContentView(R.layout.activity_main); Button button = (Button) findViewById(R.id.startRecorderActivity); button.setOnClickListener(this); String[] columns = new String[] { ShotRecord.ShotRecords.COLUMN_NAME_DATE, ShotRecord.ShotRecords.COLUMN_NAME_DESCRIPTION, ShotRecord.ShotRecords.COLUMN_NAME_SHOTS, ShotRecord.ShotRecords.COLUMN_NAME_SPENDTIME }; int[] listitemids = new int[] { R.id.txtDate, R.id.txtDescription, R.id.txtNumber, R.id.txtTime, }; mAdapter = new SimpleCursorAdapter(this, R.layout.recorder_list_entry, null, columns, listitemids, 0) { @Override public void bindView(View view, Context context, Cursor cursor) { int idxID = cursor.getColumnIndex(ShotRecord.ShotRecords._ID); int idxDate = cursor.getColumnIndex(ShotRecord.ShotRecords.COLUMN_NAME_DATE); int idxDescript = cursor.getColumnIndex(ShotRecord.ShotRecords.COLUMN_NAME_DESCRIPTION); int idxSpendTime = cursor.getColumnIndex(ShotRecord.ShotRecords.COLUMN_NAME_SPENDTIME); int idxShots = cursor.getColumnIndex(ShotRecord.ShotRecords.COLUMN_NAME_SHOTS); String date = cursor.getString(idxDate); date = date.substring(0, date.lastIndexOf(':')); String descript = cursor.getString(idxDescript); long shots = cursor.getLong(idxShots); long spendtime = cursor.getLong(idxSpendTime); TextView v = (TextView) view.findViewById(R.id.txtDate); v.setText(date); v = (TextView) view.findViewById(R.id.txtDescription); v.setText(descript); v = (TextView) view.findViewById(R.id.txtNumber); v.setText(String.format("%d", shots)); v = (TextView) view.findViewById(R.id.txtTime); v.setText(String.format("%.02f", spendtime / 1000.0)); } }; TextView emptyView = (TextView) findViewById(R.id.empty); DragSortListView listView = (DragSortListView) findViewById(R.id.listRecords); listView.setEmptyView(emptyView); listView.setAdapter(mAdapter); listView.setOnItemClickListener(this); listView.setRemoveListener(this); LoaderManager lm = getSupportLoaderManager(); lm.initLoader(1, null, this); }
From source file:ru.yandex.subtitles.ui.fragment.conversations.ConversationFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final Activity activity = getActivity(); mRecyclerView = findView(R.id.recycler); mLayoutManager = new LinearLayoutManager(activity); mLayoutManager.setReverseLayout(false); mLayoutManager.setStackFromEnd(true); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setItemAnimator(new NoFadeItemAnimator()); registerForContextMenu(mRecyclerView); mAdapter = new ConversationAdapter(activity); mAdapter.setOnItemClickListener(this); mRecyclerView.setAdapter(mAdapter);// www . j a v a 2s . com mTypeMessageView = findView(R.id.type_message_view); mTypeMessageView.setTypeMessageViewCallbacks(this); mTypeMessageView.setRootView(findView(R.id.root_view)); final long threadId = getArguments().getLong(EXTRA_THREAD_ID); final LoaderManager loaderManager = getLoaderManager(); final Bundle messagesArgs = MessagesLoader.forThreadId(threadId); loaderManager.initLoader(R.id.messages_loader, messagesArgs, mMessagesLoaderCallbacks); final Bundle analyticsArgs = ThreadAnalyticsLoader.forThreadId(threadId); loaderManager.initLoader(R.id.thread_analytics_loader, analyticsArgs, mThreadAnalyticsLoaderCallbacks); loaderManager.initLoader(R.id.quick_responses_loader, null, mQuickResponsesLoaderCallbacks); mPartialResultReceiver.subscribe(activity); mSpeakerReceiver = new SpeakerBroadcastReceiver(mAdapter); mSpeakerReceiver.subscribe(activity); }
From source file:org.mozilla.gecko.home.PinSiteDialog.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final LoaderManager manager = getLoaderManager(); // Initialize the search adapter mAdapter = new SearchAdapter(getActivity()); mList.setAdapter(mAdapter);/*from w ww . jav a 2 s.c o m*/ // 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(""); }
From source file:com.example.levelup.core.app.RegisterFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); LoaderManager loaderManager = getLoaderManager(); if (mAccessTokenLoaderCallbacks != null) { mAccessTokenLoaderCallbacks.reconnectOrDismiss(); }/*from w ww . j av a 2s . c o m*/ // Reconnect the loader callbacks. if (loaderManager.getLoader(LOADER_LOGIN) != null) { loaderManager.initLoader(LOADER_LOGIN, null, mAccessTokenLoaderCallbacks); } if (loaderManager.getLoader(LOADER_REGISTER) != null) { loaderManager.initLoader(LOADER_REGISTER, null, mRegisterLoaderCallbacks); } }
From source file:mobisocial.musubi.ui.fragments.ConversationsFragment.java
void initLoaders(boolean restart) { LoaderManager lm = getLoaderManager(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/* w w w . j a v a2 s .c o m*/ Bundle args = new Bundle(); args.putLong("start", cal.getTimeInMillis()); if (restart) { lm.restartLoader(0, args, this); } else { lm.initLoader(0, args, this); } cal.add(Calendar.DAY_OF_MONTH, -1); for (int i = 1; i < FeedListFragment.DAYS_TO_SHOW; i++) { long time = cal.getTimeInMillis(); args = new Bundle(); args.putLong("start", time); args.putLong("end", time + FeedListFragment.ONE_DAY); if (restart) { lm.restartLoader(i, args, this); } else { lm.initLoader(i, args, this); } cal.add(Calendar.DAY_OF_MONTH, -1); } args = new Bundle(); args.putLong("end", cal.getTimeInMillis() + FeedListFragment.ONE_DAY); if (restart) { lm.restartLoader(FeedListFragment.DAYS_TO_SHOW, args, this); } else { lm.initLoader(FeedListFragment.DAYS_TO_SHOW, args, this); } }
From source file:org.dodgybits.shuffle.android.core.listener.CursorLoader.java
private void startListLoading(Location location) { ViewMode viewMode = location.getViewMode(); int listId = listId(); Log.d(TAG, "Creating relevant list cursor for " + viewMode + " listId " + listId); final LoaderManager lm = mActivity.getSupportLoaderManager(); switch (viewMode) { case TASK:// w w w . j av a 2 s .c om case TASK_LIST: case SEARCH_RESULTS_LIST: case SEARCH_RESULTS_TASK: lm.initLoader(listId, null, TASK_LIST_LOADER_CALLBACKS); if (location.getListQuery() == ListQuery.deleted) { lm.initLoader(listId, null, CONTEXT_LIST_LOADER_CALLBACKS); lm.initLoader(listId, null, PROJECT_LIST_LOADER_CALLBACKS); } break; case CONTEXT_LIST: lm.initLoader(listId, null, CONTEXT_LIST_LOADER_CALLBACKS); break; case PROJECT_LIST: lm.initLoader(listId, null, PROJECT_LIST_LOADER_CALLBACKS); break; case DELETED_LIST: lm.initLoader(("task" + listId).hashCode(), null, TASK_LIST_LOADER_CALLBACKS); lm.initLoader(("context" + listId).hashCode(), null, CONTEXT_LIST_LOADER_CALLBACKS); lm.initLoader(("project" + listId).hashCode(), null, PROJECT_LIST_LOADER_CALLBACKS); break; default: // TODO } }
From source file:com.wit.android.support.database.LoadableAssistant.java
/** * Starts a loader using {@link LoaderManager} obtained from the given <var>activity</var> with * the current id and the specified parameters. * <p>//from ww w . j av a 2s . c om * If the LoaderManager already has a Loader with the id of this assistant, such a loader will be * restarted by {@link LoaderManager#restartLoader(int, android.os.Bundle, LoaderManager.LoaderCallbacks)}, * otherwise will be initiated by {@link LoaderManager#initLoader(int, android.os.Bundle, LoaderManager.LoaderCallbacks)}. * <p> * <b>Note</b>, that this assistant must have valid (none negative) loader id, otherwise the * requested loader can not be started. * * @param activity Activity used to access LoaderManager instance. * @param params The desired parameters for loader. * @return {@code True} if loader was successfully started (initiated/restarted), {@code false} * otherwise. */ public boolean startLoader(@NonNull FragmentActivity activity, @Nullable Bundle params) { if (mLoaderId >= 0) { final LoaderManager loaderManager = activity.getSupportLoaderManager(); if (loaderManager != null) { if (loaderManager.getLoader(mLoaderId) != null) { loaderManager.restartLoader(mLoaderId, params, this); } else { loaderManager.initLoader(mLoaderId, params, this); } return true; } } return false; }
From source file:org.dmfs.webcal.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); setupNavbar();/* www .j av a 2 s . c om*/ mFragmentManager = getSupportFragmentManager(); if (savedInstanceState == null) { selectItem(R.id.side_nav_all_calendars); setNavigationSelection(0); } else if (mSelectedItemId >= 0) { selectItem(mSelectedItemId); setNavigationSelectionById(mSelectedItemId); } if (mFirstStart) { mFirstStart = false; openDrawer(); } if (savedInstanceState == null) { Analytics.sessionStart("MAIN"); } SharedPreferences prefs = getSharedPreferences(getPackageName() + "_preferences", 0); if (prefs.getBoolean("enable_analytics", true)) { Analytics.enable(); } else { Analytics.disable(); } PushHelper.registerPush(this); LoaderManager lm = getSupportLoaderManager(); lm.initLoader(-2, null, this); initIabHelper(); }