Java Code Examples for org.telegram.messenger.MediaController#AlbumEntry

The following examples show how to use org.telegram.messenger.MediaController#AlbumEntry . 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: PhotoPickerAlbumsCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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 3
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onRevealAnimationEnd(boolean open) {
    NotificationCenter.getInstance(currentAccount).setAnimationInProgress(false);
    revealAnimationInProgress = false;
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (open && Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
    if (open) {
        checkCamera(true);
        showHint();
    }
}
 
Example 4
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void init() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry != null) {
        for (int a = 0; a < Math.min(100, albumEntry.photos.size()); a++) {
            MediaController.PhotoEntry photoEntry = albumEntry.photos.get(a);
            photoEntry.reset();
        }
    }
    if (currentHintAnimation != null) {
        currentHintAnimation.cancel();
        currentHintAnimation = null;
    }
    hintTextView.setAlpha(0.0f);
    hintTextView.setVisibility(View.INVISIBLE);
    attachPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    cameraPhotoLayoutManager.scrollToPositionWithOffset(0, 1000000);
    clearSelectedPhotos();
    layoutManager.scrollToPositionWithOffset(0, 1000000);
    updatePhotosButton();
}
 
Example 5
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
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 6
Source File: PhotoPickerAlbumsCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
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 7
Source File: PhotoPickerAlbumsCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
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 8
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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 9
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
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 10
Source File: PhotoPickerAlbumsCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
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(v -> {
            if (delegate != null) {
                delegate.didSelectAlbum(albumEntries[(Integer) v.getTag()]);
            }
        });
    }
}
 
Example 11
Source File: ChatAttachAlertPhotoLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (parentAlert.baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 12
Source File: ChatAttachAlertPhotoLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (parentAlert.baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 13
Source File: PhotoPickerActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public PhotoPickerActivity(int type, MediaController.AlbumEntry selectedAlbum, HashMap<Object, Object> selectedPhotos, ArrayList<Object> selectedPhotosOrder, ArrayList<MediaController.SearchImage> recentImages, boolean onlyOnePhoto, boolean allowCaption, ChatActivity chatActivity) {
    super();
    this.selectedAlbum = selectedAlbum;
    this.selectedPhotos = selectedPhotos;
    this.selectedPhotosOrder = selectedPhotosOrder;
    this.type = type;
    this.recentImages = recentImages;
    this.singlePhoto = onlyOnePhoto;
    this.chatActivity = chatActivity;
    this.allowCaption = allowCaption;
}
 
Example 14
Source File: ChatAttachAlertPhotoLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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 15
Source File: PhotoAlbumPickerActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
    if (holder.getItemViewType() == 0)
    {
        PhotoPickerAlbumsCell photoPickerAlbumsCell = (PhotoPickerAlbumsCell) holder.itemView;
        photoPickerAlbumsCell.setAlbumsCount(columnsCount);
        for (int a = 0; a < columnsCount; a++)
        {
            int index;
            if (singlePhoto || !allowSearchImages)
            {
                index = position * columnsCount + a;
            }
            else
            {
                index = (position - 1) * columnsCount + a;
            }
            if (index < albumsSorted.size())
            {
                MediaController.AlbumEntry albumEntry = albumsSorted.get(index);
                photoPickerAlbumsCell.setAlbum(a, albumEntry);
            }
            else
            {
                photoPickerAlbumsCell.setAlbum(a, null);
            }
        }
        photoPickerAlbumsCell.requestLayout();
    }
}
 
Example 16
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void loadGalleryPhotos() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (albumEntry == null && Build.VERSION.SDK_INT >= 21) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
}
 
Example 17
Source File: ChatAttachAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onOpenAnimationEnd() {
    MediaController.AlbumEntry albumEntry;
    if (baseFragment instanceof ChatActivity) {
        albumEntry = MediaController.allMediaAlbumEntry;
    } else {
        albumEntry = MediaController.allPhotosAlbumEntry;
    }
    if (Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
        MediaController.loadGalleryPhotosAlbums(0);
    }
    currentAttachLayout.onOpenAnimationEnd();
    AndroidUtilities.makeAccessibilityAnnouncement(LocaleController.getString("AccDescrAttachButton", R.string.AccDescrAttachButton));
}
 
Example 18
Source File: PhotoAlbumPickerActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    PhotoPickerAlbumsCell photoPickerAlbumsCell = (PhotoPickerAlbumsCell) holder.itemView;
    photoPickerAlbumsCell.setAlbumsCount(columnsCount);
    for (int a = 0; a < columnsCount; a++) {
        int index = position * columnsCount + a;
        if (index < albumsSorted.size()) {
            MediaController.AlbumEntry albumEntry = albumsSorted.get(index);
            photoPickerAlbumsCell.setAlbum(a, albumEntry);
        } else {
            photoPickerAlbumsCell.setAlbum(a, null);
        }
    }
    photoPickerAlbumsCell.requestLayout();
}
 
Example 19
Source File: PhotoPickerAlbumsCell.java    From TelePlus-Android with GNU General Public License v2.0 votes vote down vote up
void didSelectAlbum(MediaController.AlbumEntry albumEntry); 
Example 20
Source File: PhotoPickerAlbumsCell.java    From TelePlus-Android with GNU General Public License v2.0 votes vote down vote up
void didSelectAlbum(MediaController.AlbumEntry albumEntry);