List of usage examples for android.content AsyncQueryHandler startInsert
public final void startInsert(int token, Object cookie, Uri uri, ContentValues initialValues)
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())); }//from w w w . j a v a2 s. c o 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: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 w w w . j a v 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.google.samples.apps.iosched.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri); Uri myScheduleUri = ScheduleContract.MySchedule .buildMyScheduleUri(AccountUtils.getActiveAccountName(mActivity)); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };// w ww . j a v a 2s . c o m final ContentValues values = new ContentValues(); values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId); values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0); handler.startInsert(-1, null, myScheduleUri, values); // ANALYTICS EVENT: Add or remove a session from the schedule // Contains: Session title, whether it was added or removed (starred or unstarred) AnalyticsHelper.sendEvent("Session", starred ? "Starred" : "Unstarred", title); // Because change listener is set to null during initialization, these // won't fire on pageview. mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false)); // Request an immediate user data sync to reflect the starred user sessions in the cloud SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true); }
From source file:com.razza.apps.iosched.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LogUtils.LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri); Uri myScheduleUri = ScheduleContract.MySchedule .buildMyScheduleUri(AccountUtils.getActiveAccountName(mActivity)); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };//from w w w .jav a 2s. com final ContentValues values = new ContentValues(); values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId); values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0); handler.startInsert(-1, null, myScheduleUri, values); // ANALYTICS EVENT: Add or remove a session from the schedule // Contains: Session title, whether it was added or removed (starred or unstarred) AnalyticsHelper.sendEvent("Session", starred ? "Starred" : "Unstarred", title); // Because change listener is set to null during initialization, these // won't fire on pageview. mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false)); // Request an immediate user data sync to reflect the starred user sessions in the cloud SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true); }
From source file:xyz.template.material.menu.utils.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri); Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(mActivity); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };//from w ww . j av a2s. c om final ContentValues values = new ContentValues(); values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId); values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0); handler.startInsert(-1, null, myScheduleUri, values); /* [ANALYTICS:EVENT] * TRIGGER: Add or remove a session from the schedule. * CATEGORY: 'Session' * ACTION: 'Starred' or 'Unstarred' * LABEL: session title/subtitle * [/ANALYTICS] */ // AnalyticsManager.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)); // Request an immediate user data sync to reflect the starred user sessions in the cloud // SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true); }
From source file:com.saarang.samples.apps.iosched.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LogUtils.LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri); Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(mActivity); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };/* w w w .ja v a2s . c o m*/ final ContentValues values = new ContentValues(); values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId); values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0); handler.startInsert(-1, null, myScheduleUri, values); /* [ANALYTICS:EVENT] * TRIGGER: Add or remove a session from the schedule. * CATEGORY: 'Session' * ACTION: 'Starred' or 'Unstarred' * LABEL: session title/subtitle * [/ANALYTICS] */ AnalyticsManager.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)); // Request an immediate user data sync to reflect the starred user sessions in the cloud SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true); }
From source file:com.google.samples.apps.sergio.util.SessionsHelper.java
public void setSessionStarred(Uri sessionUri, boolean starred, String title) { LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" + starred + " title=" + title); String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri); Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(mActivity); AsyncQueryHandler handler = new AsyncQueryHandler(mActivity.getContentResolver()) { };/*w ww.j av a 2s.c o m*/ final ContentValues values = new ContentValues(); values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId); values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0); handler.startInsert(-1, null, myScheduleUri, values); /* [ANALYTICS:EVENT] * TRIGGER: Add or remove a session from the schedule. * CATEGORY: 'Session' * ACTION: 'Starred' or 'Unstarred' * LABEL: session title/subtitle * [/ANALYTICS] */ AnalyticsManager.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)); // Request an immediate user data sync to reflect the starred user sessions in the cloud SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true); }
From source file:org.ohmage.streams.StreamPointBuilder.java
/** * Asynchronously send this point to ohmage. * <p/>//from w ww.jav a 2 s . co m * If you have many points to send within a few milliseconds of each * other, you will get better performance by calling {@link #write(StreamWriter)} or * {@link #writeAsync(AsyncBulkInsertHandler)}. * <p/> * This call returns without waiting for ohmage to save the point. Implement * {@link AsyncQueryHandler#onInsertComplete} for the handler provided to get callbacks whenever * a point is saved to ohmage. * <p/> * Before sending data to ohmage, the stream should check that the content provider exists by * calling {@link StreamContract#checkContentProviderExists(ContentResolver)} * * @param handler an {@link AsyncQueryHandler} to send the point * @param token A token passed into {@link AsyncQueryHandler#onInsertComplete} to identify * this write operation. * @param cookie An object that gets passed into {@link AsyncQueryHandler#onInsertComplete} */ public void writeAsync(AsyncQueryHandler handler, int token, Object cookie) { buildMetaData(); handler.startInsert(token, cookie, StreamContract.Streams.CONTENT_URI, toContentValues()); }