List of usage examples for android.animation AnimatorSet playTogether
public void playTogether(Collection<Animator> items)
From source file:net.bluehack.ui.ChatActivity.java
private void createMenu(View v, boolean single) { if (actionBar.isActionModeShowed()) { return;/* www .j a v a2s . c o m*/ } MessageObject message = null; if (v instanceof ChatMessageCell) { message = ((ChatMessageCell) v).getMessageObject(); } else if (v instanceof ChatActionCell) { message = ((ChatActionCell) v).getMessageObject(); } if (message == null) { return; } final int type = getMessageType(message); if (single && message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { scrollToMessageId(message.messageOwner.reply_to_msg_id, 0, true, 0); return; } selectedObject = null; forwaringMessage = null; for (int a = 1; a >= 0; a--) { selectedMessagesCanCopyIds[a].clear(); selectedMessagesIds[a].clear(); } cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updatePinnedMessageView(true); boolean allowChatActions = true; boolean allowPin = message.getDialogId() != mergeDialogId && message.getId() > 0 && ChatObject.isChannel(currentChat) && currentChat.megagroup && (currentChat.creator || currentChat.editor) && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty); boolean allowUnpin = message.getDialogId() != mergeDialogId && info != null && info.pinned_msg_id == message.getId() && (currentChat.creator || currentChat.editor); boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId; if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 || type == 1 && message.getDialogId() == mergeDialogId || currentEncryptedChat == null && message.getId() < 0 || isBroadcast || currentChat != null && (ChatObject.isNotInChat(currentChat) || ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) { allowChatActions = false; } if (single || type < 2 || type == 20) { if (type >= 0) { selectedObject = message; if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); ArrayList<CharSequence> items = new ArrayList<>(); final ArrayList<Integer> options = new ArrayList<>(); if (type == 0) { items.add(LocaleController.getString("Retry", R.string.Retry)); options.add(0); items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } else if (type == 1) { if (currentChat != null && !isBroadcast) { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } else { if (single && selectedObject.getId() > 0 && allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } } else if (type == 20) { items.add(LocaleController.getString("Retry", R.string.Retry)); options.add(0); items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } else { if (currentEncryptedChat == null) { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); } if (type == 3) { if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject .isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) { items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs)); options.add(11); } } else if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (selectedObject.getDocument() != null) { if (MessageObject.isNewGifDocument(selectedObject.getDocument())) { items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs)); options.add(11); } items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile)); options.add(5); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (type == 6) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(7); items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (type == 7) { if (selectedObject.isMask()) { items.add(LocaleController.getString("AddToMasks", R.string.AddToMasks)); } else { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); } options.add(9); } else if (type == 8) { TLRPC.User user = MessagesController.getInstance() .getUser(selectedObject.messageOwner.media.user_id); if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle)); options.add(15); } if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(16); items.add(LocaleController.getString("Call", R.string.Call)); options.add(17); } } items.add(LocaleController.getString("Forward", R.string.Forward)); options.add(2); if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } else { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); } if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) { items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile)); options.add(5); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); options.add(9); } items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } if (options.isEmpty()) { return; } final CharSequence[] finalItems = items.toArray(new CharSequence[items.size()]); builder.setItems(finalItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (selectedObject == null || i < 0 || i >= options.size()) { return; } processSelectedOption(options.get(i)); } }); builder.setTitle(LocaleController.getString("Message", R.string.Message)); showDialog(builder.create()); } return; } final ActionBarMenu actionMode = actionBar.createActionMode(); View item = actionMode.getItem(forward); if (item != null) { item.setVisibility(View.VISIBLE); } item = actionMode.getItem(delete); if (item != null) { item.setVisibility(View.VISIBLE); } if (editDoneItem != null) { editDoneItem.setVisibility(View.GONE); } actionBar.showActionMode(); updatePinnedMessageView(true); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); addToSelectedMessages(message); selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); }
From source file:kr.wdream.ui.ChatActivity.java
private void createMenu(View v, boolean single) { if (actionBar.isActionModeShowed()) { return;//from w ww.j ava 2 s . c om } MessageObject message = null; if (v instanceof ChatMessageCell) { message = ((ChatMessageCell) v).getMessageObject(); } else if (v instanceof ChatActionCell) { message = ((ChatActionCell) v).getMessageObject(); } if (message == null) { return; } final int type = getMessageType(message); if (single && message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { scrollToMessageId(message.messageOwner.reply_to_msg_id, 0, true, 0); return; } selectedObject = null; forwaringMessage = null; for (int a = 1; a >= 0; a--) { selectedMessagesCanCopyIds[a].clear(); selectedMessagesIds[a].clear(); } cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updatePinnedMessageView(true); boolean allowChatActions = true; boolean allowPin = message.getDialogId() != mergeDialogId && message.getId() > 0 && ChatObject.isChannel(currentChat) && currentChat.megagroup && (currentChat.creator || currentChat.editor) && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty); boolean allowUnpin = message.getDialogId() != mergeDialogId && info != null && info.pinned_msg_id == message.getId() && (currentChat.creator || currentChat.editor); boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId; if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 || type == 1 && message.getDialogId() == mergeDialogId || currentEncryptedChat == null && message.getId() < 0 || isBroadcast || currentChat != null && (ChatObject.isNotInChat(currentChat) || ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) { allowChatActions = false; } if (single || type < 2 || type == 20) { if (type >= 0) { selectedObject = message; if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); ArrayList<CharSequence> items = new ArrayList<>(); final ArrayList<Integer> options = new ArrayList<>(); if (type == 0) { items.add(LocaleController.getString("Retry", kr.wdream.storyshop.R.string.Retry)); options.add(0); items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } else if (type == 1) { if (currentChat != null && !isBroadcast) { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", kr.wdream.storyshop.R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", kr.wdream.storyshop.R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", kr.wdream.storyshop.R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } else { if (single && selectedObject.getId() > 0 && allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } } else if (type == 20) { items.add(LocaleController.getString("Retry", kr.wdream.storyshop.R.string.Retry)); options.add(0); items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } else { if (currentEncryptedChat == null) { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); } if (type == 3) { if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject .isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) { items.add(LocaleController.getString("SaveToGIFs", kr.wdream.storyshop.R.string.SaveToGIFs)); options.add(11); } } else if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", kr.wdream.storyshop.R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.getDocument() != null) { if (MessageObject.isNewGifDocument(selectedObject.getDocument())) { items.add(LocaleController.getString("SaveToGIFs", kr.wdream.storyshop.R.string.SaveToGIFs)); options.add(11); } items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", kr.wdream.storyshop.R.string.ApplyLocalizationFile)); options.add(5); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (type == 6) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(7); items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (type == 7) { if (selectedObject.isMask()) { items.add(LocaleController.getString("AddToMasks", kr.wdream.storyshop.R.string.AddToMasks)); } else { items.add(LocaleController.getString("AddToStickers", kr.wdream.storyshop.R.string.AddToStickers)); } options.add(9); } else if (type == 8) { TLRPC.User user = MessagesController.getInstance() .getUser(selectedObject.messageOwner.media.user_id); if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { items.add(LocaleController.getString("AddContactTitle", kr.wdream.storyshop.R.string.AddContactTitle)); options.add(15); } if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(16); items.add(LocaleController.getString("Call", kr.wdream.storyshop.R.string.Call)); options.add(17); } } items.add(LocaleController.getString("Forward", kr.wdream.storyshop.R.string.Forward)); options.add(2); if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", kr.wdream.storyshop.R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", kr.wdream.storyshop.R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", kr.wdream.storyshop.R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } else { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); } if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", kr.wdream.storyshop.R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) { items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", kr.wdream.storyshop.R.string.ApplyLocalizationFile)); options.add(5); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", kr.wdream.storyshop.R.string.AddToStickers)); options.add(9); } items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } if (options.isEmpty()) { return; } final CharSequence[] finalItems = items.toArray(new CharSequence[items.size()]); builder.setItems(finalItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (selectedObject == null || i < 0 || i >= options.size()) { return; } processSelectedOption(options.get(i)); } }); builder.setTitle(LocaleController.getString("Message", kr.wdream.storyshop.R.string.Message)); showDialog(builder.create()); } return; } final ActionBarMenu actionMode = actionBar.createActionMode(); View item = actionMode.getItem(forward); if (item != null) { item.setVisibility(View.VISIBLE); } item = actionMode.getItem(delete); if (item != null) { item.setVisibility(View.VISIBLE); } if (editDoneItem != null) { editDoneItem.setVisibility(View.GONE); } actionBar.showActionMode(); updatePinnedMessageView(true); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); addToSelectedMessages(message); selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); }
From source file:com.b44t.ui.Components.PasscodeView.java
private void shakeTextView(final float x, final int num) { if (num == 6) { return;/*from ww w . j a va2 s.com*/ } AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether(ObjectAnimator.ofFloat(passcodeTextView, "translationX", AndroidUtilities.dp(x))); AnimatorSet.setDuration(50); AnimatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { shakeTextView(num == 5 ? 0 : -x, num + 1); } }); AnimatorSet.start(); }
From source file:org.telegram.ui.Components.ChatActivityEnterView.java
private void hideRecordedAudioPanel() { audioToSendPath = null;/*from ww w .j a v a 2 s . com*/ audioToSend = null; audioToSendMessageObject = null; AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.playTogether(ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f)); AnimatorSet.setDuration(200); AnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { recordedAudioPanel.setVisibility(GONE); } }); AnimatorSet.start(); }