diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a16862cf..5ff92168 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + a:versionCode="34" + a:versionName="1.2.0.7" > diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index eb742899..277fcabe 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -325,8 +325,19 @@ Utiliser ID3 tag à la place du système de fichier basique Utiliser un proxy Support de lecture de flux à travers un proxy (peut provoquer des fritures) - Video - Video player + Vidéo + Lecteur vidéo + Actualisation de la vue + 0,5 secondes + 1 seconde + 1,5 secondes + 2 secondes + 2,5 secondes + 3 secondes + 3,5 secondes + 4 secondes + 4,5 secondes + 5 secondes Lire uniquement les flux médias si connecté au réseau Wi-Fi Wi-Fi en streaming uniquement Année de fin: diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index ee0f49cf..c31bf482 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -327,6 +327,17 @@ Média lejátszása stream proxy-n keresztül (akadozások elkerülése érdekében). Videó Videólejátszó + Megtekinté Frissítési + 0,5 másodperc + 1 másodperc + 1,5 másodperc + 2 másodperc + 2,5 másodperc + 3 másodperc + 3,5 másodperc + 4 másodperc + 4,5 másodperc + 5 másodperc Streaming, csak ha rendelkezésre áll Wi-Fi kapcsolat. Csak Wi-Fi streaming Utolsó év: diff --git a/res/values/arrays.xml b/res/values/arrays.xml index dbb517f9..23464fc0 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -214,5 +214,31 @@ Default Flash + + @string/settings.view_refresh_500 + @string/settings.view_refresh_1000 + @string/settings.view_refresh_1500 + @string/settings.view_refresh_2000 + @string/settings.view_refresh_2500 + @string/settings.view_refresh_3000 + @string/settings.view_refresh_3500 + @string/settings.view_refresh_4000 + @string/settings.view_refresh_4500 + @string/settings.view_refresh_5000 + + + 500 + 1000 + 1500 + 2000 + 2500 + 3000 + 3500 + 4000 + 4500 + 5000 + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index dd923b7f..b8cbc619 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -327,6 +327,17 @@ Stream media playback through a proxy (may help stutter) Video Video player + View Refresh + .5 seconds + 1 second + 1.5 seconds + 2 seconds + 2.5 seconds + 3 seconds + 3.5 seconds + 4 seconds + 4.5 seconds + 5 seconds Only stream media if connected to Wi-Fi Wi-Fi Streaming Only End Year: diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 3ceda8b4..4f82c9f5 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -39,6 +39,12 @@ a:key="discAndTrackSort" a:summary="@string/settings.disc_sort_summary" a:title="@string/settings.disc_sort" /> + list = mainList ? downloadList : backgroundDownloadList; int max = list.size(); - if(to >= max) { + if (to >= max) { to = max - 1; - } - else if(to < 0) { + } else if(to < 0) { to = 0; } int currentPlayingIndex = getCurrentPlayingIndex(); DownloadFile movedSong = list.remove(from); list.add(to, movedSong); - if(jukeboxEnabled && mainList) { + + if (jukeboxEnabled && mainList) { updateJukeboxPlaylist(); } else if(mainList && (movedSong == nextPlaying || (currentPlayingIndex + 1) == to)) { // Moving next playing or moving a song to be next playing @@ -1499,7 +1501,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { currentDownloading = downloadFile; currentDownloading.download(); cleanupCandidates.add(currentDownloading); - if(i == (start + 1)) { + if (i == (start + 1)) { setNextPlayerState(DOWNLOADING); } break; @@ -1675,8 +1677,10 @@ public class DownloadServiceImpl extends Service implements DownloadService { public CheckCompletionTask(DownloadFile downloadFile) { setNextPlayerState(PlayerState.IDLE); + this.downloadFile = downloadFile; - if(downloadFile != null) { + + if (downloadFile != null) { partialFile = downloadFile.getPartialFile(); } else { partialFile = null; @@ -1691,8 +1695,10 @@ public class DownloadServiceImpl extends Service implements DownloadService { // Do an initial sleep so this prepare can't compete with main prepare Util.sleepQuietly(5000L); + while (!bufferComplete()) { Util.sleepQuietly(5000L); + if (isCancelled()) { return; } diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java b/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java index 323a4af2..35dbc168 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java @@ -116,6 +116,7 @@ public final class Constants { public static final String PREFERENCES_KEY_VIDEO_PLAYER = "videoPlayer"; public static final String PREFERENCES_KEY_SEND_BLUETOOTH_NOTIFICATIONS = "sendBluetoothNotifications"; public static final String PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART = "sendBluetoothAlbumArt"; + public static final String PREFERENCES_KEY_VIEW_REFRESH = "viewRefresh"; // Name of the preferences file. public static final String PREFERENCES_FILE_NAME = "com.thejoshwa.ultrasonic.androidapp_preferences"; diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/StreamProxy.java b/src/com/thejoshwa/ultrasonic/androidapp/util/StreamProxy.java index a710f945..277c54f4 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/StreamProxy.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/StreamProxy.java @@ -157,22 +157,12 @@ public class StreamProxy implements Runnable { Log.i(TAG, "Streaming song in background"); DownloadFile downloadFile = downloadService.getCurrentPlaying(); MusicDirectory.Entry song = downloadFile.getSong(); + long fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8; + Log.i(TAG, "Streaming fileSize: " + fileSize); // Create HTTP header String headers = "HTTP/1.0 200 OK\r\n"; headers += "Content-Type: " + "application/octet-stream" + "\r\n"; - - Integer contentLength = downloadFile.getContentLength(); - long fileSize; - - if (contentLength == null) { - fileSize = downloadFile.getBitRate() * ((song.getDuration() != null) ? song.getDuration() : 0) * 1000 / 8; - } else { - fileSize = contentLength; - headers += "Content-Length: " + fileSize + "\r\n"; - } - - Log.i(TAG, "Streaming fileSize: " + fileSize); headers += "Connection: close\r\n"; headers += "\r\n"; diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java b/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java index 114f62ea..aabd365f 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java @@ -1338,4 +1338,10 @@ public class Util extends DownloadActivity { SharedPreferences preferences = getPreferences(context); return preferences.getBoolean(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART, true); } + + public static int getViewRefreshInterval(Context context) { + SharedPreferences preferences = getPreferences(context); + return Integer.parseInt(preferences.getString(Constants.PREFERENCES_KEY_VIEW_REFRESH, "1000")); + } + } diff --git a/src/com/thejoshwa/ultrasonic/androidapp/view/AlbumView.java b/src/com/thejoshwa/ultrasonic/androidapp/view/AlbumView.java index 08fe9051..231c2940 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/view/AlbumView.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/view/AlbumView.java @@ -19,6 +19,7 @@ package com.thejoshwa.ultrasonic.androidapp.view; import android.content.Context; +import android.graphics.drawable.Drawable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -39,15 +40,34 @@ import com.thejoshwa.ultrasonic.androidapp.util.Util; public class AlbumView extends UpdateView { private static final String TAG = AlbumView.class.getSimpleName(); + private static Drawable starDrawable; + private static Drawable starHollowDrawable; + private static String theme; + private TextView titleView; private TextView artistView; private View coverArtView; private ImageView starImageView; + private Context context; public AlbumView(Context context) { super(context); + this.context = context; + LayoutInflater.from(context).inflate(R.layout.album_list_item, this, true); + String theme = Util.getTheme(context); + boolean themesMatch = theme.equals(this.theme); + this.theme = theme; + + if (starHollowDrawable == null || !themesMatch) { + starHollowDrawable = Util.getDrawableFromAttribute(context, R.attr.star_hollow); + } + + if (starDrawable == null || !themesMatch) { + starDrawable = Util.getDrawableFromAttribute(context, R.attr.star_full); + } + titleView = (TextView) findViewById(R.id.album_title); artistView = (TextView) findViewById(R.id.album_artist); coverArtView = findViewById(R.id.album_coverart); @@ -55,47 +75,51 @@ public class AlbumView extends UpdateView { } public void setAlbum(final MusicDirectory.Entry album, ImageLoader imageLoader) { - titleView.setText(album.getTitle()); - artistView.setText(album.getArtist()); - artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE); - starImageView.setImageDrawable(album.getStarred() ? Util.getDrawableFromAttribute(getContext(), R.attr.star_full) : Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow)); - imageLoader.loadImage(coverArtView, album, false, 0, false, true); + String title = album.getTitle(); + String artist = album.getArtist(); + boolean starred = album.getStarred(); + + titleView.setText(title); + artistView.setText(artist); + artistView.setVisibility(artist == null ? View.GONE : View.VISIBLE); + starImageView.setImageDrawable(starred ? starDrawable : starHollowDrawable); + imageLoader.loadImage(this.coverArtView, album, false, 0, false, true); - if (Util.isOffline(getContext())) { + if (Util.isOffline(this.context)) { starImageView.setVisibility(View.GONE); + } else { + starImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + final boolean isStarred = album.getStarred(); + final String id = album.getId(); + + if (!isStarred) { + starImageView.setImageDrawable(starDrawable); + album.setStarred(true); + } else { + starImageView.setImageDrawable(starHollowDrawable); + album.setStarred(false); + } + + new Thread(new Runnable() { + public void run() { + MusicService musicService = MusicServiceFactory.getMusicService(null); + boolean useId3 = Util.getShouldUseId3Tags(getContext()); + + try { + if (!isStarred) { + musicService.star(!useId3 ? id : null, useId3 ? id : null, null, getContext(), null); + } else { + musicService.unstar(!useId3 ? id : null, useId3 ? id : null, null, getContext(), null); + } + } catch (Exception e) { + Log.e(TAG, e.getMessage(), e); + } + } + }).start(); + } + }); } - - starImageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - final boolean isStarred = album.getStarred(); - final String id = album.getId(); - - if (!isStarred) { - starImageView.setImageDrawable(Util.getDrawableFromAttribute(getContext(), R.attr.star_full)); - album.setStarred(true); - } else { - starImageView.setImageDrawable(Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow)); - album.setStarred(false); - } - - new Thread(new Runnable() { - public void run() { - MusicService musicService = MusicServiceFactory.getMusicService(null); - boolean useId3 = Util.getShouldUseId3Tags(getContext()); - - try { - if (!isStarred) { - musicService.star(!useId3 ? id : null, useId3 ? id : null, null, getContext(), null); - } else { - musicService.unstar(!useId3 ? id : null, useId3 ? id : null, null, getContext(), null); - } - } catch (Exception e) { - Log.e(TAG, e.getMessage(), e); - } - } - }).start(); - } - }); } -} +} \ No newline at end of file diff --git a/src/com/thejoshwa/ultrasonic/androidapp/view/PlaylistView.java b/src/com/thejoshwa/ultrasonic/androidapp/view/PlaylistView.java index 377b85a6..53be8812 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/view/PlaylistView.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/view/PlaylistView.java @@ -25,7 +25,7 @@ import com.thejoshwa.ultrasonic.androidapp.R; import com.thejoshwa.ultrasonic.androidapp.domain.Playlist; /** - * Used to display albums in a {@code ListView}. + * Used to display playlists in a {@code ListView}. * * @author Sindre Mehus */ diff --git a/src/com/thejoshwa/ultrasonic/androidapp/view/SongView.java b/src/com/thejoshwa/ultrasonic/androidapp/view/SongView.java index 9562c969..8496063f 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/view/SongView.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/view/SongView.java @@ -47,23 +47,70 @@ import java.io.File; public class SongView extends UpdateView implements Checkable { private static final String TAG = SongView.class.getSimpleName(); + private static Drawable starHollowDrawable; + private static Drawable starDrawable; + private static Drawable unpinImage; + private static Drawable downloadedImage; + private static Drawable downloadingImage; + private static Drawable playingImage; + private static String theme; + private CheckedTextView checkedTextView; private ImageView starImageView; private TextView titleTextView; private TextView statusTextView; private Entry song; private Context context; - + private Drawable leftImage; + private ImageType previousLeftImageType; + private ImageType previousRightImageType; + private ImageType leftImageType; + private ImageType rightImageType; + private Drawable rightImage; private DownloadService downloadService; + private DownloadFile downloadFile; + private boolean playing = false; public SongView(Context context) { super(context); this.context = context; + + String theme = Util.getTheme(context); + boolean themesMatch = theme.equals(this.theme); + + this.theme = theme; + + if (starHollowDrawable == null || !themesMatch) { + starHollowDrawable = Util.getDrawableFromAttribute(context, R.attr.star_hollow); + } + + if (starDrawable == null || !themesMatch) { + starDrawable = Util.getDrawableFromAttribute(context, R.attr.star_full); + } + + if (unpinImage == null || !themesMatch) { + unpinImage = Util.getDrawableFromAttribute(context, R.attr.unpin); + } + + if (downloadedImage == null || !themesMatch) { + downloadedImage = Util.getDrawableFromAttribute(context, R.attr.downloaded); + } + + if (downloadingImage == null || !themesMatch) { + downloadingImage = Util.getDrawableFromAttribute(context, R.attr.downloading); + } + + if (playingImage == null || !themesMatch) { + playingImage = Util.getDrawableFromAttribute(context, R.attr.media_play_small); + } } - public void setSong(final Entry song, boolean checkable) { + protected void setSong(final Entry song, boolean checkable) { + updateBackground(); + this.song = song; - + this.downloadFile = downloadService.forSong(song); + if (song.isVideo()) { LayoutInflater.from(this.context).inflate(R.layout.video_list_item, this, true); } else { @@ -78,30 +125,32 @@ public class SongView extends UpdateView implements Checkable { TextView durationTextView = (TextView) findViewById(R.id.song_duration); statusTextView = (TextView) findViewById(R.id.song_status); - StringBuilder artist = new StringBuilder(60); String bitRate = null; + if (song.getBitRate() != null) { - bitRate = String.format(getContext().getString(R.string.song_details_kbps), song.getBitRate()); + bitRate = String.format(this.context.getString(R.string.song_details_kbps), song.getBitRate()); } - VideoPlayerType videoPlayer = Util.getVideoPlayerType(getContext()); + VideoPlayerType videoPlayer = Util.getVideoPlayerType(this.context); String fileFormat; + String suffix = song.getSuffix(); + String transcodedSuffix = song.getTranscodedSuffix(); - if (song.getTranscodedSuffix() == null || song.getTranscodedSuffix().equals(song.getSuffix()) || (song.isVideo() && videoPlayer != VideoPlayerType.FLASH)) { - fileFormat = song.getSuffix(); + if (transcodedSuffix == null || transcodedSuffix.equals(suffix) || (song.isVideo() && videoPlayer != VideoPlayerType.FLASH)) { + fileFormat = suffix; } else { - fileFormat = String.format("%s > %s", song.getSuffix(), song.getTranscodedSuffix()); + fileFormat = String.format("%s > %s", suffix, transcodedSuffix); } String artistName = song.getArtist(); if (artistName != null) { - if (Util.shouldDisplayBitrateWithArtist(getContext())) { + if (Util.shouldDisplayBitrateWithArtist(this.context)) { artist.append(artistName).append(" (") - .append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate + " ", fileFormat)) + .append(String.format(this.context.getString(R.string.song_details_all), bitRate == null ? "" : bitRate + " ", fileFormat)) .append(")"); } else { artist.append(artistName); @@ -111,7 +160,7 @@ public class SongView extends UpdateView implements Checkable { int trackNumber = song.getTrack(); if (trackTextView != null) { - if (Util.shouldShowTrackNumber(getContext()) && trackNumber != 0) { + if (Util.shouldShowTrackNumber(this.context) && trackNumber != 0) { trackTextView.setText(String.format("%02d.", trackNumber)); } else { trackTextView.setVisibility(View.GONE); @@ -130,61 +179,58 @@ public class SongView extends UpdateView implements Checkable { durationTextView.setText(Util.formatTotalDuration(duration)); } - starImageView.setImageDrawable(song.getStarred() ? Util.getDrawableFromAttribute(getContext(), R.attr.star_full) : Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow)); checkedTextView.setVisibility(checkable && !song.isVideo() ? View.VISIBLE : View.GONE); - if (Util.isOffline(getContext())) { + if (Util.isOffline(this.context)) { starImageView.setVisibility(View.GONE); + } else { + starImageView.setImageDrawable(song.getStarred() ? starDrawable : starHollowDrawable); + + starImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + final boolean isStarred = song.getStarred(); + final String id = song.getId(); + + if (!isStarred) { + starImageView.setImageDrawable(starDrawable); + song.setStarred(true); + } else { + starImageView.setImageDrawable(starHollowDrawable); + song.setStarred(false); + } + + new Thread(new Runnable() { + public void run() { + MusicService musicService = MusicServiceFactory.getMusicService(SongView.this.context); + + try { + if (!isStarred) { + musicService.star(id, null, null, SongView.this.context, null); + } else { + musicService.unstar(id, null, null, SongView.this.context, null); + } + } catch (Exception e) { + Log.e(TAG, e.getMessage(), e); + } + } + }).start(); + } + }); } - - starImageView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - final boolean isStarred = song.getStarred(); - final String id = song.getId(); - - if (!isStarred) { - starImageView.setImageDrawable(Util.getDrawableFromAttribute(getContext(), R.attr.star_full)); - song.setStarred(true); - } else { - starImageView.setImageDrawable(Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow)); - song.setStarred(false); - } - - new Thread(new Runnable() { - public void run() { - MusicService musicService = MusicServiceFactory.getMusicService(null); - - try { - if (!isStarred) { - musicService.star(id, null, null, getContext(), null); - } else { - musicService.unstar(id, null, null, getContext(), null); - } - } catch (Exception e) { - Log.e(TAG, e.getMessage(), e); - } - } - }).start(); - } - }); - - updateBackground(); + update(); } @Override protected void updateBackground() { if (downloadService == null) { - downloadService = DownloadServiceImpl.getInstance(); - if(downloadService == null) { + if (downloadService == null) { return; } } - - downloadService.forSong(song); } @Override @@ -193,39 +239,62 @@ public class SongView extends UpdateView implements Checkable { return; } - DownloadFile downloadFile = downloadService.forSong(song); - downloadFile.getCompleteFile(); + downloadFile = downloadService.forSong(this.song); File partialFile = downloadFile.getPartialFile(); - Drawable leftImage = null; - Drawable rightImage = null; - if (downloadFile.isWorkDone()) { - leftImage = downloadFile.isSaved() ? Util.getDrawableFromAttribute(getContext(), R.attr.unpin) : Util.getDrawableFromAttribute(getContext(), R.attr.downloaded); + ImageType newLeftImageType = downloadFile.isSaved() ? ImageType.unpin : ImageType.downloaded; + + if (this.leftImageType != newLeftImageType) { + this.leftImage = downloadFile.isSaved() ? unpinImage : downloadedImage; + this.leftImageType = newLeftImageType; + } + } else { + this.leftImageType = ImageType.none; + this.leftImage = null; } - if (statusTextView != null) { - if (downloadFile.isDownloading() && !downloadFile.isDownloadCancelled() && partialFile.exists()) { - statusTextView.setText(Util.formatLocalizedBytes(partialFile.length(), getContext())); - rightImage = Util.getDrawableFromAttribute(getContext(), R.attr.downloading); - } else { - statusTextView.setText(null); - } - - statusTextView.setCompoundDrawablesWithIntrinsicBounds(leftImage, null, rightImage, null); + if (downloadFile.isDownloading() && !downloadFile.isDownloadCancelled() && partialFile.exists()) { + this.statusTextView.setText(Util.formatLocalizedBytes(partialFile.length(), this.context)); + this.rightImageType = ImageType.downloading; + this.rightImage = downloadingImage; + } else { + this.rightImageType = ImageType.none; + this.rightImage = null; + + if (this.statusTextView.getText() != null) { + this.statusTextView.setText(null); + } } - + + if (this.previousLeftImageType != leftImageType || this.previousRightImageType != rightImageType) { + this.previousLeftImageType = leftImageType; + this.previousRightImageType = rightImageType; + this.statusTextView.setCompoundDrawablesWithIntrinsicBounds(leftImage, null, rightImage, null); + } + if (!song.getStarred()) { - starImageView.setImageDrawable(Util.getDrawableFromAttribute(getContext(), R.attr.star_hollow)); + if (starImageView.getDrawable() != starHollowDrawable) { + starImageView.setImageDrawable(starHollowDrawable); + } } else { - starImageView.setImageDrawable(Util.getDrawableFromAttribute(getContext(), R.attr.star_full)); + if (starImageView.getDrawable() != starDrawable) { + starImageView.setImageDrawable(starDrawable); + } } boolean playing = downloadService.getCurrentPlaying() == downloadFile; + if (playing) { - titleTextView.setCompoundDrawablesWithIntrinsicBounds(Util.getDrawableFromAttribute(getContext(), R.attr.media_play_small), null, null, null); + if (!this.playing) { + this.playing = true; + titleTextView.setCompoundDrawablesWithIntrinsicBounds(playingImage, null, null, null); + } } else { - titleTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + if (this.playing) { + this.playing = false; + titleTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + } } } @@ -243,4 +312,11 @@ public class SongView extends UpdateView implements Checkable { public void toggle() { checkedTextView.toggle(); } + + public enum ImageType { + none, + unpin, + downloaded, + downloading + } } diff --git a/src/com/thejoshwa/ultrasonic/androidapp/view/UpdateView.java b/src/com/thejoshwa/ultrasonic/androidapp/view/UpdateView.java index 04b3ae11..52154dc6 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/view/UpdateView.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/view/UpdateView.java @@ -7,6 +7,9 @@ import android.util.Log; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.LinearLayout; + +import com.thejoshwa.ultrasonic.androidapp.util.Util; + import java.util.ArrayList; import java.util.List; import java.util.WeakHashMap; @@ -18,19 +21,14 @@ public class UpdateView extends LinearLayout { private static Handler backgroundHandler; private static Handler uiHandler; private static Runnable updateRunnable; + private static Context context; public UpdateView(Context context) { super(context); + this.context = context; setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - INSTANCES.put(this, null); - int instanceCount = INSTANCES.size(); - - if (instanceCount > 50) { - Log.w(TAG, instanceCount + " live UpdateView instances"); - } - startUpdater(); } @@ -77,6 +75,7 @@ public class UpdateView extends LinearLayout { Log.w(TAG, "Error when updating song views.", x); } } + private static void updateAllLive(final List views) { final Runnable runnable = new Runnable() { @Override @@ -88,7 +87,7 @@ public class UpdateView extends LinearLayout { } catch (Throwable x) { Log.w(TAG, "Error when updating song views.", x); } - uiHandler.postDelayed(updateRunnable, 1000L); + uiHandler.postDelayed(updateRunnable, Util.getViewRefreshInterval(context)); } };