Example usage for android.content AsyncQueryHandler AsyncQueryHandler

List of usage examples for android.content AsyncQueryHandler AsyncQueryHandler

Introduction

In this page you can find the example usage for android.content AsyncQueryHandler AsyncQueryHandler.

Prototype

public AsyncQueryHandler(ContentResolver cr) 

Source Link

Usage

From source file:org.catnut.ui.MainActivity.java

private void prepareDrawer() {
    // for drawer
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);
    // for user' s profile
    new AsyncQueryHandler(getContentResolver()) {
        @Override/*  w  w  w.ja v  a2s. c o  m*/
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            if (cursor.moveToNext()) {
                mNick = cursor.getString(cursor.getColumnIndex(User.screen_name));
                mTextNick.setText(mNick);
                Picasso.with(MainActivity.this).load(cursor.getString(cursor.getColumnIndex(User.avatar_large)))
                        .placeholder(R.drawable.error).error(R.drawable.error).into(mProfileCover);
                TextView location = (TextView) findViewById(R.id.location);
                location.setText(cursor.getString(cursor.getColumnIndex(User.location)));

                String description = cursor.getString(cursor.getColumnIndex(User.description));
                mDescription.setText(
                        TextUtils.isEmpty(description) ? getString(R.string.no_description) : description);

                View flowingCount = findViewById(R.id.following_count);
                CatnutUtils.setText(flowingCount, android.R.id.text1,
                        cursor.getString(cursor.getColumnIndex(User.friends_count)));
                CatnutUtils.setText(flowingCount, android.R.id.text2, getString(R.string.followings));
                View flowerCount = findViewById(R.id.followers_count);
                CatnutUtils.setText(flowerCount, android.R.id.text1,
                        cursor.getString(cursor.getColumnIndex(User.followers_count)));
                CatnutUtils.setText(flowerCount, android.R.id.text2, getString(R.string.followers));
                View tweetsCount = findViewById(R.id.tweets_count);

                tweetsCount.setOnClickListener(MainActivity.this);
                flowingCount.setOnClickListener(MainActivity.this);
                flowerCount.setOnClickListener(MainActivity.this);
                CatnutUtils.setText(tweetsCount, android.R.id.text1,
                        cursor.getString(cursor.getColumnIndex(User.statuses_count)));
                CatnutUtils.setText(tweetsCount, android.R.id.text2, getString(R.string.tweets));
            }
            cursor.close();
        }
    }.startQuery(0, null, CatnutProvider.parse(User.MULTIPLE, mApp.getAccessToken().uid),
            new String[] { User.screen_name, User.avatar_large, User.description, User.statuses_count,
                    User.followers_count, User.friends_count, User.verified, User.location },
            null, null, null);
}

From source file:org.catnut.fragment.ProfileFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // ??*_*?view?
    String query = CatnutUtils.buildQuery(PROJECTION, User.screen_name + "=" + CatnutUtils.quote(mScreenName),
            User.TABLE, null, null, null);
    new AsyncQueryHandler(getActivity().getContentResolver()) {
        @Override/*from w w  w  .  ja v a2 s.  com*/
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            if (cursor.moveToNext()) {
                injectProfile(cursor);
            } else {
                // fall back to load from network...
                mApp.getRequestQueue().add(new CatnutRequest(getActivity(), UserAPI.profile(mScreenName),
                        new UserProcessor.UserProfileProcessor(), new Response.Listener<JSONObject>() {
                            @Override
                            public void onResponse(JSONObject response) {
                                injectProfile(response);
                            }
                        }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError error) {
                                Toast.makeText(getActivity(), getString(R.string.user_not_found),
                                        Toast.LENGTH_SHORT).show();
                            }
                        }));
            }
            cursor.close();
        }
    }.startQuery(0, null, CatnutProvider.parse(User.MULTIPLE), null, query, null, null);
    // ??
    if (mApp.getPreferences().getBoolean(getString(R.string.pref_show_latest_tweet), true)) {
        String queryLatestTweet = CatnutUtils.buildQuery(new String[] { Status.columnText,
                //                     Status.thumbnail_pic,
                Status.bmiddle_pic, Status.comments_count, Status.reposts_count, Status.retweeted_status,
                Status.attitudes_count, Status.source, Status.created_at, },
                new StringBuilder("uid=(select _id from ").append(User.TABLE).append(" where ")
                        .append(User.screen_name).append("=").append(CatnutUtils.quote(mScreenName)).append(")")
                        .append(" and ").append(Status.TYPE).append(" in(").append(Status.HOME).append(",")
                        .append(Status.RETWEET).append(",").append(Status.OTHERS).append(")").toString(),
                Status.TABLE, null, BaseColumns._ID + " desc", "1");
        new AsyncQueryHandler(getActivity().getContentResolver()) {
            @Override
            protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
                if (cursor.moveToNext()) {
                    mTweetLayout.setOnClickListener(tweetsOnclickListener);
                    ViewStub viewStub = (ViewStub) mTweetLayout.findViewById(R.id.latest_tweet);
                    View tweet = viewStub.inflate();
                    mRetweetLayout = tweet.findViewById(R.id.retweet);
                    tweet.findViewById(R.id.timeline).setVisibility(View.GONE);
                    tweet.findViewById(R.id.verified).setVisibility(View.GONE);
                    tweet.findViewById(R.id.tweet_overflow).setVisibility(View.GONE);
                    CatnutUtils.setText(tweet, R.id.nick, getString(R.string.latest_statues))
                            .setTextColor(getResources().getColor(R.color.actionbar_background));
                    String tweetText = cursor.getString(cursor.getColumnIndex(Status.columnText));
                    TweetImageSpan tweetImageSpan = new TweetImageSpan(getActivity());
                    TweetTextView text = (TweetTextView) CatnutUtils.setText(tweet, R.id.text,
                            tweetImageSpan.getImageSpan(tweetText));
                    CatnutUtils.vividTweet(text, null);
                    CatnutUtils.setTypeface(text, mTypeface);
                    text.setLineSpacing(0, mLineSpacing);

                    String thumbsUrl = cursor.getString(cursor.getColumnIndex(Status.bmiddle_pic));
                    if (!TextUtils.isEmpty(thumbsUrl)) {
                        View thumbs = tweet.findViewById(R.id.thumbs);
                        Picasso.with(getActivity()).load(thumbsUrl).placeholder(R.drawable.error)
                                .error(R.drawable.error).into((ImageView) thumbs);
                        thumbs.setVisibility(View.VISIBLE);
                    }

                    int replyCount = cursor.getInt(cursor.getColumnIndex(Status.comments_count));
                    CatnutUtils.setText(tweet, R.id.reply_count, CatnutUtils.approximate(replyCount));
                    int retweetCount = cursor.getInt(cursor.getColumnIndex(Status.reposts_count));
                    CatnutUtils.setText(tweet, R.id.reteet_count, CatnutUtils.approximate(retweetCount));
                    int favoriteCount = cursor.getInt(cursor.getColumnIndex(Status.attitudes_count));
                    CatnutUtils.setText(tweet, R.id.like_count, CatnutUtils.approximate(favoriteCount));
                    String source = cursor.getString(cursor.getColumnIndex(Status.source));
                    CatnutUtils.setText(tweet, R.id.source, Html.fromHtml(source).toString());
                    String create_at = cursor.getString(cursor.getColumnIndex(Status.created_at));
                    CatnutUtils
                            .setText(tweet, R.id.create_at,
                                    DateUtils.getRelativeTimeSpanString(DateTime.getTimeMills(create_at)))
                            .setVisibility(View.VISIBLE);
                    // retweet
                    final String jsonString = cursor.getString(cursor.getColumnIndex(Status.retweeted_status));
                    try {
                        JSONObject jsonObject = new JSONObject(jsonString);
                        TweetTextView retweet = (TweetTextView) mRetweetLayout.findViewById(R.id.retweet_text);
                        retweet.setText(jsonObject.optString(Status.text));
                        CatnutUtils.vividTweet(retweet, tweetImageSpan);
                        CatnutUtils.setTypeface(retweet, mTypeface);
                        retweet.setLineSpacing(0, mLineSpacing);
                        long mills = DateTime.getTimeMills(jsonObject.optString(Status.created_at));
                        TextView tv = (TextView) mRetweetLayout.findViewById(R.id.retweet_create_at);
                        tv.setText(DateUtils.getRelativeTimeSpanString(mills));
                        TextView retweetUserScreenName = (TextView) mRetweetLayout
                                .findViewById(R.id.retweet_nick);
                        JSONObject user = jsonObject.optJSONObject(User.SINGLE);
                        if (user == null) {
                            retweetUserScreenName.setText(getString(R.string.unknown_user));
                        } else {
                            retweetUserScreenName.setText(user.optString(User.screen_name));
                            mRetweetLayout.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Intent intent = new Intent(getActivity(), TweetActivity.class);
                                    intent.putExtra(Constants.JSON, jsonString);
                                    startActivity(intent);
                                }
                            });
                        }
                    } catch (Exception e) {
                        mRetweetLayout.setVisibility(View.GONE);
                    }
                }
                cursor.close();
            }
        }.startQuery(0, null, CatnutProvider.parse(Status.MULTIPLE), null, queryLatestTweet, null, null);
    }
}

From source file:org.jamienicol.episodes.ShowActivity.java

private void toggleShowStarred() {
    final ContentResolver contentResolver = getContentResolver();
    final AsyncQueryHandler handler = new AsyncQueryHandler(contentResolver) {
    };//w  ww  .ja v  a2 s. c o m
    final ContentValues values = new ContentValues();
    values.put(ShowsTable.COLUMN_STARRED, !isShowStarred);
    final String selection = String.format("%s=?", ShowsTable.COLUMN_ID);
    final String[] selectionArgs = { String.valueOf(showId) };

    handler.startUpdate(0, null, ShowsProvider.CONTENT_URI_SHOWS, values, selection, selectionArgs);
}

From source file:org.jamienicol.episodes.ShowActivity.java

private void toggleShowArchived() {
    final ContentResolver contentResolver = getContentResolver();
    final AsyncQueryHandler handler = new AsyncQueryHandler(contentResolver) {
    };/*from  w w  w  . j  av  a  2s.c om*/
    final ContentValues values = new ContentValues();
    values.put(ShowsTable.COLUMN_ARCHIVED, !isShowArchived);
    final String selection = String.format("%s=?", ShowsTable.COLUMN_ID);
    final String[] selectionArgs = { String.valueOf(showId) };

    handler.startUpdate(0, null, ShowsProvider.CONTENT_URI_SHOWS, values, selection, selectionArgs);
}

From source file:org.jamienicol.episodes.ShowActivity.java

private void markShowWatched(boolean watched) {
    final ContentResolver contentResolver = getContentResolver();
    final AsyncQueryHandler handler = new AsyncQueryHandler(contentResolver) {
    };/*from  w ww.  jav a 2 s  .  c  o  m*/
    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), "0" };

    handler.startUpdate(0, null, ShowsProvider.CONTENT_URI_EPISODES, epValues, selection, selectionArgs);
}

From source file:org.catnut.ui.ComposeTweetActivity.java

private void injectLayout() {
    // for panel/*  w  w  w . j  av  a  2s. c  om*/
    mSlidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);
    mEmotions = (GridView) findViewById(R.id.emotions);
    mEmotions.setAdapter(new EmotionsAdapter(this));
    mEmotions.setOnItemClickListener(this);
    mSlidingPaneLayout.setPanelSlideListener(new SliderListener());
    mSlidingPaneLayout.openPane();
    mSlidingPaneLayout.getViewTreeObserver().addOnGlobalLayoutListener(new FirstLayoutListener());
    // for tweet
    mAvatar = (ImageView) findViewById(R.id.avatar);
    mScreenName = (TextView) findViewById(R.id.screen_name);
    mText = (EditText) findViewById(R.id.text);
    mLocationMarker = findViewById(R.id.location_marker);
    // set data to layout...
    new AsyncQueryHandler(getContentResolver()) {
        @Override
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            if (cursor.moveToNext()) {
                Picasso.with(ComposeTweetActivity.this)
                        .load(cursor.getString(cursor.getColumnIndex(User.avatar_large)))
                        .placeholder(R.drawable.error).error(R.drawable.error).into(mAvatar);
                mScreenName.setText("@" + cursor.getString(cursor.getColumnIndex(User.screen_name)));
            }
            cursor.close();
        }
    }.startQuery(0, null, CatnutProvider.parse(User.MULTIPLE, mApp.getAccessToken().uid),
            new String[] { User.avatar_large, User.screen_name }, null, null, null);
    // other stuffs...
    mText.addTextChangedListener(this);
}

From source file:org.jamienicol.episodes.ShowActivity.java

private void deleteShow() {
    final ContentResolver contentResolver = getContentResolver();
    final AsyncQueryHandler handler = new AsyncQueryHandler(contentResolver) {
    };//  w  ww  .j  a v a2s  .com

    /* delete all the show's episodes */
    final String epSelection = String.format("%s=?", EpisodesTable.COLUMN_SHOW_ID);
    final String[] epSelectionArgs = { String.valueOf(showId) };

    handler.startDelete(0, null, ShowsProvider.CONTENT_URI_EPISODES, epSelection, epSelectionArgs);

    /* delete the show itself */
    final Uri showUri = Uri.withAppendedPath(ShowsProvider.CONTENT_URI_SHOWS, String.valueOf(showId));
    handler.startDelete(0, null, showUri, null, null);
}

From source file:com.commonsware.android.arXiv.CategoriesListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!getUserVisibleHint())
        return false;
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null)
        return false;
    ContentValues cv = new ContentValues();
    int id;/*www  .  jav  a 2 s  .  c om*/
    if (mySourcePref == 0) {
        String tempquery = "search_query=cat:" + urls[info.position] + "*";
        String tempurl = "http://export.arxiv.org/api/query?" + tempquery
                + "&sortBy=submittedDate&sortOrder=ascending";
        cv.put(Feeds.TITLE, shortItems[info.position]);
        cv.put(Feeds.SHORTTITLE, tempquery);
        cv.put(Feeds.URL, tempurl);
        cv.put(Feeds.UNREAD, -1);
        cv.put(Feeds.COUNT, -1);
        id = R.string.added_to_favorites;
    } else {
        cv.put(Feeds.TITLE, shortItems[info.position] + " (RSS)");
        cv.put(Feeds.SHORTTITLE, shortItems[info.position]);
        cv.put(Feeds.URL, urls[info.position]);
        cv.put(Feeds.UNREAD, -2);
        cv.put(Feeds.COUNT, -2);
        id = R.string.added_to_favorites_rss;
    }
    cv.put(Feeds.LAST_UPDATE, 0);
    new AsyncQueryHandler(getActivity().getContentResolver()) {
        @Override
        protected void onInsertComplete(int id, Object cookie, Uri uri) {
            Toast.makeText(getActivity(), id, Toast.LENGTH_SHORT).show();
        }
    }.startInsert(id, null, Feeds.CONTENT_URI, cv);
    return true;
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.MapFragment.java

/**
 * Create an {@link AsyncQueryHandler} for use with the
 * {@link MapInfoWindowAdapter}./*from ww  w.j  a  v a2s .  com*/
 */
private AsyncQueryHandler createInfowindowHandler(ContentResolver contentResolver) {
    return new AsyncQueryHandler(contentResolver) {
        StringBuilder mBuffer = new StringBuilder();
        Formatter mFormatter = new Formatter(mBuffer, Locale.getDefault());

        @Override
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {

            MarkerModel model = mMarkers.get(cookie);

            mInfoAdapter.clearData();

            if (model == null || cursor == null) {
                // query did not complete or incorrect data was loaded
                return;
            }

            final long time = UIUtils.getCurrentTime(getActivity());

            switch (token) {
            case SessionAfterQuery._TOKEN: {
                extractSession(cursor, model, time);
            }
                break;
            case SandboxCompaniesAtQuery._TOKEN: {
                extractSandbox(cursor, model, time);
            }
            }

            // update the displayed window
            model.marker.showInfoWindow();
        }

        private void extractSandbox(Cursor cursor, MarkerModel model, long time) {
            // get tracks data from cache: icon and color
            TrackModel track = mTracks.get(model.track);
            int color = (track != null) ? track.color : 0;
            int iconResId = 0;
            if (track != null) {
                iconResId = getResources().getIdentifier("track_" + ParserUtils.sanitizeId(track.name),
                        "drawable", getActivity().getPackageName());
            }

            if (cursor != null && cursor.getCount() > 0) {
                cursor.moveToFirst();

                StringBuilder sb = new StringBuilder();
                int count = 0;
                final int maxCompaniesDisplay = getResources()
                        .getInteger(R.integer.sandbox_company_list_max_display);
                while (!cursor.isAfterLast() && count < maxCompaniesDisplay) {
                    if (sb.length() > 0) {
                        sb.append(", ");
                    }
                    sb.append(cursor.getString(SandboxCompaniesAtQuery.COMPANY_NAME));
                    count++;
                    cursor.moveToNext();
                }
                if (count >= maxCompaniesDisplay && !cursor.isAfterLast()) {
                    // Additional sandbox companies to display
                    sb.append(", &hellip;");
                }

                mInfoAdapter.setSandbox(model.marker, model.label, color, iconResId,
                        sb.length() > 0 ? sb.toString() : null);

            } else {
                // No active sandbox companies
                mInfoAdapter.setSandbox(model.marker, model.label, color, iconResId, null);
            }

            model.marker.showInfoWindow();
        }

        private static final long SHOW_UPCOMING_TIME = 24 * 60 * 60 * 1000; // 24 hours

        private void extractSession(Cursor cursor, MarkerModel model, long time) {

            if (cursor != null && cursor.getCount() > 0) {
                cursor.moveToFirst();

                String currentTitle = null;
                String nextTitle = null;
                String nextTime = null;

                final long blockStart = cursor.getLong(SessionAfterQuery.BLOCK_START);
                final long blockEnd = cursor.getLong(SessionAfterQuery.BLOCK_END);
                boolean inProgress = time >= blockStart && time <= blockEnd;

                if (inProgress) {
                    // A session is running, display its name and optionally
                    // the next session
                    currentTitle = cursor.getString(SessionAfterQuery.SESSION_TITLE);

                    //move to the next entry
                    cursor.moveToNext();
                }

                if (!cursor.isAfterLast()) {
                    //There is a session coming up next, display only it if it's within 24 hours of the current time
                    final long nextStart = cursor.getLong(SessionAfterQuery.BLOCK_START);

                    if (nextStart < time + SHOW_UPCOMING_TIME) {
                        nextTitle = cursor.getString(SessionAfterQuery.SESSION_TITLE);
                        mBuffer.setLength(0);

                        boolean showWeekday = !DateUtils.isToday(blockStart)
                                && !UIUtils.isSameDayDisplay(UIUtils.getCurrentTime(getActivity()), blockStart,
                                        getActivity());

                        nextTime = DateUtils.formatDateRange(getActivity(), mFormatter, blockStart, blockStart,
                                DateUtils.FORMAT_SHOW_TIME | (showWeekday
                                        ? DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY
                                        : 0),
                                PrefUtils.getDisplayTimeZone(getActivity()).getID()).toString();
                    }
                }

                // populate the info window adapter
                mInfoAdapter.setSessionData(model.marker, model.label, currentTitle, nextTitle, nextTime,
                        inProgress);

            } else {
                // No entries, display name of room only
                mInfoAdapter.setMarker(model.marker, model.label);
            }
        }

    };
}

From source file:org.catnut.fragment.TweetFragment.java

private void loadTweet() {
    // load tweet from local...
    String query = CatnutUtils.buildQuery(
            new String[] { Status.uid, Status.columnText, Status.bmiddle_pic, Status.original_pic,
                    Status.comments_count, Status.reposts_count, Status.attitudes_count, Status.source,
                    Status.favorited, Status.retweeted_status, Status.pic_urls, "s." + Status.created_at,
                    User.screen_name, User.avatar_large, User.remark, User.verified },
            "s._id=" + mId, Status.TABLE + " as s", "inner join " + User.TABLE + " as u on s.uid=u._id", null,
            null);//from w  w  w .  j a  va 2s  . c o  m
    new AsyncQueryHandler(getActivity().getContentResolver()) {
        @Override
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            if (cursor.moveToNext()) {
                Picasso.with(getActivity()).load(cursor.getString(cursor.getColumnIndex(User.avatar_large)))
                        .placeholder(R.drawable.error).error(R.drawable.error).into(mAvatar);
                final long uid = cursor.getLong(cursor.getColumnIndex(Status.uid));
                final String screenName = cursor.getString(cursor.getColumnIndex(User.screen_name));
                mAvatar.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getActivity(), ProfileActivity.class);
                        intent.putExtra(Constants.ID, uid);
                        intent.putExtra(User.screen_name, screenName);
                        startActivity(intent);
                    }
                });
                String remark = cursor.getString(cursor.getColumnIndex(User.remark));
                mRemark.setText(TextUtils.isEmpty(remark) ? screenName : remark);
                mScreenName.setText(getString(R.string.mention_text, screenName));
                mPlainText = cursor.getString(cursor.getColumnIndex(Status.columnText));
                mText.setText(mPlainText);
                CatnutUtils.vividTweet(mText, mImageSpan);
                CatnutUtils.setTypeface(mText, mTypeface);
                mText.setLineSpacing(0, mLineSpacing);
                int replyCount = cursor.getInt(cursor.getColumnIndex(Status.comments_count));
                mReplayCount.setText(CatnutUtils.approximate(replyCount));
                int retweetCount = cursor.getInt(cursor.getColumnIndex(Status.reposts_count));
                mReteetCount.setText(CatnutUtils.approximate(retweetCount));
                int favoriteCount = cursor.getInt(cursor.getColumnIndex(Status.attitudes_count));
                mFavoriteCount.setText(CatnutUtils.approximate(favoriteCount));
                String source = cursor.getString(cursor.getColumnIndex(Status.source));
                mSource.setText(Html.fromHtml(source).toString());
                mCreateAt.setText(DateUtils.getRelativeTimeSpanString(
                        DateTime.getTimeMills(cursor.getString(cursor.getColumnIndex(Status.created_at)))));
                if (CatnutUtils.getBoolean(cursor, User.verified)) {
                    mTweetLayout.findViewById(R.id.verified).setVisibility(View.VISIBLE);
                }
                String thumb = cursor.getString(cursor.getColumnIndex(Status.bmiddle_pic));
                String url = cursor.getString(cursor.getColumnIndex(Status.original_pic));
                loadThumbs(thumb, url, mThumbs,
                        CatnutUtils.optPics(cursor.getString(cursor.getColumnIndex(Status.pic_urls))),
                        mPicsOverflow);
                // retweet
                final String jsonString = cursor.getString(cursor.getColumnIndex(Status.retweeted_status));
                if (!TextUtils.isEmpty(jsonString)) {
                    View retweet = mRetweetLayout.inflate();
                    try {
                        JSONObject json = new JSONObject(jsonString);
                        JSONObject user = json.optJSONObject(User.SINGLE);
                        String _remark = user.optString(User.remark);
                        if (TextUtils.isEmpty(_remark)) {
                            _remark = user.optString(User.screen_name);
                        }
                        CatnutUtils.setText(retweet, R.id.retweet_nick,
                                getString(R.string.mention_text, _remark));
                        long mills = DateTime.getTimeMills(json.optString(Status.created_at));
                        CatnutUtils.setText(retweet, R.id.retweet_create_at,
                                DateUtils.getRelativeTimeSpanString(mills));
                        TweetTextView retweetText = (TweetTextView) CatnutUtils.setText(retweet,
                                R.id.retweet_text, json.optString(Status.text));
                        CatnutUtils.vividTweet(retweetText, mImageSpan);
                        CatnutUtils.setTypeface(retweetText, mTypeface);
                        retweetText.setLineSpacing(0, mLineSpacing);
                        retweet.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                Intent intent = new Intent(getActivity(), TweetActivity.class);
                                intent.putExtra(Constants.JSON, jsonString);
                                startActivity(intent);
                            }
                        });
                        retweet.findViewById(R.id.verified)
                                .setVisibility(user.optBoolean(User.verified) ? View.VISIBLE : View.GONE);
                        if (json.has(Status.thumbnail_pic)) {
                            loadThumbs(json.optString(Status.bmiddle_pic), json.optString(Status.bmiddle_pic),
                                    (ImageView) retweet.findViewById(R.id.thumbs),
                                    json.optJSONArray(Status.pic_urls),
                                    retweet.findViewById(R.id.pics_overflow));
                        }
                    } catch (JSONException e) {
                        Log.e(TAG, "convert text to string error!", e);
                        retweet.setVisibility(View.GONE);
                    }
                }
                // shareAndFavorite&favorite
                shareAndFavorite(CatnutUtils.getBoolean(cursor, Status.favorited), mPlainText);
            }
            cursor.close();
        }
    }.startQuery(0, null, CatnutProvider.parse(Status.MULTIPLE), null, query, null, null);
}