Search in sources :

Example 1 with AudioBrowserAdapter

use of org.videolan.vlc.gui.audio.AudioBrowserAdapter in project vlc-android by videolan.

the class SavePlaylistDialog method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMedialibrary = VLCApplication.getMLInstance();
    mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_PLAYLIST, this, false);
    mTracks = (MediaWrapper[]) getArguments().getParcelableArray(KEY_TRACKS);
    mNewTrack = (MediaWrapper[]) getArguments().getParcelableArray(KEY_NEW_TRACKS);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) AudioBrowserAdapter(org.videolan.vlc.gui.audio.AudioBrowserAdapter)

Example 2 with AudioBrowserAdapter

use of org.videolan.vlc.gui.audio.AudioBrowserAdapter in project vlc-android by GeoffreyMetais.

the class PlaylistActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.playlist_activity);
    initAudioPlayerContainerActivity();
    mFragmentContainer = findViewById(R.id.container_list);
    mOriginalBottomPadding = mFragmentContainer.getPaddingBottom();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mPlaylist = (MediaLibraryItem) (savedInstanceState != null ? savedInstanceState.getParcelable(AudioBrowserFragment.TAG_ITEM) : getIntent().getParcelableExtra(AudioBrowserFragment.TAG_ITEM));
    mIsPlaylist = mPlaylist.getItemType() == MediaLibraryItem.TYPE_PLAYLIST;
    mBinding.setPlaylist(mPlaylist);
    mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this);
    mBinding.songs.setLayoutManager(new LinearLayoutManager(this));
    mBinding.songs.setAdapter(mAdapter);
    tracksProvider = ViewModelProviders.of(this, new TracksProvider.Factory(mPlaylist)).get(TracksProvider.class);
    tracksProvider.getDataset().observe(this, new Observer<List<MediaLibraryItem>>() {

        @Override
        public void onChanged(@Nullable List<MediaLibraryItem> tracks) {
            if (tracks != null)
                mAdapter.update(tracks);
        }
    });
    final int fabVisibility = savedInstanceState != null ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
    if (!TextUtils.isEmpty(mPlaylist.getArtworkMrl())) {
        WorkersKt.runBackground(new Runnable() {

            @Override
            public void run() {
                final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(mPlaylist.getArtworkMrl()), 0);
                if (cover != null) {
                    mBinding.setCover(new BitmapDrawable(PlaylistActivity.this.getResources(), cover));
                    WorkersKt.runOnMainThread(new Runnable() {

                        @Override
                        public void run() {
                            mBinding.appbar.setExpanded(true, true);
                            if (fabVisibility != -1)
                                mBinding.fab.setVisibility(fabVisibility);
                        }
                    });
                } else
                    WorkersKt.runOnMainThread(new Runnable() {

                        @Override
                        public void run() {
                            fabFallback();
                        }
                    });
            }
        });
    } else
        fabFallback();
    mBinding.fab.setOnClickListener(this);
}
Also used : MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Bitmap(android.graphics.Bitmap) TracksProvider(org.videolan.vlc.viewmodels.audio.TracksProvider) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) AudioBrowserAdapter(org.videolan.vlc.gui.audio.AudioBrowserAdapter)

Example 3 with AudioBrowserAdapter

use of org.videolan.vlc.gui.audio.AudioBrowserAdapter in project vlc-android by videolan.

the class PlaylistActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.playlist_activity);
    initAudioPlayerContainerActivity();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mPlaylist = (MediaLibraryItem) (savedInstanceState != null ? savedInstanceState.getParcelable(AudioBrowserFragment.TAG_ITEM) : getIntent().getParcelableExtra(AudioBrowserFragment.TAG_ITEM));
    mIsPlaylist = mPlaylist.getItemType() == MediaLibraryItem.TYPE_PLAYLIST;
    mBinding.setPlaylist(mPlaylist);
    mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, false);
    mBinding.songs.setLayoutManager(new LinearLayoutManager(this));
    mBinding.songs.setAdapter(mAdapter);
    final int fabVisibility = savedInstanceState != null ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
    if (!TextUtils.isEmpty(mPlaylist.getArtworkMrl())) {
        VLCApplication.runBackground(new Runnable() {

            @Override
            public void run() {
                final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(mPlaylist.getArtworkMrl()), 0);
                if (cover != null) {
                    mBinding.setCover(new BitmapDrawable(PlaylistActivity.this.getResources(), cover));
                    VLCApplication.runOnMainThread(new Runnable() {

                        @Override
                        public void run() {
                            mBinding.appbar.setExpanded(true, true);
                            if (fabVisibility != -1)
                                mBinding.fab.setVisibility(fabVisibility);
                        }
                    });
                } else
                    VLCApplication.runOnMainThread(new Runnable() {

                        @Override
                        public void run() {
                            fabFallback();
                        }
                    });
            }
        });
    } else
        fabFallback();
    mBinding.fab.setOnClickListener(this);
}
Also used : Bitmap(android.graphics.Bitmap) AudioBrowserAdapter(org.videolan.vlc.gui.audio.AudioBrowserAdapter) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 4 with AudioBrowserAdapter

use of org.videolan.vlc.gui.audio.AudioBrowserAdapter in project vlc-android by GeoffreyMetais.

the class SavePlaylistDialog method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMedialibrary = VLCApplication.getMLInstance();
    mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_PLAYLIST, this);
    mTracks = (MediaWrapper[]) getArguments().getParcelableArray(KEY_TRACKS);
    mNewTrack = (MediaWrapper[]) getArguments().getParcelableArray(KEY_NEW_TRACKS);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) AudioBrowserAdapter(org.videolan.vlc.gui.audio.AudioBrowserAdapter)

Aggregations

AudioBrowserAdapter (org.videolan.vlc.gui.audio.AudioBrowserAdapter)4 Bitmap (android.graphics.Bitmap)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)1 TracksProvider (org.videolan.vlc.viewmodels.audio.TracksProvider)1