Commit c3a621bc authored by Geoffrey Métais's avatar Geoffrey Métais

Move media related Util methods to MediaUtils

parent a53adc46
......@@ -20,17 +20,17 @@
*****************************************************************************/
package org.videolan.vlc.gui.tv;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.gui.browser.BaseBrowserFragment;
import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.util.Strings;
import android.app.Activity;
import android.content.Intent;
import android.os.Parcelable;
import android.support.v17.leanback.widget.Row;
import org.videolan.vlc.gui.browser.BaseBrowserFragment;
import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
public class TvUtil {
......@@ -38,7 +38,7 @@ public class TvUtil {
if (item instanceof MediaWrapper) {
MediaWrapper mediaWrapper = (MediaWrapper) item;
if (mediaWrapper.getType() == MediaWrapper.TYPE_VIDEO) {
VideoPlayerActivity.start(activity, mediaWrapper.getUri(), Strings.getMediaTitle(mediaWrapper));
VideoPlayerActivity.start(activity, mediaWrapper.getUri(), MediaUtils.getMediaTitle(mediaWrapper));
} else if (mediaWrapper.getType() == MediaWrapper.TYPE_AUDIO) {
Intent intent = new Intent(activity,
DetailsActivity.class);
......
......@@ -27,9 +27,8 @@ import android.view.ViewGroup;
import android.widget.TextView;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import java.util.ArrayList;
......@@ -74,8 +73,8 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
MediaWrapper mediaWrapper = mDataset.get(position);
holder.mTitleTv.setText(Strings.getMediaTitle(mediaWrapper));
holder.mArtistTv.setText(Util.getMediaArtist(holder.itemView.getContext(), mediaWrapper));
holder.mTitleTv.setText(MediaUtils.getMediaTitle(mediaWrapper));
holder.mArtistTv.setText(MediaUtils.getMediaArtist(holder.itemView.getContext(), mediaWrapper));
holder.itemView.setActivated(position == mSelectedItem);
holder.itemView.setOnClickListener(this);
}
......
......@@ -26,8 +26,8 @@ package org.videolan.vlc.gui.tv.browser;
import android.os.Bundle;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.Util;
import java.util.concurrent.CyclicBarrier;
......@@ -45,7 +45,7 @@ public abstract class MediaLibBrowserFragment extends GridFragment {
public void onResume() {
super.onResume();
if (mMediaLibrary.isWorking())
Util.actionScanStart();
MediaUtils.actionScanStart();
}
public void onPause() {
......
......@@ -68,6 +68,7 @@ import org.videolan.vlc.gui.AudioPlayerContainerActivity;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.media.MediaWrapperList;
import org.videolan.vlc.util.Util;
......@@ -1065,10 +1066,10 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
Bitmap cover = AudioUtil.getCover(this, media, 512);
MediaMetadataCompat.Builder bob = new MediaMetadataCompat.Builder();
bob.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
.putString(MediaMetadataCompat.METADATA_KEY_GENRE, Util.getMediaGenre(this, media))
.putString(MediaMetadataCompat.METADATA_KEY_GENRE, MediaUtils.getMediaGenre(this, media))
.putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, media.getTrackNumber())
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, Util.getMediaReferenceArtist(this, media))
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, Util.getMediaAlbum(this, media))
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, MediaUtils.getMediaReferenceArtist(this, media))
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, MediaUtils.getMediaAlbum(this, media))
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, media.getLength());
if (cover != null && cover.getConfig() != null) //In case of format not supported
bob.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, cover.copy(cover.getConfig(), false));
......@@ -1077,8 +1078,8 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
//Send metadata to Pebble watch
if (mPebbleEnabled) {
final Intent i = new Intent("com.getpebble.action.NOW_PLAYING");
i.putExtra("artist", Util.getMediaArtist(this, media));
i.putExtra("album", Util.getMediaAlbum(this, media));
i.putExtra("artist", MediaUtils.getMediaArtist(this, media));
i.putExtra("album", MediaUtils.getMediaAlbum(this, media));
i.putExtra("track", media.getTitle());
sendBroadcast(i);
}
......@@ -1191,7 +1192,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
i.putExtra("title", media.getTitle());
i.putExtra("artist", media.isArtistUnknown() && media.getNowPlaying() != null ?
media.getNowPlaying()
: Util.getMediaArtist(this, media));
: MediaUtils.getMediaArtist(this, media));
}
else {
i.putExtra("title", getString(R.string.widget_default_text));
......@@ -1366,7 +1367,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@MainThread
public String getAlbum() {
if (hasCurrentMedia())
return Util.getMediaAlbum(PlaybackService.this, getCurrentMedia());
return MediaUtils.getMediaAlbum(PlaybackService.this, getCurrentMedia());
else
return null;
}
......@@ -1377,7 +1378,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
final MediaWrapper media = getCurrentMedia();
return media.isArtistUnknown() && media.getNowPlaying() != null ?
media.getNowPlaying()
: Util.getMediaArtist(PlaybackService.this, media);
: MediaUtils.getMediaArtist(PlaybackService.this, media);
} else
return null;
}
......@@ -1385,7 +1386,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@MainThread
public String getArtistPrev() {
if (mPrevIndex != -1)
return Util.getMediaArtist(PlaybackService.this, mMediaList.getMedia(mPrevIndex));
return MediaUtils.getMediaArtist(PlaybackService.this, mMediaList.getMedia(mPrevIndex));
else
return null;
}
......@@ -1393,7 +1394,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@MainThread
public String getArtistNext() {
if (mNextIndex != -1)
return Util.getMediaArtist(PlaybackService.this, mMediaList.getMedia(mNextIndex));
return MediaUtils.getMediaArtist(PlaybackService.this, mMediaList.getMedia(mNextIndex));
else
return null;
}
......
......@@ -30,11 +30,11 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import java.util.ArrayList;
......@@ -90,7 +90,7 @@ public class HistoryAdapter extends BaseAdapter {
Log.d(TAG, "Loading media position " + position + " - " + m.getTitle());
holder.title.setText(m.getTitle());
holderText = Util.getMediaSubtitle(VLCApplication.getAppContext(), m);
holderText = MediaUtils.getMediaSubtitle(VLCApplication.getAppContext(), m);
holder.text.setText(holderText);
Bitmap b = AudioUtil.getCover(VLCApplication.getAppContext(), m, 64);
......
......@@ -77,6 +77,7 @@ import org.videolan.vlc.gui.video.VideoListAdapter;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.interfaces.IRefreshable;
import org.videolan.vlc.interfaces.ISortable;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
......@@ -582,7 +583,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
}
}
} else if (requestCode == ACTIVITY_RESULT_OPEN){
Util.openUri(this, data.getData());
MediaUtils.openUri(this, data.getData());
}
}
......
......@@ -48,8 +48,6 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
......@@ -57,10 +55,13 @@ import org.videolan.vlc.gui.PlaybackServiceFragment;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.MediaComparators;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.WeakHandler;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import java.io.File;
import java.util.ArrayList;
......@@ -287,13 +288,12 @@ public class AudioAlbumsSongsFragment extends PlaybackServiceFragment implements
public void run() {
for (int i = 0; i < mMediaList.size(); ++i) {
MediaWrapper media = mMediaList.get(i);
mAlbumsAdapter.addSeparator(Util.getMediaReferenceArtist(activity, media), media);
mAlbumsAdapter.add(Util.getMediaAlbum(activity, media), null, media);
mSongsAdapter.addSeparator(Util.getMediaAlbum(activity, media), media);
mAlbumsAdapter.addSeparator(MediaUtils.getMediaReferenceArtist(activity, media), media);
mAlbumsAdapter.add(MediaUtils.getMediaAlbum(activity, media), null, media);
mSongsAdapter.addSeparator(MediaUtils.getMediaAlbum(activity, media), media);
}
mSongsAdapter.sortByAlbum();
mAlbumsAdapter.notifyDataSetChanged();
mSongsAdapter.notifyDataSetChanged();
mSwipeRefreshLayout.setRefreshing(false);
}
});
......
......@@ -52,9 +52,6 @@ import android.widget.TextView;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.MediaBrowser;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.MainActivity;
......@@ -62,12 +59,16 @@ import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.browser.MediaBrowserFragment;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.MediaComparators;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import org.videolan.vlc.interfaces.IBrowser;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import java.io.File;
import java.util.ArrayList;
......@@ -326,7 +327,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
Intent i = new Intent(getActivity(), SecondaryActivity.class);
i.putExtra("fragment", "albumsSongs");
i.putParcelableArrayListExtra("list", mediaList);
i.putExtra("filter", Util.getMediaArtist(activity, mediaList.get(0)));
i.putExtra("filter", MediaUtils.getMediaArtist(activity, mediaList.get(0)));
startActivity(i);
}
};
......@@ -338,7 +339,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
Intent i = new Intent(getActivity(), SecondaryActivity.class);
i.putExtra("fragment", SecondaryActivity.ALBUM);
i.putParcelableArrayListExtra("list", mediaList);
i.putExtra("filter", Util.getMediaAlbum(getActivity(), mediaList.get(0)));
i.putExtra("filter", MediaUtils.getMediaAlbum(getActivity(), mediaList.get(0)));
startActivity(i);
}
};
......@@ -350,7 +351,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
Intent i = new Intent(getActivity(), SecondaryActivity.class);
i.putExtra("fragment", SecondaryActivity.ALBUMS_SONGS);
i.putParcelableArrayListExtra("list", mediaList);
i.putExtra("filter", Util.getMediaGenre(getActivity(), mediaList.get(0)));
i.putExtra("filter", MediaUtils.getMediaGenre(getActivity(), mediaList.get(0)));
startActivity(i);
}
};
......
......@@ -40,15 +40,15 @@ import android.widget.SectionIndexer;
import android.widget.TextView;
import org.videolan.vlc.BR;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.AsyncImageLoader;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.MediaComparators;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.interfaces.IAudioClickHandler;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import java.util.ArrayList;
import java.util.Collections;
......@@ -165,17 +165,17 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
for (MediaWrapper media : list) {
switch (type){
case TYPE_ALBUMS:
title = Util.getMediaAlbum(mContext, media);
subTitle = Util.getMediaReferenceArtist(mContext, media);
title = MediaUtils.getMediaAlbum(mContext, media);
subTitle = MediaUtils.getMediaReferenceArtist(mContext, media);
key = null;
break;
case TYPE_ARTISTS:
title = Util.getMediaReferenceArtist(mContext, media);
title = MediaUtils.getMediaReferenceArtist(mContext, media);
subTitle = null;
key = null;
break;
case TYPE_GENRES:
title = Util.getMediaGenre(mContext, media);
title = MediaUtils.getMediaGenre(mContext, media);
subTitle = null;
key = null;
break;
......@@ -186,12 +186,12 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
break;
case TYPE_SONGS:
title = media.getTitle();
subTitle = Util.getMediaArtist(mContext, media);
subTitle = MediaUtils.getMediaArtist(mContext, media);
key = media.getAlbum() + media.getArtist() + media.getLocation();
break;
default:
title = media.getTitle();
subTitle = Util.getMediaArtist(mContext, media);
subTitle = MediaUtils.getMediaArtist(mContext, media);
key = media.getLocation();
}
add(title, subTitle, media, key);
......
......@@ -31,13 +31,13 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.databinding.PlaylistItemBinding;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.interfaces.SwipeDragHelperAdapter;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.WeakHandler;
import java.util.ArrayList;
......@@ -71,7 +71,7 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
holder.binding.setPosition(position);
holder.binding.setHandler(mClickHandler);
holder.binding.setMedia(media);
holder.binding.setSubTitle(Util.getMediaSubtitle(ctx, media));
holder.binding.setSubTitle(MediaUtils.getMediaSubtitle(ctx, media));
holder.binding.setTitleColor(mCurrentIndex == position
? UiTools.getColorFromAttribute(ctx, R.attr.list_title_last)
: UiTools.getColorFromAttribute(ctx, R.attr.list_title));
......
......@@ -32,15 +32,15 @@ import android.widget.CheckBox;
import android.widget.ImageView;
import org.videolan.libvlc.Media;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.databinding.BrowserItemSeparatorBinding;
import org.videolan.vlc.databinding.DirectoryViewItemBinding;
import org.videolan.vlc.gui.helpers.MediaComparators;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.CustomDirectories;
import org.videolan.vlc.util.Util;
import java.io.File;
import java.util.ArrayList;
......@@ -318,7 +318,7 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
if (mw.getType() == MediaWrapper.TYPE_DIR)
fragment.browse(mw, holder.getAdapterPosition(), true);
else if (mw.getType() == MediaWrapper.TYPE_VIDEO)
Util.openMedia(v.getContext(), mw);
MediaUtils.openMedia(v.getContext(), mw);
else if (mw.getType() == MediaWrapper.TYPE_AUDIO) {
int position = 0;
LinkedList<MediaWrapper> mediaLocations = new LinkedList<MediaWrapper>();
......@@ -332,9 +332,9 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
position = mediaLocations.size() - 1;
}
}
Util.openList(v.getContext(), mediaLocations, position);
MediaUtils.openList(v.getContext(), mediaLocations, position);
} else {
Util.openStream(v.getContext(), mw.getLocation());
MediaUtils.openStream(v.getContext(), mw.getLocation());
}
}
......
......@@ -48,6 +48,7 @@ import android.widget.TextView;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.MediaBrowser;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
......@@ -420,7 +421,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
switch (id){
case R.id.directory_view_play:
mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
Util.openMedia(getActivity(), mw);
MediaUtils.openMedia(getActivity(), mw);
return true;
case R.id.directory_view_append: {
if (mService != null)
......@@ -460,7 +461,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
if (mediaItem.getType() == MediaWrapper.TYPE_AUDIO || mediaItem.getType() == MediaWrapper.TYPE_VIDEO)
mediaList.add(mediaItem);
}
Util.openList(getActivity(), mediaList, 0);
MediaUtils.openList(getActivity(), mediaList, 0);
return true;
// case R.id.directory_view_hide_media:
// try {
......
......@@ -85,7 +85,7 @@ public class FileBrowserFragment extends BaseBrowserFragment {
else
title = mCurrentMedia.getTitle();
} else
title = Strings.getName(mMrl);
title = Strings.getFileNameFromPath(mMrl);
return title;
}
}
......
......@@ -49,7 +49,7 @@ public class CommonDialogs {
final Context context,
final String addressMedia,
final VLCRunnable runnable) {
final String name = Strings.getName(Uri.decode(addressMedia));
final String name = Strings.getFileNameFromPath(Uri.decode(addressMedia));
return deleteMedia(type, context, addressMedia, name, runnable);
}
......
......@@ -38,9 +38,10 @@ import android.widget.Toast;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.MurmurHash;
import org.videolan.vlc.util.Util;
......@@ -202,8 +203,8 @@ public class AudioUtil {
return Uri.decode(artworkURL).replace("file://", "");
} else if(artworkURL != null && artworkURL.startsWith("attachment://")) {
// Decode if the album art is embedded in the file
String mArtist = Util.getMediaArtist(context, media);
String mAlbum = Util.getMediaAlbum(context, media);
String mArtist = MediaUtils.getMediaArtist(context, media);
String mAlbum = MediaUtils.getMediaAlbum(context, media);
/* Parse decoded attachment */
if( mArtist.length() == 0 || mAlbum.length() == 0 ||
......@@ -278,7 +279,7 @@ public class AudioUtil {
}
private static String getCoverCachePath(Context context, MediaWrapper media, int width) {
final int hash = MurmurHash.hash32(Util.getMediaArtist(context, media) + Util.getMediaAlbum(context, media));
final int hash = MurmurHash.hash32(MediaUtils.getMediaArtist(context, media) + MediaUtils.getMediaAlbum(context, media));
return COVER_DIR + (hash >= 0 ? "" + hash : "m" + (-hash)) + "_" + width;
}
......
......@@ -33,11 +33,11 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.videolan.vlc.R;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.util.Util;
public class SearchSuggestionsAdapter extends CursorAdapter {
......@@ -102,7 +102,7 @@ public class SearchSuggestionsAdapter extends CursorAdapter {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Util.openMedia(context, mw);
MediaUtils.openMedia(context, mw);
}
});
view.setOnTouchListener(new View.OnTouchListener() {
......
......@@ -27,9 +27,9 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.R;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaUtils;
import java.util.ArrayList;
......@@ -65,7 +65,7 @@ public class MRLAdapter extends RecyclerView.Adapter<MRLAdapter.ViewHolder> {
holder.uriTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Util.openStream(v.getContext(), uri);
MediaUtils.openStream(v.getContext(), uri);
}
});
holder.deleteButton.setOnClickListener(new View.OnClickListener() {
......
......@@ -21,11 +21,11 @@
package org.videolan.vlc.gui.network;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.design.widget.TextInputLayout;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
......@@ -34,10 +34,10 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaUtils;
import java.util.ArrayList;
......@@ -98,7 +98,7 @@ public class MRLPanelFragment extends Fragment implements View.OnKeyListener, Te
private boolean processUri() {
if (!TextUtils.isEmpty(mEditText.getEditText().getText().toString())){
Util.openStream(getActivity(), mEditText.getEditText().getText().toString().trim());
MediaUtils.openStream(getActivity(), mEditText.getEditText().getText().toString().trim());
MediaDatabase.getInstance().addMrlhistoryItem(mEditText.getEditText().getText().toString().trim());
updateHistory();
getActivity().supportInvalidateOptionsMenu();
......
......@@ -58,22 +58,23 @@ import android.widget.TextView;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaGroup;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.media.Thumbnailer;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.browser.MediaBrowserFragment;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import org.videolan.vlc.interfaces.ISortable;
import org.videolan.vlc.interfaces.IVideoBrowser;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaGroup;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.media.Thumbnailer;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import java.io.File;
import java.util.ArrayList;
......@@ -157,11 +158,11 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
// init the information for the scan (2/2)
IntentFilter filter = new IntentFilter();
filter.addAction(Util.ACTION_SCAN_START);
filter.addAction(Util.ACTION_SCAN_STOP);
filter.addAction(MediaUtils.ACTION_SCAN_START);
filter.addAction(MediaUtils.ACTION_SCAN_STOP);
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(messageReceiverVideoListFragment, filter);
if (mMediaLibrary.isWorking()) {
Util.actionScanStart();
MediaUtils.actionScanStart();
}
mAnimator = new VideoGridAnimator(mGridView);
......@@ -496,10 +497,10 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equalsIgnoreCase(Util.ACTION_SCAN_START)) {
if (action.equalsIgnoreCase(MediaUtils.ACTION_SCAN_START)) {
mLayoutFlipperLoading.setVisibility(View.VISIBLE);
mTextViewNomedia.setVisibility(View.INVISIBLE);
} else if (action.equalsIgnoreCase(Util.ACTION_SCAN_STOP)) {
} else if (action.equalsIgnoreCase(MediaUtils.ACTION_SCAN_STOP)) {
mLayoutFlipperLoading.setVisibility(View.INVISIBLE);
mTextViewNomedia.setVisibility(View.VISIBLE);
}
......
......@@ -110,7 +110,7 @@ public class MediaLibrary {
public void scanMediaItems() {
if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {
isStopping = false;
Util.actionScanStart();
MediaUtils.actionScanStart();
mLoadingThread = new Thread(new GetMediaItemsRunnable());
mLoadingThread.start();
}
......@@ -436,7 +436,7 @@ public class MediaLibrary {
mBrowser.get().hideProgressBar();
}
Util.actionScanStop();
MediaUtils.actionScanStop();
if (mRestart) {
Log.d(TAG, "Restarting scan");
......
package org.videolan.vlc.media;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.content.LocalBroadcastManager;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import java.util.List;
public class MediaUtils {
public static final String ACTION_SCAN_START = Util.buildPkgString("gui.ScanStart");
public static final String ACTION_SCAN_STOP = Util.buildPkgString("gui.ScanStop");
public static void actionScanStart() {
Intent intent = new Intent();
intent.setAction(ACTION_SCAN_START);
LocalBroadcastManager.getInstance(VLCApplication.getAppContext()).sendBroadcast(intent);
}
public static void actionScanStop() {
Intent intent = new Intent();
intent.setAction(ACTION_SCAN_STOP);
LocalBroadcastManager.getInstance(VLCApplication.getAppContext()).sendBroadcast(intent);
}
public static void openMedia(final Context context, final MediaWrapper media){
if (media == null)
return;
if (media.getType() == MediaWrapper.TYPE_VIDEO)
VideoPlayerActivity.start(context, media.getUri(), media.getTitle());