本文整理汇总了Java中org.telegram.ui.Components.AlertsCreator类的典型用法代码示例。如果您正苦于以下问题:Java AlertsCreator类的具体用法?Java AlertsCreator怎么用?Java AlertsCreator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AlertsCreator类属于org.telegram.ui.Components包,在下文中一共展示了AlertsCreator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addUsersToChannel
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
public void addUsersToChannel(int chat_id, ArrayList<TLRPC.InputUser> users, final BaseFragment fragment) {
if (users == null || users.isEmpty()) {
return;
}
final TLRPC.TL_channels_inviteToChannel req = new TLRPC.TL_channels_inviteToChannel();
req.channel = getInputChannel(chat_id);
req.users = users;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
if (error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertsCreator.processError(error, fragment, req, true);
}
});
return;
}
processUpdates((TLRPC.Updates) response, false);
}
});
}
示例2: addUsersToChannel
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
public void addUsersToChannel(int chat_id, ArrayList<TLRPC.InputUser> users, final BaseFragment fragment) {
if (users == null || users.isEmpty()) {
return;
}
TLRPC.TL_channels_inviteToChannel req = new TLRPC.TL_channels_inviteToChannel();
req.channel = getInputChannel(chat_id);
req.users = users;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
if (error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (fragment != null) {
AlertsCreator.showAddUserAlert(error.text, fragment, true);
} else if (error.text.equals("PEER_FLOOD")) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.needShowAlert, 1);
}
}
});
return;
}
processUpdates((TLRPC.Updates) response, false);
}
});
}
示例3: setUserChannelRole
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
public void setUserChannelRole(TLRPC.User user, TLRPC.ChannelParticipantRole role) {
if (user == null || role == null) {
return;
}
TLRPC.TL_channels_editAdmin req = new TLRPC.TL_channels_editAdmin();
req.channel = MessagesController.getInputChannel(chatId);
req.user_id = MessagesController.getInputUser(user);
req.role = role;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
if (error == null) {
MessagesController.getInstance().processUpdates((TLRPC.Updates) response, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().loadFullChat(chatId, 0, true);
}
}, 1000);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertsCreator.showAddUserAlert(error.text, ChannelUsersActivity.this, !isMegagroup);
}
});
}
}
});
}
示例4: setUserBannedRole
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
public static void setUserBannedRole(final int chatId, TLRPC.User user, TLRPC.TL_channelBannedRights rights, final boolean isMegagroup, final BaseFragment parentFragment) {
if (user == null || rights == null) {
return;
}
final TLRPC.TL_channels_editBanned req = new TLRPC.TL_channels_editBanned();
req.channel = MessagesController.getInputChannel(chatId);
req.user_id = MessagesController.getInputUser(user);
req.banned_rights = rights;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
if (error == null) {
MessagesController.getInstance().processUpdates((TLRPC.Updates) response, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().loadFullChat(chatId, 0, true);
}
}, 1000);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertsCreator.processError(error, parentFragment, req, !isMegagroup);
}
});
}
}
});
}
示例5: setUserAdminRole
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
public static void setUserAdminRole(final int chatId, TLRPC.User user, TLRPC.TL_channelAdminRights rights, final boolean isMegagroup, final BaseFragment parentFragment) {
if (user == null || rights == null) {
return;
}
final TLRPC.TL_channels_editAdmin req = new TLRPC.TL_channels_editAdmin();
req.channel = MessagesController.getInputChannel(chatId);
req.user_id = MessagesController.getInputUser(user);
req.admin_rights = rights;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
if (error == null) {
MessagesController.getInstance().processUpdates((TLRPC.Updates) response, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().loadFullChat(chatId, 0, true);
}
}, 1000);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertsCreator.processError(error, parentFragment, req, !isMegagroup);
}
});
}
}
});
}
示例6: editMessage
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
public int editMessage(MessageObject messageObject, String message, boolean searchLinks, final BaseFragment fragment, ArrayList<TLRPC.MessageEntity> entities, final Runnable callback) {
if (fragment == null || fragment.getParentActivity() == null || callback == null) {
return 0;
}
final TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage();
req.peer = MessagesController.getInputPeer((int) messageObject.getDialogId());
req.message = message;
req.flags |= 2048;
req.id = messageObject.getId();
req.no_webpage = !searchLinks;
if (entities != null) {
req.entities = entities;
req.flags |= 8;
}
return ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
callback.run();
}
});
if (error == null) {
MessagesController.getInstance().processUpdates((TLRPC.Updates) response, false);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertsCreator.processError(error, fragment, req);
}
});
}
}
});
}
示例7: resendCode
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
private void resendCode() {
final Bundle params = new Bundle();
params.putString("phone", phone);
params.putString("ephone", emailPhone);
params.putString("phoneFormated", requestPhone);
nextPressed = true;
needShowProgress();
final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
req.phone_number = requestPhone;
req.phone_code_hash = phoneHash;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
nextPressed = false;
if (error == null) {
fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
} else {
AlertsCreator.processError(error, ChangePhoneActivity.this, req);
if (error.text.contains("PHONE_CODE_EXPIRED")) {
onBackPressed();
setPage(0, true, null, true);
}
}
needHideProgress();
}
});
}
}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
示例8: forwardMessages
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
private void forwardMessages(ArrayList<MessageObject> arrayList, boolean fromMyName) {
if (arrayList == null || arrayList.isEmpty()) {
return;
}
if (!fromMyName) {
AlertsCreator.showSendMediaAlert(SendMessagesHelper.getInstance().sendMessage(arrayList, dialog_id), this);
} else {
for (MessageObject object : arrayList) {
SendMessagesHelper.getInstance().processForwardFromMyName(object, dialog_id);
}
}
}
示例9: resendCode
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
private void resendCode() {
final Bundle params = new Bundle();
params.putString("phone", phone);
nextPressed = true;
needShowProgress();
final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
req.phone_number = phone;
req.phone_code_hash = phoneHash;
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
nextPressed = false;
if (error == null) {
fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
} else {
AlertsCreator.processError(error, CancelAccountDeletionActivity.this, req);
}
needHideProgress();
}
});
}
}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
示例10: onNextPressed
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
@Override
public void onNextPressed() {
if (nextPressed) {
return;
}
nextPressed = true;
if (currentType == 2) {
AndroidUtilities.setWaitingForSms(false);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
} else if (currentType == 3) {
AndroidUtilities.setWaitingForCall(false);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveCall);
}
waitingForEvent = false;
final TLRPC.TL_account_changePhone req = new TLRPC.TL_account_changePhone();
req.phone_number = requestPhone;
req.phone_code = codeField.getText().toString();
req.phone_code_hash = phoneHash;
destroyTimer();
needShowProgress();
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
needHideProgress();
nextPressed = false;
if (error == null) {
TLRPC.User user = (TLRPC.User) response;
destroyTimer();
destroyCodeTimer();
UserConfig.setCurrentUser(user);
UserConfig.saveConfig(true);
ArrayList<TLRPC.User> users = new ArrayList<>();
users.add(user);
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
MessagesController.getInstance().putUser(user, false);
finishFragment();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
} else {
lastError = error.text;
if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3)) {
createTimer();
}
if (currentType == 2) {
AndroidUtilities.setWaitingForSms(true);
NotificationCenter.getInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
} else if (currentType == 3) {
AndroidUtilities.setWaitingForCall(true);
NotificationCenter.getInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
}
waitingForEvent = true;
if (currentType != 3) {
AlertsCreator.processError(error, ChangePhoneActivity.this, req);
}
}
}
});
}
}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
示例11: joinChannel
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
private void joinChannel(final BlockChannelCell cell, final TLRPC.Chat channel) {
final TLRPC.TL_channels_joinChannel req = new TLRPC.TL_channels_joinChannel();
req.channel = MessagesController.getInputChannel(channel);
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
if (error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
cell.setState(0, false);
AlertsCreator.processError(error, parentFragment, req, true);
}
});
return;
}
boolean hasJoinMessage = false;
TLRPC.Updates updates = (TLRPC.Updates) response;
for (int a = 0; a < updates.updates.size(); a++) {
TLRPC.Update update = updates.updates.get(a);
if (update instanceof TLRPC.TL_updateNewChannelMessage) {
if (((TLRPC.TL_updateNewChannelMessage) update).message.action instanceof TLRPC.TL_messageActionChatAddUser) {
hasJoinMessage = true;
break;
}
}
}
MessagesController.getInstance().processUpdates(updates, false);
if (!hasJoinMessage) {
MessagesController.getInstance().generateJoinMessage(channel.id, true);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
cell.setState(2, false);
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().loadFullChat(channel.id, 0, true);
}
}, 1000);
MessagesStorage.getInstance().updateDialogsWithDeletedMessages(new ArrayList<Integer>(), null, true, channel.id);
}
});
}
示例12: onNextPressed
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
@Override
public void onNextPressed() {
if (nextPressed) {
return;
}
nextPressed = true;
if (currentType == 2) {
AndroidUtilities.setWaitingForSms(false);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
} else if (currentType == 3) {
AndroidUtilities.setWaitingForCall(false);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceiveCall);
}
waitingForEvent = false;
final TLRPC.TL_account_confirmPhone req = new TLRPC.TL_account_confirmPhone();
req.phone_code = codeField.getText().toString();
req.phone_code_hash = phoneHash;
destroyTimer();
needShowProgress();
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
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)) {
createTimer();
}
if (currentType == 2) {
AndroidUtilities.setWaitingForSms(true);
NotificationCenter.getInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
} else if (currentType == 3) {
AndroidUtilities.setWaitingForCall(true);
NotificationCenter.getInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
}
waitingForEvent = true;
if (currentType != 3) {
AlertsCreator.processError(error, CancelAccountDeletionActivity.this, req);
}
}
}
});
}
}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
示例13: sendData
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
private void sendData() {
if (canceled) {
return;
}
showEditDoneProgress(false, true);
final TLRPC.TL_payments_sendPaymentForm req = new TLRPC.TL_payments_sendPaymentForm();
req.msg_id = messageObject.getId();
if (UserConfig.tmpPassword != null && paymentForm.saved_credentials != null) {
req.credentials = new TLRPC.TL_inputPaymentCredentialsSaved();
req.credentials.id = paymentForm.saved_credentials.id;
req.credentials.tmp_password = UserConfig.tmpPassword.tmp_password;
} else if (androidPayCredentials != null) {
req.credentials = androidPayCredentials;
} else {
req.credentials = new TLRPC.TL_inputPaymentCredentials();
req.credentials.save = saveCardInfo;
req.credentials.data = new TLRPC.TL_dataJSON();
req.credentials.data.data = paymentJson;
}
if (requestedInfo != null && requestedInfo.id != null) {
req.requested_info_id = requestedInfo.id;
req.flags |= 1;
}
if (shippingOption != null) {
req.shipping_option_id = shippingOption.id;
req.flags |= 2;
}
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(final TLObject response, final TLRPC.TL_error error) {
if (response != null) {
if (response instanceof TLRPC.TL_payments_paymentResult) {
MessagesController.getInstance().processUpdates(((TLRPC.TL_payments_paymentResult) response).updates, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
goToNextStep();
}
});
} else if (response instanceof TLRPC.TL_payments_paymentVerficationNeeded) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.paymentFinished);
setDonePressed(false);
webView.setVisibility(View.VISIBLE);
webviewLoading = true;
showEditDoneProgress(true, true);
progressView.setVisibility(View.VISIBLE);
doneItem.setEnabled(false);
doneItem.getImageView().setVisibility(View.INVISIBLE);
webView.loadUrl(((TLRPC.TL_payments_paymentVerficationNeeded) response).url);
}
});
}
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
AlertsCreator.processError(error, PaymentFormActivity.this, req);
setDonePressed(false);
showEditDoneProgress(false, false);
}
});
}
}
}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
示例14: sendCardData
import org.telegram.ui.Components.AlertsCreator; //导入依赖的package包/类
private boolean sendCardData() {
Integer month;
Integer year;
String date = inputFields[FIELD_EXPIRE_DATE].getText().toString();
String args[] = date.split("/");
if (args.length == 2) {
month = Utilities.parseInt(args[0]);
year = Utilities.parseInt(args[1]);
} else {
month = null;
year = null;
}
Card card = new Card(
inputFields[FIELD_CARD].getText().toString(),
month,
year,
inputFields[FIELD_CVV].getText().toString(),
inputFields[FIELD_CARDNAME].getText().toString(),
null, null, null, null,
inputFields[FIELD_CARD_POSTCODE].getText().toString(),
inputFields[FIELD_CARD_COUNTRY].getText().toString(),
null);
cardName = card.getType() + " *" + card.getLast4();
if (!card.validateNumber()) {
shakeField(FIELD_CARD);
return false;
} else if (!card.validateExpMonth() || !card.validateExpYear() || !card.validateExpiryDate()) {
shakeField(FIELD_EXPIRE_DATE);
return false;
} else if (need_card_name && inputFields[FIELD_CARDNAME].length() == 0) {
shakeField(FIELD_CARDNAME);
return false;
} else if (!card.validateCVC()) {
shakeField(FIELD_CVV);
return false;
} else if (need_card_country && inputFields[FIELD_CARD_COUNTRY].length() == 0) {
shakeField(FIELD_CARD_COUNTRY);
return false;
} else if (need_card_postcode && inputFields[FIELD_CARD_POSTCODE].length() == 0) {
shakeField(FIELD_CARD_POSTCODE);
return false;
}
showEditDoneProgress(true, true);
try {
Stripe stripe = new Stripe(stripeApiKey);
stripe.createToken(card, new TokenCallback() {
public void onSuccess(Token token) {
if (canceled) {
return;
}
paymentJson = String.format(Locale.US, "{\"type\":\"%1$s\", \"id\":\"%2$s\"}", token.getType(), token.getId());
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
goToNextStep();
showEditDoneProgress(true, false);
setDonePressed(false);
}
});
}
public void onError(Exception error) {
if (canceled) {
return;
}
showEditDoneProgress(true, false);
setDonePressed(false);
if (error instanceof APIConnectionException || error instanceof APIException) {
AlertsCreator.showSimpleToast(PaymentFormActivity.this, LocaleController.getString("PaymentConnectionFailed", R.string.PaymentConnectionFailed));
} else {
AlertsCreator.showSimpleToast(PaymentFormActivity.this, error.getMessage());
}
}
}
);
} catch (Exception e) {
FileLog.e(e);
}
return true;
}