Example usage for android.database DatabaseUtils cursorRowToContentValues

List of usage examples for android.database DatabaseUtils cursorRowToContentValues

Introduction

In this page you can find the example usage for android.database DatabaseUtils cursorRowToContentValues.

Prototype

public static void cursorRowToContentValues(Cursor cursor, ContentValues values) 

Source Link

Document

Read the entire contents of a cursor row and store them in a ContentValues.

Usage

From source file:com.abcvoipsip.ui.favorites.FavAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    ContentValues cv = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(cursor, cv);

    int type = ContactsWrapper.TYPE_CONTACT;
    if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) {
        type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE);
    }// www.j  av a 2  s . c  o  m

    if (type == ContactsWrapper.TYPE_GROUP) {
        showViewForHeader(view, true);
        TextView tv = (TextView) view.findViewById(R.id.header_text);
        ImageView icon = (ImageView) view.findViewById(R.id.header_icon);
        PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view
                .findViewById(R.id.header_presence_spinner);

        tv.setText(cv.getAsString(SipProfile.FIELD_DISPLAY_NAME));
        icon.setImageResource(WizardUtils.getWizardIconRes(cv.getAsString(SipProfile.FIELD_WIZARD)));
        presSpinner.setProfileId(cv.getAsLong(BaseColumns._ID));

    } else {
        showViewForHeader(view, false);
        ContactsWrapper.getInstance().bindContactView(view, context, cursor);

    }
}

From source file:at.bitfire.nophonespam.CallReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(intent.getAction()) && intent
            .getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING)) {
        String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
        Log.i(TAG, "Received call: " + incomingNumber);

        Settings settings = new Settings(context);
        if (TextUtils.isEmpty(incomingNumber)) {
            // private number (no caller ID)
            if (settings.blockHiddenNumbers())
                rejectCall(context, null);

        } else {/*  w w w.j  a v a 2s.  c o m*/
            DbHelper dbHelper = new DbHelper(context);
            try {
                SQLiteDatabase db = dbHelper.getWritableDatabase();
                Cursor c = db.query(Number._TABLE, null, "? LIKE " + Number.NUMBER,
                        new String[] { incomingNumber }, null, null, null);
                if (c.moveToNext()) {
                    ContentValues values = new ContentValues();
                    DatabaseUtils.cursorRowToContentValues(c, values);
                    Number number = Number.fromValues(values);

                    rejectCall(context, number);

                    values.clear();
                    values.put(Number.LAST_CALL, System.currentTimeMillis());
                    values.put(Number.TIMES_CALLED, number.timesCalled + 1);
                    db.update(Number._TABLE, values, Number.NUMBER + "=?", new String[] { number.number });

                    BlacklistObserver.notifyUpdated();
                }
                c.close();
            } finally {
                dbHelper.close();
            }
        }
    }
}

From source file:at.bitfire.ical4android.AndroidTask.java

public Task getTask() throws FileNotFoundException, CalendarStorageException {
    if (task != null)
        return task;

    try {/*from w  ww  .  j  a  v  a 2  s. co m*/
        task = new Task();
        @Cleanup
        final Cursor cursor = taskList.provider.client.query(taskSyncURI(), null, null, null, null);
        if (cursor != null && cursor.moveToFirst()) {
            ContentValues values = new ContentValues(cursor.getColumnCount());
            DatabaseUtils.cursorRowToContentValues(cursor, values);
            populateTask(values);
        } else
            throw new FileNotFoundException("Couldn't load details of task #" + id);
        return task;
    } catch (RemoteException e) {
        throw new CalendarStorageException("Couldn't read locally stored event", e);
    } catch (ParseException e) {
        throw new CalendarStorageException("Couldn't parse locally stored event", e);
    }
}

From source file:at.bitfire.ical4android.AndroidTaskList.java

public static AndroidTaskList findByID(Account account, TaskProvider provider, AndroidTaskListFactory factory,
        long id) throws FileNotFoundException, CalendarStorageException {
    try {//from  w w  w  .  ja  v a 2s  .c  o m
        @Cleanup
        Cursor cursor = provider.client.query(
                syncAdapterURI(ContentUris.withAppendedId(provider.taskListsUri(), id), account), null, null,
                null, null);
        if (cursor != null && cursor.moveToNext()) {
            AndroidTaskList taskList = factory.newInstance(account, provider, id);

            ContentValues values = new ContentValues(cursor.getColumnCount());
            DatabaseUtils.cursorRowToContentValues(cursor, values);
            taskList.populate(values);
            return taskList;
        } else
            throw new FileNotFoundException();
    } catch (RemoteException e) {
        throw new CalendarStorageException("Couldn't query task list by ID", e);
    }
}

From source file:org.servalproject.maps.bridge.AutoUploadReceiver.java

private void doUpload(Context context, Intent intent, String uploadUrl) {

    // get the URI of the new POI
    Uri mNewPoiUri = (Uri) intent.getParcelableExtra("uri");

    if (mNewPoiUri == null) {
        Log.w(sTag, "missing uri data in intent");
        return;//w  ww  . j  a  v  a 2 s .c  o m
    }

    // get the poi data
    ContentResolver mContentResolver = context.getContentResolver();

    Cursor mCursor = mContentResolver.query(mNewPoiUri, null, null, null, null);

    // check on what was returned
    if (mCursor == null) {
        Log.w(sTag, "unable to lookup new POI details");
        return;
    }

    if (mCursor.getCount() == 0) {
        Log.w(sTag, "unable to lookup new POI details");
        return;
    }

    if (!mCursor.moveToFirst()) {

        Log.w(sTag, "unable to lookup new POI details");
        return;
    }

    /*
     * TODO refactor this code to make it more portable
     * including the same code in the BatchUploadTask class
     */

    ContentValues mContentValues = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(mCursor, mContentValues);

    String mJsonData = null;

    // convert the data to JSON
    try {
        mJsonData = BasicJsonMaker.makePoiJson(mContentValues);
    } catch (JSONException e) {
        Log.e(sTag, "unable to encode JSON data for '"
                + mCursor.getString(mCursor.getColumnIndex(PointsOfInterestContract.Table._ID)), e);
        mJsonData = null;
    }

    // build the log entry
    mContentValues = new ContentValues();
    mContentValues.put(LogContract.Table.POI_ID,
            mCursor.getString(mCursor.getColumnIndex(PointsOfInterestContract.Table._ID)));
    mContentValues.put(LogContract.Table.POI_TITLE,
            mCursor.getString(mCursor.getColumnIndex(PointsOfInterestContract.Table.TITLE)));
    mContentValues.put(LogContract.Table.JSON_CONTENT, mJsonData);

    // add the appropriate upload flag
    if (mJsonData == null) {
        mContentValues.put(LogContract.Table.UPLOAD_STATUS, LogContract.INVALID_JSON_FLAG);
    } else {
        mContentValues.put(LogContract.Table.UPLOAD_STATUS, LogContract.UPLOAD_PENDING_FLAG);
    }

    mContentValues.put(LogContract.Table.TIMESTAMP, System.currentTimeMillis());

    // add the table row
    Uri mNewLogRecord = mContentResolver.insert(LogContract.CONTENT_URI, mContentValues);

    /*
     * upload the new record
     */

    ContentValues mUpdateValues;

    String[] mProjection = new String[2];
    mProjection[0] = LogContract.Table._ID;
    mProjection[1] = LogContract.Table.JSON_CONTENT;

    mCursor = mContentResolver.query(mNewLogRecord, mProjection, null, null, null);

    if (mCursor == null || mCursor.getCount() == 0 || mCursor.moveToFirst() == false) {
        Log.w(sTag, "unable to lookup new log entry");
        return;
    }

    boolean mUploadStatus = BasicHttpUploader.doBasicPost(uploadUrl,
            mCursor.getString(mCursor.getColumnIndex(mProjection[1])));

    // define selection criteria for the update
    String mSelection = LogContract.Table._ID + " = ?";
    String[] mSelectionArgs = new String[1];
    mSelectionArgs[0] = mCursor.getString(mCursor.getColumnIndex(LogContract.Table._ID));

    if (mUploadStatus) {
        // the upload was a success
        mUpdateValues = new ContentValues();
        mUpdateValues.put(LogContract.Table.UPLOAD_STATUS, LogContract.UPLOAD_SUCCESS_FLAG);
        mUpdateValues.put(LogContract.Table.TIMESTAMP, System.currentTimeMillis());
    } else {
        // the upload was a failure
        mUpdateValues = new ContentValues();
        mUpdateValues.put(LogContract.Table.UPLOAD_STATUS, LogContract.UPLOAD_FAILED_FLAG);
        mUpdateValues.put(LogContract.Table.TIMESTAMP, System.currentTimeMillis());
    }

    // update the log entry
    mContentResolver.update(LogContract.CONTENT_URI, mUpdateValues, mSelection, mSelectionArgs);
}

From source file:at.bitfire.ical4android.AndroidTaskList.java

public static AndroidTaskList[] find(Account account, TaskProvider provider, AndroidTaskListFactory factory,
        String where, String whereArgs[]) throws CalendarStorageException {
    List<AndroidTaskList> taskLists = new LinkedList<>();
    try {//  ww  w.  j av a2  s  . co  m
        @Cleanup
        Cursor cursor = provider.client.query(syncAdapterURI(provider.taskListsUri(), account), null, null,
                null, null);
        while (cursor != null && cursor.moveToNext()) {
            ContentValues values = new ContentValues(cursor.getColumnCount());
            DatabaseUtils.cursorRowToContentValues(cursor, values);
            AndroidTaskList taskList = factory.newInstance(account, provider, values.getAsLong(TaskLists._ID));
            taskList.populate(values);
            taskLists.add(taskList);
        }
    } catch (RemoteException e) {
        throw new CalendarStorageException("Couldn't query task list by ID", e);
    }
    return taskLists.toArray(factory.newArray(taskLists.size()));
}

From source file:org.servalproject.maps.bridge.tasks.BatchUploadTask.java

private void prepareJson() {

    String mJsonData = null;//  ww w .j a  v  a 2s.c o  m
    ContentValues mContentValues;

    // loop through the cursor
    while (cursor.moveToNext()) {

        mContentValues = new ContentValues();

        DatabaseUtils.cursorRowToContentValues(cursor, mContentValues);

        // convert the data to JSON
        try {
            mJsonData = BasicJsonMaker.makePoiJson(mContentValues);
        } catch (JSONException e) {
            Log.e(sTag, "unable to encode JSON data for '"
                    + cursor.getString(cursor.getColumnIndex(PointsOfInterestContract.Table._ID)), e);
            mJsonData = null;
        }

        // build the log entry
        mContentValues = new ContentValues();
        mContentValues.put(LogContract.Table.POI_ID,
                cursor.getString(cursor.getColumnIndex(PointsOfInterestContract.Table._ID)));
        mContentValues.put(LogContract.Table.POI_TITLE,
                cursor.getString(cursor.getColumnIndex(PointsOfInterestContract.Table.TITLE)));
        mContentValues.put(LogContract.Table.JSON_CONTENT, mJsonData);

        // add the appropriate upload flag
        if (mJsonData == null) {
            mContentValues.put(LogContract.Table.UPLOAD_STATUS, LogContract.INVALID_JSON_FLAG);
        } else {
            mContentValues.put(LogContract.Table.UPLOAD_STATUS, LogContract.UPLOAD_PENDING_FLAG);
        }

        mContentValues.put(LogContract.Table.TIMESTAMP, System.currentTimeMillis());

        // add the table row
        contentResolver.insert(LogContract.CONTENT_URI, mContentValues);

        // update the ui
        publishProgress(cursor.getPosition());
    }

    cursor.close();
}

From source file:com.fututel.ui.favorites.FavAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    ContentValues cv = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(cursor, cv);

    int type = ContactsWrapper.TYPE_CONTACT;
    if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) {
        type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE);
    }//from   w  w  w  . jav a 2 s  . c o m

    showViewForType(view, type);

    if (type == ContactsWrapper.TYPE_GROUP) {
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.header_text);
        ImageView icon = (ImageView) view.findViewById(R.id.header_icon);
        PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view
                .findViewById(R.id.header_presence_spinner);

        // Get datas
        SipProfile acc = new SipProfile(cursor);

        final Long profileId = cv.getAsLong(BaseColumns._ID);
        final String groupName = acc.android_group;
        final String displayName = acc.display_name;
        final String wizard = acc.wizard;
        final boolean publishedEnabled = (acc.publish_enabled == 1);
        final String domain = acc.getDefaultDomain();

        // Bind datas to view
        tv.setText(displayName);
        icon.setImageResource(WizardUtils.getWizardIconRes(wizard));
        presSpinner.setProfileId(profileId);

        // Extra menu view if not already set
        ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner);

        MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled);
        MenuBuilder menuBuilder;
        if (menuViewWrapper.getTag() == null) {

            final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);

            ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext);
            mActionMenuPresenter.setReserveOverflow(true);
            menuBuilder = new MenuBuilder(context);
            menuBuilder.setCallback(newMcb);
            MenuInflater inflater = new MenuInflater(context);
            inflater.inflate(R.menu.fav_menu, menuBuilder);
            menuBuilder.addMenuPresenter(mActionMenuPresenter);
            ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper);
            UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null);
            menuViewWrapper.addView(menuView, layoutParams);
            menuViewWrapper.setTag(menuBuilder);
        } else {
            menuBuilder = (MenuBuilder) menuViewWrapper.getTag();
            menuBuilder.setCallback(newMcb);
        }
        menuBuilder.findItem(R.id.share_presence).setTitle(
                publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing);
        menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName));

    } else if (type == ContactsWrapper.TYPE_CONTACT) {
        ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor);
        ci.userData = cursor.getPosition();
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.contact_name);
        QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
        TextView statusText = (TextView) view.findViewById(R.id.status_text);
        ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon);

        // Bind
        if (ci.contactId != null) {
            tv.setText(ci.displayName);
            badge.assignContactUri(ci.callerInfo.contactContentUri);
            ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(),
                    ci.callerInfo, R.drawable.ic_contact_picture_holo_light);

            statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusText.setText(ci.status);
            statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence));
        }
        View v;
        v = view.findViewById(R.id.contact_view);
        v.setTag(ci);
        v.setOnClickListener(mPrimaryActionListener);
        v = view.findViewById(R.id.secondary_action_icon);
        v.setTag(ci);
        v.setOnClickListener(mSecondaryActionListener);
    } else if (type == ContactsWrapper.TYPE_CONFIGURE) {
        // We only bind if it's the correct type
        View v = view.findViewById(R.id.configure_view);
        v.setOnClickListener(this);
        ConfigureObj cfg = new ConfigureObj();
        cfg.profileId = cv.getAsLong(BaseColumns._ID);
        v.setTag(cfg);
    }
}

From source file:com.csipsimple.ui.favorites.FavAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    ContentValues cv = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(cursor, cv);

    int type = ContactsWrapper.TYPE_CONTACT;
    if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) {
        type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE);
    }/*from   w w w .  jav  a2  s . com*/

    showViewForType(view, type);

    if (type == ContactsWrapper.TYPE_GROUP) {
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.header_text);
        ImageView icon = (ImageView) view.findViewById(R.id.header_icon);
        PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view
                .findViewById(R.id.header_presence_spinner);

        // Get datas
        SipProfile acc = new SipProfile(cursor);

        final Long profileId = cv.getAsLong(BaseColumns._ID);
        final String groupName = acc.android_group;
        final String displayName = acc.display_name;
        final String wizard = acc.wizard;
        final boolean publishedEnabled = (acc.publish_enabled == 1);
        final String domain = acc.getDefaultDomain();

        // Bind datas to view
        tv.setText(displayName);
        icon.setImageResource(WizardUtils.getWizardIconRes(wizard));
        presSpinner.setProfileId(profileId);

        // Extra menu view if not already set
        ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner);

        MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled);
        MenuBuilder menuBuilder;
        if (menuViewWrapper.getTag() == null) {

            final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);

            ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext);
            mActionMenuPresenter.setReserveOverflow(true);
            menuBuilder = new MenuBuilder(context);
            menuBuilder.setCallback(newMcb);
            MenuInflater inflater = new MenuInflater(context);
            inflater.inflate(R.menu.fav_menu, menuBuilder);
            menuBuilder.addMenuPresenter(mActionMenuPresenter);
            ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper);
            UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null);
            menuViewWrapper.addView(menuView, layoutParams);
            menuViewWrapper.setTag(menuBuilder);
        } else {
            menuBuilder = (MenuBuilder) menuViewWrapper.getTag();
            menuBuilder.setCallback(newMcb);
        }
        menuBuilder.findItem(R.id.share_presence).setTitle(
                publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing);
        menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName));

    } else if (type == ContactsWrapper.TYPE_CONTACT) {
        ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor);
        ci.userData = cursor.getPosition();
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.contact_name);
        QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
        TextView statusText = (TextView) view.findViewById(R.id.status_text);
        ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon);

        // Bind
        if (ci.contactId != null) {
            tv.setText(ci.displayName);
            badge.assignContactUri(ci.callerInfo.contactContentUri);
            ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(),
                    ci.callerInfo, R.drawable.ic_contact_picture_holo_dark);

            statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusText.setText(ci.status);
            statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence));
        }
        View v;
        v = view.findViewById(R.id.contact_view);
        v.setTag(ci);
        v.setOnClickListener(mPrimaryActionListener);
        v = view.findViewById(R.id.secondary_action_icon);
        v.setTag(ci);
        v.setOnClickListener(mSecondaryActionListener);
    } else if (type == ContactsWrapper.TYPE_CONFIGURE) {
        // We only bind if it's the correct type
        View v = view.findViewById(R.id.configure_view);
        v.setOnClickListener(this);
        ConfigureObj cfg = new ConfigureObj();
        cfg.profileId = cv.getAsLong(BaseColumns._ID);
        v.setTag(cfg);
    }
}

From source file:com.roamprocess1.roaming4world.ui.favorites.FavAdapter.java

@Override
public void bindView(View view, final Context context, Cursor cursor) {
    ContentValues cv = new ContentValues();
    DatabaseUtils.cursorRowToContentValues(cursor, cv);

    int type = ContactsWrapper.TYPE_CONTACT;
    if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) {
        type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE);
    }//from  ww  w.  jav  a 2  s  .  co m

    showViewForType(view, type);

    if (type == ContactsWrapper.TYPE_GROUP) {
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.header_text);
        ImageView icon = (ImageView) view.findViewById(R.id.header_icon);
        //   PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view.findViewById(R.id.header_presence_spinner);

        // Get datas
        SipProfile acc = new SipProfile(cursor);

        final Long profileId = cv.getAsLong(BaseColumns._ID);
        final String groupName = acc.android_group;
        final String displayName = acc.display_name;
        final String wizard = acc.wizard;
        final boolean publishedEnabled = (acc.publish_enabled == 1);
        final String domain = acc.getDefaultDomain();

        // Bind datas to view
        //tv.setText(displayName);  //Commented by Esstel Softwares
        tv.setText("Starred Android Contacts");

        icon.setImageResource(WizardUtils.getWizardIconRes(wizard));
        //  presSpinner.setProfileId(profileId);

        // Extra menu view if not already set
        ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner);

        MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled);
        MenuBuilder menuBuilder;
        if (menuViewWrapper.getTag() == null) {

            final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);

            ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext);
            mActionMenuPresenter.setReserveOverflow(true);
            menuBuilder = new MenuBuilder(context);
            menuBuilder.setCallback(newMcb);
            MenuInflater inflater = new MenuInflater(context);
            inflater.inflate(R.menu.fav_menu_new, menuBuilder);
            menuBuilder.addMenuPresenter(mActionMenuPresenter);
            ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper);
            UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null);
            menuViewWrapper.addView(menuView, layoutParams);
            menuViewWrapper.setTag(menuBuilder);
        } else {
            menuBuilder = (MenuBuilder) menuViewWrapper.getTag();
            menuBuilder.setCallback(newMcb);
        }
        //  menuBuilder.findItem(R.id.share_presence).setTitle(publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing);
        // menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName));

    } else if (type == ContactsWrapper.TYPE_CONTACT) {
        ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor);
        ci.userData = cursor.getPosition();
        // Get views
        TextView tv = (TextView) view.findViewById(R.id.contact_name);
        QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
        TextView statusText = (TextView) view.findViewById(R.id.status_text);
        ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon);

        // Bind
        if (ci.contactId != null) {
            tv.setText(ci.displayName);
            badge.assignContactUri(ci.callerInfo.contactContentUri);
            ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(),
                    ci.callerInfo, R.drawable.ic_contact_picture_holo_dark);

            statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusText.setText(ci.status);
            statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE);
            statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence));
        }
        View v;
        v = view.findViewById(R.id.contact_view);
        v.setTag(ci);
        v.setOnClickListener(mPrimaryActionListener);
        v = view.findViewById(R.id.secondary_action_icon);
        v.setTag(ci);
        v.setOnClickListener(mSecondaryActionListener);
    } else if (type == ContactsWrapper.TYPE_CONFIGURE) {
        // We only bind if it's the correct type
        // View v = view.findViewById(R.id.configure_view);
        //v.setOnClickListener(this);
        //ConfigureObj cfg = new ConfigureObj();
        // cfg.profileId = cv.getAsLong(BaseColumns._ID);
        // v.setTag(cfg);
    }
}