Search in sources :

Example 1 with AsyncQueryHandler

use of android.content.AsyncQueryHandler in project qksms by moezbhatti.

the class SearchFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPrefs = mContext.getPrefs();
    mRes = mContext.getResources();
    // When the query completes cons up a new adapter and set our list adapter to that.
    mQueryHandler = new AsyncQueryHandler(mContext.getContentResolver()) {

        protected void onQueryComplete(int token, Object cookie, Cursor c) {
            mAdapter.changeCursor(c);
            mAdapter.setQuery(mSearchString);
        }
    };
}
Also used : AsyncQueryHandler(android.content.AsyncQueryHandler) Cursor(android.database.Cursor)

Example 2 with AsyncQueryHandler

use of android.content.AsyncQueryHandler in project Etar-Calendar by Etar-Group.

the class SelectSyncedCalendarsMultiAccountActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    dynamicTheme.onResume(this);
    if (mAdapter != null) {
        mAdapter.startRefreshStopDelay();
    }
    new AsyncQueryHandler(getContentResolver()) {

        @Override
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            mAccountsCursor = Utils.matrixCursorFromCursor(cursor);
            mAdapter = new SelectSyncedCalendarsMultiAccountAdapter(findViewById(R.id.calendars).getContext(), mAccountsCursor, SelectSyncedCalendarsMultiAccountActivity.this);
            mList.setAdapter(mAdapter);
            // TODO initialize from sharepref
            int count = mList.getCount();
            for (int i = 0; i < count; i++) {
                mList.expandGroup(i);
            }
        }
    }.startQuery(0, null, Calendars.CONTENT_URI, PROJECTION, //Cheap hack to make WHERE a GROUP BY query
    "1) GROUP BY (" + ACCOUNT_UNIQUE_KEY, null, /* selectionArgs */
    Calendars.ACCOUNT_NAME);
//TODO change to something that supports group by queries.
}
Also used : AsyncQueryHandler(android.content.AsyncQueryHandler) MatrixCursor(android.database.MatrixCursor) Cursor(android.database.Cursor)

Example 3 with AsyncQueryHandler

use of android.content.AsyncQueryHandler in project iosched by google.

the class SessionsHelper method setSessionStarred.

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()) {
    };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_TIMESTAMP, new Date().getTime());
    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(true);
}
Also used : ContentValues(android.content.ContentValues) AsyncQueryHandler(android.content.AsyncQueryHandler) Uri(android.net.Uri) Date(java.util.Date)

Example 4 with AsyncQueryHandler

use of android.content.AsyncQueryHandler in project iosched by google.

the class VideoLibraryModel method processUserAction.

@Override
public void processUserAction(final VideoLibraryUserActionEnum action, @Nullable final Bundle args, final UserActionCallback callback) {
    switch(action) {
        case VIDEO_PLAYED:
            // been viewed by the user in AppData.
            if (args != null && args.containsKey(KEY_VIDEO_ID)) {
                String playedVideoId = args.getString(KEY_VIDEO_ID);
                LOGD(TAG, "setVideoViewed id=" + playedVideoId);
                Uri myPlayedVideoUri = ScheduleContract.MyViewedVideos.buildMyViewedVideosUri(AccountUtils.getActiveAccountName(mContext));
                AsyncQueryHandler handler = new AsyncQueryHandler(mContext.getContentResolver()) {
                };
                final ContentValues values = new ContentValues();
                values.put(ScheduleContract.MyViewedVideos.VIDEO_ID, playedVideoId);
                handler.startInsert(-1, null, myPlayedVideoUri, values);
                // Because change listener is set to null during initialization, these
                // won't fire on pageview.
                mContext.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mContext, false));
                // Request an immediate user data sync to reflect the viewed video in the cloud.
                SyncHelper.requestManualSync(true);
            } else {
                LOGE(TAG, "The VideoLibraryUserActionEnum.VIDEO_VIEWED action was called " + "without a " + "proper Bundle.");
            }
            break;
    }
}
Also used : ContentValues(android.content.ContentValues) AsyncQueryHandler(android.content.AsyncQueryHandler) Uri(android.net.Uri)

Example 5 with AsyncQueryHandler

use of android.content.AsyncQueryHandler in project Etar-Calendar by Etar-Group.

the class GoogleCalendarUriIntentFilter method updateSelfAttendeeStatus.

private void updateSelfAttendeeStatus(int eventId, String ownerAccount, final int status, final Intent intent) {
    final ContentResolver cr = getContentResolver();
    final AsyncQueryHandler queryHandler = new AsyncQueryHandler(cr) {

        @Override
        protected void onUpdateComplete(int token, Object cookie, int result) {
            if (result == 0) {
                Log.w(TAG, "No rows updated - starting event viewer");
                intent.putExtra(Attendees.ATTENDEE_STATUS, status);
                startActivity(intent);
                return;
            }
            final int toastId;
            switch(status) {
                case Attendees.ATTENDEE_STATUS_ACCEPTED:
                    toastId = R.string.rsvp_accepted;
                    break;
                case Attendees.ATTENDEE_STATUS_DECLINED:
                    toastId = R.string.rsvp_declined;
                    break;
                case Attendees.ATTENDEE_STATUS_TENTATIVE:
                    toastId = R.string.rsvp_tentative;
                    break;
                default:
                    return;
            }
            Toast.makeText(GoogleCalendarUriIntentFilter.this, toastId, Toast.LENGTH_LONG).show();
        }
    };
    final ContentValues values = new ContentValues();
    values.put(Attendees.ATTENDEE_STATUS, status);
    queryHandler.startUpdate(0, null, Attendees.CONTENT_URI, values, Attendees.ATTENDEE_EMAIL + "=? AND " + Attendees.EVENT_ID + "=?", new String[] { ownerAccount, String.valueOf(eventId) });
}
Also used : ContentValues(android.content.ContentValues) AsyncQueryHandler(android.content.AsyncQueryHandler) ContentResolver(android.content.ContentResolver)

Aggregations

AsyncQueryHandler (android.content.AsyncQueryHandler)5 ContentValues (android.content.ContentValues)3 Cursor (android.database.Cursor)2 Uri (android.net.Uri)2 ContentResolver (android.content.ContentResolver)1 MatrixCursor (android.database.MatrixCursor)1 Date (java.util.Date)1