导航菜单

页面标题

页面副标题

CallApp v2.226 - ChooseSocialProfileActivity.java 源代码

正在查看: CallApp v2.226 应用的 ChooseSocialProfileActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.callapp.contacts.activity.choosesocialprofile;

import a1.d0;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Pair;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.a;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.callapp.common.model.json.JSONFBUserOrPage;
import com.callapp.common.model.json.JSONSocialNetworkID;
import com.callapp.contacts.CallAppApplication;
import com.callapp.contacts.R;
import com.callapp.contacts.activity.base.BaseNoTitleActivity;
import com.callapp.contacts.activity.base.BaseViewTypeData;
import com.callapp.contacts.activity.choosesocialprofile.ChooseImageAdapter;
import com.callapp.contacts.activity.contact.details.ContactDetailsActivity;
import com.callapp.contacts.activity.crop.CallAppCropActivity;
import com.callapp.contacts.activity.crop.ChooseImageSourceDialogListener;
import com.callapp.contacts.activity.fragments.OpenLoginDialogBackgroundFragment;
import com.callapp.contacts.activity.select.PersonSelectActivity;
import com.callapp.contacts.api.helper.common.ContactSocialNetworksCertaintyHelper;
import com.callapp.contacts.api.helper.common.RemoteAccountHelper;
import com.callapp.contacts.api.helper.common.SocialNetworksSearchUtil;
import com.callapp.contacts.api.helper.facebook.FacebookHelper;
import com.callapp.contacts.api.helper.instagram.InstagramHelper;
import com.callapp.contacts.event.listener.BackgroundFragmentListener;
import com.callapp.contacts.loader.ChosenContactPhotoManager;
import com.callapp.contacts.loader.UserMediaManager;
import com.callapp.contacts.loader.business.GooglePlacesLoader;
import com.callapp.contacts.loader.social.QuotaReachedException;
import com.callapp.contacts.loader.social.SearchIsNotAvailableExecption;
import com.callapp.contacts.loader.social.UserNotFoundException;
import com.callapp.contacts.manager.CallAppShortcutManager;
import com.callapp.contacts.manager.ContactLoaderManager;
import com.callapp.contacts.manager.FeedbackManager;
import com.callapp.contacts.manager.analytics.AnalyticsManager;
import com.callapp.contacts.manager.phone.PhoneManager;
import com.callapp.contacts.manager.popup.DialogPopup;
import com.callapp.contacts.manager.popup.PopupManager;
import com.callapp.contacts.manager.preferences.Prefs;
import com.callapp.contacts.manager.preferences.prefs.IntegerSetPref;
import com.callapp.contacts.manager.task.OutcomeListener;
import com.callapp.contacts.manager.task.Task;
import com.callapp.contacts.model.Constants;
import com.callapp.contacts.model.PersonData;
import com.callapp.contacts.model.contact.ContactData;
import com.callapp.contacts.model.contact.ContactDataChangeListener;
import com.callapp.contacts.model.contact.ContactDataUtils;
import com.callapp.contacts.model.contact.ContactField;
import com.callapp.contacts.model.contact.DataSource;
import com.callapp.contacts.model.contact.GooglePlacesData;
import com.callapp.contacts.model.contact.SocialMatchesData;
import com.callapp.contacts.model.contact.SocialSearchResults;
import com.callapp.contacts.model.contact.social.ContactFieldEnumSets;
import com.callapp.contacts.model.contact.social.SocialDataUtils;
import com.callapp.contacts.model.objectbox.ChosenContactPhoto;
import com.callapp.contacts.model.objectbox.UserMediaData;
import com.callapp.contacts.model.objectbox.UserMediaData_;
import com.callapp.contacts.popup.ChooseImageSourceDialog;
import com.callapp.contacts.popup.DefaultPersonSelectListener;
import com.callapp.contacts.util.Activities;
import com.callapp.contacts.util.AndroidUtils;
import com.callapp.contacts.util.CLog;
import com.callapp.contacts.util.IoUtils;
import com.callapp.contacts.util.ThemeUtils;
import com.callapp.contacts.util.ViewUtils;
import com.callapp.framework.phone.Phone;
import com.callapp.framework.util.CollectionUtils;
import com.callapp.framework.util.StringUtils;
import com.google.android.play.core.splitcompat.SplitCompatApplication;
import io.objectbox.query.QueryBuilder;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class ChooseSocialProfileActivity extends BaseNoTitleActivity implements ContactDataChangeListener, BackgroundFragmentListener<Integer>, ChooseImageAdapter.OnChooseImageEventListener {
    private static final int CALLAPP_AUTO_SELECT_ID = 1000;
    private static final int CALLAPP_DEFAULT_INDEX = 0;
    public static final String CONTACT_ID_EXTRA = "CONTACT_ID_EXTRA";
    public static final String CONTACT_NAME_EXTRA = "CONTACT_NAME_EXTRA";
    public static final String CONTACT_PHONE_EXTRA = "CONTACT_PHONE_EXTRA";
    private static final int FACEBOOK_INDEX = 2;
    private static final int GOOGLEPLACES_INDEX = 3;
    private static final int INDEX_NOT_FOUND = -1;
    private static final int INSTAGRAM_INDEX = 5;
    private static final String OPEN_LOGIN_DIALOG_BACKGROUND_FRAGMENT = "openLoginDialogBackgroundFragment";
    public static final String PREFIX_CUSTOM_PROFILE_ = "custom_profile_";
    public static final int REQUEST_CODE_CONTACT_SOCIAL = 9625;
    private static final int TWITTER_INDEX = 4;
    private static final int USER_MEDIA_INDEX = 1;
    private Task candidateImageTask;
    private ChooseImageAdapter chooseImageAdapter;
    private ContactData contact;
    private long contactId;
    private String contactName;
    private int defaultPhotoResId;
    private int defaultUnknownPhotoResId;
    private int hasSearchResultsResId;
    private Uri imageUri;
    private String phoneNum;
    private List<BaseViewTypeData> socialMatchesData;
    private final String PHOTO_URI_PARAM = "photo_uri_param";
    private final String CONTACT_ID_PARAM = "contact_id_param";
    private final String PHONE_NUM_PARAM = "phone_num_param";
    private final SparseArray<JSONSocialNetworkID> socialNetworkUserIds = new SparseArray<>();
    private final SparseArray<PersonData> socialNetworkPersons = new SparseArray<>();
    private String fqlType = "";
    private final AndroidUtils.FieldsChangedHandler<DataSource> dataSourceFieldsChangedHandler = new AndroidUtils.FieldsChangedHandler<>(DataSource.ACTIVE_SOCIAL_DATA_SOURCES_LIST);
    private final AndroidUtils.FieldsChangedHandler<ContactField> photoUrlFieldChangedHandler = new AndroidUtils.FieldsChangedHandler<>(ContactField.photoUrl);

    public class AnonymousClass6 extends Task {
        public final JSONSocialNetworkID a;
        public final RemoteAccountHelper b;
        public final Integer c;

        public AnonymousClass6(JSONSocialNetworkID jSONSocialNetworkID, RemoteAccountHelper remoteAccountHelper, Integer num) {
            this.a = jSONSocialNetworkID;
            this.b = remoteAccountHelper;
            this.c = num;
        }

        @Override
        public final void doTask() {
            final Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    AnonymousClass6 anonymousClass6 = AnonymousClass6.this;
                    if (anonymousClass6.a.isSure()) {
                        return;
                    }
                    ?? r3 = ChooseSocialProfileActivity.this;
                    ContactData contactData = ((ChooseSocialProfileActivity) r3).contact;
                    RemoteAccountHelper remoteAccountHelper = anonymousClass6.b;
                    DefaultPersonSelectListener defaultPersonSelectListener = new DefaultPersonSelectListener(remoteAccountHelper, contactData) {
                        @Override
                        public final void a() {
                            AnonymousClass6 anonymousClass62 = AnonymousClass6.this;
                            ChooseSocialProfileActivity.this.doesntChosePerson(anonymousClass62.c.intValue());
                        }

                        @Override
                        public final void b(String str) {
                            super.b(str);
                            AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
                            ChooseSocialProfileActivity.this.dataSourceFieldsChangedHandler.setFieldChanged(RemoteAccountHelper.getRemoteAccountHelper(AnonymousClass6.this.c.intValue()).getDataSource());
                            ChooseSocialProfileActivity.this.socialNetworkUserIds.put(AnonymousClass6.this.c.intValue(), new JSONSocialNetworkID(str, true));
                            AnonymousClass6 anonymousClass62 = AnonymousClass6.this;
                            ChooseSocialProfileActivity.this.initNetUi(anonymousClass62.c);
                        }

                        @Override
                        public final void c() {
                            super.c();
                            AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
                            ChooseSocialProfileActivity.this.dataSourceFieldsChangedHandler.setFieldChanged(RemoteAccountHelper.getRemoteAccountHelper(AnonymousClass6.this.c.intValue()).getDataSource());
                            ChooseSocialProfileActivity.this.socialNetworkUserIds.remove(AnonymousClass6.this.c.intValue());
                            AnonymousClass6 anonymousClass62 = AnonymousClass6.this;
                            ChooseSocialProfileActivity.this.initNetUi(anonymousClass62.c);
                        }
                    };
                    ContactSocialNetworksCertaintyHelper.ProfileDialogListener profileDialogListener = new ContactSocialNetworksCertaintyHelper.ProfileDialogListener() {
                        @Override
                        public final void a() {
                            AnonymousClass6 anonymousClass62 = AnonymousClass6.this;
                            ChooseSocialProfileActivity.this.markProfileAsSure(anonymousClass62.c, anonymousClass62.b, anonymousClass62.a);
                        }
                    };
                    ContactData contactData2 = ((ChooseSocialProfileActivity) r3).contact;
                    new ContactSocialNetworksCertaintyHelper(r3, contactData2, remoteAccountHelper.getDataSource(), defaultPersonSelectListener, profileDialogListener).b(r3, contactData2);
                }
            };
            ?? r1 = ChooseSocialProfileActivity.this;
            ContactData unused = ((ChooseSocialProfileActivity) r1).contact;
            RemoteAccountHelper remoteAccountHelper = this.b;
            if (remoteAccountHelper.isNativeAppInstalled()) {
                Activities.g(r1, runnable);
            }
            final String id = this.a.getId();
            if (StringUtils.x(id)) {
                remoteAccountHelper.y(r1, r1.getSocialId(remoteAccountHelper, id), runnable, new OutcomeListener() {
                    @Override
                    public final void d(boolean z) {
                        if (z) {
                            return;
                        }
                        AnonymousClass6 anonymousClass6 = AnonymousClass6.this;
                        if (7 != anonymousClass6.c.intValue() || anonymousClass6.a == null) {
                            return;
                        }
                        ChooseSocialProfileActivity.this.handleOpenInstagramPrivateProfile(id, runnable);
                    }
                });
                r1.notifyForUpdatesAndUpdateCandidate();
            }
        }
    }

    public void doesntChosePerson(int i) {
        this.socialNetworkUserIds.remove(i);
        initNetUi(Integer.valueOf(i));
    }

    public static PersonData findPrivateUsers(String str, String str2, int i) {
        List<PersonData> list;
        try {
            try {
                list = RemoteAccountHelper.getRemoteAccountHelper(i).z(str2);
            } catch (QuotaReachedException unused) {
                return null;
            }
        } catch (SearchIsNotAvailableExecption unused2) {
            list = null;
        }
        if (!CollectionUtils.h(list)) {
            return null;
        }
        for (PersonData personData : list) {
            String id = personData.getId();
            if (StringUtils.x(id) && id.equals(str)) {
                return personData;
            }
        }
        return null;
    }

    private int getCheckedImagePosition(Intent intent) {
        ChosenContactPhoto b = ChosenContactPhotoManager.b(intent.getLongExtra("CONTACT_ID_EXTRA", -1L), PhoneManager.get().e(intent.getStringExtra("CONTACT_PHONE_EXTRA")));
        if (b == null || b.getDataSource() == null || !b.hasRealChosenPhoto()) {
            return 0;
        }
        return getIndexInSocialsList(Integer.valueOf(b.getDataSource().dbCode));
    }

    private DevicePhotoData getEmptyDevicePhotoData() {
        DevicePhotoData devicePhotoData = new DevicePhotoData(false);
        devicePhotoData.setTitle(Activities.getString(R.string.text_add_photo_from_your_device));
        return devicePhotoData;
    }

    private Uri getFileUri() {
        if (this.imageUri == null) {
            try {
                this.imageUri = IoUtils.l(this, File.createTempFile("custom_profile_" + this.contactId + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()), ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
            } catch (IOException e) {
                CLog.b(ChooseSocialProfileActivity.class, e);
            }
        }
        return this.imageUri;
    }

    public int getIndexInSocialsList(Integer num) {
        int intValue = num.intValue();
        if (intValue == 0) {
            return 1;
        }
        if (intValue == 1) {
            return 2;
        }
        if (intValue == 4) {
            return 4;
        }
        if (intValue == 5) {
            return 3;
        }
        if (intValue != 7) {
            return intValue != 1000 ? -1 : 0;
        }
        return 5;
    }

    private JSONSocialNetworkID getSocialId(int i) {
        return this.socialNetworkUserIds.get(i);
    }

    public void handleCannotGetDataFromSocialId(Integer num) {
        ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num))).setState(SocialMatchesData.SocialMatchState.UNKNOWN);
        initNetUi(num, true);
    }

    private void handleHadSocialId(final Integer num, final RemoteAccountHelper remoteAccountHelper, final JSONSocialNetworkID jSONSocialNetworkID) {
        new Task() {
            @Override
            public final void doTask() {
                String str;
                String str2;
                PersonData personData;
                PersonData findPrivateUsers;
                GooglePlacesData googlePlacesData;
                Integer num2 = num;
                ChooseSocialProfileActivity chooseSocialProfileActivity = ChooseSocialProfileActivity.this;
                try {
                    if (num2.intValue() != 5 || (googlePlacesData = chooseSocialProfileActivity.contact.getGooglePlacesData()) == null) {
                        str = null;
                        str2 = null;
                    } else {
                        str2 = googlePlacesData.getFullName();
                        str = googlePlacesData.getPhotoUrl();
                    }
                    boolean x = StringUtils.x(str2);
                    JSONSocialNetworkID jSONSocialNetworkID2 = jSONSocialNetworkID;
                    JSONSocialNetworkID jSONSocialNetworkID3 = x ? null : jSONSocialNetworkID2;
                    RemoteAccountHelper remoteAccountHelper2 = remoteAccountHelper;
                    if (!x && jSONSocialNetworkID2 != null) {
                        String id = jSONSocialNetworkID2.getId();
                        if (remoteAccountHelper2 instanceof FacebookHelper) {
                            JSONFBUserOrPage S = FacebookHelper.get().S(id, true);
                            if (S != null) {
                                str2 = S.getName();
                                chooseSocialProfileActivity.fqlType = S.getFqlType();
                            }
                        } else {
                            str2 = remoteAccountHelper2.r(id);
                        }
                        if ((StringUtils.t(str2) || StringUtils.v(str2)) && remoteAccountHelper2.isLoggedIn() && (findPrivateUsers = ChooseSocialProfileActivity.findPrivateUsers(id, chooseSocialProfileActivity.contactName, num2.intValue())) != null) {
                            str2 = findPrivateUsers.getName();
                            str = findPrivateUsers.getImageUrl();
                        }
                        if (StringUtils.t(str)) {
                            str = remoteAccountHelper2.n(id);
                        }
                        if (StringUtils.t(str)) {
                            str = remoteAccountHelper2.q(id);
                        }
                    }
                    if (StringUtils.t(str) && StringUtils.t(str2) && (personData = (PersonData) chooseSocialProfileActivity.socialNetworkPersons.get(num2.intValue())) != null) {
                        str2 = personData.getName();
                        str = personData.getImageUrl();
                    }
                    if (StringUtils.t(str2) && (StringUtils.t(str) || remoteAccountHelper2.u(str))) {
                        chooseSocialProfileActivity.handleCannotGetDataFromSocialId(num2);
                        return;
                    }
                    chooseSocialProfileActivity.updateSureButtons(jSONSocialNetworkID3, num2);
                    chooseSocialProfileActivity.updateName(num2, str2);
                    chooseSocialProfileActivity.updatePhoto(num2, str, remoteAccountHelper2, true);
                    chooseSocialProfileActivity.notifyForUpdatesAndUpdateCandidate();
                } catch (QuotaReachedException | UserNotFoundException unused) {
                    chooseSocialProfileActivity.handleCannotGetDataFromSocialId(num2);
                }
            }
        }.execute();
    }

    private void handleNotHaveId(Integer num) {
        RemoteAccountHelper remoteAccountHelper = RemoteAccountHelper.getRemoteAccountHelper(num.intValue());
        if (remoteAccountHelper instanceof InstagramHelper) {
            ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num))).setState(SocialMatchesData.SocialMatchState.HIDE);
        } else if (!remoteAccountHelper.isLoggedIn()) {
            ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num))).setState(SocialMatchesData.SocialMatchState.NOT_CONNECTED);
        } else if (remoteAccountHelper.e()) {
            ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num))).setState(SocialMatchesData.SocialMatchState.UNKNOWN);
        } else {
            ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num))).setState(SocialMatchesData.SocialMatchState.HIDE);
        }
        updatePhoto(num, null, remoteAccountHelper, false);
        updateName(num, null);
        notifyForUpdatesAndUpdateCandidate();
    }

    public void handleOpenInstagramPrivateProfile(String str, Runnable runnable) {
        PersonData personData = this.socialNetworkPersons.get(7);
        if (personData == null && str != null) {
            personData = findPrivateUsers(str, this.contactName, 7);
        }
        if (personData == null || personData.getId() == null || !personData.getId().equals(str)) {
            return;
        }
        InstagramHelper.get().J(this, personData.getUserName(), runnable, true);
    }

    private void initDevicePhotoData() {
        if (this.contact.getUserMediaData() != null) {
            ((DevicePhotoData) this.socialMatchesData.get(1)).setPhotoUrl(this.contact.getUserMediaData().getPhotoUrl());
        }
    }

    public void initNetUi(Integer num) {
        initNetUi(num, false);
    }

    private void initSocialIds(ContactData contactData) {
        this.socialNetworkUserIds.put(1, ContactDataUtils.getSocialNetworkID(contactData, 1));
        this.socialNetworkUserIds.put(4, ContactDataUtils.getSocialNetworkID(contactData, 4));
        this.socialNetworkUserIds.put(7, ContactDataUtils.getSocialNetworkID(contactData, 7));
        initDevicePhotoData();
    }

    private List<BaseViewTypeData> loadBasicData() {
        this.socialMatchesData = new ArrayList();
        SplitCompatApplication splitCompatApplication = CallAppApplication.get();
        this.socialMatchesData.add(0, new SocialMatchesData(1000, R.drawable.ic_callapp_icon_notification, ThemeUtils.e(splitCompatApplication, R.color.colorPrimary), this.defaultPhotoResId));
        this.socialMatchesData.add(1, getEmptyDevicePhotoData());
        this.socialMatchesData.add(2, new SocialMatchesData(1, R.drawable.ic_facebook_white, ThemeUtils.e(splitCompatApplication, R.color.facebook_background_color), this.defaultPhotoResId));
        this.socialMatchesData.add(3, new SocialMatchesData(5, R.drawable.ic_google_white, ThemeUtils.e(splitCompatApplication, R.color.google_background_color), this.defaultPhotoResId));
        this.socialMatchesData.add(4, new SocialMatchesData(4, ThemeUtils.isThemeLight() ? R.drawable.ic_twitter_white : R.drawable.ic_twitter_black, ThemeUtils.e(splitCompatApplication, R.color.twitter_background_color), this.defaultPhotoResId));
        this.socialMatchesData.add(5, new SocialMatchesData(7, R.drawable.ic_instagram_white, ThemeUtils.e(splitCompatApplication, R.color.instagram_background_color), this.defaultPhotoResId));
        ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(1000))).setState(SocialMatchesData.SocialMatchState.AUTO_SELECT);
        return this.socialMatchesData;
    }

    public void markProfileAsSure(Integer num, RemoteAccountHelper remoteAccountHelper, JSONSocialNetworkID jSONSocialNetworkID) {
        AnalyticsManager.get().p(Constants.CONTACT_SOCIAL, "Marked profile as sure at 6-pack", Constants.CLICK);
        jSONSocialNetworkID.setSure(true);
        this.dataSourceFieldsChangedHandler.setFieldChanged(RemoteAccountHelper.getRemoteAccountHelper(num.intValue()).getDataSource());
        ((SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num))).setState(SocialMatchesData.SocialMatchState.SURE);
        setProfileAndPhotoToContact(num.intValue(), jSONSocialNetworkID.getId());
    }

    public void notifyForUpdatesAndUpdateCandidate() {
        updateCandidate();
        CallAppApplication.get().runOnMainThread(new Runnable() {
            @Override
            public final void run() {
                ChooseSocialProfileActivity.this.chooseImageAdapter.notifyDataSetChanged();
            }
        });
    }

    public void onDefaultPictureChecked() {
        new Task() {
            @Override
            public final void doTask() {
                ChooseSocialProfileActivity chooseSocialProfileActivity = ChooseSocialProfileActivity.this;
                ChosenContactPhotoManager.a(chooseSocialProfileActivity.contact.getDeviceId(), chooseSocialProfileActivity.contact.getPhone());
                CallAppApplication.get().runOnMainThread(new Runnable() {
                    @Override
                    public final void run() {
                        AnonymousClass5 anonymousClass5 = AnonymousClass5.this;
                        if (ChooseSocialProfileActivity.this.chooseImageAdapter != null) {
                            ChooseSocialProfileActivity.this.chooseImageAdapter.setCheckedImagePosition(0);
                        }
                    }
                });
                chooseSocialProfileActivity.onPictureChanged(chooseSocialProfileActivity.contact.getPhotoUrl());
                AnalyticsManager.get().q(Constants.SOCIAL_PROFILE, "User changed the default image of another contact", "0", 0.0d, new String[0]);
            }
        }.execute();
        this.photoUrlFieldChangedHandler.setFieldChanged(ContactField.photoUrl);
    }

    public void onPictureChanged(String str) {
        this.contact.resetChosenPicture();
        this.contact.updatePhoto();
        updateShortcutIconIfNeeded(this.contact, str);
    }

    private void onPictureChecked(final DataSource dataSource, final String str) {
        new Task() {
            @Override
            public final void doTask() {
                DataSource dataSource2 = dataSource;
                if (dataSource2 == null) {
                    StringUtils.I(ChooseSocialProfileActivity.class);
                    CLog.a();
                    return;
                }
                ChooseSocialProfileActivity chooseSocialProfileActivity = ChooseSocialProfileActivity.this;
                long deviceId = chooseSocialProfileActivity.contact.getDeviceId();
                Phone phone = chooseSocialProfileActivity.contact.getPhone();
                String str2 = str;
                ChosenContactPhotoManager.c(deviceId, phone, dataSource2, str2);
                AnalyticsManager.get().q(Constants.SOCIAL_PROFILE, "User changed the default image of another contact", "" + dataSource2.dbCode, 0.0d, new String[0]);
                chooseSocialProfileActivity.onPictureChanged(str2);
            }
        }.execute();
        this.photoUrlFieldChangedHandler.setFieldChanged(ContactField.photoUrl);
        FeedbackManager.get().d(null, Activities.getString(R.string.auto_select_toast));
    }

    private void onSelectedLocalImage(String str) {
        UserMediaManager.b(this.contact.getDeviceId(), this.contact.getPhone(), str, false);
        this.contact.setUserMediaData(new UserMediaData(str));
        initDevicePhotoData();
        onRadioClicked(1);
    }

    public static void openContactProfile(Activity activity, ContactData contactData) {
        if (contactData == null || contactData.isUnknownNumber()) {
            StringUtils.I(ChooseSocialProfileActivity.class);
            CLog.a();
            return;
        }
        Intent intent = new Intent((Context) CallAppApplication.get(), (Class<?>) ChooseSocialProfileActivity.class);
        intent.setFlags(67108864);
        intent.putExtra("CONTACT_ID_EXTRA", contactData.getDeviceId());
        intent.putExtra("CONTACT_NAME_EXTRA", contactData.getNameOrNumber());
        intent.putExtra("CONTACT_PHONE_EXTRA", contactData.getPhone().c());
        activity.startActivityForResult(intent, REQUEST_CODE_CONTACT_SOCIAL);
    }

    private void openLoginDialog(Integer num) {
        OpenLoginDialogBackgroundFragment openLoginDialogBackgroundFragment = (OpenLoginDialogBackgroundFragment) getSupportFragmentManager().G(OPEN_LOGIN_DIALOG_BACKGROUND_FRAGMENT);
        if (openLoginDialogBackgroundFragment != null) {
            openLoginDialogBackgroundFragment.w(num.intValue());
        }
    }

    private Task openSocialProfileInNewTask(Integer num, RemoteAccountHelper remoteAccountHelper, JSONSocialNetworkID jSONSocialNetworkID) {
        return new AnonymousClass6(jSONSocialNetworkID, remoteAccountHelper, num).execute();
    }

    private void setProfileAndPhotoToContact(int i, String str) {
        RemoteAccountHelper remoteAccountHelper = RemoteAccountHelper.getRemoteAccountHelper(i);
        if (remoteAccountHelper != null) {
            remoteAccountHelper.E(this.contact, str, true);
            notifyForUpdatesAndUpdateCandidate();
        }
    }

    public static void show(Activity activity, ContactData contactData) {
        if (contactData == null) {
            StringUtils.I(ChooseSocialProfileActivity.class);
            CLog.a();
            return;
        }
        Intent intent = new Intent(activity, (Class<?>) ChooseSocialProfileActivity.class);
        intent.setFlags(67108864);
        intent.putExtra("CONTACT_ID_EXTRA", contactData.getDeviceId());
        intent.putExtra("CONTACT_NAME_EXTRA", contactData.getNameOrNumber());
        intent.putExtra("CONTACT_PHONE_EXTRA", contactData.getPhone().c());
        activity.startActivityForResult(intent, REQUEST_CODE_CONTACT_SOCIAL);
    }

    private void showChooseImageDialog() {
        if (StringUtils.x(this.phoneNum)) {
            AnalyticsManager.get().o(Constants.USER_CORRECTED_INFO, "Click on add image");
            ChooseImageSourceDialog chooseImageSourceDialog = new ChooseImageSourceDialog(ChooseImageSourceDialog.ImageSourceType.IMAGE);
            chooseImageSourceDialog.setListener(new ChooseImageSourceDialogListener(this, getFileUri(), Constants.USER_CORRECTED_INFO));
            PopupManager.get().c(this, chooseImageSourceDialog, true);
        }
    }

    private void updateCandidate() {
        Task task = this.candidateImageTask;
        if (task != null && task.isRunning()) {
            this.candidateImageTask.cancel();
        }
        this.candidateImageTask = new Task() {
            @Override
            public final void doTask() {
                ChooseSocialProfileActivity chooseSocialProfileActivity = ChooseSocialProfileActivity.this;
                if (chooseSocialProfileActivity.contact != null) {
                    Pair<String, DataSource> candidateContactPhoto = chooseSocialProfileActivity.contact.getCandidateContactPhoto();
                    BaseViewTypeData baseViewTypeData = (BaseViewTypeData) chooseSocialProfileActivity.socialMatchesData.get(chooseSocialProfileActivity.getIndexInSocialsList(1000));
                    if (baseViewTypeData instanceof SocialMatchesData) {
                        if (candidateContactPhoto != null) {
                            SocialMatchesData socialMatchesData = (SocialMatchesData) baseViewTypeData;
                            socialMatchesData.setPhotoUrl((String) candidateContactPhoto.first);
                            socialMatchesData.setDataSource((DataSource) candidateContactPhoto.second);
                            socialMatchesData.setPhotoResId(0);
                        }
                        if (candidateContactPhoto == null || StringUtils.t((CharSequence) candidateContactPhoto.first)) {
                            SocialMatchesData socialMatchesData2 = (SocialMatchesData) baseViewTypeData;
                            socialMatchesData2.setPhotoUrl(null);
                            socialMatchesData2.setDataSource(null);
                            socialMatchesData2.setPhotoResId(chooseSocialProfileActivity.defaultUnknownPhotoResId);
                        }
                    }
                }
            }
        }.execute();
    }

    public void updateName(Integer num, String str) {
        SocialMatchesData socialMatchesData = (SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num));
        if (str == null) {
            socialMatchesData.setName("");
        } else {
            socialMatchesData.setName(StringUtils.b(str));
        }
    }

    public void updatePhoto(Integer num, String str, RemoteAccountHelper remoteAccountHelper, boolean z) {
        int i;
        List<PersonData> list;
        boolean u = remoteAccountHelper.u(str);
        SocialSearchResults a = SocialNetworksSearchUtil.a(remoteAccountHelper.getApiConstantNetworkId(), this.contact);
        SocialMatchesData socialMatchesData = (SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num));
        if (z) {
            i = this.defaultPhotoResId;
        } else if (a == null || (list = a.results) == null || list.size() <= 1) {
            i = this.defaultUnknownPhotoResId;
        } else {
            i = this.hasSearchResultsResId;
            socialMatchesData.setState(SocialMatchesData.SocialMatchState.MULTI_MATCH);
        }
        if (u || StringUtils.t(str)) {
            socialMatchesData.setPhotoUrl(null);
            socialMatchesData.setPhotoResId(i);
        } else {
            socialMatchesData.setPhotoUrl(str);
            socialMatchesData.setDataSource(remoteAccountHelper.getDataSource());
        }
    }

    private void updateShortcutIconIfNeeded(ContactData contactData, String str) {
        if (CallAppShortcutManager.g(this, contactData.getPhone().c())) {
            CallAppShortcutManager.h(contactData.getPhone().c(), this, contactData.getFirstName(), contactData.getFullName(), CallAppShortcutManager.d(this, contactData), str);
        }
    }

    public void updateSureButtons(JSONSocialNetworkID jSONSocialNetworkID, Integer num) {
        SocialMatchesData socialMatchesData = (SocialMatchesData) this.socialMatchesData.get(getIndexInSocialsList(num));
        if (jSONSocialNetworkID == null) {
            socialMatchesData.setState(SocialMatchesData.SocialMatchState.PLACES_SURE);
            this.socialNetworkUserIds.remove(num.intValue());
        } else if (jSONSocialNetworkID.isSure()) {
            socialMatchesData.setState(SocialMatchesData.SocialMatchState.SURE);
        } else {
            socialMatchesData.setState(SocialMatchesData.SocialMatchState.UNSURE);
        }
    }

    @Override
    public int getLayoutResourceId() {
        return R.layout.activity_choose_social_profile;
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        Uri activityResult;
        Uri data;
        super.onActivityResult(i, i2, intent);
        SocialNetworksSearchUtil.b(i, i2, intent);
        if (i != 996) {
            if (i == 15000) {
                if (i2 == -1) {
                    CallAppCropActivity.openCropScreen((Activity) this, CallAppCropActivity.REQUEST_CODE_IMAGE_CROP, new CallAppCropActivity.ImageCropBuilder().setImagePathUri(getFileUri()).setSavePathUri(getFileUri()).setShouldDelete(true).setPhoneNumber(this.phoneNum).setContactId(this.contactId));
                    return;
                }
                return;
            } else {
                if (i == 20000) {
                    if (i2 != 1000 || (activityResult = CallAppCropActivity.getActivityResult(intent)) == null) {
                        return;
                    }
                    onSelectedLocalImage(activityResult.toString());
                    return;
                }
                if (i == 25000 && i2 == -1 && intent != null && (data = intent.getData()) != null) {
                    CallAppCropActivity.openCropScreen((Activity) this, CallAppCropActivity.REQUEST_CODE_IMAGE_CROP, new CallAppCropActivity.ImageCropBuilder().setImagePathUri(data).setSavePathUri(getFileUri()).setIsFromGallery(true).setShouldDelete(true).setPhoneNumber(this.phoneNum).setContactId(this.contactId));
                    return;
                }
                return;
            }
        }
        if (intent == null) {
            notifyForUpdatesAndUpdateCandidate();
            return;
        }
        int intExtra = intent.getIntExtra(PersonSelectActivity.INTENT_EXTRA_NET_ID, -1);
        if (i2 != -1) {
            if (i2 != 0 || intExtra == -1) {
                return;
            }
            doesntChosePerson(intExtra);
            return;
        }
        this.dataSourceFieldsChangedHandler.setFieldChanged(RemoteAccountHelper.getRemoteAccountHelper(intExtra).getDataSource());
        String stringExtra = intent.getStringExtra(PersonSelectActivity.RESULT_INTENT_EXTRA_USER_ID);
        if (intExtra == -1 || StringUtils.t(stringExtra)) {
            return;
        }
        if ("DONTHAVE".equals(stringExtra)) {
            this.socialNetworkUserIds.remove(intExtra);
            RemoteAccountHelper.getRemoteAccountHelper(intExtra).D(this.contactId, this.phoneNum);
        } else {
            JSONSocialNetworkID jSONSocialNetworkID = new JSONSocialNetworkID(stringExtra, true);
            this.socialNetworkUserIds.put(intExtra, jSONSocialNetworkID);
            this.socialNetworkPersons.put(intExtra, (PersonData) intent.getParcelableExtra(PersonSelectActivity.INTENT_EXTRA_PERSON_DATA));
            setProfileAndPhotoToContact(intExtra, stringExtra);
            this.contact.assertDeviceDataExist();
            ContactDataUtils.updateSocialNetwork(this.contact, intExtra, jSONSocialNetworkID);
        }
        initNetUi(Integer.valueOf(intExtra));
    }

    public void onBackPressed() {
        Intent intent = new Intent();
        this.dataSourceFieldsChangedHandler.a(intent);
        this.photoUrlFieldChangedHandler.a(intent);
        setResult(-1, intent);
        ContactLoaderManager.get().unRegisterForContactDetailsStack(this.contact, this);
        super/*androidx.activity.ComponentActivity*/.onBackPressed();
    }

    public void onCancel() {
    }

    @Override
    public void onContactChanged(ContactData contactData, Set<ContactField> set) {
        if (CollectionUtils.b(set, ContactField.googlePlaces)) {
            initNetUi(5);
        }
        if (CollectionUtils.b(set, ContactField.newContact)) {
            this.fqlType = "";
        }
        Iterator<E> it = DataSource.SOCIAL_NETWORKS_DATA_SOURCE.iterator();
        while (it.hasNext()) {
            DataSource dataSource = (DataSource) it.next();
            if (getIndexInSocialsList(Integer.valueOf(dataSource.dbCode)) != -1) {
                if (CollectionUtils.b(set, dataSource.socialIdField)) {
                    JSONSocialNetworkID jSONSocialNetworkID = this.socialNetworkUserIds.get(dataSource.dbCode);
                    JSONSocialNetworkID socialNetworkID = ContactDataUtils.getSocialNetworkID(contactData, dataSource.dbCode);
                    if (socialNetworkID != null && !socialNetworkID.equals(jSONSocialNetworkID)) {
                        this.socialNetworkUserIds.put(dataSource.dbCode, socialNetworkID);
                        initNetUi(Integer.valueOf(dataSource.dbCode));
                    }
                }
                if (CollectionUtils.b(set, dataSource.socialSearchField) && ContactDataUtils.getSocialNetworkID(contactData, dataSource.dbCode) == null) {
                    initNetUi(Integer.valueOf(dataSource.dbCode));
                }
            }
        }
        notifyForUpdatesAndUpdateCandidate();
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (bundle != null) {
            String string = bundle.getString("photo_uri_param");
            if (StringUtils.x(string)) {
                this.imageUri = Uri.parse(string);
            }
            this.contactId = bundle.getLong("contact_id_param");
            this.phoneNum = bundle.getString("phone_num_param");
        }
        Toolbar findViewById = findViewById(R.id.toolbar);
        findViewById.setBackgroundColor(ThemeUtils.getColor(R.color.background));
        findViewById.setTitleTextColor(ThemeUtils.getColor(R.color.title));
        setSupportActionBar(findViewById);
        getSupportActionBar().u(ViewUtils.i(R.drawable.ic_top_bar_back, Integer.valueOf(ThemeUtils.getColor(R.color.icon))));
        getSupportActionBar().r(true);
        getSupportActionBar().w("");
        this.defaultPhotoResId = R.drawable.profile_pic_default;
        this.defaultUnknownPhotoResId = R.drawable.profile_pic_default;
        this.hasSearchResultsResId = R.drawable.profile_pic_multiple;
        RecyclerView findViewById2 = findViewById(R.id.recyclerView);
        findViewById2.setLayoutManager(new LinearLayoutManager(this));
        int checkedImagePosition = getCheckedImagePosition(getIntent());
        List<BaseViewTypeData> loadBasicData = loadBasicData();
        this.socialMatchesData = loadBasicData;
        ChooseImageAdapter chooseImageAdapter = new ChooseImageAdapter(loadBasicData, checkedImagePosition, R.drawable.profile_pic_default, this);
        this.chooseImageAdapter = chooseImageAdapter;
        findViewById2.setAdapter(chooseImageAdapter);
        if (bundle == null) {
            OpenLoginDialogBackgroundFragment openLoginDialogBackgroundFragment = new OpenLoginDialogBackgroundFragment();
            FragmentManager supportFragmentManager = getSupportFragmentManager();
            a f = d0.f(supportFragmentManager, supportFragmentManager);
            f.g(0, openLoginDialogBackgroundFragment, OPEN_LOGIN_DIALOG_BACKGROUND_FRAGMENT, 1);
            f.d();
            getSupportFragmentManager().D();
        }
        onNewIntent(getIntent());
        Prefs.m2.set(Long.MAX_VALUE);
    }

    @Override
    public void onDestroy() {
        if (this.contact != null) {
            ContactLoaderManager.get().unRegisterForContactDetailsStack(this.contact, this);
        }
        super.onDestroy();
    }

    public void onError() {
    }

    public void onNewIntent(Intent intent) {
        super/*androidx.activity.ComponentActivity*/.onNewIntent(intent);
        if (intent == null) {
            finish();
            return;
        }
        if (!intent.getBooleanExtra(ContactDetailsActivity.EXTRA_BRING_TO_FRONT_RETRY, false) || this.contactId == -1) {
            long longExtra = intent.getLongExtra("CONTACT_ID_EXTRA", -1L);
            this.contactId = longExtra;
            if (longExtra == -1) {
                finish();
                return;
            }
            this.contactName = intent.getStringExtra("CONTACT_NAME_EXTRA");
            this.phoneNum = intent.getStringExtra("CONTACT_PHONE_EXTRA");
            if (this.contact != null) {
                ContactLoaderManager.get().unRegisterForContactDetailsStack(this.contact, this);
            }
            Pair<ContactData, Set<ContactField>> registerForContactDetailsStack = ContactLoaderManager.get().registerForContactDetailsStack(PhoneManager.get().e(this.phoneNum), this.contactId, this, ContactFieldEnumSets.ALL);
            this.contact = (ContactData) registerForContactDetailsStack.first;
            if (((Set) registerForContactDetailsStack.second).size() > 0) {
                onContactChanged(this.contact, (Set) registerForContactDetailsStack.second);
            }
            this.chooseImageAdapter.setContact(this.contact);
            initSocialIds(this.contact);
            for (int i = 0; i < this.socialMatchesData.size(); i++) {
                if (this.socialMatchesData.get(i) instanceof SocialMatchesData) {
                    initNetUi(Integer.valueOf(((SocialMatchesData) this.socialMatchesData.get(i)).getSocialNetId()));
                }
            }
        }
    }

    @Override
    public void onRadioClicked(int i) {
        if (i != -1) {
            this.chooseImageAdapter.setCheckedImagePosition(i);
            BaseViewTypeData baseViewTypeData = this.socialMatchesData.get(i);
            if (baseViewTypeData.getViewType() == 13) {
                SocialMatchesData socialMatchesData = (SocialMatchesData) baseViewTypeData;
                if (socialMatchesData.getSocialNetId() == 1000) {
                    onDefaultPictureChecked();
                    return;
                } else {
                    onPictureChecked(DataSource.getDataSource(socialMatchesData.getSocialNetId()), socialMatchesData.getPhotoUrl());
                    return;
                }
            }
            if (baseViewTypeData.getViewType() == 14) {
                if (this.contact.getUserMediaData() == null || !StringUtils.x(this.contact.getUserMediaData().getPhotoUrl())) {
                    showChooseImageDialog();
                } else {
                    onPictureChecked(DataSource.userMedia, ((DevicePhotoData) baseViewTypeData).getPhotoUrl());
                }
            }
        }
    }

    public void onRestoreInstanceState(@NonNull Bundle bundle) {
        String string = bundle.getString("photo_uri_param");
        if (StringUtils.x(string)) {
            this.imageUri = Uri.parse(string);
        }
        this.contactId = bundle.getLong("contact_id_param");
        this.phoneNum = bundle.getString("phone_num_param");
        super/*android.app.Activity*/.onRestoreInstanceState(bundle);
    }

    @Override
    public void onRowClicked(int i) {
        if (i == -1 || i == 0) {
            return;
        }
        BaseViewTypeData baseViewTypeData = this.socialMatchesData.get(i);
        if (baseViewTypeData.getViewType() != 13) {
            if (baseViewTypeData.getViewType() == 14) {
                showChooseImageDialog();
                return;
            }
            return;
        }
        SocialMatchesData socialMatchesData = (SocialMatchesData) baseViewTypeData;
        AnalyticsManager.get().p(Constants.CONTACT_SOCIAL, "Social match sure unsure activity", Constants.CLICK);
        if (5 == socialMatchesData.getSocialNetId() && this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()) == null && GooglePlacesLoader.e(this, this.contact.getGooglePlacesData())) {
            return;
        }
        RemoteAccountHelper remoteAccountHelper = RemoteAccountHelper.getRemoteAccountHelper(socialMatchesData.getSocialNetId());
        if (remoteAccountHelper.isLoggedIn()) {
            if (this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()) != null && StringUtils.x(this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()).getId())) {
                openSocialProfileInNewTask(Integer.valueOf(socialMatchesData.getSocialNetId()), remoteAccountHelper, this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()));
                return;
            } else {
                if (this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()) == null || StringUtils.t(this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()).getId())) {
                    PersonSelectActivity.startPersonSelectActivity(this, this.contact, Integer.valueOf(socialMatchesData.getSocialNetId()), this.contactName, this.fqlType, PersonSelectActivity.SELECT_PERSON_REQUEST);
                    return;
                }
                return;
            }
        }
        IntegerSetPref integerSetPref = Prefs.E1;
        Set<Integer> set = integerSetPref.get();
        if (set == null) {
            set = new HashSet<>();
        }
        if (!set.contains(Integer.valueOf(remoteAccountHelper.getApiConstantNetworkId()))) {
            openLoginDialog(Integer.valueOf(socialMatchesData.getSocialNetId()));
            set.add(Integer.valueOf(remoteAccountHelper.getApiConstantNetworkId()));
            integerSetPref.set(set);
        } else if (this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()) == null || !StringUtils.x(this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()).getId())) {
            openLoginDialog(Integer.valueOf(socialMatchesData.getSocialNetId()));
        } else {
            openSocialProfileInNewTask(Integer.valueOf(socialMatchesData.getSocialNetId()), remoteAccountHelper, this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()));
        }
    }

    @Override
    public void onSaveInstanceState(@NonNull Bundle bundle) {
        Uri uri = this.imageUri;
        if (uri != null) {
            bundle.putString("photo_uri_param", uri.getPath());
        }
        bundle.putLong("contact_id_param", this.contactId);
        bundle.getString("phone_num_param", this.phoneNum);
        super.onSaveInstanceState(bundle);
    }

    @Override
    public void onSureClick(int i) {
        AnalyticsManager.get().p(Constants.CONTACT_SOCIAL, "Marked profile as sure at 6-pack", Constants.CLICK);
        SocialMatchesData socialMatchesData = (SocialMatchesData) this.socialMatchesData.get(i);
        markProfileAsSure(Integer.valueOf(socialMatchesData.getSocialNetId()), RemoteAccountHelper.getRemoteAccountHelper(socialMatchesData.getSocialNetId()), this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()));
    }

    @Override
    public void onUnsureClick(int i) {
        if (i != 1) {
            final SocialMatchesData socialMatchesData = (SocialMatchesData) this.socialMatchesData.get(i);
            AnalyticsManager.get().p(Constants.CONTACT_SOCIAL, "Marked profile as not him at 6-pack", Constants.CLICK);
            SocialDataUtils.onUserDismissingSocial(this, Integer.valueOf(socialMatchesData.getSocialNetId()), this.contact, this.socialNetworkUserIds.get(socialMatchesData.getSocialNetId()), new DialogPopup.IDialogOnClickListener() {
                @Override
                public final void onClickListener(Activity activity) {
                    SocialMatchesData socialMatchesData2 = socialMatchesData;
                    boolean G = RemoteAccountHelper.getRemoteAccountHelper(socialMatchesData2.getSocialNetId()).G();
                    ?? r1 = ChooseSocialProfileActivity.this;
                    if (G) {
                        PersonSelectActivity.startPersonSelectActivity(r1, ((ChooseSocialProfileActivity) r1).contact, Integer.valueOf(socialMatchesData2.getSocialNetId()), ((ChooseSocialProfileActivity) r1).contactName, ((ChooseSocialProfileActivity) r1).fqlType, PersonSelectActivity.SELECT_PERSON_REQUEST);
                    }
                    socialMatchesData2.setState(SocialMatchesData.SocialMatchState.UNSURE);
                    if (((ChooseSocialProfileActivity) r1).chooseImageAdapter != null && ((ChooseSocialProfileActivity) r1).chooseImageAdapter.getCheckedImagePosition() == r1.getIndexInSocialsList(Integer.valueOf(socialMatchesData2.getSocialNetId()))) {
                        r1.onDefaultPictureChecked();
                    }
                    ((ChooseSocialProfileActivity) r1).dataSourceFieldsChangedHandler.setFieldChanged(RemoteAccountHelper.getRemoteAccountHelper(socialMatchesData2.getSocialNetId()).getDataSource());
                    ((ChooseSocialProfileActivity) r1).photoUrlFieldChangedHandler.setFieldChanged(ContactField.photoUrl);
                    r1.doesntChosePerson(socialMatchesData2.getSocialNetId());
                }
            });
            return;
        }
        DevicePhotoData devicePhotoData = (DevicePhotoData) this.socialMatchesData.get(i);
        String photoUrl = devicePhotoData.getPhotoUrl();
        File file = new File(Uri.parse(photoUrl).getPath());
        try {
            if (file.exists()) {
                file.delete();
            } else {
                getContentResolver().delete(Uri.parse(photoUrl), null, null);
            }
        } catch (Exception unused) {
        }
        this.contact.setUserMediaData(null);
        QueryBuilder i2 = CallAppApplication.get().getObjectBoxStore().u(UserMediaData.class).i();
        i2.k(UserMediaData_.photoUrl, photoUrl, QueryBuilder.b.CASE_INSENSITIVE);
        i2.b().E0();
        devicePhotoData.setPhotoUrl(null);
        notifyForUpdatesAndUpdateCandidate();
        this.photoUrlFieldChangedHandler.setFieldChanged(ContactField.photoUrl);
        onDefaultPictureChecked();
    }

    public String getSocialId(RemoteAccountHelper remoteAccountHelper, String str) {
        if (!(remoteAccountHelper instanceof FacebookHelper)) {
            return str;
        }
        StringBuilder z = d0.z(str, "#@@#");
        z.append(this.fqlType);
        return z.toString();
    }

    private void initNetUi(Integer num, boolean z) {
        if (num.intValue() != 1000) {
            RemoteAccountHelper remoteAccountHelper = RemoteAccountHelper.getRemoteAccountHelper(num.intValue());
            JSONSocialNetworkID socialId = getSocialId(num.intValue());
            boolean z2 = num.intValue() == 5 && this.contact.getGooglePlacesData() != null;
            if (((socialId == null || StringUtils.t(socialId.getId())) && !z2) || z) {
                handleNotHaveId(num);
            } else {
                handleHadSocialId(num, remoteAccountHelper, socialId);
            }
        }
        notifyForUpdatesAndUpdateCandidate();
    }

    @Override
    public void onComplete(Integer num) {
        this.dataSourceFieldsChangedHandler.setFieldChanged(RemoteAccountHelper.getRemoteAccountHelper(num.intValue()).getDataSource());
        if (this.socialNetworkUserIds.get(num.intValue()) != null) {
            initNetUi(num);
        } else if (RemoteAccountHelper.getRemoteAccountHelper(num.intValue()).G()) {
            PersonSelectActivity.startPersonSelectActivity(this, this.contact, num, this.contactName, this.fqlType, PersonSelectActivity.SELECT_PERSON_REQUEST);
        } else {
            initNetUi(num);
        }
    }
}