导航菜单

页面标题

页面副标题

CallApp v2.226 - PhotoUpdater.java 源代码

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

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


package com.callapp.contacts.model.contact;

import android.util.Pair;
import com.callapp.contacts.api.helper.common.RemoteAccountHelper;
import com.callapp.framework.util.StringUtils;

public class PhotoUpdater {
    private DataSource currentDataSource;
    private Integer currentPhotoBGColor;
    private PhotoUrls currentUrls;
    private final DataSource dataSourceToStop;

    public PhotoUpdater(DataSource dataSource) {
        this.dataSourceToStop = dataSource;
    }

    public Integer getCurrentPhotoBGColor() {
        return this.currentPhotoBGColor;
    }

    public PhotoUrls getCurrentUrls() {
        return this.currentUrls;
    }

    public DataSource getDataSource() {
        return this.currentDataSource;
    }

    public boolean update(PhotoUpdaterBuilder photoUpdaterBuilder) {
        RemoteAccountHelper l;
        DataSource dataSource;
        String photoUrl = photoUpdaterBuilder.getPhotoUrl();
        String thumbnailUrl = photoUpdaterBuilder.getThumbnailUrl();
        DataSource dataSource2 = photoUpdaterBuilder.getDataSource();
        if (StringUtils.t(photoUrl) && StringUtils.t(thumbnailUrl) && ((dataSource = this.dataSourceToStop) == null || dataSource != dataSource2)) {
            return false;
        }
        boolean isOnlyThumbnail = photoUpdaterBuilder.isOnlyThumbnail();
        DataSource dataSource3 = photoUpdaterBuilder.dataSourceToEnrich != null ? photoUpdaterBuilder.dataSourceToEnrich : dataSource2;
        PhotoUrls photoUrls = new PhotoUrls(photoUrl, thumbnailUrl, dataSource3);
        if (dataSource3 != null && (l = RemoteAccountHelper.l(dataSource3)) != null && l.u(photoUrls.getPhotoUrl())) {
            return false;
        }
        this.currentUrls = photoUrls;
        this.currentDataSource = dataSource2;
        this.currentPhotoBGColor = photoUpdaterBuilder.getPhotoBGColor();
        if (StringUtils.x(photoUrls.getPhotoUrl())) {
            return true;
        }
        if (isOnlyThumbnail && StringUtils.x(photoUrls.getThumbnail())) {
            return true;
        }
        DataSource dataSource4 = this.dataSourceToStop;
        return dataSource4 != null && dataSource4 == dataSource2;
    }

    public static class PhotoUpdaterBuilder {
        private DataSource dataSource;
        private DataSource dataSourceToEnrich;
        private boolean onlyThumbnail;
        private Integer photoBGColor;
        private String photoUrl;
        private String thumbnailUrl;

        public PhotoUpdaterBuilder(String str, String str2) {
            this.photoUrl = str;
            this.thumbnailUrl = str2;
        }

        public Pair<String, String> enrichUrl(String str) {
            Pair<String, String> pair = new Pair<>(str, str);
            if (!StringUtils.d(str, "https://graph.facebook.com/")) {
                return pair;
            }
            this.dataSourceToEnrich = DataSource.facebook;
            return StringUtils.d(str, "/picture?type=normal") ? new Pair<>(StringUtils.B(str, "/picture?type=normal", "/picture?width=600"), str) : StringUtils.d(str, "/picture?width=") ? new Pair<>(str, StringUtils.B(str, "/picture?width=600", "/picture?type=normal")) : pair;
        }

        public DataSource getDataSource() {
            return this.dataSource;
        }

        public Integer getPhotoBGColor() {
            return this.photoBGColor;
        }

        public String getPhotoUrl() {
            return this.photoUrl;
        }

        public String getThumbnailUrl() {
            return this.thumbnailUrl;
        }

        public boolean isOnlyThumbnail() {
            return this.onlyThumbnail;
        }

        public PhotoUpdaterBuilder onlyThumbnail(boolean z) {
            this.onlyThumbnail = z;
            return this;
        }

        public PhotoUpdaterBuilder withDataSource(DataSource dataSource) {
            this.dataSource = dataSource;
            return this;
        }

        public PhotoUpdaterBuilder withPhotoBGColor(Integer num) {
            this.photoBGColor = num;
            return this;
        }

        public PhotoUpdaterBuilder(String str, DataSource dataSource) {
            this.dataSource = dataSource;
            Pair<String, String> enrichUrl = enrichUrl(str);
            this.photoUrl = (String) enrichUrl.first;
            this.thumbnailUrl = (String) enrichUrl.second;
        }
    }
}