List of usage examples for android.content AsyncQueryHandler AsyncQueryHandler
public AsyncQueryHandler(ContentResolver cr)
From source file:com.conferenceengineer.android.iosched.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); sessionUri = ScheduleContract.addCallerIsSyncAdapterParameter(sessionUri); final ContentValues values = new ContentValues(); values.put(ScheduleContract.Sessions.SESSION_STARRED, starred); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };/*from w ww. j a va2 s. co m*/ handler.startUpdate(-1, null, sessionUri, values, null, null); // Because change listener is set to null during initialization, these // won't fire on pageview. mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false)); // Sync to the cloudz. uploadStarredSession(mActivity, sessionUri, starred); }
From source file:com.kku.apps.pricesearch.util.Utils.java
public static void entryFavorites(Context context, ListItem item) { final ContentValues cv = new ContentValues(); cv.put(FavoritesColumns.KEYWORDS, item.getKeywords()); cv.put(FavoritesColumns.NAME, item.getName()); if (item.getImage() != null) { cv.put(FavoritesColumns.IMAGE, getByteImage(item.getImage())); }/*from ww w . j av a2 s. c o m*/ cv.put(FavoritesColumns.ITEMURL, item.getItemUrl()); cv.put(FavoritesColumns.PRICE, item.getPrice()); cv.put(FavoritesColumns.SHOP, item.getShop()); cv.put(FavoritesColumns.LOGO, item.getLogo()); cv.put(FavoritesColumns.DATE, Utils.getDate()); final AsyncQueryHandler dbHandler = new AsyncQueryHandler(context.getContentResolver()) { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { super.onQueryComplete(token, cookie, cursor); } }; dbHandler.startInsert(0, null, SearchContract.URI_FAVORITES, cv); }
From source file:com.gdgdevfest.android.apps.devfestbcn.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); sessionUri = ScheduleContract.addCallerIsSyncAdapterParameter(sessionUri); final ContentValues values = new ContentValues(); values.put(ScheduleContract.Sessions.SESSION_STARRED, starred); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };//from w w w. jav a2 s . c o m handler.startUpdate(-1, null, sessionUri, values, null, null); EasyTracker.getTracker().sendEvent("Session", starred ? "Starred" : "Unstarred", title, 0L); // Because change listener is set to null during initialization, these // won't fire on pageview. mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false)); // Sync to the cloudz. uploadStarredSession(mActivity, sessionUri, starred); }
From source file:net.abcdroid.devfest12.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); sessionUri = ScheduleContract.addCallerIsSyncAdapterParameter(sessionUri); final ContentValues values = new ContentValues(); values.put(ScheduleContract.Sessions.SESSION_STARRED, starred); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };//from ww w .j av a2 s . co m handler.startUpdate(-1, null, sessionUri, values, null, null); EasyTracker.getTracker().trackEvent("Session", starred ? "Starred" : "Unstarred", title, 0L); // Because change listener is set to null during initialization, these // won't fire on pageview. final Intent refreshIntent = new Intent(mActivity, MyScheduleWidgetProvider.class); refreshIntent.setAction(MyScheduleWidgetProvider.REFRESH_ACTION); mActivity.sendBroadcast(refreshIntent); // Sync to the cloud. final Intent updateServerIntent = new Intent(mActivity, ScheduleUpdaterService.class); updateServerIntent.putExtra(ScheduleUpdaterService.EXTRA_SESSION_ID, ScheduleContract.Sessions.getSessionId(sessionUri)); updateServerIntent.putExtra(ScheduleUpdaterService.EXTRA_IN_SCHEDULE, starred); mActivity.startService(updateServerIntent); }
From source file:com.commonsware.android.arXiv.ArticleList.java
public void addFavorite() { ContentValues cv = new ContentValues(); cv.put(Feeds.TITLE, name);//from w ww. j a v a2 s. co m cv.put(Feeds.SHORTTITLE, query); cv.put(Feeds.URL, url); cv.put(Feeds.UNREAD, -1); cv.put(Feeds.COUNT, -1); cv.put(Feeds.LAST_UPDATE, 0); new AsyncQueryHandler(this.getContentResolver()) { @Override protected void onInsertComplete(int id, Object cookie, Uri uri) { Toast.makeText(getBaseContext(), id, Toast.LENGTH_SHORT).show(); } }.startInsert(R.string.added_to_favorites, null, Feeds.CONTENT_URI, cv); favorite = true; supportInvalidateOptionsMenu(); }
From source file:com.amgems.uwschedule.ui.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_activity); setupViews();//from ww w .ja va 2 s . c om getContentResolver().delete(ScheduleContract.Courses.CONTENT_URI, null, null); getContentResolver().delete(ScheduleContract.Meetings.CONTENT_URI, null, null); // Initialize inbound data mUsername = getIntent().getStringExtra(EXTRAS_HOME_USERNAME); mCookieStore = CookieStore.getInstance(getApplicationContext()); // Set up navigation drawer items mDrawerLayoutRoot.setDrawerListener(mDrawerToggle); List<DrawerListAdapter.Group> drawerGroups = new ArrayList<DrawerListAdapter.Group>(); drawerGroups.add(new DrawerListAdapter.Group(R.string.drawer_group_home, R.drawable.ic_nav_home)); drawerGroups.add(new DrawerListAdapter.Group(R.string.drawer_group_friends, R.drawable.ic_nav_friends)); drawerGroups.add(new DrawerListAdapter.Group(R.string.drawer_group_favorites, R.drawable.ic_nav_favorites)); mDrawerListView.setAdapter(new DrawerListAdapter(this, drawerGroups)); mCoursesViewPager.setAdapter(new CoursesFragmentPagerAdapter(getSupportFragmentManager())); mDrawerEmailTextView.setText(mUsername + USER_EMAIL_POSTFIX); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); WebService.init(); mAsyncDataHandler = new AsyncDataHandler(new AsyncQueryHandler(this.getContentResolver()) { }); LoaderManager manager = getLoaderManager(); if (manager.getLoader(GET_SLN_LOADER_ID) == null) { manager.initLoader(GET_SLN_LOADER_ID, null, this); } mPublisher = new Publisher<String>() { private List<Subscriber<? super String>> mSubscriberList = new ArrayList<Subscriber<? super String>>(); private String mData; @Override public void register(Subscriber<? super String> dataSubscriber) { mSubscriberList.add(dataSubscriber); dataSubscriber.update(mData); } @Override public void publish(String data) { mData = data; for (Subscriber<? super String> subscriber : mSubscriberList) { subscriber.update(data); } } }; }
From source file:com.kku.apps.pricesearch.util.Utils.java
public static void entryHistory(Context context, ListItem item) { final ContentValues cv = new ContentValues(); cv.put(HistoryColumns.KEYWORDS, item.getKeywords()); cv.put(HistoryColumns.NAME, item.getName()); if (item.getImage() != null) { cv.put(HistoryColumns.IMAGE, getByteImage(item.getImage())); }//w w w. j a va 2s . co m cv.put(HistoryColumns.DATE, Utils.getDate()); final AsyncQueryHandler dbHandler = new AsyncQueryHandler(context.getContentResolver()) { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { super.onQueryComplete(token, cookie, cursor); } }; dbHandler.startInsert(0, null, SearchContract.URI_HISTORY, cv); }
From source file:org.jamienicol.episodes.SeasonActivity.java
private void markSeasonWatched(boolean watched) { final ContentResolver contentResolver = getContentResolver(); final AsyncQueryHandler handler = new AsyncQueryHandler(contentResolver) { };//w w w .ja v a 2 s. com final ContentValues epValues = new ContentValues(); epValues.put(EpisodesTable.COLUMN_WATCHED, watched); final String selection = String.format("%s=? AND %s=?", EpisodesTable.COLUMN_SHOW_ID, EpisodesTable.COLUMN_SEASON_NUMBER); final String[] selectionArgs = { String.valueOf(showId), String.valueOf(seasonNumber) }; handler.startUpdate(0, null, ShowsProvider.CONTENT_URI_EPISODES, epValues, selection, selectionArgs); }
From source file:com.github.longkai.zhihu.ui.HotItemsFragment.java
@Override public void onClick(View v) { loading = true;// ww w . j a v a2 s .c o m page++; // ? new AsyncQueryHandler(getActivity().getContentResolver()) { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { mAdapter.changeCursor(cursor); loading = false; if (cursor.moveToLast()) { // todo bug // ?button? // ?id????= = long index = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)); if (index == MIN_ITEM_INDEX) { loadMore.setText(getString(R.string.no_more)); loadMore.setClickable(false); } } } }.startQuery(0, null, Utils.parseUri(ITEMS), ITEMS_PROJECTION, null, null, "_id desc limit " + (page * COUNT)); }
From source file:de.sindzinski.lpictrainer.TestActivity.java
public void onCheckAll() { Integer points = 0;/* w ww . java 2 s . co m*/ Integer maxPoints = 0; //Uri mDataUrl = Uri.parse(TrainerContract.AnswerEntry.CONTENT_URI + "/" // + mAnswer.index); String[] projection = { TrainerContract.AnswerEntry._ID, TrainerContract.AnswerEntry.COLUMN_ID, // AnswerEntry.COLUMN_CHECKED, TrainerContract.AnswerEntry.COLUMN_POINTS, }; //String selectionClause = TrainerContract.AnswerEntry.CO + "=" + mAnswer.index; String selectionClause = null; String[] selectionArgs = null; String sortOrder = null; // try { // Cursor cursor = this.getContentResolver().query( // AnswerEntry.CONTENT_URI, // projection, // selectionClause, // selectionArgs, // sortOrder); // // if (cursor != null) { // if (cursor.moveToFirst()) { // do { // //points = points + 1; // int rowPoints = Integer.parseInt(cursor.getString(cursor.getColumnIndexOrThrow(TrainerContract.QuestionEntry.COLUMN_POINTS))); // if (rowPoints > 0 ) { // points = points + 1; // } // // } while (cursor.moveToNext()); // } // // always close the cursor // cursor.close(); // } // } catch (SQLiteException e) { // Logger.e(TAG, "Error reading database: " + e); // } // maxPoints = to - from; // Toast.makeText(this, // "You reached " + points.toString() + " out of " + maxPoints.toString(), Toast.LENGTH_LONG).show(); int token = 2; AsyncQueryHandler handler = new AsyncQueryHandler(this.getContentResolver()) { @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { super.onQueryComplete(token, cookie, cursor); if (cursor != null) { Integer points = 0; Integer maxPoints = 0; if (cursor.moveToFirst()) { do { if (Integer.parseInt(cursor.getString(cursor .getColumnIndexOrThrow(TrainerContract.QuestionEntry.COLUMN_POINTS))) > 0) { points = points + 1; } //points = points + cursor.getColumnIndexOrThrow(TrainerContract.QuestionEntry.COLUMN_POINTS); } while (cursor.moveToNext()); } // always close the cursor cursor.close(); maxPoints = to - from; Toast.makeText(de.sindzinski.lpictrainer.TestActivity.this, "You reached " + points.toString() + " out of " + maxPoints.toString(), Toast.LENGTH_LONG).show(); } } }; handler.startQuery(token, null, TrainerContract.AnswerEntry.CONTENT_URI, projection, selectionClause, selectionArgs, sortOrder); }