diff options
Diffstat (limited to 'src/github/daneren2005')
10 files changed, 121 insertions, 112 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index 8fef07a8..b6daea98 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -111,7 +111,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis private View stopButton;
private View startButton;
private ImageButton repeatButton;
- private ImageButton shuffleButton;
+ private View toggleListButton;
private ImageButton starButton;
private ImageButton bookmarkButton;
private ImageButton rateBadButton;
@@ -187,7 +187,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark);
rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad);
rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good);
- shuffleButton = (ImageButton) rootView.findViewById(R.id.download_shuffle);
+ toggleListButton =rootView.findViewById(R.id.download_toggle_list);
starButton = (ImageButton)rootView.findViewById(R.id.download_star);
if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) {
@@ -350,7 +350,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis public void onClick(View view) {
RepeatMode repeatMode = getDownloadService().getRepeatMode().next();
getDownloadService().setRepeatMode(repeatMode);
- updateButtons();
+ onDownloadListChanged();
switch (repeatMode) {
case OFF:
Util.toast(context, R.string.download_repeat_off);
@@ -453,18 +453,11 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis }
});
- shuffleButton.setOnClickListener(new View.OnClickListener() {
+ toggleListButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- DownloadService downloadService = getDownloadService();
- downloadService.setShuffleMode(!downloadService.isShuffleMode());
- updateButtons();
+ toggleFullscreenAlbumArt();
setControlsVisible(true);
- if(downloadService.isShuffleMode()) {
- Util.toast(context, R.string.download_shuffle_on);
- } else {
- Util.toast(context, R.string.download_shuffle_off);
- }
}
});
@@ -551,7 +544,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis if (downloadService != null && context.getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) {
context.getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE);
warnIfNetworkOrStorageUnavailable();
- downloadService.setShuffleRemote(true);
+ downloadService.setShufflePlayEnabled(true);
}
if(Build.MODEL.equals("Nexus 4") || Build.MODEL.equals("GT-I9100")) {
@@ -741,7 +734,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
- getDownloadService().setShuffleRemote(false);
+ getDownloadService().setShufflePlayEnabled(false);
getDownloadService().clear();
return null;
}
@@ -772,9 +765,19 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis }
context.supportInvalidateOptionsMenu();
return true;
- case R.id.menu_toggle_list:
- toggleFullscreenAlbumArt();
- setControlsVisible(true);
+ case R.id.menu_shuffle:
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ getDownloadService().shuffle();
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, R.string.download_menu_shuffle_notification);
+ }
+ }.execute();
return true;
case R.id.menu_save_playlist:
List<Entry> entries = new LinkedList<Entry>();
@@ -946,39 +949,6 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis rateBadButton.setVisibility(View.VISIBLE);
rateGoodButton.setVisibility(View.VISIBLE);
}
-
- DownloadService downloadService = getDownloadService();
- if(downloadService == null) {
- return;
- }
-
- switch (downloadService.getRepeatMode()) {
- case OFF:
- if("light".equals(SubsonicActivity.getThemeName()) | "light_fullscreen".equals(SubsonicActivity.getThemeName())) {
- repeatButton.setImageResource(R.drawable.media_repeat_off_light);
- } else {
- repeatButton.setImageResource(R.drawable.media_repeat_off);
- }
- break;
- case ALL:
- repeatButton.setImageResource(R.drawable.media_repeat_all);
- break;
- case SINGLE:
- repeatButton.setImageResource(R.drawable.media_repeat_single);
- break;
- default:
- break;
- }
-
- if(downloadService.isShuffleMode()) {
- shuffleButton.setImageResource(R.drawable.ic_menu_shuffle_selected);
- } else {
- if("light".equals(SubsonicActivity.getThemeName())) {
- shuffleButton.setImageResource(R.drawable.ic_menu_shuffle_light);
- } else {
- shuffleButton.setImageResource(R.drawable.ic_menu_shuffle_dark);
- }
- }
}
// Scroll to current playing/downloading.
@@ -1143,7 +1113,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis List<DownloadFile> list;
list = downloadService.getSongs();
- if(downloadService.isShuffleRemote()) {
+ if(downloadService.isShufflePlayEnabled()) {
emptyTextView.setText(R.string.download_shuffle_loading);
}
else {
@@ -1162,6 +1132,24 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
currentRevision = downloadService.getDownloadListUpdateRevision();
+
+ switch (downloadService.getRepeatMode()) {
+ case OFF:
+ if("light".equals(SubsonicActivity.getThemeName()) | "light_fullscreen".equals(SubsonicActivity.getThemeName())) {
+ repeatButton.setImageResource(R.drawable.media_repeat_off_light);
+ } else {
+ repeatButton.setImageResource(R.drawable.media_repeat_off);
+ }
+ break;
+ case ALL:
+ repeatButton.setImageResource(R.drawable.media_repeat_all);
+ break;
+ case SINGLE:
+ repeatButton.setImageResource(R.drawable.media_repeat_single);
+ break;
+ default:
+ break;
+ }
if(scrollWhenLoaded) {
scrollToCurrent();
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java index b7ef204f..f73989fb 100644 --- a/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -13,6 +13,7 @@ import android.view.Menu; import android.view.MenuInflater;
import android.view.View;
import android.view.MenuItem;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
@@ -324,7 +325,7 @@ public class SearchFragment extends SubsonicFragment { if (!append) {
downloadService.clear();
}
- downloadService.download(Arrays.asList(song), save, false, playNext);
+ downloadService.download(Arrays.asList(song), save, false, playNext, false);
if (autoplay) {
downloadService.play(downloadService.size() - 1);
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index 46251073..c26429ce 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -18,6 +18,8 @@ */ package github.daneren2005.dsub.fragments; +import android.content.DialogInterface; +import android.util.Log; import android.view.ContextMenu; import android.view.MenuInflater; import android.view.MenuItem; @@ -28,12 +30,18 @@ import github.daneren2005.dsub.R; import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.MusicService; +import github.daneren2005.dsub.service.MusicServiceFactory; +import github.daneren2005.dsub.service.OfflineException; +import github.daneren2005.dsub.service.ServerTooOldException; +import github.daneren2005.dsub.util.LoadingTask; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.BookmarkAdapter; +import github.daneren2005.dsub.view.SongView; import java.text.Format; import java.text.SimpleDateFormat; @@ -106,7 +114,7 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En @Override protected Void doInBackground() throws Throwable { downloadService.clear(); - downloadService.download(Arrays.asList(bookmark), false, true, false, 0, bookmark.getBookmark().getPosition()); + downloadService.download(Arrays.asList(bookmark), false, true, false, false, 0, bookmark.getBookmark().getPosition()); return null; } diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 677664b5..a8b4ab38 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -780,7 +780,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
private void playNow(final boolean shuffle, final boolean append, final boolean playNext) {
if(getSelectedSongs().size() > 0) {
- download(append, false, !append, playNext);
+ download(append, false, !append, playNext, shuffle);
selectAll(false, false);
}
else {
@@ -804,7 +804,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter downloadRecursively(id, false, append, !append, shuffle, false);
} else {
selectAll(true, false);
- download(append, false, !append, false);
+ download(append, false, !append, false, shuffle);
selectAll(false, false);
}
}
@@ -857,7 +857,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter return indexes;
}
- private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext) {
+ private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext, final boolean shuffle) {
if (getDownloadService() == null) {
return;
}
@@ -866,7 +866,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter warnIfNetworkOrStorageUnavailable();
// Conditions for using play now button
- if(!append && !save && autoplay && !playNext) {
+ if(!append && !save && autoplay && !playNext && !shuffle) {
// Call playNow which goes through and tries to use bookmark information
playNow(songs, playlistName, playlistId);
return;
@@ -879,7 +879,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter getDownloadService().clear();
}
- getDownloadService().download(songs, save, autoplay, playNext);
+ getDownloadService().download(songs, save, autoplay, playNext, shuffle);
if (playlistName != null) {
getDownloadService().setSuggestedPlaylistName(playlistName, playlistId);
} else {
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index 741ed8a5..caf9079f 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -98,6 +98,17 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { replaceFragment(fragment);
break;
+ case R.id.playlist_menu_play_shuffled:
+ fragment = new SelectDirectoryFragment();
+ args = new Bundle();
+ args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
+ args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
+ fragment.setArguments(args);
+
+ replaceFragment(fragment);
+ break;
case R.id.playlist_menu_delete:
deletePlaylist(playlist);
break;
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 1a5cd5a7..5cab2497 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -376,6 +376,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR artistOverride = true;
downloadRecursively(entry.getId(), false, false, true, false, false);
break;
+ case R.id.album_menu_play_shuffled:
+ artistOverride = true;
+ downloadRecursively(entry.getId(), false, false, true, true, false);
+ break;
case R.id.album_menu_play_next:
artistOverride = true;
downloadRecursively(entry.getId(), false, true, false, false, false, true);
@@ -411,10 +415,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR playNow(songs);
break;
case R.id.song_menu_play_next:
- getDownloadService().download(songs, false, false, true);
+ getDownloadService().download(songs, false, false, true, false);
break;
case R.id.song_menu_play_last:
- getDownloadService().download(songs, false, false, false);
+ getDownloadService().download(songs, false, false, false, false);
break;
case R.id.song_menu_download:
getDownloadService().downloadBackground(songs, false);
@@ -889,7 +893,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR downloadService.clear();
}
if(!background) {
- downloadService.download(songs, save, autoplay, playNext);
+ downloadService.download(songs, save, autoplay, playNext, false);
if(!append) {
transition = true;
}
@@ -1553,7 +1557,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
downloadService.clear();
- downloadService.download(entries, false, true, true, entries.indexOf(song), position);
+ downloadService.download(entries, false, true, true, false, entries.indexOf(song), position);
downloadService.setSuggestedPlaylistName(playlistName, playlistId);
return null;
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index c7298169..50a2d34e 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -53,11 +53,12 @@ import github.daneren2005.dsub.view.UpdateView; import github.daneren2005.serverproxy.BufferProxy; import java.io.File; +import java.io.IOError; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.Random; import java.util.Timer; import java.util.TimerTask; @@ -69,6 +70,7 @@ import android.content.SharedPreferences; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.audiofx.AudioEffect; +import android.media.audiofx.Equalizer; import android.os.Build; import android.os.Handler; import android.os.IBinder; @@ -114,7 +116,6 @@ public class DownloadService extends Service { private Handler mediaPlayerHandler; private final DownloadServiceLifecycleSupport lifecycleSupport = new DownloadServiceLifecycleSupport(this); private ShufflePlayBuffer shufflePlayBuffer; - private Random random = new Random(); private final LruCache<MusicDirectory.Entry, DownloadFile> downloadFileCache = new LruCache<MusicDirectory.Entry, DownloadFile>(100); private final List<DownloadFile> cleanupCandidates = new ArrayList<DownloadFile>(); @@ -129,8 +130,7 @@ public class DownloadService extends Service { private PlayerState playerState = IDLE; private PlayerState nextPlayerState = IDLE; private boolean removePlayed; - private boolean shuffleRemote; - private boolean shuffleMode; + private boolean shufflePlay; private long revision; private static DownloadService instance; private String suggestedPlaylistName; @@ -229,7 +229,6 @@ public class DownloadService extends Service { instance = this; lifecycleSupport.onCreate(); shufflePlayBuffer = new ShufflePlayBuffer(this); - shuffleMode = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, false); } @Override @@ -302,11 +301,11 @@ public class DownloadService extends Service { return binder; } - public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext) { - download(songs, save, autoplay, playNext, 0, 0); + public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) { + download(songs, save, autoplay, playNext, shuffle, 0, 0); } - public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, int start, int position) { - setShuffleRemote(false); + public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int start, int position) { + setShufflePlayEnabled(false); int offset = 1; if (songs.isEmpty()) { @@ -339,6 +338,10 @@ public class DownloadService extends Service { } updateJukeboxPlaylist(); + if(shuffle) { + shuffle(); + } + if (autoplay) { play(start, true, position); } else { @@ -393,12 +396,12 @@ public class DownloadService extends Service { if(prefs.getBoolean(Constants.PREFERENCES_KEY_REMOVE_PLAYED, false)) { removePlayed = true; } - boolean startShufflePlay = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_REMOTE, false); - download(songs, false, false, false); + boolean startShufflePlay = prefs.getBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, false); + download(songs, false, false, false, false); if(startShufflePlay) { - shuffleRemote = true; + shufflePlay = true; SharedPreferences.Editor editor = prefs.edit(); - editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_REMOTE, true); + editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, true); editor.commit(); } if (currentPlayingIndex != -1) { @@ -434,29 +437,33 @@ public class DownloadService extends Service { return removePlayed; } - public synchronized void setShuffleRemote(boolean enabled) { - shuffleRemote = enabled; - if (shuffleRemote) { + public synchronized void setShufflePlayEnabled(boolean enabled) { + shufflePlay = enabled; + if (shufflePlay) { clear(); checkDownloads(); } SharedPreferences.Editor editor = Util.getPreferences(this).edit(); - editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_REMOTE, enabled); + editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, enabled); editor.commit(); } - public boolean isShuffleRemote() { - return shuffleRemote; + public boolean isShufflePlayEnabled() { + return shufflePlay; } - - public synchronized void setShuffleMode(boolean shuffleMode) { - this.shuffleMode = shuffleMode; - SharedPreferences.Editor editor = Util.getPreferences(this).edit(); - editor.putBoolean(Constants.PREFERENCES_KEY_SHUFFLE_MODE, shuffleMode); - editor.commit(); - } - public boolean isShuffleMode() { - return shuffleMode; + + public synchronized void shuffle() { + Collections.shuffle(downloadList); + currentPlayingIndex = downloadList.indexOf(currentPlaying); + if (currentPlaying != null) { + downloadList.remove(getCurrentPlayingIndex()); + downloadList.add(0, currentPlaying); + currentPlayingIndex = 0; + } + revision++; + lifecycleSupport.serializeDownloadQueue(); + updateJukeboxPlaylist(); + setNextPlaying(); } public RepeatMode getRepeatMode() { @@ -717,16 +724,13 @@ public class DownloadService extends Service { } private int getNextPlayingIndex() { int index = getCurrentPlayingIndex(); - int newIndex = index; - - // Increment based off of repeat mode if (index != -1) { switch (getRepeatMode()) { case OFF: - newIndex = index + 1; + index = index + 1; break; case ALL: - newIndex = (index + 1) % size(); + index = (index + 1) % size(); break; case SINGLE: break; @@ -734,17 +738,7 @@ public class DownloadService extends Service { break; } } - - // If we are in shuffle mode and index changed, get random index - if(shuffleMode && index != newIndex) { - // Retry if next random is same as current - // Add size condition to prevent infinite loop - do { - newIndex = random.nextInt(size()); - } while(index == newIndex && size() > 1); - } - - return newIndex; + return index; } public DownloadFile getCurrentPlaying() { @@ -1731,7 +1725,7 @@ public class DownloadService extends Service { if(removePlayed) { checkRemovePlayed(); } - if (shuffleRemote) { + if (shufflePlay) { checkShufflePlay(); } @@ -1913,7 +1907,7 @@ public class DownloadService extends Service { // Is an audio book // Next playing exists and is not a wrap around or a shuffle // Next playing is from same context as current playing, so not at end of list - if(entry.isAudioBook() && nextPlaying != null && downloadList.indexOf(nextPlaying) != 0 && !shuffleMode && !shuffleRemote + if(entry.isAudioBook() && nextPlaying != null && downloadList.indexOf(nextPlaying) != 0 && !shufflePlay && entry.getParent() != null && entry.getParent().equals(nextPlaying.getSong().getParent())) { isPastCutoff = false; } diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 9cd2896b..0a1e2cdd 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -198,7 +198,7 @@ public class DownloadServiceLifecycleSupport { } editor.commit(); - downloadService.setShuffleRemote(true); + downloadService.setShufflePlayEnabled(true); } else { downloadService.start(); } diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index e5707cca..50651a80 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -113,8 +113,7 @@ public final class Constants { public static final String PREFERENCES_KEY_PERSISTENT_NOTIFICATION = "persistentNotification"; public static final String PREFERENCES_KEY_GAPLESS_PLAYBACK = "gaplessPlayback"; public static final String PREFERENCES_KEY_REMOVE_PLAYED = "removePlayed"; - public static final String PREFERENCES_KEY_SHUFFLE_REMOTE = "shuffleMode"; - public static final String PREFERENCES_KEY_SHUFFLE_MODE = "shuffleCurrentMode"; + public static final String PREFERENCES_KEY_SHUFFLE_MODE = "shuffleMode"; public static final String PREFERENCES_KEY_CHAT_REFRESH = "chatRefreshRate"; public static final String PREFERENCES_KEY_CHAT_ENABLED = "chatEnabled"; public static final String PREFERENCES_KEY_VIDEO_PLAYER = "videoPlayer"; diff --git a/src/github/daneren2005/dsub/view/SeekBarPreference.java b/src/github/daneren2005/dsub/view/SeekBarPreference.java index e96d76f8..a22d049b 100644 --- a/src/github/daneren2005/dsub/view/SeekBarPreference.java +++ b/src/github/daneren2005/dsub/view/SeekBarPreference.java @@ -116,7 +116,11 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee SeekBar seekBar = (SeekBar)view.findViewById(R.id.seek_bar);
seekBar.setMax(mMax - mMin);
- seekBar.setProgress(Integer.parseInt(mValue));
+ try {
+ seekBar.setProgress(Integer.parseInt(mValue));
+ } catch(Exception e) {
+ seekBar.setProgress(0);
+ }
seekBar.setOnSeekBarChangeListener(this);
return view;
|