Commit 75c93f70 authored by Geoffrey Métais's avatar Geoffrey Métais

Use isListEmpty util method to clear code

parent 26086ee0
......@@ -39,6 +39,7 @@ import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.gui.helpers.BitmapUtil;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.WeakHandler;
import java.util.ArrayList;
......@@ -131,7 +132,7 @@ public class RecommendationsService extends IntentService {
mNotificationManager.cancelAll();
int id = 0;
ArrayList<MediaWrapper> videoList = MediaLibrary.getInstance().getVideoItems();
if (videoList == null || videoList.isEmpty())
if (Util.isListEmpty(videoList))
return false;
Bitmap pic;
Collections.shuffle(videoList);
......
......@@ -71,6 +71,7 @@ import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
......@@ -461,7 +462,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
if (id == R.id.audio_list_browser_delete) {
List<MediaWrapper> mediaList = adapter.getMedias(position);
if (mediaList == null || mediaList.isEmpty())
if (Util.isListEmpty(mediaList))
return false;
final MediaWrapper media = mediaList.get(0);
final AudioBrowserListAdapter.ListItem listItem = adapter.getItem(position);
......@@ -603,7 +604,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
@Override
public void setReadyToDisplay(boolean ready) {
if (mAdaptersToNotify == null || mAdaptersToNotify.isEmpty())
if (Util.isListEmpty(mAdaptersToNotify))
mReadyToDisplay = ready;
else
display();
......
......@@ -63,6 +63,7 @@ import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
......@@ -228,7 +229,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
Fragment next = createFragment();
Bundle args = new Bundle();
ArrayList<MediaWrapper> list = mFoldersContentLists != null ? mFoldersContentLists.get(position) : null;
if(list != null && !list.isEmpty())
if (!Util.isListEmpty(list))
VLCApplication.storeData(KEY_MEDIA_LIST, list);
args.putParcelable(KEY_MEDIA, media);
next.setArguments(args);
......@@ -422,7 +423,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
int type = mw.getType();
boolean canWrite = this instanceof FileBrowserFragment && FileUtils.canWrite(mw.getUri().getPath());
if (type == MediaWrapper.TYPE_DIR) {
boolean isEmpty = mFoldersContentLists.get(position) == null || mFoldersContentLists.get(position).isEmpty();
boolean isEmpty = Util.isListEmpty(mFoldersContentLists.get(position));
inflater.inflate(R.menu.directory_view_dir, menu);
// if (canWrite) {
// boolean nomedia = new File(mw.getLocation() + "/.nomedia").exists();
......
......@@ -34,6 +34,7 @@ import org.videolan.libvlc.Media;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.Util;
public class StorageBrowserAdapter extends BaseBrowserAdapter {
......@@ -64,8 +65,7 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
vh.binding.setHasContextMenu(hasContextMenu);
vh.binding.setType(TYPE_STORAGE);
vh.binding.setChecked(((StorageBrowserFragment) fragment).mScannedDirectory ||
(isRoot && (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty())) ||
mMediaDirsLocation.contains(storagePath));
(isRoot && Util.isListEmpty(mMediaDirsLocation)) || mMediaDirsLocation.contains(storagePath));
vh.binding.setCheckEnabled(!((StorageBrowserFragment) fragment).mScannedDirectory);
if (hasContextMenu)
vh.setContextMenuListener();
......@@ -127,7 +127,7 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
fragment.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty())
if (Util.isListEmpty(mMediaDirsLocation))
fragment.refresh();
}
});
......
......@@ -71,6 +71,7 @@ import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.media.Thumbnailer;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import java.util.ArrayList;
......@@ -535,7 +536,7 @@ public class MainTvActivity extends BaseTvActivity implements IVideoBrowser, OnI
Bitmap picture;
ArrayList<MediaWrapper> videoList = mMediaLibrary.getVideoItems();
MediaDatabase mediaDatabase = MediaDatabase.getInstance();
if (sThumbnailer != null && videoList != null && !videoList.isEmpty()) {
if (sThumbnailer != null && !Util.isListEmpty(videoList)) {
for (MediaWrapper MediaWrapper : videoList) {
picture = mediaDatabase.getPicture(MediaWrapper.getUri());
if (picture == null)
......
......@@ -19,6 +19,7 @@ import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.SubtitlesDownloader;
import org.videolan.vlc.util.Util;
import java.util.ArrayList;
import java.util.List;
......@@ -107,7 +108,7 @@ public class MediaUtils {
}
public static void openList(final Context context, final List<MediaWrapper> list, final int position){
if (list == null || list.isEmpty())
if (Util.isListEmpty(list))
return;
new DialogCallback(context, new DialogCallback.Runnable() {
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment