Java Code Examples for org.telegram.messenger.MediaController#PhotoEntry
The following examples show how to use
org.telegram.messenger.MediaController#PhotoEntry .
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: PhotoPickerActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public int setPhotoUnchecked(Object object) { Object key = null; if (object instanceof MediaController.PhotoEntry) { key = ((MediaController.PhotoEntry) object).imageId; } else if (object instanceof MediaController.SearchImage) { key = ((MediaController.SearchImage) object).id; } if (key == null) { return -1; } if (selectedPhotos.containsKey(key)) { selectedPhotos.remove(key); int position = selectedPhotosOrder.indexOf(key); if (position >= 0) { selectedPhotosOrder.remove(position); } if (allowIndices) { updateCheckedPhotoIndices(); } return position; } return -1; }
Example 2
Source File: PhotoPickerPhotoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setImage(MediaController.PhotoEntry photoEntry) { Drawable thumb = getResources().getDrawable(R.drawable.nophotos); if (photoEntry.thumbPath != null) { imageView.setImage(photoEntry.thumbPath, null, thumb); } else if (photoEntry.path != null) { imageView.setOrientation(photoEntry.orientation, true); if (photoEntry.isVideo) { videoInfoContainer.setVisibility(View.VISIBLE); videoTextView.setText(AndroidUtilities.formatShortDuration(photoEntry.duration)); setContentDescription(LocaleController.getString("AttachVideo", R.string.AttachVideo) + ", " + LocaleController.formatCallDuration(photoEntry.duration)); imageView.setImage("vthumb://" + photoEntry.imageId + ":" + photoEntry.path, null, thumb); } else { videoInfoContainer.setVisibility(View.INVISIBLE); setContentDescription(LocaleController.getString("AttachPhoto", R.string.AttachPhoto)); imageView.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, thumb); } } else { imageView.setImageDrawable(thumb); } }
Example 3
Source File: PhotoPickerActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public int setPhotoUnchecked(Object object) { Object key = null; if (object instanceof MediaController.PhotoEntry) { key = ((MediaController.PhotoEntry) object).imageId; } else if (object instanceof MediaController.SearchImage) { key = ((MediaController.SearchImage) object).id; } if (key == null) { return -1; } if (selectedPhotos.containsKey(key)) { selectedPhotos.remove(key); int position = selectedPhotosOrder.indexOf(key); if (position >= 0) { selectedPhotosOrder.remove(position); } if (allowIndices) { updateCheckedPhotoIndices(); } return position; } return -1; }
Example 4
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void updatePhotosCounter(boolean added) { if (counterTextView == null) { return; } boolean hasVideo = false; boolean hasPhotos = false; for (HashMap.Entry<Object, Object> entry : selectedPhotos.entrySet()) { MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) entry.getValue(); if (photoEntry.isVideo) { hasVideo = true; } else { hasPhotos = true; } if (hasVideo && hasPhotos) { break; } } int newSelectedCount = Math.max(1, selectedPhotos.size()); if (hasVideo && hasPhotos) { counterTextView.setText(LocaleController.formatPluralString("Media", selectedPhotos.size()).toUpperCase()); if (newSelectedCount != currentSelectedCount || added) { parentAlert.selectedTextView.setText(LocaleController.formatPluralString("MediaSelected", newSelectedCount)); } } else if (hasVideo) { counterTextView.setText(LocaleController.formatPluralString("Videos", selectedPhotos.size()).toUpperCase()); if (newSelectedCount != currentSelectedCount || added) { parentAlert.selectedTextView.setText(LocaleController.formatPluralString("VideosSelected", newSelectedCount)); } } else { counterTextView.setText(LocaleController.formatPluralString("Photos", selectedPhotos.size()).toUpperCase()); if (newSelectedCount != currentSelectedCount || added) { parentAlert.selectedTextView.setText(LocaleController.formatPluralString("PhotosSelected", newSelectedCount)); } } currentSelectedCount = newSelectedCount; }
Example 5
Source File: ChatAttachAlertPhotoLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public int getPhotoIndex(int index) { MediaController.PhotoEntry photoEntry = getPhotoEntryAtPosition(index); if (photoEntry == null) { return -1; } return selectedPhotosOrder.indexOf(photoEntry.imageId); }
Example 6
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void updatePhotoAtIndex(int index) { PhotoPickerPhotoCell cell = getCellForIndex(index); if (cell != null) { if (selectedAlbum != null) { cell.photoImage.setOrientation(0, true); MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); if (photoEntry.thumbPath != null) { cell.photoImage.setImage(photoEntry.thumbPath, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); } else if (photoEntry.path != null) { cell.photoImage.setOrientation(photoEntry.orientation, true); if (photoEntry.isVideo) { cell.photoImage.setImage("vthumb://" + photoEntry.imageId + ":" + photoEntry.path, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); } else { cell.photoImage.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, cell.getContext().getResources().getDrawable(R.drawable.nophotos)); } } else { cell.photoImage.setImageResource(R.drawable.nophotos); } } else { ArrayList<MediaController.SearchImage> array; if (searchResult.isEmpty() && lastSearchString == null) { array = recentImages; } else { array = searchResult; } cell.setImage(array.get(index)); } } }
Example 7
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 5 votes |
private MediaController.PhotoEntry getPhotoEntryAtPosition(int position) { if (position < 0) { return null; } int cameraCount = cameraPhotos.size(); if (position < cameraCount) { return (MediaController.PhotoEntry) cameraPhotos.get(position); } position -= cameraCount; if (position < selectedAlbumEntry.photos.size()) { return selectedAlbumEntry.photos.get(position); } return null; }
Example 8
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override void applyCaption(String text) { int imageId = (Integer) selectedPhotosOrder.get(0); Object entry = selectedPhotos.get(imageId); if (entry instanceof MediaController.PhotoEntry) { MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) entry; photoEntry.caption = text; } else if (entry instanceof MediaController.SearchImage) { MediaController.SearchImage searchImage = (MediaController.SearchImage) entry; searchImage.caption = text; } }
Example 9
Source File: PhotoAttachPhotoCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setPhotoEntry(MediaController.PhotoEntry entry, boolean needCheckShow, boolean last) { pressed = false; photoEntry = entry; isLast = last; if (photoEntry.isVideo) { imageView.setOrientation(0, true); videoInfoContainer.setVisibility(VISIBLE); int minutes = photoEntry.duration / 60; int seconds = photoEntry.duration - minutes * 60; videoTextView.setText(String.format("%d:%02d", minutes, seconds)); } else { videoInfoContainer.setVisibility(INVISIBLE); } if (photoEntry.thumbPath != null) { imageView.setImage(photoEntry.thumbPath, null, getResources().getDrawable(R.drawable.nophotos)); } else if (photoEntry.path != null) { if (photoEntry.isVideo) { imageView.setImage("vthumb://" + photoEntry.imageId + ":" + photoEntry.path, null, getResources().getDrawable(R.drawable.nophotos)); } else { imageView.setOrientation(photoEntry.orientation, true); imageView.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, getResources().getDrawable(R.drawable.nophotos)); } } else { imageView.setImageResource(R.drawable.nophotos); } boolean showing = needCheckShow && PhotoViewer.isShowingImage(photoEntry.path); imageView.getImageReceiver().setVisible(!showing, true); checkBox.setAlpha(showing ? 0.0f : 1.0f); videoInfoContainer.setAlpha(showing ? 0.0f : 1.0f); requestLayout(); }
Example 10
Source File: PhotoAttachPhotoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setPhotoEntry(MediaController.PhotoEntry entry, boolean needCheckShow, boolean last) { pressed = false; photoEntry = entry; isLast = last; if (photoEntry.isVideo) { imageView.setOrientation(0, true); videoInfoContainer.setVisibility(VISIBLE); videoTextView.setText(AndroidUtilities.formatShortDuration(photoEntry.duration)); } else { videoInfoContainer.setVisibility(INVISIBLE); } if (photoEntry.thumbPath != null) { imageView.setImage(photoEntry.thumbPath, null, Theme.chat_attachEmptyDrawable); } else if (photoEntry.path != null) { if (photoEntry.isVideo) { imageView.setImage("vthumb://" + photoEntry.imageId + ":" + photoEntry.path, null, Theme.chat_attachEmptyDrawable); } else { imageView.setOrientation(photoEntry.orientation, true); imageView.setImage("thumb://" + photoEntry.imageId + ":" + photoEntry.path, null, Theme.chat_attachEmptyDrawable); } } else { imageView.setImageDrawable(Theme.chat_attachEmptyDrawable); } boolean showing = needCheckShow && PhotoViewer.isShowingImage(photoEntry.path); imageView.getImageReceiver().setVisible(!showing, true); checkBox.setAlpha(showing ? 0.0f : 1.0f); videoInfoContainer.setAlpha(showing ? 0.0f : 1.0f); requestLayout(); }
Example 11
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo) { MediaController.PhotoEntry photoEntry = getPhotoEntryAtPosition(index); if (photoEntry != null) { photoEntry.editedInfo = videoEditedInfo; } if (selectedPhotos.isEmpty() && photoEntry != null) { addToSelectedPhotos(photoEntry, -1); } delegate.didPressedButton(7); }
Example 12
Source File: ChatAttachAlertDocumentLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void sendSelectedPhotos(HashMap<Object, Object> photos, ArrayList<Object> order, boolean notify, int scheduleDate) { if (photos.isEmpty() || delegate == null || sendPressed) { return; } sendPressed = true; ArrayList<SendMessagesHelper.SendingMediaInfo> media = new ArrayList<>(); for (int a = 0; a < order.size(); a++) { Object object = photos.get(order.get(a)); SendMessagesHelper.SendingMediaInfo info = new SendMessagesHelper.SendingMediaInfo(); media.add(info); if (object instanceof MediaController.PhotoEntry) { MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) object; if (photoEntry.imagePath != null) { info.path = photoEntry.imagePath; } else { info.path = photoEntry.path; } info.thumbPath = photoEntry.thumbPath; info.videoEditedInfo = photoEntry.editedInfo; info.isVideo = photoEntry.isVideo; info.caption = photoEntry.caption != null ? photoEntry.caption.toString() : null; info.entities = photoEntry.entities; info.masks = photoEntry.stickers; info.ttl = photoEntry.ttl; } } delegate.didSelectPhotos(media, notify, scheduleDate); }
Example 13
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private int addToSelectedPhotos(Object object, int index) { Object key = null; if (object instanceof MediaController.PhotoEntry) { key = ((MediaController.PhotoEntry) object).imageId; } else if (object instanceof MediaController.SearchImage) { key = ((MediaController.SearchImage) object).id; } if (key == null) { return -1; } if (selectedPhotos.containsKey(key)) { selectedPhotos.remove(key); int position = selectedPhotosOrder.indexOf(key); if (position >= 0) { selectedPhotosOrder.remove(position); } if (allowIndices) { updateCheckedPhotoIndices(); } if (index >= 0) { if (object instanceof MediaController.PhotoEntry) { ((MediaController.PhotoEntry) object).reset(); } else if (object instanceof MediaController.SearchImage) { ((MediaController.SearchImage) object).reset(); } provider.updatePhotoAtIndex(index); } return position; } else { selectedPhotos.put(key, object); selectedPhotosOrder.add(key); return -1; } }
Example 14
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public boolean isPhotoChecked(int index) { MediaController.PhotoEntry photoEntry = getPhotoEntryAtPosition(index); return photoEntry != null && selectedPhotos.containsKey(photoEntry.imageId); }
Example 15
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 4 votes |
private MediaController.PhotoEntry getPhoto(int position) { if (needCamera && selectedAlbumEntry == galleryAlbumEntry) { position--; } return getPhotoEntryAtPosition(position); }
Example 16
Source File: PhotoAttachPhotoCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public MediaController.PhotoEntry getPhotoEntry() { return photoEntry; }
Example 17
Source File: PhotoAttachPhotoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public MediaController.PhotoEntry getPhotoEntry() { return photoEntry; }
Example 18
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public boolean isPhotoChecked(int index) { MediaController.PhotoEntry photoEntry = getPhotoEntryAtPosition(index); return photoEntry != null && selectedPhotos.containsKey(photoEntry.imageId); }
Example 19
Source File: SharedDocumentCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setPhotoEntry(MediaController.PhotoEntry entry) { String path; if (entry.thumbPath != null) { thumbImageView.setImage(entry.thumbPath, null, Theme.chat_attachEmptyDrawable); path = entry.thumbPath; } else if (entry.path != null) { if (entry.isVideo) { thumbImageView.setOrientation(0, true); thumbImageView.setImage("vthumb://" + entry.imageId + ":" + entry.path, null, Theme.chat_attachEmptyDrawable); } else { thumbImageView.setOrientation(entry.orientation, true); thumbImageView.setImage("thumb://" + entry.imageId + ":" + entry.path, null, Theme.chat_attachEmptyDrawable); } path = entry.path; } else { thumbImageView.setImageDrawable(Theme.chat_attachEmptyDrawable); path = ""; } File file = new File(path); nameTextView.setText(file.getName()); String type = FileLoader.getFileExtension(file); StringBuilder builder = new StringBuilder(); extTextView.setVisibility(GONE); if (entry.width != 0 && entry.height != 0) { if (builder.length() > 0) { builder.append(", "); } builder.append(String.format(Locale.US, "%dx%d", entry.width, entry.height)); } if (entry.isVideo) { if (builder.length() > 0) { builder.append(", "); } builder.append(AndroidUtilities.formatShortDuration(entry.duration)); } if (entry.size != 0) { if (builder.length() > 0) { builder.append(", "); } builder.append(AndroidUtilities.formatFileSize(entry.size)); } if (builder.length() > 0) { builder.append(", "); } builder.append(LocaleController.getInstance().formatterStats.format(entry.dateTaken)); dateTextView.setText(builder); //placeholderImageView.setImageResource(AndroidUtilities.getThumbForNameOrMime(path, null, false)); //placeholderImageView.setVisibility(VISIBLE); placeholderImageView.setVisibility(GONE); }
Example 20
Source File: PhotoAttachPhotoCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public MediaController.PhotoEntry getPhotoEntry() { return photoEntry; }