Java Code Examples for com.android.contacts.model.RawContactDeltaList

Following code examples demonstrate how to use com.android.contacts.model.RawContactDeltaListfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.contacts.model.RawContactDeltaListand various code implementation of this class.

    public static String checkRawContactDeltaList(RawContactDeltaList state, Context context) {
        StringBuilder builder = new StringBuilder();
        boolean containEmail = false;
        boolean groupMembership = false;
        boolean ringtone = false;
        boolean structuredPostal = false;
        boolean im = false;
        boolean note = false;
        boolean photo = false;
        boolean z = false;
        boolean z2 = false;
        boolean organization = false;
        int nameCount = 0;
        int numberCount = 0;
        boolean hasWechat = false;
        boolean hasWhatsapp = false;
        if (!(state == null || state.isEmpty())) {
            for (RawContactDelta delta : state) {
                HashMap<String, ArrayList<ValuesDelta>> entries = delta.getEntries();
                if (entries.containsKey("vnd.android.cursor.item/name")) {
                    nameCount++;
                }
                if (entries.containsKey("vnd.android.cursor.item/phone_v2")) {
                    numberCount += ((ArrayList) entries.get("vnd.android.cursor.item/phone_v2")).size();
                }
                if (isContainKind(entries, "vnd.android.cursor.item/email_v2")) {
                    containEmail = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/group_membership")) {
                    groupMembership = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/vnd.com.tencent.mm.chatting.profile")) {
                    hasWechat = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/vnd.com.whatsapp.profile")) {
                    hasWhatsapp = true;
                }
                boolean lHasRingtoneChanges = false;
                if (delta.getValues().getAfter() != null) {
                    lHasRingtoneChanges = delta.getValues().getAfter().containsKey("custom_ringtone");
                }
                if (lHasRingtoneChanges) {
                    ringtone = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/postal-address_v2")) {
                    structuredPostal = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/im")) {
                    im = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/note")) {
                    note = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/photo")) {
                    photo = true;
                }
                if (isContainKind(entries, "vnd.android.cursor.item/contact_event")) {
                    for (ValuesDelta value : (ArrayList) entries.get("vnd.android.cursor.item/contact_event")) {
                        String type = getAsString(value, "data2");
                        if (type != null) {
                            z = !z ? type.equals("3") : true;
                            z2 = !z2 ? type.equals("4") : true;
                        }
                    }
                }
                if (isContainKind(entries, "vnd.android.cursor.item/organization")) {
                    organization = true;
                }
            }
        }
        builder.append(containEmail ? '1' : '0');
        builder.append(groupMembership ? '1' : '0');
        builder.append(ringtone ? '1' : '0');
        builder.append(structuredPostal ? '1' : '0');
        builder.append(im ? '1' : '0');
        builder.append(note ? '1' : '0');
        builder.append(photo ? '1' : '0');
        builder.append(z ? '1' : '0');
        builder.append(z2 ? '1' : '0');
        builder.append(organization ? '1' : '0');
        if (!(nameCount < 1 || numberCount != 1 || organization || containEmail || groupMembership || ringtone || structuredPostal || im || note || photo || z)) {
            StatisticalHelper.report(AMapException.CODE_AMAP_ID_NOT_EXIST);
        }
        if (hasWechat) {
            StatisticalHelper.report(2026);
        }
        if (hasWhatsapp) {
            StatisticalHelper.report(2027);
        }
        if (numberCount > 0 && context != null && CommonUtilMethods.checkApkExist(context, "com.huawei.espacev2")) {
            StatisticalHelper.report(2029);
        }
        return builder.toString();
    } 


    private void multiRecoSave(Intent intent) {
        Context context = this;
        AccountTypeManager accountTypes = AccountTypeManager.getInstance(this);
        ContactEditorUtils editorUtils = ContactEditorUtils.getInstance(this);
        editorUtils.setExcludeSim(true);
        editorUtils.setExcludeSim1(true);
        editorUtils.setExcludeSim2(true);
        AccountWithDataSet defaultAccount = null;
        if (!editorUtils.shouldShowAccountChangedNotification()) {
            defaultAccount = editorUtils.getDefaultAccount();
        }
        if (defaultAccount == null) {
            defaultAccount = accountTypes.getAccountWithDataSet(0);
        }
        if (defaultAccount != null) {
            AccountType accountType = accountTypes.getAccountType(defaultAccount.type, defaultAccount.dataSet);
            ContentValues values = new ContentValues();
            values.put("is_camcard", Integer.valueOf(2));
            RawContact rawContact = new RawContact(values);
            rawContact.setAccount(defaultAccount);
            RawContactDelta rawContactDelta = new RawContactDelta(ValuesDelta.fromAfter(rawContact.getValues()));
            Bundle extra = intent.getExtras();
            String path = intent.getStringExtra("photo_path");
            RawContactModifier.parseExtras(this, accountType, rawContactDelta, extra);
            RawContactDeltaList mState = RawContactDeltaList.fromSingle(rawContactDelta);
            Bundle updatePhoto = new Bundle();
            if (path != null) {
                updatePhoto.putParcelable(String.valueOf(-1), CCardPhotoUtils.generatePhotoUri(this, new File(path)));
            }
            Intent serviceIntent = ContactSaveService.createSaveContactIntent(this, mState, "saveMode", 0, false, null, null, updatePhoto);
            serviceIntent.putExtra("key_from_camcard", true);
            startService(serviceIntent);
            if (HwLog.HWDBG) {
                HwLog.d(TAG, "start ContactSaveService");
            }
        }
    } 

        public void onClick(View v) {
            RawContactDeltaList delta = mContactData.createRawContactDeltaList();

            final float appScale =
                    mContext.getResources().getCompatibilityInfo().applicationScale;
            final int[] pos = new int[2];
            v.getLocationOnScreen(pos);

            final Rect rect = new Rect();
            rect.left = (int) (pos[0] * appScale + 0.5f);
            rect.top = (int) (pos[1] * appScale + 0.5f);
            rect.right = (int) ((pos[0] + v.getWidth()) * appScale + 0.5f);
            rect.bottom = (int) ((pos[1] + v.getHeight()) * appScale + 0.5f);

            Uri photoUri = null;
            if (mContactData.getPhotoUri() != null) {
                photoUri = Uri.parse(mContactData.getPhotoUri());
            }
            Intent photoSelectionIntent = PhotoSelectionActivity.buildIntent(mContext,
                    photoUri, mPhotoBitmap, mPhotoBytes, rect, delta, mContactData.isUserProfile(),
                    mContactData.isDirectoryEntry(), mExpandPhotoOnClick);
            if (mPhotoBitmap != null) {
                ContactPhotoManager.getInstance(mContext).cacheBitmap(
                        photoUri, mPhotoBitmap, mPhotoBytes);
            }
            mContext.startActivity(photoSelectionIntent);
        } 

Advertisement
Javadoc
Container for multiple RawContactDelta objects, usually when editing together as an entire aggregate

. Provides convenience methods for parceling and applying another RawContactDeltaList over it.

Read More
Advertisement