diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-05-02 12:10:33 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-05-02 12:10:33 -0700 |
commit | 2a4817a915659cd57255f52b682244c4a458a14f (patch) | |
tree | 401536a0c518a016d900ca918cae71650306b36c /app/src/main/java | |
parent | 80665e81bec1bee22b1d93d287aa0ca0e23d0079 (diff) | |
parent | e954d2575a7a51b8792c7c97f2b1c3e94edaca2e (diff) | |
download | dsub-2a4817a915659cd57255f52b682244c4a458a14f.tar.gz dsub-2a4817a915659cd57255f52b682244c4a458a14f.tar.bz2 dsub-2a4817a915659cd57255f52b682244c4a458a14f.zip |
Merge branch 'master' into SlideUpPanel2
Diffstat (limited to 'app/src/main/java')
3 files changed, 37 insertions, 22 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/AlbumListAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/AlbumListAdapter.java index b2fcded3..7151362c 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/AlbumListAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/AlbumListAdapter.java @@ -19,6 +19,7 @@ package github.daneren2005.dsub.adapter; import android.content.Context; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -38,6 +39,7 @@ import java.util.List; import java.util.Set; public class AlbumListAdapter extends EndlessAdapter implements SectionIndexer { + private static final String TAG = AlbumListAdapter.class.getSimpleName(); Context context; ArrayAdapter<MusicDirectory.Entry> adapter; String type; @@ -97,26 +99,35 @@ public class AlbumListAdapter extends EndlessAdapter implements SectionIndexer { } private void recreateIndexes() { - if(!shouldIndex) { - return; - } - - Set<String> sectionSet = new LinkedHashSet<String>(30); - List<Integer> positionList = new ArrayList<Integer>(30); - for (int i = 0; i < adapter.getCount(); i++) { - MusicDirectory.Entry entry = adapter.getItem(i); - String index = entry.getAlbum().substring(0, 1); - if(!Character.isLetter(index.charAt(0))) { - index = "#"; + try { + if (!shouldIndex) { + return; } - if (!sectionSet.contains(index)) { - sectionSet.add(index); - positionList.add(i); + Set<String> sectionSet = new LinkedHashSet<String>(30); + List<Integer> positionList = new ArrayList<Integer>(30); + for (int i = 0; i < adapter.getCount(); i++) { + MusicDirectory.Entry entry = adapter.getItem(i); + String index; + if (entry.getAlbum() != null) { + index = entry.getAlbum().substring(0, 1); + if (!Character.isLetter(index.charAt(0))) { + index = "#"; + } + } else { + index = "*"; + } + + if (!sectionSet.contains(index)) { + sectionSet.add(index); + positionList.add(i); + } } + sections = sectionSet.toArray(new Object[sectionSet.size()]); + positions = positionList.toArray(new Integer[positionList.size()]); + } catch(Exception e) { + Log.e(TAG, "Error while recreating indexes"); } - sections = sectionSet.toArray(new Object[sectionSet.size()]); - positions = positionList.toArray(new Integer[positionList.size()]); } @Override diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java index 80183c40..6f325a4e 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -221,7 +221,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis albumArtImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { - if(me.getAction() == MotionEvent.ACTION_DOWN) { + if (me.getAction() == MotionEvent.ACTION_DOWN) { lastY = (int) me.getRawY(); } return gestureScanner.onTouchEvent(me); @@ -267,7 +267,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis @Override protected void done(Boolean result) { - if(result) { + if (result) { onCurrentChanged(); onProgressChanged(); } @@ -461,7 +461,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis albumArtImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if(overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { + if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { toggleFullscreenAlbumArt(); setControlsVisible(true); } @@ -1329,8 +1329,12 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis switch (playerState) { case DOWNLOADING: if(currentPlaying != null) { - long bytes = currentPlaying.getPartialFile().length(); - statusTextView.setText(context.getResources().getString(R.string.download_playerstate_downloading, Util.formatLocalizedBytes(bytes, context))); + if(Util.isWifiRequiredForDownload(context)) { + statusTextView.setText(context.getResources().getString(R.string.download_playerstate_mobile_disabled)); + } else { + long bytes = currentPlaying.getPartialFile().length(); + statusTextView.setText(context.getResources().getString(R.string.download_playerstate_downloading, Util.formatLocalizedBytes(bytes, context))); + } } break; case PREPARING: diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index 876dc648..969e178e 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -1036,7 +1036,7 @@ public final class Util { return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); } - private static boolean isWifiRequiredForDownload(Context context) { + public static boolean isWifiRequiredForDownload(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.PREFERENCES_KEY_WIFI_REQUIRED_FOR_DOWNLOAD, false); } |