aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-03-07 20:30:00 -0800
committerScott Jackson <daneren2005@gmail.com>2013-03-07 20:30:00 -0800
commitfea1f42af85563ecf6b716e907875b14b68588ff (patch)
tree1cd14c0a4f26fba40644eadd4dd29da73e7a5cf6 /subsonic-android
parent4a32d662a22aef43896932e6cb122ec6de89e0cd (diff)
downloaddsub-fea1f42af85563ecf6b716e907875b14b68588ff.tar.gz
dsub-fea1f42af85563ecf6b716e907875b14b68588ff.tar.bz2
dsub-fea1f42af85563ecf6b716e907875b14b68588ff.zip
Convert spaces to tabs + get rid of unused imports
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/MusicActivity.java190
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java142
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java261
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java138
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java66
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java39
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java28
7 files changed, 408 insertions, 456 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MusicActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MusicActivity.java
index 26dc575a..300fb780 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/MusicActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/MusicActivity.java
@@ -19,9 +19,9 @@ public class MusicActivity extends SubsonicActivity {
private static final String TAG = MusicActivity.class.getSimpleName();
private static boolean infoDialogDisplayed;
private MainActivityPagerAdapter pagerAdapter;
- private ViewPager viewPager;
+ private ViewPager viewPager;
private SubsonicTabFragment prevPageFragment;
-
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -29,94 +29,94 @@ public class MusicActivity extends SubsonicActivity {
exit();
}
setContentView(R.layout.music);
-
+
pagerAdapter = new MainActivityPagerAdapter(getSupportFragmentManager());
- viewPager = (ViewPager) findViewById(R.id.pager);
- viewPager.setAdapter(pagerAdapter);
- viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
- @Override
- public void onPageSelected(int position) {
- notifyFragmentOnPageSelected(position);
- }
- });
-
- if (savedInstanceState == null) {
- int position = Util.isOffline(this) ? 0 : 2;
- if (position == viewPager.getCurrentItem()) {
- notifyFragmentOnPageSelected(position);
- } else {
- viewPager.setCurrentItem(position);
- }
- }
-
- handleIntentAction(getIntent());
+ viewPager = (ViewPager) findViewById(R.id.pager);
+ viewPager.setAdapter(pagerAdapter);
+ viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ @Override
+ public void onPageSelected(int position) {
+ notifyFragmentOnPageSelected(position);
+ }
+ });
+
+ if (savedInstanceState == null) {
+ int position = Util.isOffline(this) ? 0 : 2;
+ if (position == viewPager.getCurrentItem()) {
+ notifyFragmentOnPageSelected(position);
+ } else {
+ viewPager.setCurrentItem(position);
+ }
+ }
+
+ handleIntentAction(getIntent());
}
-
+
@Override
- protected void onPostCreate(Bundle bundle) {
- super.onPostCreate(bundle);
-
- getSupportActionBar().setDisplayHomeAsUpEnabled(false);
- getSupportActionBar().setHomeButtonEnabled(false);
-
- showInfoDialog();
- }
-
+ protected void onPostCreate(Bundle bundle) {
+ super.onPostCreate(bundle);
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+ getSupportActionBar().setHomeButtonEnabled(false);
+
+ showInfoDialog();
+ }
+
@Override
- public void onResume() {
- super.onResume();
- }
-
+ public void onResume() {
+ super.onResume();
+ }
+
@Override
- protected void onNewIntent(Intent intent) {
- handleIntentAction(intent);
- // mPagerAdapter.notifyDataSetChanged();
- }
-
+ protected void onNewIntent(Intent intent) {
+ handleIntentAction(intent);
+ // mPagerAdapter.notifyDataSetChanged();
+ }
+
private void handleIntentAction(Intent intent) {
- if (intent.hasExtra(Constants.INTENT_EXTRA_NAME_EXIT)) {
- exit();
- }
- }
-
+ if (intent.hasExtra(Constants.INTENT_EXTRA_NAME_EXIT)) {
+ exit();
+ }
+ }
+
private void exit() {
- stopService(new Intent(this, DownloadServiceImpl.class));
- finish();
- }
-
+ stopService(new Intent(this, DownloadServiceImpl.class));
+ finish();
+ }
+
private void showInfoDialog() {
- if (!infoDialogDisplayed) {
- infoDialogDisplayed = true;
- if (Util.getRestUrl(this, null).contains("demo.subsonic.org")) {
- Util.info(this, R.string.main_welcome_title, R.string.main_welcome_text);
- }
- }
- }
-
+ if (!infoDialogDisplayed) {
+ infoDialogDisplayed = true;
+ if (Util.getRestUrl(this, null).contains("demo.subsonic.org")) {
+ Util.info(this, R.string.main_welcome_title, R.string.main_welcome_text);
+ }
+ }
+ }
+
private void notifyFragmentOnPageSelected(int position) {
- /*if (prevPageFragment != null) {
- prevPageFragment.onPageDeselected();
- }
+ /*if (prevPageFragment != null) {
+ prevPageFragment.onPageDeselected();
+ }
prevPageFragment = (SubsonicTabFragment) pagerAdapter.instantiateItem(viewPager, position);
prevPageFragment.onPageSelected();*/
- }
-
+ }
+
public class MainActivityPagerAdapter extends FragmentPagerAdapter {
-
- private final String [] titles = new String [] {
- "Home",
- "Library",
+
+ private final String [] titles = new String [] {
+ "Home",
+ "Library",
"Playlists"
- };
-
- public MainActivityPagerAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int i) {
- Fragment fragment;
- Bundle args = new Bundle();
+ };
+
+ public MainActivityPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int i) {
+ Fragment fragment;
+ Bundle args = new Bundle();
switch(i) {
case 0:
fragment = new MainFragment();
@@ -130,22 +130,22 @@ public class MusicActivity extends SubsonicActivity {
default:
fragment = null;
}
-
- if (fragment != null) {
- fragment.setArguments(args);
- }
-
- return fragment;
- }
-
- @Override
- public int getCount() {
- return 3;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- return titles[position];
- }
- }
+
+ if (fragment != null) {
+ fragment.setArguments(args);
+ }
+
+ return fragment;
+ }
+
+ @Override
+ public int getCount() {
+ return 3;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return titles[position];
+ }
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
index 88851d48..38140f87 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -21,12 +21,12 @@ import java.util.Arrays;
public class MainFragment extends SubsonicTabFragment {
private LayoutInflater inflater;
-
+
private static final int MENU_GROUP_SERVER = 10;
- private static final int MENU_ITEM_SERVER_1 = 101;
- private static final int MENU_ITEM_SERVER_2 = 102;
- private static final int MENU_ITEM_SERVER_3 = 103;
-
+ private static final int MENU_ITEM_SERVER_1 = 101;
+ private static final int MENU_ITEM_SERVER_2 = 102;
+ private static final int MENU_ITEM_SERVER_3 = 103;
+
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
@@ -39,7 +39,7 @@ public class MainFragment extends SubsonicTabFragment {
loadSettings();
createLayout();
-
+
return rootView;
}
@@ -52,54 +52,54 @@ public class MainFragment extends SubsonicTabFragment {
public void onDestroy() {
super.onDestroy();
}
-
+
@Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, view, menuInfo);
-
- android.view.MenuItem menuItem1 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_1, MENU_ITEM_SERVER_1, Util.getServerName(context, 1));
- android.view.MenuItem menuItem2 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_2, MENU_ITEM_SERVER_2, Util.getServerName(context, 2));
- android.view.MenuItem menuItem3 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_3, MENU_ITEM_SERVER_3, Util.getServerName(context, 3));
- menu.setGroupCheckable(MENU_GROUP_SERVER, true, true);
- menu.setHeaderTitle(R.string.main_select_server);
-
- switch (Util.getActiveServer(context)) {
- case 1:
- menuItem1.setChecked(true);
- break;
- case 2:
- menuItem2.setChecked(true);
- break;
- case 3:
- menuItem3.setChecked(true);
- break;
- }
- }
-
+ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, view, menuInfo);
+
+ android.view.MenuItem menuItem1 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_1, MENU_ITEM_SERVER_1, Util.getServerName(context, 1));
+ android.view.MenuItem menuItem2 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_2, MENU_ITEM_SERVER_2, Util.getServerName(context, 2));
+ android.view.MenuItem menuItem3 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_3, MENU_ITEM_SERVER_3, Util.getServerName(context, 3));
+ menu.setGroupCheckable(MENU_GROUP_SERVER, true, true);
+ menu.setHeaderTitle(R.string.main_select_server);
+
+ switch (Util.getActiveServer(context)) {
+ case 1:
+ menuItem1.setChecked(true);
+ break;
+ case 2:
+ menuItem2.setChecked(true);
+ break;
+ case 3:
+ menuItem3.setChecked(true);
+ break;
+ }
+ }
+
@Override
- public boolean onContextItemSelected(android.view.MenuItem menuItem) {
- switch (menuItem.getItemId()) {
- case MENU_ITEM_SERVER_1:
- setActiveServer(1);
- break;
- case MENU_ITEM_SERVER_2:
- setActiveServer(2);
- break;
- case MENU_ITEM_SERVER_3:
- setActiveServer(3);
- break;
- default:
- return super.onContextItemSelected(menuItem);
- }
-
- return true;
- }
-
+ public boolean onContextItemSelected(android.view.MenuItem menuItem) {
+ switch (menuItem.getItemId()) {
+ case MENU_ITEM_SERVER_1:
+ setActiveServer(1);
+ break;
+ case MENU_ITEM_SERVER_2:
+ setActiveServer(2);
+ break;
+ case MENU_ITEM_SERVER_3:
+ setActiveServer(3);
+ break;
+ default:
+ return super.onContextItemSelected(menuItem);
+ }
+
+ return true;
+ }
+
@Override
protected void refresh() {
createLayout();
}
-
+
private void createLayout() {
View buttons = inflater.inflate(R.layout.main_buttons, null);
@@ -140,20 +140,20 @@ public class MainFragment extends SubsonicTabFragment {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view == serverButton) {
- dummyView.showContextMenu();
- } else if (view == offlineButton) {
- toggleOffline();
+ dummyView.showContextMenu();
+ } else if (view == offlineButton) {
+ toggleOffline();
} else if (view == albumsNewestButton) {
- // showAlbumList("newest");
- } else if (view == albumsRandomButton) {
- // showAlbumList("random");
- } else if (view == albumsHighestButton) {
- // showAlbumList("highest");
- } else if (view == albumsRecentButton) {
- // showAlbumList("recent");
- } else if (view == albumsFrequentButton) {
- // showAlbumList("frequent");
- } else if (view == albumsStarredButton) {
+ // showAlbumList("newest");
+ } else if (view == albumsRandomButton) {
+ // showAlbumList("random");
+ } else if (view == albumsHighestButton) {
+ // showAlbumList("highest");
+ } else if (view == albumsRecentButton) {
+ // showAlbumList("recent");
+ } else if (view == albumsFrequentButton) {
+ // showAlbumList("frequent");
+ } else if (view == albumsStarredButton) {
// showAlbumList("starred");
}
}
@@ -176,17 +176,17 @@ public class MainFragment extends SubsonicTabFragment {
editor.commit();
}
}
-
+
private void setActiveServer(int instance) {
- if (Util.getActiveServer(context) != instance) {
- DownloadService service = getDownloadService();
- if (service != null) {
- service.clearIncomplete();
- }
- Util.setActiveServer(context, instance);
- }
- }
-
+ if (Util.getActiveServer(context) != instance) {
+ DownloadService service = getDownloadService();
+ if (service != null) {
+ service.clearIncomplete();
+ }
+ Util.setActiveServer(context, instance);
+ }
+ }
+
private void toggleOffline() {
Util.setOffline(context, !Util.isOffline(context));
refresh();
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index 01c66886..919010c1 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -13,15 +13,12 @@ import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.activity.SelectArtistActivity;
-import github.daneren2005.dsub.activity.SubsonicTabActivity;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.Indexes;
import github.daneren2005.dsub.domain.MusicFolder;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.BackgroundTask;
-import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.ArtistAdapter;
@@ -31,170 +28,170 @@ import java.util.List;
public class SelectArtistFragment extends SubsonicTabFragment implements AdapterView.OnItemClickListener {
private static final String TAG = SelectArtistFragment.class.getSimpleName();
private static final int MENU_GROUP_MUSIC_FOLDER = 10;
-
+
private ListView artistList;
- private View folderButton;
- private TextView folderName;
- private List<MusicFolder> musicFolders = null;
-
+ private View folderButton;
+ private TextView folderName;
+ private List<MusicFolder> musicFolders = null;
+
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
}
-
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
rootView = inflater.inflate(R.layout.select_artist, container, false);
-
+
artistList = (ListView) rootView.findViewById(R.id.select_artist_list);
- artistList.setOnItemClickListener(this);
+ artistList.setOnItemClickListener(this);
- folderButton = inflater.inflate(R.layout.select_artist_header, artistList, false);
- folderName = (TextView) folderButton.findViewById(R.id.select_artist_folder_2);
+ folderButton = inflater.inflate(R.layout.select_artist_header, artistList, false);
+ folderName = (TextView) folderButton.findViewById(R.id.select_artist_folder_2);
- if (!Util.isOffline(context)) {
- artistList.addHeaderView(folderButton);
- }
+ if (!Util.isOffline(context)) {
+ artistList.addHeaderView(folderButton);
+ }
- registerForContextMenu(artistList);
+ registerForContextMenu(artistList);
load(false);
-
+
return rootView;
}
-
+
@Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, view, menuInfo);
+ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, view, menuInfo);
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- if (artistList.getItemAtPosition(info.position) instanceof Artist) {
- MenuInflater inflater = context.getMenuInflater();
+ if (artistList.getItemAtPosition(info.position) instanceof Artist) {
+ MenuInflater inflater = context.getMenuInflater();
if(Util.isOffline(context))
inflater.inflate(R.menu.select_artist_context_offline, menu);
else
inflater.inflate(R.menu.select_artist_context, menu);
- } else if (info.position == 0) {
- String musicFolderId = Util.getSelectedMusicFolderId(context);
- MenuItem menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, -1, 0, R.string.select_artist_all_folders);
- if (musicFolderId == null) {
- menuItem.setChecked(true);
- }
- if (musicFolders != null) {
- for (int i = 0; i < musicFolders.size(); i++) {
- MusicFolder musicFolder = musicFolders.get(i);
- menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, i, i + 1, musicFolder.getName());
- if (musicFolder.getId().equals(musicFolderId)) {
- menuItem.setChecked(true);
- }
- }
- }
- menu.setGroupCheckable(MENU_GROUP_MUSIC_FOLDER, true, true);
- }
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem menuItem) {
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
-
- Artist artist = (Artist) artistList.getItemAtPosition(info.position);
-
- if (artist != null) {
- switch (menuItem.getItemId()) {
- case R.id.artist_menu_play_now:
- // downloadRecursively(artist.getId(), false, false, true, false, false);
- break;
+ } else if (info.position == 0) {
+ String musicFolderId = Util.getSelectedMusicFolderId(context);
+ MenuItem menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, -1, 0, R.string.select_artist_all_folders);
+ if (musicFolderId == null) {
+ menuItem.setChecked(true);
+ }
+ if (musicFolders != null) {
+ for (int i = 0; i < musicFolders.size(); i++) {
+ MusicFolder musicFolder = musicFolders.get(i);
+ menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, i, i + 1, musicFolder.getName());
+ if (musicFolder.getId().equals(musicFolderId)) {
+ menuItem.setChecked(true);
+ }
+ }
+ }
+ menu.setGroupCheckable(MENU_GROUP_MUSIC_FOLDER, true, true);
+ }
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem menuItem) {
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
+
+ Artist artist = (Artist) artistList.getItemAtPosition(info.position);
+
+ if (artist != null) {
+ switch (menuItem.getItemId()) {
+ case R.id.artist_menu_play_now:
+ // downloadRecursively(artist.getId(), false, false, true, false, false);
+ break;
case R.id.artist_menu_play_shuffled:
// downloadRecursively(artist.getId(), false, false, true, true, false);
- break;
- case R.id.artist_menu_play_last:
- // downloadRecursively(artist.getId(), false, true, false, false, false);
- break;
+ break;
+ case R.id.artist_menu_play_last:
+ // downloadRecursively(artist.getId(), false, true, false, false, false);
+ break;
case R.id.artist_menu_download:
- // downloadRecursively(artist.getId(), false, true, false, false, true);
- break;
- case R.id.artist_menu_pin:
- // downloadRecursively(artist.getId(), true, true, false, false, true);
- break;
+ // downloadRecursively(artist.getId(), false, true, false, false, true);
+ break;
+ case R.id.artist_menu_pin:
+ // downloadRecursively(artist.getId(), true, true, false, false, true);
+ break;
case R.id.artist_menu_delete:
- // deleteRecursively(artist);
- break;
- default:
- // return super.onContextItemSelected(menuItem);
- }
- } else if (info.position == 0) {
- MusicFolder selectedFolder = menuItem.getItemId() == -1 ? null : musicFolders.get(menuItem.getItemId());
- String musicFolderId = selectedFolder == null ? null : selectedFolder.getId();
- String musicFolderName = selectedFolder == null ? context.getString(R.string.select_artist_all_folders)
- : selectedFolder.getName();
- Util.setSelectedMusicFolderId(context, musicFolderId);
- folderName.setText(musicFolderName);
- refresh();
- }
-
- return true;
- }
+ // deleteRecursively(artist);
+ break;
+ default:
+ // return super.onContextItemSelected(menuItem);
+ }
+ } else if (info.position == 0) {
+ MusicFolder selectedFolder = menuItem.getItemId() == -1 ? null : musicFolders.get(menuItem.getItemId());
+ String musicFolderId = selectedFolder == null ? null : selectedFolder.getId();
+ String musicFolderName = selectedFolder == null ? context.getString(R.string.select_artist_all_folders)
+ : selectedFolder.getName();
+ Util.setSelectedMusicFolderId(context, musicFolderId);
+ folderName.setText(musicFolderName);
+ refresh();
+ }
+
+ return true;
+ }
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view == folderButton) {
- selectFolder();
- } else {
- Artist artist = (Artist) parent.getItemAtPosition(position);
- /*Intent intent = new Intent(this, SelectAlbumActivity.class);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
- Util.startActivityWithoutTransition(this, intent);*/
- }
+ selectFolder();
+ } else {
+ Artist artist = (Artist) parent.getItemAtPosition(position);
+ /*Intent intent = new Intent(this, SelectAlbumActivity.class);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
+ Util.startActivityWithoutTransition(this, intent);*/
+ }
}
-
+
@Override
protected void refresh() {
- load(true);
- }
-
+ load(true);
+ }
+
private void load(final boolean refresh) {
artistList.setVisibility(View.INVISIBLE);
-
- BackgroundTask<Indexes> task = new TabBackgroundTask<Indexes>(this) {
- @Override
- protected Indexes doInBackground() throws Throwable {
- MusicService musicService = MusicServiceFactory.getMusicService(context);
- if (!Util.isOffline(context)) {
- musicFolders = musicService.getMusicFolders(refresh, context, this);
- }
- String musicFolderId = Util.getSelectedMusicFolderId(context);
- return musicService.getIndexes(musicFolderId, refresh, context, this);
- }
-
- @Override
- protected void done(Indexes result) {
- List<Artist> artists = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
- artists.addAll(result.getShortcuts());
- artists.addAll(result.getArtists());
- artistList.setAdapter(new ArtistAdapter(context, artists));
-
- // Display selected music folder
- if (musicFolders != null) {
- String musicFolderId = Util.getSelectedMusicFolderId(context);
- if (musicFolderId == null) {
- folderName.setText(R.string.select_artist_all_folders);
- } else {
- for (MusicFolder musicFolder : musicFolders) {
- if (musicFolder.getId().equals(musicFolderId)) {
- folderName.setText(musicFolder.getName());
- break;
- }
- }
- }
+
+ BackgroundTask<Indexes> task = new TabBackgroundTask<Indexes>(this) {
+ @Override
+ protected Indexes doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ if (!Util.isOffline(context)) {
+ musicFolders = musicService.getMusicFolders(refresh, context, this);
+ }
+ String musicFolderId = Util.getSelectedMusicFolderId(context);
+ return musicService.getIndexes(musicFolderId, refresh, context, this);
+ }
+
+ @Override
+ protected void done(Indexes result) {
+ List<Artist> artists = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
+ artists.addAll(result.getShortcuts());
+ artists.addAll(result.getArtists());
+ artistList.setAdapter(new ArtistAdapter(context, artists));
+
+ // Display selected music folder
+ if (musicFolders != null) {
+ String musicFolderId = Util.getSelectedMusicFolderId(context);
+ if (musicFolderId == null) {
+ folderName.setText(R.string.select_artist_all_folders);
+ } else {
+ for (MusicFolder musicFolder : musicFolders) {
+ if (musicFolder.getId().equals(musicFolderId)) {
+ folderName.setText(musicFolder.getName());
+ break;
+ }
+ }
+ }
artistList.setVisibility(View.VISIBLE);
- }
- }
- };
- task.execute();
- }
-
+ }
+ }
+ };
+ task.execute();
+ }
+
private void selectFolder() {
- folderButton.showContextMenu();
- }
+ folderButton.showContextMenu();
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 2d57b177..eaba77e5 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -11,56 +11,46 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
-import android.widget.TextView;
import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.activity.SelectArtistActivity;
-import github.daneren2005.dsub.activity.SelectPlaylistActivity;
-import github.daneren2005.dsub.activity.SubsonicTabActivity;
-import github.daneren2005.dsub.domain.Artist;
-import github.daneren2005.dsub.domain.Indexes;
-import github.daneren2005.dsub.domain.MusicFolder;
import github.daneren2005.dsub.domain.Playlist;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.CacheCleaner;
-import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
-import github.daneren2005.dsub.view.ArtistAdapter;
import github.daneren2005.dsub.view.PlaylistAdapter;
-import java.util.ArrayList;
import java.util.List;
public class SelectPlaylistFragment extends SubsonicTabFragment implements AdapterView.OnItemClickListener {
private static final String TAG = SelectPlaylistFragment.class.getSimpleName();
-
+
private ListView list;
- private View emptyTextView;
+ private View emptyTextView;
private PlaylistAdapter playlistAdapter;
-
+
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
}
-
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
rootView = inflater.inflate(R.layout.select_playlist, container, false);
-
+
list = (ListView) rootView.findViewById(R.id.select_playlist_list);
- emptyTextView = rootView.findViewById(R.id.select_playlist_empty);
- list.setOnItemClickListener(this);
- registerForContextMenu(list);
+ emptyTextView = rootView.findViewById(R.id.select_playlist_empty);
+ list.setOnItemClickListener(this);
+ registerForContextMenu(list);
load(false);
-
+
return rootView;
}
-
+
@Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, view, menuInfo);
-
+ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, view, menuInfo);
+
MenuInflater inflater = context.getMenuInflater();
if (Util.isOffline(context)) {
inflater.inflate(R.menu.select_playlist_context_offline, menu);
@@ -68,36 +58,36 @@ public class SelectPlaylistFragment extends SubsonicTabFragment implements Adapt
else {
inflater.inflate(R.menu.select_playlist_context, menu);
}
- }
+ }
- @Override
- public boolean onContextItemSelected(MenuItem menuItem) {
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
- Playlist playlist = (Playlist) list.getItemAtPosition(info.position);
+ @Override
+ public boolean onContextItemSelected(MenuItem menuItem) {
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
+ Playlist playlist = (Playlist) list.getItemAtPosition(info.position);
Intent intent;
- /*switch (menuItem.getItemId()) {
+ /*switch (menuItem.getItemId()) {
case R.id.playlist_menu_download:
downloadPlaylist(playlist.getId(), playlist.getName(), false, true, false, false, true);
break;
case R.id.playlist_menu_pin:
downloadPlaylist(playlist.getId(), playlist.getName(), true, true, false, false, true);
break;
- case R.id.playlist_menu_play_now:
- intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
- Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent);
- break;
+ case R.id.playlist_menu_play_now:
+ intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
+ Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent);
+ break;
case R.id.playlist_menu_play_shuffled:
intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
- Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent);
- break;
+ Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent);
+ break;
case R.id.playlist_menu_delete:
deletePlaylist(playlist);
break;
@@ -107,45 +97,45 @@ public class SelectPlaylistFragment extends SubsonicTabFragment implements Adapt
case R.id.playlist_update_info:
updatePlaylistInfo(playlist);
break;
- default:
- return super.onContextItemSelected(menuItem);
- }*/
- return true;
- }
-
+ default:
+ return super.onContextItemSelected(menuItem);
+ }*/
+ return true;
+ }
+
@Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- Playlist playlist = (Playlist) parent.getItemAtPosition(position);
-
- /*Intent intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
- Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent);*/
- }
-
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ Playlist playlist = (Playlist) parent.getItemAtPosition(position);
+
+ /*Intent intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
+ Util.startActivityWithoutTransition(SelectPlaylistActivity.this, intent);*/
+ }
+
@Override
protected void refresh() {
- load(true);
- }
-
+ load(true);
+ }
+
private void load(final boolean refresh) {
- BackgroundTask<List<Playlist>> task = new TabBackgroundTask<List<Playlist>>(this) {
- @Override
- protected List<Playlist> doInBackground() throws Throwable {
- MusicService musicService = MusicServiceFactory.getMusicService(context);
- List<Playlist> playlists = musicService.getPlaylists(refresh, context, this);
+ BackgroundTask<List<Playlist>> task = new TabBackgroundTask<List<Playlist>>(this) {
+ @Override
+ protected List<Playlist> doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ List<Playlist> playlists = musicService.getPlaylists(refresh, context, this);
if(!Util.isOffline(context) && refresh) {
new CacheCleaner(context, getDownloadService()).cleanPlaylists(playlists);
}
return playlists;
- }
-
- @Override
- protected void done(List<Playlist> result) {
- list.setAdapter(playlistAdapter = new PlaylistAdapter(context, result));
- emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE);
- }
- };
- task.execute();
- }
+ }
+
+ @Override
+ protected void done(List<Playlist> result) {
+ list.setAdapter(playlistAdapter = new PlaylistAdapter(context, result));
+ emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE);
+ }
+ };
+ task.execute();
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
index b64bd217..6d115bb9 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
@@ -19,50 +19,16 @@
package github.daneren2005.dsub.fragments;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.PackageInfo;
-import android.media.AudioManager;
-import android.media.MediaMetadataRetriever;
-import android.os.Build;
import android.os.Bundle;
-import android.os.Environment;
import android.util.Log;
-import android.view.KeyEvent;
import android.view.View;
-import android.widget.EditText;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragment;
import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.activity.DownloadActivity;
import github.daneren2005.dsub.activity.SubsonicActivity;
import github.daneren2005.dsub.activity.SubsonicTabActivity;
-import github.daneren2005.dsub.domain.Artist;
-import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.dsub.domain.Playlist;
-import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
-import github.daneren2005.dsub.service.DownloadServiceImpl;
-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.updates.Updater;
-import github.daneren2005.dsub.util.Constants;
-import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.ImageLoader;
-import github.daneren2005.dsub.util.LoadingTask;
-import github.daneren2005.dsub.util.ModalBackgroundTask;
-import github.daneren2005.dsub.util.SilentBackgroundTask;
-import github.daneren2005.dsub.util.Util;
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
public class SubsonicTabFragment extends SherlockFragment {
private static final String TAG = SubsonicTabActivity.class.getSimpleName();
@@ -90,26 +56,26 @@ public class SubsonicTabFragment extends SherlockFragment {
super.onAttach(activity);
context = (SubsonicActivity)activity;
}
-
+
public DownloadService getDownloadService() {
return context != null ? context.getDownloadService() : null;
}
-
+
protected void refresh() {
-
- }
-
+
+ }
+
public void setProgressVisible(boolean visible) {
- View view = rootView.findViewById(R.id.tab_progress);
- if (view != null) {
- view.setVisibility(visible ? View.VISIBLE : View.GONE);
- }
- }
+ View view = rootView.findViewById(R.id.tab_progress);
+ if (view != null) {
+ view.setVisibility(visible ? View.VISIBLE : View.GONE);
+ }
+ }
- public void updateProgress(String message) {
- TextView view = (TextView) rootView.findViewById(R.id.tab_progress_message);
- if (view != null) {
- view.setText(message);
- }
- }
+ public void updateProgress(String message) {
+ TextView view = (TextView) rootView.findViewById(R.id.tab_progress_message);
+ if (view != null) {
+ view.setText(message);
+ }
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java
index f50dd199..71727c04 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java
@@ -24,7 +24,6 @@ import java.util.List;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
-import github.daneren2005.dsub.activity.SubsonicTabActivity;
import github.daneren2005.dsub.domain.Playlist;
import java.util.Collections;
import java.util.Comparator;
@@ -34,16 +33,16 @@ import java.util.Comparator;
*/
public class PlaylistAdapter extends ArrayAdapter<Playlist> {
- private final Context activity;
+ private final Context activity;
- public PlaylistAdapter(Context activity, List<Playlist> Playlists) {
- super(activity, R.layout.playlist_list_item, Playlists);
- this.activity = activity;
- }
+ public PlaylistAdapter(Context activity, List<Playlist> Playlists) {
+ super(activity, R.layout.playlist_list_item, Playlists);
+ this.activity = activity;
+ }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- Playlist entry = getItem(position);
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ Playlist entry = getItem(position);
PlaylistView view;
if (convertView != null && convertView instanceof PlaylistView) {
view = (PlaylistView) convertView;
@@ -52,18 +51,18 @@ public class PlaylistAdapter extends ArrayAdapter<Playlist> {
}
view.setPlaylist(entry);
return view;
- }
-
+ }
+
public static class PlaylistComparator implements Comparator<Playlist> {
- @Override
- public int compare(Playlist playlist1, Playlist playlist2) {
- return playlist1.getName().compareToIgnoreCase(playlist2.getName());
- }
+ @Override
+ public int compare(Playlist playlist1, Playlist playlist2) {
+ return playlist1.getName().compareToIgnoreCase(playlist2.getName());
+ }
- public static List<Playlist> sort(List<Playlist> playlists) {
- Collections.sort(playlists, new PlaylistComparator());
- return playlists;
- }
+ public static List<Playlist> sort(List<Playlist> playlists) {
+ Collections.sort(playlists, new PlaylistComparator());
+ return playlists;
+ }
- }
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
index b09c91d4..effd5a98 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
@@ -36,32 +36,32 @@ import java.io.File;
*/
public class PlaylistView extends UpdateView {
private static final String TAG = PlaylistView.class.getSimpleName();
-
+
private Playlist playlist;
- private TextView titleView;
+ private TextView titleView;
private ImageView moreButton;
- public PlaylistView(Context context) {
- super(context);
- LayoutInflater.from(context).inflate(R.layout.playlist_list_item, this, true);
+ public PlaylistView(Context context) {
+ super(context);
+ LayoutInflater.from(context).inflate(R.layout.playlist_list_item, this, true);
- titleView = (TextView) findViewById(R.id.playlist_name);
+ titleView = (TextView) findViewById(R.id.playlist_name);
moreButton = (ImageView) findViewById(R.id.playlist_more);
moreButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
v.showContextMenu();
}
});
- }
+ }
+
+ public void setPlaylist(Playlist playlist) {
+ this.playlist = playlist;
- public void setPlaylist(Playlist playlist) {
- this.playlist = playlist;
-
- titleView.setText(playlist.getName());
+ titleView.setText(playlist.getName());
update();
- }
-
+ }
+
@Override
protected void update() {
File file = FileUtil.getPlaylistFile(playlist.getName());
@@ -70,5 +70,5 @@ public class PlaylistView extends UpdateView {
} else {
moreButton.setImageResource(R.drawable.list_item_more);
}
- }
+ }
}