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();
}
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();
}
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);
}
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())));
}
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);
}
Aggregations