List of usage examples for android.content Loader getId
public int getId()
From source file:com.frostwire.android.gui.fragments.BrowsePeerFragment.java
@Override public void onLoadFinished(Loader<Object> loader, Object data) { if (data == null) { LOG.warn("Something wrong, data is null"); return;/*from ww w. ja v a 2s. c om*/ } if (loader.getId() == LOADER_FILES_ID) { updateFiles((Object[]) data); } updateHeader(); if (swipeRefresh != null) { swipeRefresh.setRefreshing(false); } }
From source file:com.android.browser.BookmarksPageCallbacks.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (loader.getId() == LOADER_ACCOUNTS) { LoaderManager lm = getLoaderManager(); int id = LOADER_BOOKMARKS; while (cursor.moveToNext()) { String accountName = cursor.getString(0); String accountType = cursor.getString(1); Bundle args = new Bundle(); args.putString(ACCOUNT_NAME, accountName); args.putString(ACCOUNT_TYPE, accountType); BrowserBookmarksAdapter adapter = new BrowserBookmarksAdapter(getActivity()); mBookmarkAdapters.put(id, adapter); boolean expand = true; try { expand = mState.getBoolean( accountName != null ? accountName : BookmarkExpandableView.LOCAL_ACCOUNT_NAME); } catch (JSONException e) { } // no state for accountName mGrid.addAccount(accountName, adapter, expand); lm.restartLoader(id, args, this); id++;//from ww w .j a v a 2 s . c om } // TODO: Figure out what a reload of these means // Currently, a reload is triggered whenever bookmarks change // This is less than ideal // It also causes UI flickering as a new adapter is created // instead of re-using an existing one when the account_name is the // same. // For now, this is a one-shot load getLoaderManager().destroyLoader(LOADER_ACCOUNTS); } else if (loader.getId() >= LOADER_BOOKMARKS) { BrowserBookmarksAdapter adapter = mBookmarkAdapters.get(loader.getId()); adapter.changeCursor(cursor); } }
From source file:com.android.xbrowser.BookmarksPageCallbacks.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (loader.getId() == LOADER_ACCOUNTS) { LoaderManager lm = getLoaderManager(); int id = LOADER_BOOKMARKS; while (cursor.moveToNext()) { String accountName = cursor.getString(0); String accountType = cursor.getString(1); Bundle args = new Bundle(); args.putString(ACCOUNT_NAME, accountName); args.putString(ACCOUNT_TYPE, accountType); BrowserBookmarksAdapter adapter = new BrowserBookmarksAdapter(getActivity(), VIEW_THUMBNAILS); mBookmarkAdapters.put(id, adapter); boolean expand = true; try { expand = mState.getBoolean( accountName != null ? accountName : BookmarkExpandableView.LOCAL_ACCOUNT_NAME); } catch (JSONException e) { } // no state for accountName mGrid.addAccount(accountName, adapter, expand); lm.restartLoader(id, args, this); id++;/*from ww w .ja v a 2 s . co m*/ } // TODO: Figure out what a reload of these means // Currently, a reload is triggered whenever bookmarks change // This is less than ideal // It also causes UI flickering as a new adapter is created // instead of re-using an existing one when the account_name is the // same. // For now, this is a one-shot load getLoaderManager().destroyLoader(LOADER_ACCOUNTS); } else if (loader.getId() >= LOADER_BOOKMARKS) { BrowserBookmarksAdapter adapter = mBookmarkAdapters.get(loader.getId()); adapter.changeCursor(cursor); } }
From source file:com.aengbee.android.leanback.ui.VideoDetailsFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor != null && cursor.moveToNext()) { switch (loader.getId()) { case RELATED_VIDEO_LOADER: { mVideoCursorAdapter.changeCursor(cursor); break; }// w w w . ja v a 2 s . com default: { // Loading video from global search. mSelectedVideo = (Video) mVideoCursorMapper.convert(cursor); setupAdapter(); setupDetailsOverviewRow(); setupMovieListRow(); updateBackground(mSelectedVideo.bgImageUrl); // When a Related Video item is clicked. setOnItemViewClickedListener(new ItemViewClickedListener()); } } } }
From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (loader.getId() == LOADER_ACCOUNTS) { LoaderManager lm = getLoaderManager(); int id = LOADER_BOOKMARKS; while (cursor.moveToNext()) { String accountName = cursor.getString(0); String accountType = cursor.getString(1); Bundle args = new Bundle(); args.putString(ACCOUNT_NAME, accountName); args.putString(ACCOUNT_TYPE, accountType); BrowserBookmarksAdapter adapter = new BrowserBookmarksAdapter(this); mBookmarkAdapters.put(id, adapter); boolean expand = true; try { expand = mState.getBoolean( accountName != null ? accountName : BookmarkExpandableView.LOCAL_ACCOUNT_NAME); } catch (JSONException e) { } // no state for accountName mGrid.addAccount(accountName, adapter, expand); lm.restartLoader(id, args, this); id++;//from ww w .j a v a 2 s . c om } // TODO: Figure out what a reload of these means // Currently, a reload is triggered whenever bookmarks change // This is less than ideal // It also causes UI flickering as a new adapter is created // instead of re-using an existing one when the account_name is the // same. // For now, this is a one-shot load getLoaderManager().destroyLoader(LOADER_ACCOUNTS); } else if (loader.getId() >= LOADER_BOOKMARKS) { BrowserBookmarksAdapter adapter = mBookmarkAdapters.get(loader.getId()); adapter.changeCursor(cursor); } }
From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java
@Override public void onLoadFinished(Loader<DotaGameData> loader, DotaGameData data) { if (data == null && loader.getId() == 0) { // if data is null, then we didn't receive anything from valve servers. // there's a chance that the game is done, so... mHandler.post(mGameResultRunnable); } else if (data == null && loader.getId() == 1) { // there's a chance that the steam api is down, should "wait", but attempt to fetch // new data. mHandler.postDelayed(mGameUpdaterRunnable, GAME_UPDATE_INTERVAL); mUpdateProgressBar.setProgress(2000); mUpdateProgressBar.startAnimation(mUpdateProgressAnim); } else if (data.getType() == 50) { // this only comes from gameresulttaskloader indicating that there's no result: // only means that the game may still be live, so we'll try to grab new data. mHandler.postDelayed(mGameUpdaterRunnable, GAME_UPDATE_INTERVAL); mUpdateProgressBar.setProgress(2000); mUpdateProgressBar.startAnimation(mUpdateProgressAnim); } else if (data.getType() == 0) { // this only comes from gamedetailtaskloader indicating that there's data. // we should process it, then schedule an update to fetch new data. // we should keep the logic for doing live/result data here only. mPresenter.processNewData((Game) data); mHandler.postDelayed(mGameUpdaterRunnable, GAME_UPDATE_INTERVAL); LogUtils.LOGD(TAG, "gotMatchData"); mUpdateProgressBar.setProgress(2000); mUpdateProgressBar.startAnimation(mUpdateProgressAnim); } else if (data.getType() == 1) { // this only comes from gameresulttaskloader indicating result was found: // we should process it, then not bother scheduling any further updates. LogUtils.LOGD(TAG, "gotResultData"); mPresenter.processResultData((FinishedGame) data); gameCompleted = true;/*from w w w . j a v a2s . c o m*/ } }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayFragment_WebView.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor != null && cursor.moveToFirst()) { switch (loader.getId()) { case QUEUE_VIDEOS_LOADER: { mQueue.clear();/* www. j a v a 2s.com*/ while (!cursor.isAfterLast()) { Video v = (Video) mVideoCursorMapper.convert(cursor); // Set the queue index to the selected video. if (v.id == mSelectedVideo.id) { mQueueIndex = mQueue.size(); } // Add the video to the queue. MediaSessionCompat.QueueItem item = getQueueItem(v); mQueue.add(item); cursor.moveToNext(); } mSession.setQueue(mQueue); mSession.setQueueTitle(getString(R.string.queue_name)); break; } case RECOMMENDED_VIDEOS_LOADER: { mVideoCursorAdapter.changeCursor(cursor); break; } default: { // Playing a specific video. Video video = (Video) mVideoCursorMapper.convert(cursor); playVideo(video, mAutoPlayExtras); break; } } } }
From source file:de.kraenksoft.c3tv.ui.PlaybackOverlayFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor != null && cursor.moveToFirst()) { switch (loader.getId()) { case QUEUE_VIDEOS_LOADER: { mQueue.clear();//from ww w .j av a 2s. c om while (!cursor.isAfterLast()) { Video v = (Video) mVideoCursorMapper.convert(cursor); // Set the queue index to the selected video. if (v.id == mSelectedVideo.id) { mQueueIndex = mQueue.size(); } // Add the video to the queue. MediaSession.QueueItem item = getQueueItem(v); mQueue.add(item); cursor.moveToNext(); } mSession.setQueue(mQueue); mSession.setQueueTitle(getString(R.string.queue_name)); break; } case RECOMMENDED_VIDEOS_LOADER: { mVideoCursorAdapter.changeCursor(cursor); break; } default: { // Playing a specific video. Video video = (Video) mVideoCursorMapper.convert(cursor); Bundle extras = new Bundle(); extras.putBoolean(AUTO_PLAY, true); playVideo(video, extras); break; } } } }
From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override public void onLoaderReset(Loader<Cursor> loader) { switch (loader.getId()) { case SessionsQuery._TOKEN: mLivestreamAdapter.swapCursor(null); break;//from www. j a v a2 s.co m } }
From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { switch (loader.getId()) { case SessionSummaryQuery._TOKEN: loadSessionSummary(data);//from w w w. ja va 2 s . co m break; case SessionsQuery._TOKEN: loadSessionsList(data); break; } }