[Android] Use isListEmpty util method to clear code
Geoffrey Métais
git at videolan.org
Tue Jun 14 15:29:32 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun 14 15:27:38 2016 +0200| [75c93f70b1d5660f513a023bd3ebad2f5382d8dc] | committer: Geoffrey Métais
Use isListEmpty util method to clear code
> https://code.videolan.org/videolan/vlc-android/commit/75c93f70b1d5660f513a023bd3ebad2f5382d8dc
---
vlc-android/src/org/videolan/vlc/RecommendationsService.java | 3 ++-
.../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java | 5 +++--
.../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 5 +++--
.../src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java | 6 +++---
vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java | 3 ++-
vlc-android/src/org/videolan/vlc/media/MediaUtils.java | 3 ++-
6 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/RecommendationsService.java b/vlc-android/src/org/videolan/vlc/RecommendationsService.java
index 2be8939..02cb119 100644
--- a/vlc-android/src/org/videolan/vlc/RecommendationsService.java
+++ b/vlc-android/src/org/videolan/vlc/RecommendationsService.java
@@ -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);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index b71c18f..0e95846 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -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();
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 3ab5019..d5eb199 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -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();
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
index fe77ce0..70e0e15 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -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();
}
});
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index f2d3267..f0c4ae0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -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)
diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.java b/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
index 8094bc8..10dfa00 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.java
@@ -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
More information about the Android
mailing list