org.telegram.messenger.MediaController Java Examples
The following examples show how to use
org.telegram.messenger.MediaController.
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: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private int addToSelectedPhotos(MediaController.PhotoEntry object, int index) { Object key = object.imageId; if (selectedPhotos.containsKey(key)) { selectedPhotos.remove(key); int position = selectedPhotosOrder.indexOf(key); if (position >= 0) { selectedPhotosOrder.remove(position); } updatePhotosCounter(); updateCheckedPhotoIndices(); if (index >= 0) { object.reset(); photoViewerProvider.updatePhotoAtIndex(index); } return position; } else { selectedPhotos.put(key, object); selectedPhotosOrder.add(key); updatePhotosCounter(); return -1; } }
Example #2
Source File: ChatActivityEnterView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setReplyingMessageObject(MessageObject messageObject) { if (messageObject != null) { if (botMessageObject == null && botButtonsMessageObject != replyingMessageObject) { botMessageObject = botButtonsMessageObject; } replyingMessageObject = messageObject; setButtons(replyingMessageObject, true); } else if (messageObject == null && replyingMessageObject == botButtonsMessageObject) { replyingMessageObject = null; setButtons(botMessageObject, false); botMessageObject = null; } else { replyingMessageObject = messageObject; } MediaController.getInstance().setReplyingMessage(messageObject); }
Example #3
Source File: PhotoFilterView.java From Telegram with GNU General Public License v2.0 | 6 votes |
public MediaController.SavedFilterState getSavedFilterState() { MediaController.SavedFilterState state = new MediaController.SavedFilterState(); state.enhanceValue = enhanceValue; state.exposureValue = exposureValue; state.contrastValue = contrastValue; state.warmthValue = warmthValue; state.saturationValue = saturationValue; state.fadeValue = fadeValue; state.tintShadowsColor = tintShadowsColor; state.tintHighlightsColor = tintHighlightsColor; state.highlightsValue = highlightsValue; state.shadowsValue = shadowsValue; state.vignetteValue = vignetteValue; state.grainValue = grainValue; state.blurType = blurType; state.sharpenValue = sharpenValue; state.curvesToolValue = curvesToolValue; state.blurExcludeSize = blurExcludeSize; state.blurExcludePoint = blurExcludePoint; state.blurExcludeBlurSize = blurExcludeBlurSize; state.blurAngle = blurAngle; return lastState = state; }
Example #4
Source File: PhotoFilterView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public MediaController.SavedFilterState getSavedFilterState() { MediaController.SavedFilterState state = new MediaController.SavedFilterState(); state.enhanceValue = enhanceValue; state.exposureValue = exposureValue; state.contrastValue = contrastValue; state.warmthValue = warmthValue; state.saturationValue = saturationValue; state.fadeValue = fadeValue; state.tintShadowsColor = tintShadowsColor; state.tintHighlightsColor = tintHighlightsColor; state.highlightsValue = highlightsValue; state.shadowsValue = shadowsValue; state.vignetteValue = vignetteValue; state.grainValue = grainValue; state.blurType = blurType; state.sharpenValue = sharpenValue; state.curvesToolValue = curvesToolValue; state.blurExcludeSize = blurExcludeSize; state.blurExcludePoint = blurExcludePoint; state.blurExcludeBlurSize = blurExcludeBlurSize; state.blurAngle = blurAngle; return state; }
Example #5
Source File: PhotoPickerActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate) { if (selectedPhotos.isEmpty()) { if (selectedAlbum != null) { if (index < 0 || index >= selectedAlbum.photos.size()) { return; } MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); photoEntry.editedInfo = videoEditedInfo; addToSelectedPhotos(photoEntry, -1); } else { if (index < 0 || index >= searchResult.size()) { return; } MediaController.SearchImage searchImage = searchResult.get(index); searchImage.editedInfo = videoEditedInfo; addToSelectedPhotos(searchImage, -1); } } sendSelectedPhotos(notify, scheduleDate); }
Example #6
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 #7
Source File: PhotoAlbumPickerActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.albumsDidLoad) { int guid = (Integer) args[0]; if (classGuid == guid) { if (selectPhotoType != 0 || !allowSearchImages) { albumsSorted = (ArrayList<MediaController.AlbumEntry>) args[2]; } else { albumsSorted = (ArrayList<MediaController.AlbumEntry>) args[1]; } if (progressView != null) { progressView.setVisibility(View.GONE); } if (listView != null && listView.getEmptyView() == null) { listView.setEmptyView(emptyView); } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } loading = false; } } else if (id == NotificationCenter.closeChats) { removeSelfFromStack(); } }
Example #8
Source File: ChatActivityEnterView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setReplyingMessageObject(MessageObject messageObject) { if (messageObject != null) { if (botMessageObject == null && botButtonsMessageObject != replyingMessageObject) { botMessageObject = botButtonsMessageObject; } replyingMessageObject = messageObject; setButtons(replyingMessageObject, true); } else if (messageObject == null && replyingMessageObject == botButtonsMessageObject) { replyingMessageObject = null; setButtons(botMessageObject, false); botMessageObject = null; } else { replyingMessageObject = messageObject; } MediaController.getInstance().setReplyingMessage(messageObject); }
Example #9
Source File: FragmentContextView.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void checkVisibility() { boolean show = false; if (isLocation) { if (fragment instanceof DialogsActivity) { show = LocationController.getLocationsCount() != 0; } else { show = LocationController.getInstance(fragment.getCurrentAccount()).isSharingLocation(((ChatActivity) fragment).getDialogId()); } } else { if (VoIPService.getSharedInstance() != null && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING) { show = true; } else { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject != null && messageObject.getId() != 0) { show = true; } } } setVisibility(show ? VISIBLE : GONE); }
Example #10
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 #11
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo) { if (selectedPhotos.isEmpty()) { if (selectedAlbum != null) { if (index < 0 || index >= selectedAlbum.photos.size()) { return; } MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); photoEntry.editedInfo = videoEditedInfo; addToSelectedPhotos(photoEntry, -1); } else { ArrayList<MediaController.SearchImage> array; if (searchResult.isEmpty() && lastSearchString == null) { array = recentImages; } else { array = searchResult; } if (index < 0 || index >= array.size()) { return; } addToSelectedPhotos(array.get(index), -1); } } sendSelectedPhotos(); }
Example #12
Source File: PhotoPickerAlbumsCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setAlbum(int a, MediaController.AlbumEntry albumEntry) { albumEntries[a] = albumEntry; if (albumEntry != null) { AlbumView albumView = albumViews[a]; albumView.imageView.setOrientation(0, true); if (albumEntry.coverPhoto != null && albumEntry.coverPhoto.path != null) { albumView.imageView.setOrientation(albumEntry.coverPhoto.orientation, true); if (albumEntry.coverPhoto.isVideo) { albumView.imageView.setImage("vthumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); } else { albumView.imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); } } else { albumView.imageView.setImageResource(R.drawable.nophotos); } albumView.nameTextView.setText(albumEntry.bucketName); albumView.countTextView.setText(String.format("%d", albumEntry.photos.size())); } else { albumViews[a].setVisibility(INVISIBLE); } }
Example #13
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 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; MediaController.AlbumEntry albumEntry; if (baseFragment instanceof ChatActivity) { albumEntry = MediaController.allMediaAlbumEntry; } else { albumEntry = MediaController.allPhotosAlbumEntry; } if (position < albumEntry.photos.size()) { return albumEntry.photos.get(position); } return null; }
Example #14
Source File: PhotoPickerAlbumsCell.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void setAlbum(int a, MediaController.AlbumEntry albumEntry) { albumEntries[a] = albumEntry; if (albumEntry != null) { AlbumView albumView = albumViews[a]; albumView.imageView.setOrientation(0, true); if (albumEntry.coverPhoto != null && albumEntry.coverPhoto.path != null) { albumView.imageView.setOrientation(albumEntry.coverPhoto.orientation, true); if (albumEntry.coverPhoto.isVideo) { albumView.imageView.setImage("vthumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, Theme.chat_attachEmptyDrawable); } else { albumView.imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, Theme.chat_attachEmptyDrawable); } } else { albumView.imageView.setImageDrawable(Theme.chat_attachEmptyDrawable); } albumView.nameTextView.setText(albumEntry.bucketName); albumView.countTextView.setText(String.format("%d", albumEntry.photos.size())); } else { albumViews[a].setVisibility(INVISIBLE); } }
Example #15
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (!needCamera || !deviceHasGoodCamera || position != 0) { if (needCamera && deviceHasGoodCamera) { position--; } PhotoAttachPhotoCell cell = (PhotoAttachPhotoCell) holder.itemView; MediaController.PhotoEntry photoEntry = getPhotoEntryAtPosition(position); cell.setPhotoEntry(photoEntry, needCamera, position == getItemCount() - 1); if (baseFragment instanceof ChatActivity && maxSelectedPhotos < 0) { cell.setChecked(selectedPhotosOrder.indexOf(photoEntry.imageId), selectedPhotos.containsKey(photoEntry.imageId), false); } else { cell.setChecked(-1, selectedPhotos.containsKey(photoEntry.imageId), false); } cell.getImageView().setTag(position); cell.setTag(position); cell.setIsVertical(this == cameraAttachAdapter && cameraPhotoLayoutManager.getOrientation() == LinearLayoutManager.VERTICAL); } else if (needCamera && deviceHasGoodCamera && position == 0) { if (cameraView != null && cameraView.isInitied()) { holder.itemView.setVisibility(View.INVISIBLE); } else { holder.itemView.setVisibility(View.VISIBLE); } } }
Example #16
Source File: PhotoPickerAlbumsCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setAlbum(int a, MediaController.AlbumEntry albumEntry) { albumEntries[a] = albumEntry; if (albumEntry != null) { AlbumView albumView = albumViews[a]; albumView.imageView.setOrientation(0, true); if (albumEntry.coverPhoto != null && albumEntry.coverPhoto.path != null) { albumView.imageView.setOrientation(albumEntry.coverPhoto.orientation, true); if (albumEntry.coverPhoto.isVideo) { albumView.imageView.setImage("vthumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, Theme.chat_attachEmptyDrawable); } else { albumView.imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, Theme.chat_attachEmptyDrawable); } } else { albumView.imageView.setImageDrawable(Theme.chat_attachEmptyDrawable); } albumView.nameTextView.setText(albumEntry.bucketName); albumView.countTextView.setText(String.format("%d", albumEntry.photos.size())); } else { albumViews[a].setVisibility(INVISIBLE); } }
Example #17
Source File: PhotoPickerAlbumsCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public PhotoPickerAlbumsCell(Context context) { super(context); albumEntries = new MediaController.AlbumEntry[4]; albumViews = new AlbumView[4]; for (int a = 0; a < 4; a++) { albumViews[a] = new AlbumView(context); addView(albumViews[a]); albumViews[a].setVisibility(INVISIBLE); albumViews[a].setTag(a); albumViews[a].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (delegate != null) { delegate.didSelectAlbum(albumEntries[(Integer) v.getTag()]); } } }); } }
Example #18
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 6 votes |
private int addToSelectedPhotos(MediaController.PhotoEntry object, int index) { Object key = object.imageId; if (selectedPhotos.containsKey(key)) { selectedPhotos.remove(key); int position = selectedPhotosOrder.indexOf(key); if (position >= 0) { selectedPhotosOrder.remove(position); } updatePhotosCounter(false); updateCheckedPhotoIndices(); if (index >= 0) { object.reset(); photoViewerProvider.updatePhotoAtIndex(index); } return position; } else { selectedPhotos.put(key, object); selectedPhotosOrder.add(key); updatePhotosCounter(true); return -1; } }
Example #19
Source File: PhotoPickerAlbumsCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void setAlbum(int a, MediaController.AlbumEntry albumEntry) { albumEntries[a] = albumEntry; if (albumEntry != null) { AlbumView albumView = albumViews[a]; albumView.imageView.setOrientation(0, true); if (albumEntry.coverPhoto != null && albumEntry.coverPhoto.path != null) { albumView.imageView.setOrientation(albumEntry.coverPhoto.orientation, true); if (albumEntry.coverPhoto.isVideo) { albumView.imageView.setImage("vthumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); } else { albumView.imageView.setImage("thumb://" + albumEntry.coverPhoto.imageId + ":" + albumEntry.coverPhoto.path, null, getContext().getResources().getDrawable(R.drawable.nophotos)); } } else { albumView.imageView.setImageResource(R.drawable.nophotos); } albumView.nameTextView.setText(albumEntry.bucketName); albumView.countTextView.setText(String.format("%d", albumEntry.photos.size())); } else { albumViews[a].setVisibility(INVISIBLE); } }
Example #20
Source File: FragmentContextView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void checkVisibility() { boolean show = false; if (isLocation) { if (fragment instanceof DialogsActivity) { show = LocationController.getLocationsCount() != 0; } else { show = LocationController.getInstance(fragment.getCurrentAccount()).isSharingLocation(((ChatActivity) fragment).getDialogId()); } } else { if (VoIPService.getSharedInstance() != null && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING) { show = true; } else { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject != null && messageObject.getId() != 0) { show = true; } } } setVisibility(show ? VISIBLE : GONE); }
Example #21
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public int getItemCount() { int count = 0; if (needCamera && deviceHasGoodCamera) { count++; } count += cameraPhotos.size(); MediaController.AlbumEntry albumEntry; if (baseFragment instanceof ChatActivity) { albumEntry = MediaController.allMediaAlbumEntry; } else { albumEntry = MediaController.allPhotosAlbumEntry; } if (albumEntry != null) { count += albumEntry.photos.size(); } return count; }
Example #22
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo) { if (selectedPhotos.isEmpty()) { if (selectedAlbum != null) { if (index < 0 || index >= selectedAlbum.photos.size()) { return; } MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index); photoEntry.editedInfo = videoEditedInfo; addToSelectedPhotos(photoEntry, -1); } else { ArrayList<MediaController.SearchImage> array; if (searchResult.isEmpty() && lastSearchString == null) { array = recentImages; } else { array = searchResult; } if (index < 0 || index >= array.size()) { return; } addToSelectedPhotos(array.get(index), -1); } } sendSelectedPhotos(); }
Example #23
Source File: SharedAudioCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void didPressedMiniButton(boolean animated) { if (miniButtonState == 0) { miniButtonState = 1; radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), true, 0); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } else if (miniButtonState == 1) { if (MediaController.getInstance().isPlayingMessage(currentMessageObject)) { MediaController.getInstance().cleanupPlayer(true, true); } miniButtonState = 0; FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } }
Example #24
Source File: AudioPlayerAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void updatePlaybackButton() { float currentPlaybackSpeed = MediaController.getInstance().getPlaybackSpeed(true); if (currentPlaybackSpeed > 1) { playbackSpeedButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_inappPlayerPlayPause), PorterDuff.Mode.MULTIPLY)); } else { playbackSpeedButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_inappPlayerClose), PorterDuff.Mode.MULTIPLY)); } }
Example #25
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View view = listView.getChildAt(a); if (view.getTag() == null) { continue; } PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view; int num = (Integer) view.getTag(); if (selectedAlbum != null) { if (num < 0 || num >= selectedAlbum.photos.size()) { continue; } } else { ArrayList<MediaController.SearchImage> array; if (searchResult.isEmpty() && lastSearchString == null) { array = recentImages; } else { array = searchResult; } if (num < 0 || num >= array.size()) { continue; } } if (num == index) { cell.showCheck(true); break; } } }
Example #26
Source File: ChatActivityEnterView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void cancelRecordingAudioVideo() { if (hasRecordVideo && videoSendButton.getTag() != null) { CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable); delegate.needStartRecordVideo(2); } else { delegate.needStartRecordAudio(0); MediaController.getInstance().stopRecording(0); } recordingAudioVideo = false; updateRecordIntefrace(); }
Example #27
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected void onDestroy() { super.onDestroy(); onFinish(); MediaController.getInstance().setFeedbackView(chatActivityEnterView, false); if (wakeLock.isHeld()) { wakeLock.release(); } if (avatarImageView != null) { avatarImageView.setImageDrawable(null); } }
Example #28
Source File: ChatAttachAlertPhotoLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void updateAlbumsDropDown() { dropDownContainer.removeAllSubItems(); if (mediaEnabled) { ArrayList<MediaController.AlbumEntry> albums; if (parentAlert.baseFragment instanceof ChatActivity) { albums = MediaController.allMediaAlbums; } else { albums = MediaController.allPhotoAlbums; } dropDownAlbums = new ArrayList<>(albums); Collections.sort(dropDownAlbums, (o1, o2) -> { if (o1.bucketId == 0 && o2.bucketId != 0) { return -1; } else if (o1.bucketId != 0 && o2.bucketId == 0) { return 1; } int index1 = albums.indexOf(o1); int index2 = albums.indexOf(o2); if (index1 > index2) { return 1; } else if (index1 < index2) { return -1; } else { return 0; } }); } else { dropDownAlbums = new ArrayList<>(); } if (dropDownAlbums.isEmpty()) { dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } else { dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, dropDownDrawable, null); for (int a = 0, N = dropDownAlbums.size(); a < N; a++) { dropDownContainer.addSubItem(10 + a, dropDownAlbums.get(a).bucketName); } } }
Example #29
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public RecyclerListView.Holder createHolder() { PhotoAttachPhotoCell cell = new PhotoAttachPhotoCell(mContext); cell.setDelegate(v -> { if (!mediaEnabled) { return; } int index = (Integer) v.getTag(); MediaController.PhotoEntry photoEntry = v.getPhotoEntry(); boolean added = !selectedPhotos.containsKey(photoEntry.imageId); if (added && maxSelectedPhotos >= 0 && selectedPhotos.size() >= maxSelectedPhotos) { return; } int num = added ? selectedPhotosOrder.size() : -1; if (baseFragment instanceof ChatActivity && maxSelectedPhotos < 0) { v.setChecked(num, added, true); } else { v.setChecked(-1, added, true); } addToSelectedPhotos(photoEntry, index); int updateIndex = index; if (PhotoAttachAdapter.this == cameraAttachAdapter) { if (photoAttachAdapter.needCamera && deviceHasGoodCamera) { updateIndex++; } photoAttachAdapter.notifyItemChanged(updateIndex); } else { cameraAttachAdapter.notifyItemChanged(updateIndex); } updatePhotosButton(); }); return new RecyclerListView.Holder(cell); }
Example #30
Source File: ChatAttachAlertPhotoLayout.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void updateAlbumsDropDown() { dropDownContainer.removeAllSubItems(); if (mediaEnabled) { ArrayList<MediaController.AlbumEntry> albums; if (parentAlert.baseFragment instanceof ChatActivity) { albums = MediaController.allMediaAlbums; } else { albums = MediaController.allPhotoAlbums; } dropDownAlbums = new ArrayList<>(albums); Collections.sort(dropDownAlbums, (o1, o2) -> { if (o1.bucketId == 0 && o2.bucketId != 0) { return -1; } else if (o1.bucketId != 0 && o2.bucketId == 0) { return 1; } int index1 = albums.indexOf(o1); int index2 = albums.indexOf(o2); if (index1 > index2) { return 1; } else if (index1 < index2) { return -1; } else { return 0; } }); } else { dropDownAlbums = new ArrayList<>(); } if (dropDownAlbums.isEmpty()) { dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } else { dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, dropDownDrawable, null); for (int a = 0, N = dropDownAlbums.size(); a < N; a++) { dropDownContainer.addSubItem(10 + a, dropDownAlbums.get(a).bucketName); } } }