package com.facebook; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; import com.facebook.internal.ImageRequest; import com.facebook.internal.Utility; import com.facebook.internal.Validate; import com.ubt.jimu.base.entities.Constant; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes.dex */ public final class Profile implements Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { // from class: com.facebook.Profile.2 @Override // android.os.Parcelable.Creator public Profile createFromParcel(Parcel parcel) { return new Profile(parcel); } @Override // android.os.Parcelable.Creator public Profile[] newArray(int i) { return new Profile[i]; } }; private static final String FIRST_NAME_KEY = "first_name"; private static final String ID_KEY = "id"; private static final String LAST_NAME_KEY = "last_name"; private static final String LINK_URI_KEY = "link_uri"; private static final String MIDDLE_NAME_KEY = "middle_name"; private static final String NAME_KEY = "name"; private final String firstName; private final String id; private final String lastName; private final Uri linkUri; private final String middleName; private final String name; public static void fetchProfileForCurrentAccessToken() { AccessToken currentAccessToken = AccessToken.getCurrentAccessToken(); if (currentAccessToken == null) { setCurrentProfile(null); } else { Utility.a(currentAccessToken.getToken(), new Utility.GraphMeRequestWithCacheCallback() { // from class: com.facebook.Profile.1 @Override // com.facebook.internal.Utility.GraphMeRequestWithCacheCallback public void a(FacebookException facebookException) { } @Override // com.facebook.internal.Utility.GraphMeRequestWithCacheCallback public void a(JSONObject jSONObject) { String optString = jSONObject.optString("id"); if (optString == null) { return; } String optString2 = jSONObject.optString(Constant.Community.SOURCE_LINK_TYPE); Profile.setCurrentProfile(new Profile(optString, jSONObject.optString(Profile.FIRST_NAME_KEY), jSONObject.optString(Profile.MIDDLE_NAME_KEY), jSONObject.optString(Profile.LAST_NAME_KEY), jSONObject.optString("name"), optString2 != null ? Uri.parse(optString2) : null)); } }); } } public static Profile getCurrentProfile() { return ProfileManager.c().a(); } public static void setCurrentProfile(Profile profile) { ProfileManager.c().a(profile); } @Override // android.os.Parcelable public int describeContents() { return 0; } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Profile)) { return false; } Profile profile = (Profile) obj; if (this.id.equals(profile.id) && this.firstName == null) { if (profile.firstName == null) { return true; } } else if (this.firstName.equals(profile.firstName) && this.middleName == null) { if (profile.middleName == null) { return true; } } else if (this.middleName.equals(profile.middleName) && this.lastName == null) { if (profile.lastName == null) { return true; } } else if (this.lastName.equals(profile.lastName) && this.name == null) { if (profile.name == null) { return true; } } else { if (!this.name.equals(profile.name) || this.linkUri != null) { return this.linkUri.equals(profile.linkUri); } if (profile.linkUri == null) { return true; } } return false; } public String getFirstName() { return this.firstName; } public String getId() { return this.id; } public String getLastName() { return this.lastName; } public Uri getLinkUri() { return this.linkUri; } public String getMiddleName() { return this.middleName; } public String getName() { return this.name; } public Uri getProfilePictureUri(int i, int i2) { return ImageRequest.a(this.id, i, i2); } public int hashCode() { int hashCode = 527 + this.id.hashCode(); String str = this.firstName; if (str != null) { hashCode = (hashCode * 31) + str.hashCode(); } String str2 = this.middleName; if (str2 != null) { hashCode = (hashCode * 31) + str2.hashCode(); } String str3 = this.lastName; if (str3 != null) { hashCode = (hashCode * 31) + str3.hashCode(); } String str4 = this.name; if (str4 != null) { hashCode = (hashCode * 31) + str4.hashCode(); } Uri uri = this.linkUri; return uri != null ? (hashCode * 31) + uri.hashCode() : hashCode; } JSONObject toJSONObject() { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("id", this.id); jSONObject.put(FIRST_NAME_KEY, this.firstName); jSONObject.put(MIDDLE_NAME_KEY, this.middleName); jSONObject.put(LAST_NAME_KEY, this.lastName); jSONObject.put("name", this.name); if (this.linkUri == null) { return jSONObject; } jSONObject.put(LINK_URI_KEY, this.linkUri.toString()); return jSONObject; } catch (JSONException unused) { return null; } } @Override // android.os.Parcelable public void writeToParcel(Parcel parcel, int i) { parcel.writeString(this.id); parcel.writeString(this.firstName); parcel.writeString(this.middleName); parcel.writeString(this.lastName); parcel.writeString(this.name); Uri uri = this.linkUri; parcel.writeString(uri == null ? null : uri.toString()); } public Profile(String str, String str2, String str3, String str4, String str5, Uri uri) { Validate.a(str, "id"); this.id = str; this.firstName = str2; this.middleName = str3; this.lastName = str4; this.name = str5; this.linkUri = uri; } Profile(JSONObject jSONObject) { this.id = jSONObject.optString("id", null); this.firstName = jSONObject.optString(FIRST_NAME_KEY, null); this.middleName = jSONObject.optString(MIDDLE_NAME_KEY, null); this.lastName = jSONObject.optString(LAST_NAME_KEY, null); this.name = jSONObject.optString("name", null); String optString = jSONObject.optString(LINK_URI_KEY, null); this.linkUri = optString != null ? Uri.parse(optString) : null; } private Profile(Parcel parcel) { this.id = parcel.readString(); this.firstName = parcel.readString(); this.middleName = parcel.readString(); this.lastName = parcel.readString(); this.name = parcel.readString(); String readString = parcel.readString(); this.linkUri = readString == null ? null : Uri.parse(readString); } }