Search in sources :

Example 1 with MediaPlaybackStatusOverlayView

use of com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView in project frostwire by frostwire.

the class FileListAdapter method initPlaybackStatusOverlayTouchFeedback.

private void initPlaybackStatusOverlayTouchFeedback(View view, final FileDescriptorItem item) {
    MediaPlaybackStatusOverlayView playbackStatusOverlayView = findView(view, inGridMode() ? R.id.view_my_files_thumbnail_grid_item_playback_overlay_view : R.id.view_my_files_thumbnail_list_item_playback_overlay_view);
    if (selectAllMode) {
        playbackStatusOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.NONE);
    }
    playbackStatusOverlayView.setTag(item);
    playbackStatusOverlayView.setOnClickListener(v -> {
        if (selectAllMode) {
            onItemClicked(v);
        } else {
            localPlay(item.fd, v, getViewPosition(v));
        }
    });
}
Also used : MediaPlaybackStatusOverlayView(com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView)

Example 2 with MediaPlaybackStatusOverlayView

use of com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView in project frostwire by frostwire.

the class FileListAdapter method populateViewPlain.

private void populateViewPlain(View view, FileDescriptorItem item) {
    FileDescriptor fd = item.fd;
    TextView title = findView(view, R.id.view_my_files_thumbnail_list_image_item_file_title);
    title.setText(fd.title);
    TextView fileExtra = findView(view, R.id.view_my_files_thumbnail_list_image_item_extra_text);
    if (fd.fileType == Constants.FILE_TYPE_AUDIO || fd.fileType == Constants.FILE_TYPE_APPLICATIONS) {
        fileExtra.setText(fd.artist);
    } else if (fd.fileType == Constants.FILE_TYPE_DOCUMENTS) {
        fileExtra.setText(FilenameUtils.getExtension(fd.filePath));
    } else {
        fileExtra.setText(R.string.empty_string);
    }
    TextView fileSize = findView(view, R.id.view_my_files_thumbnail_list_image_item_file_size);
    fileSize.setText(UIUtils.getBytesInHuman(fd.fileSize));
    ImageButton downloadButton = findView(view, inGridMode() ? R.id.view_my_files_thumbnail_grid_item_browse_thumbnail_image_button : R.id.view_my_files_thumbnail_list_item_browse_thumbnail_image_button);
    MediaPlaybackStatusOverlayView mediaOverlayView = findView(view, inGridMode() ? R.id.view_my_files_thumbnail_grid_item_playback_overlay_view : R.id.view_my_files_thumbnail_list_item_playback_overlay_view);
    CoreMediaPlayer mediaPlayer = Engine.instance().getMediaPlayer();
    if (mediaPlayer != null) {
        if (fd.equals(mediaPlayer.getCurrentFD(getContext())) || fd.equals(mediaPlayer.getSimplePlayerCurrentFD(getContext()))) {
            mediaOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.STOP);
        } else {
            mediaOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.PLAY);
        }
    }
    downloadButton.setTag(fd);
    downloadButton.setOnClickListener(downloadButtonClickListener);
    populateSDState(view, item);
}
Also used : ImageButton(android.widget.ImageButton) CoreMediaPlayer(com.frostwire.android.core.player.CoreMediaPlayer) TextView(android.widget.TextView) FileDescriptor(com.frostwire.android.core.FileDescriptor) MediaPlaybackStatusOverlayView(com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView)

Example 3 with MediaPlaybackStatusOverlayView

use of com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView in project frostwire by frostwire.

the class SearchResultListAdapter method populateThumbnail.

private void populateThumbnail(View view, SearchResult sr) {
    ImageView fileTypeIcon = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon);
    if (sr.getThumbnailUrl() != null) {
        thumbLoader.load(Uri.parse(sr.getThumbnailUrl()), fileTypeIcon, 96, 96, getFileTypeIconId());
    }
    MediaPlaybackStatusOverlayView overlayView = findView(view, R.id.view_bittorrent_search_result_list_item_filetype_icon_media_playback_overlay_view);
    fileTypeIcon.setOnClickListener(previewClickListener);
    if (isAudio(sr) || sr instanceof YouTubePackageSearchResult) {
        fileTypeIcon.setTag(sr);
        overlayView.setTag(sr);
        overlayView.setVisibility(View.VISIBLE);
        overlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.PREVIEW);
        overlayView.setOnClickListener(previewClickListener);
    } else {
        fileTypeIcon.setTag(null);
        overlayView.setTag(null);
        overlayView.setVisibility(View.GONE);
        overlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.NONE);
    }
}
Also used : YouTubePackageSearchResult(com.frostwire.search.youtube.YouTubePackageSearchResult) ImageView(android.widget.ImageView) MediaPlaybackStatusOverlayView(com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView)

Example 4 with MediaPlaybackStatusOverlayView

use of com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView in project frostwire by frostwire.

the class FileListAdapter method initCheckableGridImageView.

protected void initCheckableGridImageView(ViewGroup view, final FileDescriptorItem item) throws Throwable {
    boolean isChecked = getChecked().contains(item);
    boolean showFileSize = false;
    Uri[] uris = getFileItemThumbnailUris(item);
    MediaPlaybackStatusOverlayView playbackStatusOverlayView = findView(view, R.id.view_my_files_thumbnail_grid_item_playback_overlay_view);
    MediaPlaybackOverlayPainter.MediaPlaybackState overlayPlaybackState = MediaPlaybackOverlayPainter.MediaPlaybackState.NONE;
    int thumbnailResizeWidth = (item.fd.fileType == Constants.FILE_TYPE_VIDEOS) ? 512 : 196;
    if (item.fd.fileType == Constants.FILE_TYPE_VIDEOS && !selectAllMode) {
        overlayPlaybackState = MediaPlaybackOverlayPainter.MediaPlaybackState.PLAY;
        showFileSize = true;
    }
    // TODO: why CheckableImageView needs to exist is hard to explain, I (aldenml) think that
    // it's better to move the logic to use in place and improve code locality
    final CheckableImageView checkableView = new CheckableImageView(view.getContext(), view, playbackStatusOverlayView, overlayPlaybackState, // re-sizes while keeping aspect ratio based only on given height
    thumbnailResizeWidth, 0, uris, isChecked, showFileSize);
    checkableView.setCheckableMode(selectAllMode);
    checkableView.loadImages();
    if (showFileSize) {
        checkableView.setFileSize(item.fd.fileSize);
    }
}
Also used : MediaPlaybackOverlayPainter(com.frostwire.android.gui.views.MediaPlaybackOverlayPainter) Uri(android.net.Uri) MediaPlaybackStatusOverlayView(com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView)

Example 5 with MediaPlaybackStatusOverlayView

use of com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView in project frostwire by frostwire.

the class FileListAdapter method populateViewThumbnail.

private void populateViewThumbnail(View view, FileDescriptorItem item) {
    FileDescriptor fd = item.fd;
    final ImageButton fileThumbnail = findView(view, inGridMode() ? R.id.view_my_files_thumbnail_grid_item_browse_thumbnail_image_button : R.id.view_my_files_thumbnail_list_item_browse_thumbnail_image_button);
    fileThumbnail.setScaleType(ImageView.ScaleType.CENTER_CROP);
    MediaPlaybackStatusOverlayView mediaOverlayView = findView(view, inGridMode() ? R.id.view_my_files_thumbnail_grid_item_playback_overlay_view : R.id.view_my_files_thumbnail_list_item_playback_overlay_view);
    boolean inGridMode = inGridMode();
    final int thumbnailDimensions = inGridMode ? 256 : 96;
    if (fileType == Constants.FILE_TYPE_APPLICATIONS) {
        Uri uri = ImageLoader.getApplicationArtUri(fd.album);
        thumbnailLoader.load(uri, fileThumbnail, thumbnailDimensions, thumbnailDimensions);
    } else {
        if (in(fileType, Constants.FILE_TYPE_AUDIO, Constants.FILE_TYPE_VIDEOS)) {
            if (fd.equals(Engine.instance().getMediaPlayer().getCurrentFD(getContext()))) {
                mediaOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.STOP);
            } else {
                mediaOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.PLAY);
            }
        } else if (fileType == Constants.FILE_TYPE_RINGTONES) {
            if (fd.equals(Engine.instance().getMediaPlayer().getSimplePlayerCurrentFD(getContext()))) {
                mediaOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.STOP);
            } else {
                mediaOverlayView.setPlaybackState(MediaPlaybackOverlayPainter.MediaPlaybackState.PLAY);
            }
        }
        if (fd.fileType == Constants.FILE_TYPE_AUDIO) {
            Uri uri = ImageLoader.getAlbumArtUri(fd.albumId);
            Uri uriRetry = ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, fd.id);
            uriRetry = ImageLoader.getMetadataArtUri(uriRetry);
            thumbnailLoader.load(uri, uriRetry, fileThumbnail, thumbnailDimensions, thumbnailDimensions);
        } else if (fd.fileType == Constants.FILE_TYPE_VIDEOS) {
            Uri uri = ContentUris.withAppendedId(Video.Media.EXTERNAL_CONTENT_URI, fd.id);
            Uri uriRetry = ImageLoader.getMetadataArtUri(uri);
            thumbnailLoader.load(uri, uriRetry, fileThumbnail, thumbnailDimensions, thumbnailDimensions);
        } else if (fd.fileType == Constants.FILE_TYPE_PICTURES) {
            Uri uri = ContentUris.withAppendedId(Images.Media.EXTERNAL_CONTENT_URI, fd.id);
            thumbnailLoader.load(uri, fileThumbnail, thumbnailDimensions, thumbnailDimensions);
        }
    }
    if (!inGridMode) {
        TextView title = findView(view, R.id.view_my_files_thumbnail_list_image_item_file_title);
        title.setText(fd.title);
        if (fd.fileType == Constants.FILE_TYPE_AUDIO || fd.fileType == Constants.FILE_TYPE_APPLICATIONS) {
            TextView fileExtra = findView(view, R.id.view_my_files_thumbnail_list_image_item_extra_text);
            fileExtra.setText(fd.artist);
        } else {
            TextView fileExtra = findView(view, R.id.view_my_files_thumbnail_list_image_item_extra_text);
            fileExtra.setText(R.string.empty_string);
        }
        TextView fileSize = findView(view, R.id.view_my_files_thumbnail_list_image_item_file_size);
        fileSize.setText(UIUtils.getBytesInHuman(fd.fileSize));
    }
    fileThumbnail.setTag(fd);
    fileThumbnail.setOnClickListener(downloadButtonClickListener);
    populateSDState(view, item);
}
Also used : ImageButton(android.widget.ImageButton) TextView(android.widget.TextView) Uri(android.net.Uri) FileDescriptor(com.frostwire.android.core.FileDescriptor) MediaPlaybackStatusOverlayView(com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView)

Aggregations

MediaPlaybackStatusOverlayView (com.frostwire.android.gui.views.MediaPlaybackStatusOverlayView)5 Uri (android.net.Uri)2 ImageButton (android.widget.ImageButton)2 TextView (android.widget.TextView)2 FileDescriptor (com.frostwire.android.core.FileDescriptor)2 ImageView (android.widget.ImageView)1 CoreMediaPlayer (com.frostwire.android.core.player.CoreMediaPlayer)1 MediaPlaybackOverlayPainter (com.frostwire.android.gui.views.MediaPlaybackOverlayPainter)1 YouTubePackageSearchResult (com.frostwire.search.youtube.YouTubePackageSearchResult)1