squid:S1155 - Collection.isEmpty() should be used to test for emptiness

This commit is contained in:
George Kankava 2016-06-29 14:04:24 +04:00
parent cc1329f614
commit 079cf4e759
8 changed files with 13 additions and 13 deletions

View File

@ -135,7 +135,7 @@ public class HostConnectionObserver
public void run() { public void run() {
final int HTTP_NOTIFICATION_CHECK_INTERVAL = 3000; final int HTTP_NOTIFICATION_CHECK_INTERVAL = 3000;
// If no one is listening to this, just exit // If no one is listening to this, just exit
if (playerEventsObservers.size() == 0) return; if (playerEventsObservers.isEmpty()) return;
// Check whats playing // Check whats playing
checkWhatsPlaying(); checkWhatsPlaying();
@ -151,7 +151,7 @@ public class HostConnectionObserver
final int PING_AFTER_ERROR_CHECK_INTERVAL = 2000, final int PING_AFTER_ERROR_CHECK_INTERVAL = 2000,
PING_AFTER_SUCCESS_CHECK_INTERVAL = 10000; PING_AFTER_SUCCESS_CHECK_INTERVAL = 10000;
// If no one is listening to this, just exit // If no one is listening to this, just exit
if (playerEventsObservers.size() == 0) return; if (playerEventsObservers.isEmpty()) return;
JSONRPC.Ping ping = new JSONRPC.Ping(); JSONRPC.Ping ping = new JSONRPC.Ping();
ping.execute(connection, new ApiCallback<String>() { ping.execute(connection, new ApiCallback<String>() {
@ -232,7 +232,7 @@ public class HostConnectionObserver
LogUtils.LOGD(TAG, "Unregistering observer. Still got " + playerEventsObservers.size() + LogUtils.LOGD(TAG, "Unregistering observer. Still got " + playerEventsObservers.size() +
" observers."); " observers.");
if (playerEventsObservers.size() == 0) { if (playerEventsObservers.isEmpty()) {
// No more observers, so unregister us from the host connection, or stop // No more observers, so unregister us from the host connection, or stop
// the http checker thread // the http checker thread
if (connection.getProtocol() == HostConnection.PROTOCOL_TCP) { if (connection.getProtocol() == HostConnection.PROTOCOL_TCP) {

View File

@ -119,7 +119,7 @@ public class HostManager {
* @return Host list * @return Host list
*/ */
public ArrayList<HostInfo> getHosts(boolean forcedReload) { public ArrayList<HostInfo> getHosts(boolean forcedReload) {
if (forcedReload || (hosts.size() == 0)) { if (forcedReload || (hosts.isEmpty())) {
hosts.clear(); hosts.clear();
Cursor cursor = context.getContentResolver() Cursor cursor = context.getContentResolver()
@ -167,7 +167,7 @@ public class HostManager {
// No host selected. Check if there are hosts configured and default to the first one // No host selected. Check if there are hosts configured and default to the first one
if (currentHostId == -1) { if (currentHostId == -1) {
if (hosts.size() > 0) { if (!hosts.isEmpty()) {
currentHostInfo = hosts.get(0); currentHostInfo = hosts.get(0);
currentHostId = currentHostInfo.getId(); currentHostId = currentHostInfo.getId();
prefs.edit() prefs.edit()
@ -424,7 +424,7 @@ public class HostManager {
// If we just deleted the current connection, switch to another // If we just deleted the current connection, switch to another
if ((currentHostInfo != null) && (currentHostInfo.getId() == hostId)) { if ((currentHostInfo != null) && (currentHostInfo.getId() == hostId)) {
releaseCurrentHost(); releaseCurrentHost();
if (hosts.size() > 0) if (!hosts.isEmpty())
switchHost(hosts.get(0)); switchHost(hosts.get(0));
} }
} }

View File

@ -65,7 +65,7 @@ public class ConnectionObserversManagerService extends Service
createObservers(); createObservers();
// If no observers created, stop immediately // If no observers created, stop immediately
if (mConnectionObservers.size() == 0) { if (mConnectionObservers.isEmpty()) {
LogUtils.LOGD(TAG, "No observers, stopping observer service."); LogUtils.LOGD(TAG, "No observers, stopping observer service.");
stopSelf(); stopSelf();
} }

View File

@ -153,7 +153,7 @@ public class SyncMovies extends SyncItem {
// First call, delete movies from DB // First call, delete movies from DB
deleteMovies(contentResolver, hostId, -1); deleteMovies(contentResolver, hostId, -1);
} }
if (result.size() > 0) { if (!result.isEmpty()) {
insertMovies(orchestrator, contentResolver, result); insertMovies(orchestrator, contentResolver, result);
} }

View File

@ -339,7 +339,7 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
@Override @Override
protected void onDownload() { protected void onDownload() {
if ((albumTitle == null) || (albumDisplayArtist == null) || if ((albumTitle == null) || (albumDisplayArtist == null) ||
(songInfoList == null) || (songInfoList.size() == 0)) { (songInfoList == null) || (songInfoList.isEmpty())) {
// Nothing to download // Nothing to download
Toast.makeText(getActivity(), R.string.no_files_to_download, Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), R.string.no_files_to_download, Toast.LENGTH_SHORT).show();
return; return;
@ -676,7 +676,7 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
songListView.addView(songView); songListView.addView(songView);
} while (cursor.moveToNext()); } while (cursor.moveToNext());
if (songInfoList.size() > 0) { if (!songInfoList.isEmpty()) {
// Check if download dir exists // Check if download dir exists
FileDownloadHelper.SongInfo songInfo = new FileDownloadHelper.SongInfo FileDownloadHelper.SongInfo songInfo = new FileDownloadHelper.SongInfo
(albumDisplayArtist, albumTitle, 0, 0, null, null); (albumDisplayArtist, albumTitle, 0, 0, null, null);

View File

@ -367,7 +367,7 @@ public class MediaFileListFragment extends AbstractListFragment {
action.execute(hostManager.getConnection(), new ApiCallback<String>() { action.execute(hostManager.getConnection(), new ApiCallback<String>() {
@Override @Override
public void onSuccess(String result) { public void onSuccess(String result) {
while (mediaQueueFileLocation.size() > 0) { while (!mediaQueueFileLocation.isEmpty()) {
queueMediaFile(mediaQueueFileLocation.poll().file); queueMediaFile(mediaQueueFileLocation.poll().file);
} }
} }

View File

@ -340,7 +340,7 @@ public class PlaylistFragment extends Fragment
private void displayPlaylist(final ListType.ItemsAll getItemResult, private void displayPlaylist(final ListType.ItemsAll getItemResult,
final List<ListType.ItemsAll> playlistItems) { final List<ListType.ItemsAll> playlistItems) {
if (playlistItems.size() == 0) { if (playlistItems.isEmpty()) {
displayEmptyPlaylistMessage(); displayEmptyPlaylistMessage();
return; return;
} }

View File

@ -295,7 +295,7 @@ public class FileDownloadHelper {
final List<? extends MediaInfo> mediaInfoList, final List<? extends MediaInfo> mediaInfoList,
final int fileHandlingMode, final int fileHandlingMode,
final Handler callbackHandler) { final Handler callbackHandler) {
if ((mediaInfoList == null) || (mediaInfoList.size() == 0)) if ((mediaInfoList == null) || (mediaInfoList.isEmpty()))
return; return;
if (!checkDownloadDir(context, mediaInfoList.get(0).getAbsoluteDirectoryPath())) if (!checkDownloadDir(context, mediaInfoList.get(0).getAbsoluteDirectoryPath()))