Java Code Examples for org.telegram.messenger.AndroidUtilities#shakeView()

The following examples show how to use org.telegram.messenger.AndroidUtilities#shakeView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onPasscodeError(boolean clear)
{
    if (getParentActivity() == null)
    {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null)
    {
        v.vibrate(200);
    }
    if (clear)
    {
        codeField.setText("");
    }
    AndroidUtilities.shakeView(confirmTextView, 2, 0);
}
 
Example 2
Source File: PasscodeActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onPasscodeError()
{
    if (getParentActivity() == null)
    {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null)
    {
        v.vibrate(200);
    }
    AndroidUtilities.shakeView(titleTextView, 2, 0);
}
 
Example 3
Source File: PaymentFormActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void shakeView(View view) {
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    AndroidUtilities.shakeView(view, 2, 0);
}
 
Example 4
Source File: PasscodeView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void showFingerprintError(CharSequence error) {
    fingerprintImageView.setImageResource(R.drawable.ic_fingerprint_error);
    fingerprintStatusTextView.setText(error);
    fingerprintStatusTextView.setTextColor(0xfff4511e);
    Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    AndroidUtilities.shakeView(fingerprintStatusTextView, 2, 0);
}
 
Example 5
Source File: PasscodeView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void showFingerprintError(CharSequence error) {
    fingerprintImageView.setImageResource(R.drawable.ic_fingerprint_error);
    fingerprintStatusTextView.setText(error);
    fingerprintStatusTextView.setTextColor(0xfff4511e);
    Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    AndroidUtilities.shakeView(fingerprintStatusTextView, 2, 0);
}
 
Example 6
Source File: TwoStepVerificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void onFieldError(TextView field, boolean clear) {
    if (getParentActivity() == null) {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    if (clear) {
        field.setText("");
    }
    AndroidUtilities.shakeView(field, 2, 0);
}
 
Example 7
Source File: TwoStepVerificationSetupActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void onFieldError(TextView field, boolean clear) {
    if (getParentActivity() == null) {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    if (clear) {
        field.setText("");
    }
    AndroidUtilities.shakeView(field, 2, 0);
}
 
Example 8
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void shakeField(int field) {
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    AndroidUtilities.shakeView(inputFields[field], 2, 0);
}
 
Example 9
Source File: PasscodeActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onPasscodeError()
{
    if (getParentActivity() == null)
    {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null)
    {
        v.vibrate(200);
    }
    AndroidUtilities.shakeView(titleTextView, 2, 0);
}
 
Example 10
Source File: TwoStepVerificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onPasscodeError(boolean clear) {
    if (getParentActivity() == null) {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    if (clear) {
        passwordEditText.setText("");
    }
    AndroidUtilities.shakeView(titleTextView, 2, 0);
}
 
Example 11
Source File: TwoStepVerificationSetupActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void onFieldError(TextView field, boolean clear) {
    if (getParentActivity() == null) {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    if (clear) {
        field.setText("");
    }
    AndroidUtilities.shakeView(field, 2, 0);
}
 
Example 12
Source File: TwoStepVerificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onPasscodeError(boolean clear) {
    if (getParentActivity() == null) {
        return;
    }
    Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
    if (v != null) {
        v.vibrate(200);
    }
    if (clear) {
        passwordEditText.setText("");
    }
    AndroidUtilities.shakeView(titleTextView, 2, 0);
}
 
Example 13
Source File: CancelAccountDeletionActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onNextPressed() {
    if (nextPressed) {
        return;
    }
    String code = getCode();
    if (TextUtils.isEmpty(code)) {
        AndroidUtilities.shakeView(codeFieldContainer, 2, 0);
        return;
    }
    nextPressed = true;
    if (currentType == 2) {
        AndroidUtilities.setWaitingForSms(false);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
    } else if (currentType == 3) {
        AndroidUtilities.setWaitingForCall(false);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall);
    }
    waitingForEvent = false;
    final TLRPC.TL_account_confirmPhone req = new TLRPC.TL_account_confirmPhone();
    req.phone_code = code;
    req.phone_code_hash = phoneHash;
    destroyTimer();
    needShowProgress();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        needHideProgress();
        nextPressed = false;
        if (error == null) {
            errorDialog = AlertsCreator.showSimpleAlert(CancelAccountDeletionActivity.this, LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone)));
        } else {
            lastError = error.text;
            if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) {
                createTimer();
            }
            if (currentType == 2) {
                AndroidUtilities.setWaitingForSms(true);
                NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
            } else if (currentType == 3) {
                AndroidUtilities.setWaitingForCall(true);
                NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
            }
            waitingForEvent = true;
            if (currentType != 3) {
                AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req);
            }
            if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
                for (int a = 0; a < codeField.length; a++) {
                    codeField[a].setText("");
                }
                codeField[0].requestFocus();
            } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
                onBackPressed(true);
                setPage(0, true, null, true);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 14
Source File: ChatRightsEditActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void onDonePressed() {
    if (!ChatObject.isChannel(currentChat) && (currentType == TYPE_BANNED || currentType == TYPE_ADMIN && (!isDefaultAdminRights() || rankRow != -1 && currentRank.codePointCount(0, currentRank.length()) > MAX_RANK_LENGTH))) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param != 0) {
                chatId = param;
                currentChat = MessagesController.getInstance(currentAccount).getChat(param);
                onDonePressed();
            }
        });
        return;
    }
    if (currentType == TYPE_ADMIN) {
        if (rankRow != -1 && currentRank.codePointCount(0, currentRank.length()) > MAX_RANK_LENGTH) {
            listView.smoothScrollToPosition(rankRow);
            Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
            if (v != null) {
                v.vibrate(200);
            }
            RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(rankHeaderRow);
            if (holder != null) {
                AndroidUtilities.shakeView(holder.itemView, 2, 0);
            }
            return;
        }
        if (isChannel) {
            adminRights.pin_messages = adminRights.ban_users = false;
        } else {
            adminRights.post_messages = adminRights.edit_messages = false;
        }
        MessagesController.getInstance(currentAccount).setUserAdminRole(chatId, currentUser, adminRights, currentRank, isChannel, getFragmentForAlert(1), isAddingNew);
        if (delegate != null) {
            delegate.didSetRights(
                    adminRights.change_info || adminRights.post_messages || adminRights.edit_messages ||
                    adminRights.delete_messages || adminRights.ban_users || adminRights.invite_users ||
                    adminRights.pin_messages || adminRights.add_admins ? 1 : 0, adminRights, bannedRights, currentRank);
        }
    } else if (currentType == TYPE_BANNED) {
        MessagesController.getInstance(currentAccount).setUserBannedRole(chatId, currentUser, bannedRights, isChannel, getFragmentForAlert(1));
        int rights;
        if (bannedRights.send_messages || bannedRights.send_stickers || bannedRights.embed_links || bannedRights.send_media ||
                bannedRights.send_gifs || bannedRights.send_games || bannedRights.send_inline) {
            rights = 1;
        } else {
            bannedRights.until_date = 0;
            rights = 2;
        }
        if (delegate != null) {
            delegate.didSetRights(rights, adminRights, bannedRights, currentRank);
        }
    }
    finishFragment();
}
 
Example 15
Source File: ChatRightsEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void onDonePressed() {
    if (!ChatObject.isChannel(currentChat) && (currentType == TYPE_BANNED || currentType == TYPE_ADMIN && (!isDefaultAdminRights() || rankRow != -1 && currentRank.codePointCount(0, currentRank.length()) > MAX_RANK_LENGTH))) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param != 0) {
                chatId = param;
                currentChat = MessagesController.getInstance(currentAccount).getChat(param);
                onDonePressed();
            }
        });
        return;
    }
    if (currentType == TYPE_ADMIN) {
        if (rankRow != -1 && currentRank.codePointCount(0, currentRank.length()) > MAX_RANK_LENGTH) {
            listView.smoothScrollToPosition(rankRow);
            Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
            if (v != null) {
                v.vibrate(200);
            }
            RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(rankHeaderRow);
            if (holder != null) {
                AndroidUtilities.shakeView(holder.itemView, 2, 0);
            }
            return;
        }
        if (isChannel) {
            adminRights.pin_messages = adminRights.ban_users = false;
        } else {
            adminRights.post_messages = adminRights.edit_messages = false;
        }
        MessagesController.getInstance(currentAccount).setUserAdminRole(chatId, currentUser, adminRights, currentRank, isChannel, getFragmentForAlert(1), isAddingNew);
        if (delegate != null) {
            delegate.didSetRights(
                    adminRights.change_info || adminRights.post_messages || adminRights.edit_messages ||
                    adminRights.delete_messages || adminRights.ban_users || adminRights.invite_users ||
                    adminRights.pin_messages || adminRights.add_admins ? 1 : 0, adminRights, bannedRights, currentRank);
        }
    } else if (currentType == TYPE_BANNED) {
        MessagesController.getInstance(currentAccount).setUserBannedRole(chatId, currentUser, bannedRights, isChannel, getFragmentForAlert(1));
        int rights;
        if (bannedRights.send_messages || bannedRights.send_stickers || bannedRights.embed_links || bannedRights.send_media ||
                bannedRights.send_gifs || bannedRights.send_games || bannedRights.send_inline) {
            rights = 1;
        } else {
            bannedRights.until_date = 0;
            rights = 2;
        }
        if (delegate != null) {
            delegate.didSetRights(rights, adminRights, bannedRights, currentRank);
        }
    }
    finishFragment();
}
 
Example 16
Source File: ChatEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void processDone() {
    if (donePressed || nameTextView == null) {
        return;
    }
    if (nameTextView.length() == 0) {
        Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
        if (v != null) {
            v.vibrate(200);
        }
        AndroidUtilities.shakeView(nameTextView, 2, 0);
        return;
    }
    donePressed = true;
    if (!ChatObject.isChannel(currentChat) && !historyHidden) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param == 0) {
                donePressed = false;
                return;
            }
            chatId = param;
            currentChat = MessagesController.getInstance(currentAccount).getChat(param);
            donePressed = false;
            if (info != null) {
                info.hidden_prehistory = true;
            }
            processDone();
        });
        return;
    }

    if (info != null) {
        if (ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden) {
            info.hidden_prehistory = historyHidden;
            MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chatId, historyHidden);
        }
    }

    if (imageUpdater.uploadingImage != null) {
        createAfterUpload = true;
        progressDialog = new AlertDialog(getParentActivity(), 3);
        progressDialog.setOnCancelListener(dialog -> {
            createAfterUpload = false;
            progressDialog = null;
            donePressed = false;
        });
        progressDialog.show();
        return;
    }

    if (!currentChat.title.equals(nameTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).changeChatTitle(chatId, nameTextView.getText().toString());
    }
    String about = info != null && info.about != null ? info.about : "";
    if (descriptionTextView != null && !about.equals(descriptionTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).updateChatAbout(chatId, descriptionTextView.getText().toString(), info);
    }
    if (signMessages != currentChat.signatures) {
        currentChat.signatures = true;
        MessagesController.getInstance(currentAccount).toogleChannelSignatures(chatId, signMessages);
    }
    if (uploadedAvatar != null) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, uploadedAvatar, avatar, avatarBig);
    } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null);
    }
    finishFragment();
}
 
Example 17
Source File: ChangePhoneActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onNextPressed() {
    if (nextPressed) {
        return;
    }
    String code = getCode();
    if (TextUtils.isEmpty(code)) {
        AndroidUtilities.shakeView(codeFieldContainer, 2, 0);
        return;
    }
    nextPressed = true;
    if (currentType == 2) {
        AndroidUtilities.setWaitingForSms(false);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
    } else if (currentType == 3) {
        AndroidUtilities.setWaitingForCall(false);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall);
    }
    waitingForEvent = false;
    final TLRPC.TL_account_changePhone req = new TLRPC.TL_account_changePhone();
    req.phone_number = requestPhone;
    req.phone_code = code;
    req.phone_code_hash = phoneHash;
    destroyTimer();
    needShowProgress();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        needHideProgress();
        nextPressed = false;
        if (error == null) {
            TLRPC.User user = (TLRPC.User) response;
            destroyTimer();
            destroyCodeTimer();
            UserConfig.getInstance(currentAccount).setCurrentUser(user);
            UserConfig.getInstance(currentAccount).saveConfig(true);
            ArrayList<TLRPC.User> users = new ArrayList<>();
            users.add(user);
            MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true);
            MessagesController.getInstance(currentAccount).putUser(user, false);
            finishFragment();
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
        } else {
            lastError = error.text;
            if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) {
                createTimer();
            }
            if (currentType == 2) {
                AndroidUtilities.setWaitingForSms(true);
                NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
            } else if (currentType == 3) {
                AndroidUtilities.setWaitingForCall(true);
                NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
            }
            waitingForEvent = true;
            if (currentType != 3) {
                AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
            }
            if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
                for (int a = 0; a < codeField.length; a++) {
                    codeField[a].setText("");
                }
                codeField[0].requestFocus();
            } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
                onBackPressed(true);
                setPage(0, true, null, true);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 18
Source File: FlatCheckBox.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void denied() {
    AndroidUtilities.shakeView(this, 2, 0);
}
 
Example 19
Source File: ChatEditActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void processDone() {
    if (donePressed || nameTextView == null) {
        return;
    }
    if (nameTextView.length() == 0) {
        Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
        if (v != null) {
            v.vibrate(200);
        }
        AndroidUtilities.shakeView(nameTextView, 2, 0);
        return;
    }
    donePressed = true;
    if (!ChatObject.isChannel(currentChat) && !historyHidden) {
        MessagesController.getInstance(currentAccount).convertToMegaGroup(getParentActivity(), chatId, this, param -> {
            if (param == 0) {
                donePressed = false;
                return;
            }
            chatId = param;
            currentChat = MessagesController.getInstance(currentAccount).getChat(param);
            donePressed = false;
            if (info != null) {
                info.hidden_prehistory = true;
            }
            processDone();
        });
        return;
    }

    if (info != null) {
        if (ChatObject.isChannel(currentChat) && info.hidden_prehistory != historyHidden) {
            info.hidden_prehistory = historyHidden;
            MessagesController.getInstance(currentAccount).toogleChannelInvitesHistory(chatId, historyHidden);
        }
    }

    if (imageUpdater.uploadingImage != null) {
        createAfterUpload = true;
        progressDialog = new AlertDialog(getParentActivity(), 3);
        progressDialog.setOnCancelListener(dialog -> {
            createAfterUpload = false;
            progressDialog = null;
            donePressed = false;
        });
        progressDialog.show();
        return;
    }

    if (!currentChat.title.equals(nameTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).changeChatTitle(chatId, nameTextView.getText().toString());
    }
    String about = info != null && info.about != null ? info.about : "";
    if (descriptionTextView != null && !about.equals(descriptionTextView.getText().toString())) {
        MessagesController.getInstance(currentAccount).updateChatAbout(chatId, descriptionTextView.getText().toString(), info);
    }
    if (signMessages != currentChat.signatures) {
        currentChat.signatures = true;
        MessagesController.getInstance(currentAccount).toogleChannelSignatures(chatId, signMessages);
    }
    if (uploadedAvatar != null) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, uploadedAvatar, avatar, avatarBig);
    } else if (avatar == null && currentChat.photo instanceof TLRPC.TL_chatPhoto) {
        MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null);
    }
    finishFragment();
}
 
Example 20
Source File: ChangePhoneActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onNextPressed() {
    if (nextPressed) {
        return;
    }
    String code = getCode();
    if (TextUtils.isEmpty(code)) {
        AndroidUtilities.shakeView(codeFieldContainer, 2, 0);
        return;
    }
    nextPressed = true;
    if (currentType == 2) {
        AndroidUtilities.setWaitingForSms(false);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
    } else if (currentType == 3) {
        AndroidUtilities.setWaitingForCall(false);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall);
    }
    waitingForEvent = false;
    final TLRPC.TL_account_changePhone req = new TLRPC.TL_account_changePhone();
    req.phone_number = requestPhone;
    req.phone_code = code;
    req.phone_code_hash = phoneHash;
    destroyTimer();
    needShowProgress();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        needHideProgress();
        nextPressed = false;
        if (error == null) {
            TLRPC.User user = (TLRPC.User) response;
            destroyTimer();
            destroyCodeTimer();
            UserConfig.getInstance(currentAccount).setCurrentUser(user);
            UserConfig.getInstance(currentAccount).saveConfig(true);
            ArrayList<TLRPC.User> users = new ArrayList<>();
            users.add(user);
            MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true);
            MessagesController.getInstance(currentAccount).putUser(user, false);
            finishFragment();
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
        } else {
            lastError = error.text;
            if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) {
                createTimer();
            }
            if (currentType == 2) {
                AndroidUtilities.setWaitingForSms(true);
                NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
            } else if (currentType == 3) {
                AndroidUtilities.setWaitingForCall(true);
                NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
            }
            waitingForEvent = true;
            if (currentType != 3) {
                AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
            }
            if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
                for (int a = 0; a < codeField.length; a++) {
                    codeField[a].setText("");
                }
                codeField[0].requestFocus();
            } else if (error.text.contains("PHONE_CODE_EXPIRED")) {
                onBackPressed(true);
                setPage(0, true, null, true);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}