海恒集团 v1.0.0版本的 MD5 值为:f821a526990aefe38331f69a75f49814
以下内容为反编译后的 QrCodeParseUtil.java 源代码,内容仅作参考
package im.kyamoybdkf.ui.utils;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import im.kyamoybdkf.messenger.AndroidUtilities;
import im.kyamoybdkf.messenger.ChatObject;
import im.kyamoybdkf.messenger.FileLog;
import im.kyamoybdkf.messenger.LocaleController;
import im.kyamoybdkf.messenger.MessagesController;
import im.kyamoybdkf.messenger.MessagesStorage;
import im.kyamoybdkf.messenger.NotificationCenter;
import im.kyamoybdkf.messenger.R;
import im.kyamoybdkf.messenger.SharedConfig;
import im.kyamoybdkf.messenger.UserConfig;
import im.kyamoybdkf.messenger.UserObject;
import im.kyamoybdkf.messenger.Utilities;
import im.kyamoybdkf.messenger.browser.Browser;
import im.kyamoybdkf.tgnet.ConnectionsManager;
import im.kyamoybdkf.tgnet.RequestDelegate;
import im.kyamoybdkf.tgnet.TLObject;
import im.kyamoybdkf.tgnet.TLRPC;
import im.kyamoybdkf.ui.ChatActivity;
import im.kyamoybdkf.ui.DialogsActivity;
import im.kyamoybdkf.ui.LaunchActivity;
import im.kyamoybdkf.ui.WebviewActivity;
import im.kyamoybdkf.ui.actionbar.ActionBarLayout;
import im.kyamoybdkf.ui.actionbar.AlertDialog;
import im.kyamoybdkf.ui.actionbar.BaseFragment;
import im.kyamoybdkf.ui.components.AlertsCreator;
import im.kyamoybdkf.ui.components.JoinGroupAlert;
import im.kyamoybdkf.ui.components.toast.ToastUtils;
import im.kyamoybdkf.ui.fragments.BaseFmts;
import im.kyamoybdkf.ui.hui.chats.NewProfileActivity;
import im.kyamoybdkf.ui.hui.contacts.AddContactsInfoActivity;
import java.util.ArrayList;
public class QrCodeParseUtil {
public static void tryParseQrCode(Object hostObj, int currentAccount, String url, boolean removeLast, boolean forceWithoutAnimation, boolean openBowser, boolean allowCustom) {
tryParseQrCode(hostObj, currentAccount, url, true, removeLast, forceWithoutAnimation, true, false, openBowser, allowCustom);
}
public static void tryParseQrCode(Object obj, int i, String str, boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7) {
String str2;
boolean z8;
String str3;
String str4;
String str5;
String str6;
String str7;
checkHost(obj);
if (TextUtils.isEmpty(str)) {
return;
}
Uri parse = Uri.parse(str);
String lowerCase = parse.getScheme() != null ? parse.getScheme().toLowerCase() : "";
String str8 = getMessagesController(i).sharePrefix;
Uri parse2 = !TextUtils.isEmpty(str8) ? Uri.parse(str8) : null;
String host = parse2 != null ? parse2.getHost() : null;
if ("http".equals(lowerCase) || "https".equals(lowerCase)) {
String host2 = parse.getHost();
if (host2.equals("www.shareinstall.com.cn")) {
String queryParameter = parse.getQueryParameter("Key");
if (TextUtils.isEmpty(queryParameter)) {
str2 = host2;
} else {
String str9 = new String(Base64.decode(queryParameter.replace("%3D", "="), 0));
String[] split = str9.split("#");
String str10 = split[0].split("=")[1];
String str11 = split[1].split("=")[1];
if (str9.contains("Uname")) {
tryToGroupOrChannelByUserName(obj, split[2].split("=")[1]);
str2 = host2;
} else {
str2 = host2;
tryToUser(obj, i, true, str10, str11, z2, z3);
}
}
} else {
str2 = host2;
if (str2.equals("m12345.com") || str2.equals(host)) {
if (TextUtils.isEmpty(str8)) {
z8 = false;
str3 = str8;
} else {
String str12 = str8 + "&Key=";
if (!str.startsWith(str12)) {
str3 = str12;
z8 = false;
} else {
String str13 = new String(Base64.decode(str.substring(str12.length()).replace("%3D", "="), 0));
String[] split2 = str13.split("#");
String str14 = split2[0].split("=")[1];
String str15 = split2[1].split("=")[1];
if (str13.contains("Uname")) {
tryToGroupOrChannelByUserName(obj, split2[2].split("=")[1]);
str3 = str12;
z8 = false;
} else {
str3 = str12;
z8 = false;
tryToUser(obj, i, true, str14, str15, z2, z3);
}
str4 = str2;
str5 = str;
if (z6) {
if (SharedConfig.customTabs) {
presentFragment(obj, new WebviewActivity(str5, (String) null), z8, z3);
} else {
Browser.openUrl(getContext(str4), str5, z7);
}
}
}
}
String path = parse.getPath();
if (path == null || path.length() <= 1) {
str4 = str2;
str5 = str;
} else {
String str16 = null;
String str17 = null;
String str18 = null;
String str19 = null;
String substring = path.substring(1);
if (substring.startsWith("login/")) {
str7 = substring.replace("login/", "");
} else if (substring.startsWith("joinchat/")) {
str17 = substring.replace("joinchat/", "");
str7 = null;
} else {
if (substring.startsWith("g/")) {
str6 = substring;
} else if (substring.startsWith("u/")) {
str6 = substring;
} else {
if (substring.startsWith("authtoken/")) {
return;
}
if (substring.startsWith("socks")) {
Browser.openUrl(getContext(obj), str, z7);
return;
}
ArrayList arrayList = new ArrayList(parse.getPathSegments());
if (arrayList.size() > 0 && ((String) arrayList.get(z8 ? 1 : 0)).equals("s")) {
arrayList.remove(z8 ? 1 : 0);
}
if (arrayList.size() > 0) {
str16 = (String) arrayList.get(z8 ? 1 : 0);
}
str18 = parse.getQueryParameter(TtmlNode.START);
str19 = parse.getQueryParameter("startgroup");
str7 = null;
}
String str20 = new String(Base64.decode(str.substring(str.lastIndexOf("/") + 1), z8 ? 1 : 0));
if (str6.startsWith("g/")) {
tryToGroupOrChannelByUserName(obj, str20.substring(str20.lastIndexOf("/") + 1));
return;
} else {
String[] split3 = str20.substring(z8 ? 1 : 0, str20.length() - 4).split("&", 2);
tryToUser(obj, i, true, split3[z8 ? 1 : 0], split3[1], z2, z3);
return;
}
}
if (str7 == null && str16 == null && str17 == null && str18 == null && str19 == null) {
str4 = str2;
str5 = str;
} else {
runLinkRequest(obj, i, true, str7, str16, str17, str18, str19, z2, z3, z4, z5, 0);
return;
}
}
if (z6) {
}
}
}
str3 = str8;
str4 = str2;
str5 = str;
z8 = false;
if (z6) {
}
}
}
public static void runLinkRequest(final Object hostObj, final int currentAccount, final boolean showProgressDialog, final String code, final String username, final String group, final String botUser, final String botChat, final boolean removeLast, final boolean forceWithoutAnimation, final boolean check, final boolean preview, int state) {
AlertDialog progressDialog;
AlertDialog progressDialog2;
final int i;
if (code != null) {
if (NotificationCenter.getGlobalInstance().hasObservers(NotificationCenter.didReceiveSmsCode)) {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, code);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(hostObj));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("OtherLoginCode", R.string.OtherLoginCode, code)));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(hostObj, builder.create());
return;
}
if (!showProgressDialog) {
progressDialog = null;
} else {
AlertDialog progressDialog3 = new AlertDialog(getContext(hostObj), 3);
progressDialog = progressDialog3;
}
int requestId = 0;
final AlertDialog finalProgressDialog = progressDialog;
if (username != null) {
TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
req.username = username;
progressDialog2 = progressDialog;
requestId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
QrCodeParseUtil.lambda$null$1(AlertDialog.this, tLObject, tL_error, r4, r5, r6, r7, r8, r9, r10, r11);
}
});
}
});
i = currentAccount;
} else {
progressDialog2 = progressDialog;
if (group == null) {
i = currentAccount;
} else if (state == 0) {
TLRPC.TL_messages_checkChatInvite req2 = new TLRPC.TL_messages_checkChatInvite();
req2.hash = group;
requestId = ConnectionsManager.getInstance(currentAccount).sendRequest(req2, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
QrCodeParseUtil.lambda$null$4(AlertDialog.this, tL_error, r3, tLObject, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15);
}
});
}
}, 2);
i = currentAccount;
} else if (state == 1) {
TLRPC.TL_messages_importChatInvite req3 = new TLRPC.TL_messages_importChatInvite();
req3.hash = group;
i = currentAccount;
ConnectionsManager.getInstance(currentAccount).sendRequest(req3, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
QrCodeParseUtil.lambda$runLinkRequest$7(i, finalProgressDialog, hostObj, tLObject, tL_error);
}
}, 2);
} else {
i = currentAccount;
}
}
if (requestId != 0 && showProgressDialog) {
final int finalRequestId = requestId;
AlertDialog progressDialog4 = progressDialog2;
progressDialog4.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
ConnectionsManager.getInstance(i).cancelRequest(finalRequestId, true);
}
});
try {
progressDialog4.show();
} catch (Exception e) {
}
}
}
public static void lambda$null$1(AlertDialog finalProgressDialog, TLObject response, TLRPC.TL_error error, final Object hostObj, final int currentAccount, final String botChat, final boolean removeLast, final boolean forceWithoutAnimation, final boolean check, final boolean preview, String botUser) {
long dialog_id;
if (finalProgressDialog != null) {
try {
finalProgressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
}
TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
if (error == null && getActionLayout(hostObj) != null) {
MessagesController.getInstance(currentAccount).putUsers(res.users, false);
MessagesController.getInstance(currentAccount).putChats(res.chats, false);
MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, false, true);
if (botChat != null) {
final TLRPC.User user = !res.users.isEmpty() ? res.users.get(0) : null;
if (user == null || (user.bot && user.bot_nochats)) {
try {
ToastUtils.show(R.string.BotCantJoinGroups);
return;
} catch (Exception e2) {
FileLog.e(e2);
return;
}
}
Bundle args = new Bundle();
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", 2);
args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getName(user), "%1$s"));
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
@Override
public final void didSelectDialogs(DialogsActivity dialogsActivity, ArrayList arrayList, CharSequence charSequence, boolean z) {
QrCodeParseUtil.lambda$null$0(currentAccount, hostObj, user, botChat, removeLast, forceWithoutAnimation, check, preview, dialogsActivity, arrayList, charSequence, z);
}
});
presentFragment(hostObj, fragment, removeLast, forceWithoutAnimation, check, preview);
return;
}
boolean isBot = false;
Bundle args2 = new Bundle();
if (!res.chats.isEmpty()) {
args2.putInt("chat_id", res.chats.get(0).id);
dialog_id = -res.chats.get(0).id;
} else {
args2.putInt("user_id", res.users.get(0).id);
dialog_id = res.users.get(0).id;
}
if (botUser != null && res.users.size() > 0 && res.users.get(0).bot) {
args2.putString("botUser", botUser);
isBot = true;
}
BaseFragment lastFragment = getLastFragment(hostObj);
if (lastFragment == null || MessagesController.getInstance(currentAccount).checkCanOpenChat(args2, lastFragment)) {
if (isBot && (lastFragment instanceof ChatActivity) && ((ChatActivity) lastFragment).getDialogId() == dialog_id) {
((ChatActivity) lastFragment).setBotUser(botUser);
return;
} else {
presentFragment(hostObj, new ChatActivity(args2), removeLast, forceWithoutAnimation);
return;
}
}
return;
}
try {
AlertsCreator.createSimpleAlert(getContext(hostObj), LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist)).show();
} catch (Exception e3) {
FileLog.e(e3);
}
}
public static void lambda$null$0(int currentAccount, Object hostObj, TLRPC.User user, String botChat, boolean removeLast, boolean forceWithoutAnimation, boolean check, boolean preview, DialogsActivity fragment12, ArrayList dids, CharSequence message1, boolean param) {
long did = ((Long) dids.get(0)).longValue();
Bundle args12 = new Bundle();
args12.putBoolean("scrollToTopOnResume", true);
args12.putInt("chat_id", -((int) did));
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args12, getLastFragment(hostObj))) {
MessagesController.getInstance(currentAccount).addUserToChat(-((int) did), user, null, 0, botChat, null, null);
presentFragment(hostObj, new ChatActivity(args12), removeLast, forceWithoutAnimation, check, preview);
}
}
public static void lambda$null$4(AlertDialog finalProgressDialog, TLRPC.TL_error error, final Object hostObj, TLObject response, final int currentAccount, final String group, final boolean showProgressDialog, final String code, final String username, final String botUser, final String botChat, final boolean removeLast, final boolean forceWithoutAnimation, final boolean check, final boolean preview) {
if (finalProgressDialog != null) {
try {
finalProgressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
}
if (error == null && getActionLayout(hostObj) != null) {
TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response;
if (invite.chat != null && (!ChatObject.isLeftFromChat(invite.chat) || (!invite.chat.kicked && !TextUtils.isEmpty(invite.chat.username)))) {
MessagesController.getInstance(currentAccount).putChat(invite.chat, false);
ArrayList<TLRPC.Chat> chats = new ArrayList<>();
chats.add(invite.chat);
MessagesStorage.getInstance(currentAccount).putUsersAndChats(null, chats, false, true);
Bundle args = new Bundle();
args.putInt("chat_id", invite.chat.id);
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, getLastFragment(hostObj))) {
presentFragment(hostObj, new ChatActivity(args), false, true, true, false);
}
} else {
if (invite.chat != null || (invite.channel && !invite.megagroup)) {
if (invite.chat != null) {
if (ChatObject.isChannel(invite.chat) && !invite.chat.megagroup) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(hostObj));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
Object[] objArr = new Object[1];
objArr[0] = invite.chat != null ? invite.chat.title : invite.title;
builder.setMessage(LocaleController.formatString("ChannelJoinTo", R.string.ChannelJoinTo, objArr));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
QrCodeParseUtil.runLinkRequest(hostObj, currentAccount, showProgressDialog, code, username, group, botUser, botChat, removeLast, forceWithoutAnimation, check, preview, 1);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(hostObj, builder.create());
}
}
AlertDialog.Builder builder2 = new AlertDialog.Builder(getContext(hostObj));
builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
Object[] objArr2 = new Object[1];
objArr2[0] = invite.chat != null ? invite.chat.title : invite.title;
builder2.setMessage(LocaleController.formatString("ChannelJoinTo", R.string.ChannelJoinTo, objArr2));
builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
QrCodeParseUtil.runLinkRequest(hostObj, currentAccount, showProgressDialog, code, username, group, botUser, botChat, removeLast, forceWithoutAnimation, check, preview, 1);
}
});
builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(hostObj, builder2.create());
}
if (!getActionLayout(hostObj).fragmentsStack.isEmpty()) {
BaseFragment fragment = getLastFragment(hostObj);
fragment.showDialog(new JoinGroupAlert(getContext(hostObj), invite, group, fragment));
}
AlertDialog.Builder builder22 = new AlertDialog.Builder(getContext(hostObj));
builder22.setTitle(LocaleController.getString("AppName", R.string.AppName));
Object[] objArr22 = new Object[1];
objArr22[0] = invite.chat != null ? invite.chat.title : invite.title;
builder22.setMessage(LocaleController.formatString("ChannelJoinTo", R.string.ChannelJoinTo, objArr22));
builder22.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
QrCodeParseUtil.runLinkRequest(hostObj, currentAccount, showProgressDialog, code, username, group, botUser, botChat, removeLast, forceWithoutAnimation, check, preview, 1);
}
});
builder22.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(hostObj, builder22.create());
}
return;
}
AlertDialog.Builder builder3 = new AlertDialog.Builder(getContext(hostObj));
builder3.setTitle(LocaleController.getString("AppName", R.string.AppName));
if (error.text.startsWith("FLOOD_WAIT")) {
builder3.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
} else {
builder3.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
}
builder3.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(hostObj, builder3.create());
}
public static void lambda$runLinkRequest$7(final int currentAccount, final AlertDialog finalProgressDialog, final Object hostObj, final TLObject response, final TLRPC.TL_error error) {
if (error == null) {
TLRPC.Updates updates = (TLRPC.Updates) response;
MessagesController.getInstance(currentAccount).processUpdates(updates, false);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
QrCodeParseUtil.lambda$null$6(AlertDialog.this, error, hostObj, response, currentAccount);
}
});
}
public static void lambda$null$6(AlertDialog finalProgressDialog, TLRPC.TL_error error, Object hostObj, TLObject response, int currentAccount) {
if (finalProgressDialog != null) {
try {
finalProgressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
}
if (error == null) {
if (getActionLayout(hostObj) != null) {
TLRPC.Updates updates = (TLRPC.Updates) response;
if (!updates.chats.isEmpty()) {
TLRPC.Chat chat = updates.chats.get(0);
chat.left = false;
chat.kicked = false;
MessagesController.getInstance(currentAccount).putUsers(updates.users, false);
MessagesController.getInstance(currentAccount).putChats(updates.chats, false);
Bundle args = new Bundle();
args.putInt("chat_id", chat.id);
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, getLastFragment(hostObj))) {
ChatActivity fragment = new ChatActivity(args);
presentFragment(hostObj, fragment, false, true, true, false);
return;
}
return;
}
return;
}
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(hostObj));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
if (error.text.startsWith("FLOOD_WAIT")) {
builder.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
} else if (error.text.equals("USERS_TOO_MUCH")) {
builder.setMessage(LocaleController.getString("JoinToGroupErrorFull", R.string.JoinToGroupErrorFull));
} else {
builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(hostObj, builder.create());
}
private static void tryToGroupOrChannelByUserName(Object hostObj, String userName) {
MessagesController.getInstance(UserConfig.selectedAccount).openByUserName(userName, getLastFragment(hostObj), 1, true);
}
private static void tryToUser(final Object hostObj, final int currentAccount, boolean showProgressDialog, String userId, String userHash, final boolean removeLast, final boolean forceWithoutAnimation) {
if (TextUtils.isEmpty(userId) || TextUtils.isEmpty(userHash)) {
return;
}
TLRPC.User user = new TLRPC.TL_user();
user.id = Utilities.parseInt(userId).intValue();
user.access_hash = Utilities.parseLong(userHash).longValue();
TLRPC.UserFull userFull = getMessagesController(currentAccount).getUserFull(user.id);
if (userFull != null) {
toUser(hostObj, currentAccount, true, userFull, removeLast, forceWithoutAnimation);
return;
}
TLRPC.TL_users_getFullUser req = new TLRPC.TL_users_getFullUser();
req.id = getMessagesController(currentAccount).getInputUser(user);
AlertDialog progressDialog = null;
if (showProgressDialog) {
progressDialog = new AlertDialog(getContext(hostObj), 3);
showDialog(hostObj, progressDialog);
}
final int reqId = getConnectionsManager(currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
QrCodeParseUtil.lambda$null$9(TLRPC.TL_error.this, r2, r3, tLObject, r5, r6);
}
});
}
});
if (progressDialog != null) {
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
QrCodeParseUtil.getConnectionsManager(currentAccount).cancelRequest(reqId, false);
}
});
}
}
public static void lambda$null$9(TLRPC.TL_error error, Object hostObj, int currentAccount, TLObject response, boolean removeLast, boolean forceWithoutAnimation) {
if (error == null) {
toUser(hostObj, currentAccount, false, (TLRPC.UserFull) response, removeLast, forceWithoutAnimation);
} else {
ToastUtils.show(R.string.NoUsernameFound);
}
}
private static void toUser(Object hostObj, int currentAccount, boolean fromCache, TLRPC.UserFull userFull, boolean removeLast, boolean forceWithoutAnimation) {
getMessagesController(currentAccount).putUser(userFull.user, false);
if (userFull.user.self || userFull.user.contact) {
Bundle bundle = new Bundle();
bundle.putInt("user_id", userFull.user.id);
presentFragment(hostObj, new NewProfileActivity(bundle), removeLast, forceWithoutAnimation);
} else {
Bundle bundle2 = new Bundle();
bundle2.putInt("from_type", 1);
presentFragment(hostObj, new AddContactsInfoActivity(bundle2, userFull.user), removeLast, forceWithoutAnimation);
}
}
private static void presentFragment(Object hostObj, BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation) {
presentFragment(hostObj, fragment, removeLast, forceWithoutAnimation, true, false);
}
private static void presentFragment(Object hostObj, BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, boolean check, boolean preview) {
ActionBarLayout actionBarLayout;
if (fragment != null && (actionBarLayout = getActionLayout(hostObj)) != null) {
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, check, preview);
}
}
private static MessagesController getMessagesController(int currentAccount) {
return MessagesController.getInstance(currentAccount);
}
private static MessagesStorage getMessagesStorage(int currentAccount) {
return MessagesStorage.getInstance(currentAccount);
}
private static ConnectionsManager getConnectionsManager(int currentAccount) {
return ConnectionsManager.getInstance(currentAccount);
}
private static Dialog showDialog(Object host, Dialog dialog) {
if (dialog == null) {
return null;
}
if (host instanceof BaseFragment) {
return ((BaseFragment) host).showDialog(dialog);
}
if (host instanceof BaseFmts) {
return ((BaseFmts) host).showDialog(dialog);
}
if ((host instanceof LaunchActivity) && (dialog instanceof AlertDialog)) {
return ((LaunchActivity) host).showAlertDialog((AlertDialog) dialog);
}
dialog.show();
return dialog;
}
private static void checkHost(Object host) {
if (!(host instanceof BaseFragment) && !(host instanceof BaseFmts) && !(host instanceof Activity) && !(host instanceof Fragment) && !(host instanceof View) && !(host instanceof Context)) {
throw new IllegalArgumentException("host must be one of the BaseFragment, BaseFmts, Activity, Fragment, View");
}
}
private static BaseFragment getLastFragment(Object host) {
ActionBarLayout actionBarLayout = getActionLayout(host);
if (actionBarLayout != null) {
return actionBarLayout.getLastFragment();
}
return null;
}
private static ActionBarLayout getActionLayout(Object host) {
if (host instanceof BaseFragment) {
return ((BaseFragment) host).getParentLayout();
}
if (host instanceof BaseFmts) {
return ((BaseFmts) host).getActionBarLayout();
}
if (host instanceof LaunchActivity) {
return ((LaunchActivity) host).getActionBarLayout();
}
if (host instanceof ActionBarLayout) {
return (ActionBarLayout) host;
}
return null;
}
private static Context getContext(Object host) {
if (host instanceof BaseFragment) {
return ((BaseFragment) host).getParentActivity();
}
if (host instanceof BaseFmts) {
return ((BaseFmts) host).getParentActivity();
}
if (host instanceof Activity) {
return (Activity) host;
}
if (host instanceof Fragment) {
return ((Fragment) host).getActivity();
}
if (host instanceof View) {
return ((View) host).getContext();
}
if (host instanceof Context) {
return (Context) host;
}
return null;
}
}