本文整理汇总了Java中android.content.AsyncQueryHandler类的典型用法代码示例。如果您正苦于以下问题:Java AsyncQueryHandler类的具体用法?Java AsyncQueryHandler怎么用?Java AsyncQueryHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncQueryHandler类属于android.content包,在下文中一共展示了AsyncQueryHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateItemValue
import android.content.AsyncQueryHandler; //导入依赖的package包/类
private void updateItemValue(long id, boolean value) {
ContentValues values = new ContentValues();
values.put(MultimaniaContract.TalkEntry.IS_FAVORITE, value ? 1 : 0);
AsyncQueryHandler handler = new MyScheduleAsyncQueryHandler(getActivity().getContentResolver());
handler.startUpdate(
0,
null,
MultimaniaContract.TalkEntry.CONTENT_URI,
values,
MultimaniaContract.TalkEntry._ID + "=?",
new String[]{"" + id}
);
if (mAccountName != null) {
if (value) {
ApiActions.postFavoriteTalk(getActivity(), mAccountName, id);
} else {
ApiActions.deleteFavoriteTalk(getActivity(), mAccountName, id);
}
}
}
示例2: updateItemValue
import android.content.AsyncQueryHandler; //导入依赖的package包/类
private void updateItemValue(long id, boolean value) {
ContentValues values = new ContentValues();
values.put(MultimaniaContract.TalkEntry.IS_FAVORITE, value ? 1 : 0);
AsyncQueryHandler handler = new SuggestionAsyncQueryHandler(getActivity().getContentResolver());
handler.startUpdate(
0,
null,
MultimaniaContract.TalkEntry.CONTENT_URI,
values,
MultimaniaContract.TalkEntry._ID + "=?",
new String[]{"" + id}
);
if (mAccountName != null) {
if (value) {
ApiActions.postFavoriteTalk(getActivity(), mAccountName, id);
} else {
ApiActions.deleteFavoriteTalk(getActivity(), mAccountName, id);
}
}
}
示例3: startQueryHaveLockedMessages
import android.content.AsyncQueryHandler; //导入依赖的package包/类
/**
* Check for locked messages in all threads or a specified thread.
*
* @param handler An AsyncQueryHandler that will receive onQueryComplete
* upon completion of looking for locked messages
* @param threadIds A list of threads to search. null means all threads
* @param token The token that will be passed to onQueryComplete
*/
public static void startQueryHaveLockedMessages(AsyncQueryHandler handler,
Collection<Long> threadIds,
int token) {
handler.cancelOperation(token);
Uri uri = MmsSms.CONTENT_LOCKED_URI;
String selection = null;
if (threadIds != null) {
StringBuilder buf = new StringBuilder();
int i = 0;
for (long threadId : threadIds) {
if (i++ > 0) {
buf.append(" OR ");
}
// We have to build the selection arg into the selection because deep down in
// provider, the function buildUnionSubQuery takes selectionArgs, but ignores it.
buf.append(Mms.THREAD_ID).append("=").append(Long.toString(threadId));
}
selection = buf.toString();
}
handler.startQuery(token, threadIds, uri,
ALL_THREADS_PROJECTION, selection, null, Conversations.DEFAULT_SORT_ORDER);
}
示例4: savePayment
import android.content.AsyncQueryHandler; //导入依赖的package包/类
public static void savePayment(Payment payment, final Handler handler) {
final ContentValues values = getContentValuesFromPaymentInstance(payment);
AsyncQueryHandler insertPaymentHandler = new AsyncQueryHandler(mContentResolver) {
@Override
protected void onInsertComplete(int token, Object cookie, Uri uri) {
if (handler != null) {
Message message = Message.obtain();
message.what = MESSAGE_WHAT_SAVED_PAYMENT_URL;
message.obj = uri;
handler.sendMessage(message);
}
}
};
insertPaymentHandler.startInsert(0, null, paymentsUri, values);
}
示例5: getBill
import android.content.AsyncQueryHandler; //导入依赖的package包/类
/**
* retrieve a Bill Object from DB and return it by using Handler to send a Message
*
* @param id
* @param handler
*/
public static void getBill(long id, final Handler handler) {
Uri uri = BillContract.Bills.buildBillUri(String.valueOf(id));
// Cursor cursor = mContentResolver.query(uri, projection, null, null, null);
new AsyncQueryHandler(mContentResolver) {
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
if (handler != null && cursor != null) {
Bill bill = getBillFromCursor(cursor);
Message message = Message.obtain();
message.what = MESSAGE_WHAT_GET_BILL;
message.obj = bill;
handler.sendMessage(message);
}
}
}.startQuery(0, null, uri, projection, null, null, null);
}
示例6: savePaymentInfo
import android.content.AsyncQueryHandler; //导入依赖的package包/类
public static void savePaymentInfo(PaymentInfo paymentInfo, final Handler handler) {
final ContentValues values = getContentValuesFromPaymentInfoInstance(paymentInfo);
AsyncQueryHandler insertPaymentInfoHandler = new AsyncQueryHandler(mContentResolver) {
@Override
protected void onInsertComplete(int token, Object cookie, Uri uri) {
if (handler != null) {
Message message = Message.obtain();
message.what = MESSAGE_WHAT_SAVED_PAYMENTINFO_URL;
message.obj = uri;
handler.sendMessage(message);
}
}
};
insertPaymentInfoHandler.startInsert(0, null, paymentInfosUri, values);
}
示例7: onStop
import android.content.AsyncQueryHandler; //导入依赖的package包/类
@Override
protected void onStop() {
//TODO: Archive of our own & FictionPress
if (mData != null && mData.isInLibrary()) {
ContentResolver resolver = getContentResolver();
AsyncQueryHandler handler = new AsyncQueryHandler(resolver){};
int offset = getOffset();
ContentValues values = new ContentValues(1);
values.put(SqlConstants.KEY_LAST, mCurrentPage);
values.put(SqlConstants.KEY_OFFSET, offset);
values.put(SqlConstants.KEY_LAST_READ, System.currentTimeMillis());
handler.startUpdate(0, null, StoryProvider.FF_CONTENT_URI, values,
SqlConstants.KEY_STORY_ID + " = ?",
new String[] { String.valueOf(mStoryId) });
SharedPreferences preference = getSharedPreferences(MainActivity.EXTRA_PREF,MODE_PRIVATE);
SharedPreferences.Editor editor = preference.edit();
editor.putLong(MainActivity.EXTRA_RESUME_ID, mStoryId);
editor.commit();
}
super.onStop();
}
示例8: addFavorite
import android.content.AsyncQueryHandler; //导入依赖的package包/类
public static void addFavorite(Context context, Movie movie) {
Log.d(TAG, "Inserting favorite: " + movie.getTitle());
ContentValues values = new ContentValues();
values.put(MovieContract.MovieEntry.COLUMN_MOVIE_ID, movie.getId());
values.put(MovieContract.MovieEntry.COLUMN_TITLE, movie.getTitle());
values.put(MovieContract.MovieEntry.COLUMN_ORIGINAL_TITLE, movie.getOriginalTitle());
values.put(MovieContract.MovieEntry.COLUMN_RELEASE_DATE, movie.getReleaseDate());
values.put(MovieContract.MovieEntry.COLUMN_OVERVIEW, movie.getOverview());
values.put(MovieContract.MovieEntry.COLUMN_VOTE_AVERAGE, movie.getVoteAverage());
values.put(MovieContract.MovieEntry.COLUMN_VOTE_COUNT, movie.getVoteCount());
values.put(MovieContract.MovieEntry.COLUMN_POSTER_PATH, movie.getPosterPath());
values.put(MovieContract.MovieEntry.COLUMN_BACKDROP_PATH, movie.getBackdropPath());
values.put(MovieContract.MovieEntry.COLUMN_POPULARITY, movie.getPopularity());
values.put(MovieContract.MovieEntry.COLUMN_FAVORITE, 1);
values.put(MovieContract.MovieEntry.COLUMN_LANGUAGE, movie.getOriginalLanguage());
values.put(MovieContract.MovieEntry.COLUMN_VIDEO, movie.isVideo());
values.put(MovieContract.MovieEntry.COLUMN_ADULT, movie.isAdult());
final AsyncQueryHandler handler = new AsyncCrudHandler(context.getContentResolver());
handler.startInsert(2, null, MovieContract.MovieEntry.CONTENT_URI, values);
// update genres
insertGenres(context, movie.getId(), movie.getGenreIds());
}
示例9: queryAsync
import android.content.AsyncQueryHandler; //导入依赖的package包/类
/**
* Queries the defined projection, selection and sort order on a background thread
* on the given URI through the ContentResolver retrieved from the given context.<br />
* <br />
* The callback is called on the thread that called this method when the query finishes.
* @param context
* @param uri
* @param callback
*/
public void queryAsync( Context context, Uri uri, final AsyncQueryCallback callback ) {
validateForQuery();
AsyncQueryHandler aqh = new AsyncQueryHandler( context.getContentResolver() ) {
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
callback.queryCompleted(cursor);
if ( !cursor.isClosed() ) {
cursor.close();
}
}
};
Pair<String, String[]> builtSelection = buildSelection();
aqh.startQuery(0,
null,
uri,
projection,
builtSelection.first,
builtSelection.second,
sortOrder );
}
示例10: setReservationStatus
import android.content.AsyncQueryHandler; //导入依赖的package包/类
public void setReservationStatus(Uri sessionUri,
@ScheduleContract.MyReservations.ReservationStatus int reservationStatus,
String title) {
LOGD(TAG, "setReservationStatus session uri=" + sessionUri + " reservationStatus=" +
reservationStatus + " title=" + title);
String accountName = AccountUtils.getActiveAccountName(mContext);
String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
Uri myReservationsUri = ScheduleContract.MyReservations.buildMyReservationUri(accountName);
@SuppressLint("HandlerLeak") // this is short-lived
AsyncQueryHandler handler = new AsyncQueryHandler(mContext.getContentResolver()) {
};
final ContentValues values = new ContentValues();
values.put(ScheduleContract.MyReservations.SESSION_ID, sessionId);
values.put(ScheduleContract.MyReservations.MY_RESERVATION_STATUS, reservationStatus);
values.put(ScheduleContract.MyReservations.MY_RESERVATION_ACCOUNT_NAME, accountName);
int offset = SyncUtils.getServerTimeOffset(mContext);
values.put(ScheduleContract.MyReservations.MY_RESERVATION_TIMESTAMP,
System.currentTimeMillis() + offset);
handler.startInsert(-1, null, myReservationsUri, values);
}
示例11: onInfoWindowClick
import android.content.AsyncQueryHandler; //导入依赖的package包/类
@Override
public void onInfoWindowClick(Marker marker) {
new IsFavAsyncQuery(mContext.getContentResolver(), marker) {
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
cursor.moveToFirst();
final boolean isFav = !(cursor.getInt(cursor.getColumnIndex(StopTable.IS_FAV)) ==
1);
if (isFav) {
Toast.makeText(mContext, mContext.getString(R.string.fav_added), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mContext, mContext.getString(R.string.fav_removed), Toast.LENGTH_SHORT).show();
}
cursor.close();
final ContentValues contentValues = new ContentValues(1);
contentValues.put(StopTable.IS_FAV, isFav);
new AsyncQueryHandler(mContext.getContentResolver()) {
}
.startUpdate(0, null, StopsProvider.CONTENT_URI, contentValues,
StopTable.NAME_COL + "=?", new String[]{mMarker.getTitle()});
}
}.performQuery();
}
示例12: getQueryCursor
import android.content.AsyncQueryHandler; //导入依赖的package包/类
private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
if (filter == null) {
filter = "";
}
String[] ccols = new String[] {
BaseColumns._ID, Audio.Media.MIME_TYPE, Audio.Artists.ARTIST, Audio.Albums.ALBUM,
Audio.Media.TITLE, "data1", "data2"
};
Uri search = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(filter));
Cursor ret = null;
if (async != null) {
async.startQuery(0, null, search, ccols, null, null, null);
} else {
ret = MusicUtils.query(this, search, ccols, null, null, null);
}
return ret;
}
示例13: NumberLocate
import android.content.AsyncQueryHandler; //导入依赖的package包/类
public NumberLocate(final Context mContext, final Handler handler){
this.mContext = mContext;
this.handler = handler;
queryHandler = new AsyncQueryHandler(mContext.getContentResolver()) {
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
if (cursor != null && cursor.moveToNext()) {
String city = cursor.getString(0);
cursor.close();
Message msg = new Message();
msg.obj = city;
handler.sendMessage(msg);
PhoneStatusRecevier.saveAsCache(mContext,number,city);
}
}
};
}
示例14: getQueryCursor
import android.content.AsyncQueryHandler; //导入依赖的package包/类
private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
if (filter == null) {
filter = "";
}
String[] ccols = new String[] {
BaseColumns._ID, // this will be the artist, album or track ID
MediaStore.Audio.Media.MIME_TYPE, // mimetype of audio file, or "artist" or "album"
MediaStore.Audio.Artists.ARTIST,
MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Media.TITLE,
"data1",
"data2"
};
Uri search = Uri.parse("content://media/external/audio/search/fancy/" +
Uri.encode(filter));
Cursor ret = null;
if (async != null) {
async.startQuery(0, null, search, ccols, null, null, null);
} else {
ret = MusicUtils.query(this, search, ccols, null, null, null);
}
return ret;
}
开发者ID:AndroidLearnerchn,项目名称:Android-Application-Using-CAF-Library,代码行数:26,代码来源:QueryBrowserActivity.java
示例15: getArtistCursor
import android.content.AsyncQueryHandler; //导入依赖的package包/类
private Cursor getArtistCursor(AsyncQueryHandler async, String filter) {
String[] cols = new String[] {
MediaStore.Audio.Artists._ID,
MediaStore.Audio.Artists.ARTIST,
MediaStore.Audio.Artists.NUMBER_OF_ALBUMS,
MediaStore.Audio.Artists.NUMBER_OF_TRACKS
};
Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
if (!TextUtils.isEmpty(filter)) {
uri = uri.buildUpon().appendQueryParameter("filter", Uri.encode(filter)).build();
}
Cursor ret = null;
if (async != null) {
async.startQuery(0, null, uri,
cols, null , null, MediaStore.Audio.Artists.ARTIST_KEY);
} else {
ret = MusicUtils.query(this, uri,
cols, null , null, MediaStore.Audio.Artists.ARTIST_KEY);
}
return ret;
}
开发者ID:AndroidLearnerchn,项目名称:Android-Application-Using-CAF-Library,代码行数:25,代码来源:ArtistAlbumBrowserActivity.java