Search in sources :

Example 1 with MediaInfoAdapter

use of org.videolan.vlc.gui.video.MediaInfoAdapter in project vlc-android by GeoffreyMetais.

the class InfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.info_activity);
    initAudioPlayerContainerActivity();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mItem = (MediaLibraryItem) (savedInstanceState != null ? savedInstanceState.getParcelable(TAG_ITEM) : getIntent().getParcelableExtra(TAG_ITEM));
    if (mItem == null) {
        finish();
        return;
    }
    if (mItem.getId() == 0L) {
        MediaLibraryItem libraryItem = VLCApplication.getMLInstance().getMedia(((MediaWrapper) mItem).getUri());
        if (libraryItem != null)
            mItem = libraryItem;
    }
    mBinding.setItem(mItem);
    final int fabVisibility = savedInstanceState != null ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
    if (!TextUtils.isEmpty(mItem.getArtworkMrl())) {
        WorkersKt.runBackground(new Runnable() {

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

                        @Override
                        public void run() {
                            ViewCompat.setNestedScrollingEnabled(mBinding.container, true);
                            mBinding.appbar.setExpanded(true, true);
                            if (fabVisibility != -1)
                                mBinding.fab.setVisibility(fabVisibility);
                        }
                    });
                } else
                    noCoverFallback();
            }
        });
    } else
        noCoverFallback();
    mBinding.fab.setOnClickListener(this);
    if (mItem.getItemType() == MediaLibraryItem.TYPE_MEDIA) {
        mAdapter = new MediaInfoAdapter();
        mBinding.list.setLayoutManager(new LinearLayoutManager(mBinding.getRoot().getContext()));
        mBinding.list.setAdapter(mAdapter);
        mCheckFileTask = (CheckFileTask) new CheckFileTask().execute();
        mParseTracksTask = (ParseTracksTask) new ParseTracksTask().execute();
    }
    WorkersKt.runBackground(new Runnable() {

        @Override
        public void run() {
            updateMeta();
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MediaInfoAdapter(org.videolan.vlc.gui.video.MediaInfoAdapter)

Example 2 with MediaInfoAdapter

use of org.videolan.vlc.gui.video.MediaInfoAdapter in project vlc-android by videolan.

the class InfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBinding = DataBindingUtil.setContentView(this, R.layout.info_activity);
    initAudioPlayerContainerActivity();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mItem = (MediaLibraryItem) (savedInstanceState != null ? savedInstanceState.getParcelable(TAG_ITEM) : getIntent().getParcelableExtra(TAG_ITEM));
    if (mItem == null) {
        finish();
        return;
    }
    if (mItem.getId() == 0L) {
        MediaLibraryItem libraryItem = VLCApplication.getMLInstance().getMedia(((MediaWrapper) mItem).getUri());
        if (libraryItem != null)
            mItem = libraryItem;
    }
    mBinding.setItem(mItem);
    final int fabVisibility = savedInstanceState != null ? savedInstanceState.getInt(TAG_FAB_VISIBILITY) : -1;
    if (!TextUtils.isEmpty(mItem.getArtworkMrl())) {
        VLCApplication.runBackground(new Runnable() {

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

                        @Override
                        public void run() {
                            ViewCompat.setNestedScrollingEnabled(mBinding.container, true);
                            mBinding.appbar.setExpanded(true, true);
                            if (fabVisibility != -1)
                                mBinding.fab.setVisibility(fabVisibility);
                        }
                    });
                } else
                    noCoverFallback();
            }
        });
    } else
        noCoverFallback();
    mBinding.fab.setOnClickListener(this);
    if (mItem.getItemType() == MediaLibraryItem.TYPE_MEDIA) {
        mAdapter = new MediaInfoAdapter();
        mBinding.list.setLayoutManager(new LinearLayoutManager(mBinding.getRoot().getContext()));
        mBinding.list.setAdapter(mAdapter);
        mCheckFileTask = (CheckFileTask) new CheckFileTask().execute();
        mParseTracksTask = (ParseTracksTask) new ParseTracksTask().execute();
    }
    VLCApplication.runBackground(new Runnable() {

        @Override
        public void run() {
            updateMeta();
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MediaInfoAdapter(org.videolan.vlc.gui.video.MediaInfoAdapter)

Aggregations

Bitmap (android.graphics.Bitmap)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)2 MediaInfoAdapter (org.videolan.vlc.gui.video.MediaInfoAdapter)2