Search in sources :

Example 31 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class BaseBrowserFragment method onDestroyActionMode.

@Override
public void onDestroyActionMode(ActionMode mode) {
    mActionMode = null;
    int index = -1;
    for (MediaLibraryItem media : mAdapter.getAll()) {
        ++index;
        if (media.hasStateFlags(MediaLibraryItem.FLAG_SELECTED)) {
            media.removeStateFlags(MediaLibraryItem.FLAG_SELECTED);
            mAdapter.notifyItemChanged(index, media);
        }
    }
    mAdapter.resetSelectionCount();
}
Also used : MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem)

Example 32 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class BaseBrowserFragment method browse.

public void browse(MediaWrapper media, int position, boolean save) {
    if (!isResumed() || isRemoving())
        return;
    mBrowserHandler.removeCallbacksAndMessages(null);
    final FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
    final Fragment next = createFragment();
    final Bundle args = new Bundle();
    if (!mRoot)
        VLCApplication.storeData(KEY_MEDIA_LIST + mMrl, mAdapter.getAll());
    VLCApplication.storeData(KEY_CONTENT_LIST + mMrl, mFoldersContentLists);
    final List<MediaLibraryItem> list = mFoldersContentLists.get(media);
    if (!Util.isListEmpty(list) && !(this instanceof StorageBrowserFragment))
        VLCApplication.storeData(KEY_MEDIA_LIST + media.getLocation(), list);
    args.putParcelable(KEY_MEDIA, media);
    next.setArguments(args);
    if (isRootDirectory())
        ft.hide(this);
    else
        ft.remove(this);
    if (save)
        ft.addToBackStack(mRoot ? "root" : mMrl);
    ft.add(R.id.fragment_placeholder, next, media.getLocation());
    ft.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) Bundle(android.os.Bundle) Fragment(android.support.v4.app.Fragment)

Example 33 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class StorageBrowserFragment method browseRoot.

@Override
protected void browseRoot() {
    String[] storages = AndroidDevices.getMediaDirectories();
    String[] customDirectories = CustomDirectories.getCustomDirectories();
    Storage storage;
    final ArrayList<MediaLibraryItem> storagesList = new ArrayList<>();
    for (String mediaDirLocation : storages) {
        if (TextUtils.isEmpty(mediaDirLocation))
            continue;
        storage = new Storage(Uri.fromFile(new File(mediaDirLocation)));
        if (TextUtils.equals(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY, mediaDirLocation))
            storage.setName(getString(R.string.internal_memory));
        storagesList.add(storage);
    }
    customLoop: for (String customDir : customDirectories) {
        for (String mediaDirLocation : storages) {
            if (TextUtils.isEmpty(mediaDirLocation))
                continue;
            if (customDir.startsWith(mediaDirLocation))
                continue customLoop;
        }
        storage = new Storage(Uri.parse(customDir));
        storagesList.add(storage);
    }
    VLCApplication.runOnMainThread(new Runnable() {

        @Override
        public void run() {
            mAdapter.update(storagesList);
        }
    });
    mHandler.sendEmptyMessage(BrowserFragmentHandler.MSG_HIDE_LOADING);
}
Also used : Storage(org.videolan.medialibrary.media.Storage) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) ArrayList(java.util.ArrayList) File(java.io.File)

Example 34 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class SavePlaylistDialog method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mListView = view.findViewById(android.R.id.list);
    mSaveButton = view.findViewById(R.id.dialog_playlist_save);
    mCancelButton = view.findViewById(R.id.dialog_playlist_cancel);
    mEmptyView = view.findViewById(android.R.id.empty);
    TextInputLayout mLayout = view.findViewById(R.id.dialog_playlist_name);
    mEditText = mLayout.getEditText();
    mSaveButton.setOnClickListener(this);
    mCancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mEditText.setOnEditorActionListener(this);
    mListView.setLayoutManager(new LinearLayoutManager(view.getContext()));
    mListView.setAdapter(mAdapter);
    mAdapter.update(new ArrayList<MediaLibraryItem>(Arrays.asList(mMedialibrary.getPlaylists())));
}
Also used : MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) TextInputLayout(android.support.design.widget.TextInputLayout) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 35 with MediaLibraryItem

use of org.videolan.medialibrary.media.MediaLibraryItem in project vlc-android by videolan.

the class TvUtil method updateBackground.

@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static void updateBackground(final BackgroundManager bm, Object item) {
    if (bm == null)
        return;
    if (item instanceof MediaLibraryItem) {
        final boolean crop = ((MediaLibraryItem) item).getItemType() != MediaLibraryItem.TYPE_MEDIA || ((MediaWrapper) item).getType() == MediaWrapper.TYPE_AUDIO;
        final String artworkMrl = ((MediaLibraryItem) item).getArtworkMrl();
        if (!TextUtils.isEmpty(artworkMrl)) {
            VLCApplication.runBackground(new Runnable() {

                @Override
                public void run() {
                    if (bm == null)
                        return;
                    Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(artworkMrl), 512);
                    if (cover == null)
                        return;
                    if (crop)
                        cover = BitmapUtil.centerCrop(cover, cover.getWidth(), cover.getWidth() * 10 / 16);
                    final Bitmap blurred = UiTools.blurBitmap(cover, 10f);
                    VLCApplication.runOnMainThread(new Runnable() {

                        @Override
                        public void run() {
                            if (bm == null)
                                return;
                            bm.setColor(0);
                            bm.setDrawable(new BitmapDrawable(VLCApplication.getAppResources(), blurred));
                        }
                    });
                }
            });
            return;
        }
    }
    clearBackground(bm);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)46 ArrayList (java.util.ArrayList)25 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)23 Bitmap (android.graphics.Bitmap)8 BitmapDrawable (android.graphics.drawable.BitmapDrawable)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)8 List (java.util.List)7 View (android.view.View)6 RecyclerView (android.support.v7.widget.RecyclerView)5 TextView (android.widget.TextView)4 Playlist (org.videolan.medialibrary.media.Playlist)4 Bundle (android.os.Bundle)3 LinkedList (java.util.LinkedList)3 Storage (org.videolan.medialibrary.media.Storage)3 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)3 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 WorkerThread (android.support.annotation.WorkerThread)2 TextInputLayout (android.support.design.widget.TextInputLayout)2 ImageCardView (android.support.v17.leanback.widget.ImageCardView)2