aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-04-30 20:35:09 -0700
committerScott Jackson <daneren2005@gmail.com>2013-04-30 20:35:09 -0700
commitb0e3b154eab451ee0980aa7b2266bba5bde5e8f8 (patch)
tree1d1a90a1d8bd50ecc49f19c22dc6c7a5c5a572b8 /subsonic-android/src
parentf1408cdb34a90b5e03c76bff7e5afeeb75ab46f0 (diff)
downloaddsub-b0e3b154eab451ee0980aa7b2266bba5bde5e8f8.tar.gz
dsub-b0e3b154eab451ee0980aa7b2266bba5bde5e8f8.tar.bz2
dsub-b0e3b154eab451ee0980aa7b2266bba5bde5e8f8.zip
Got rid of tab fragment
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java486
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java14
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java27
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java6
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java27
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java53
9 files changed, 302 insertions, 323 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
index cc4d93ed..b5ff4abb 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
@@ -1,243 +1,243 @@
-package github.daneren2005.dsub.activity;
-
-import android.app.AlertDialog;
-import android.app.PendingIntent;
-import android.content.ComponentName;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.view.Menu;
-import android.support.v4.view.ViewPager;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.ImageButton;
-import android.widget.TextView;
-import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.dsub.domain.PlayerState;
-import github.daneren2005.dsub.fragments.MainFragment;
-import github.daneren2005.dsub.fragments.SelectArtistFragment;
-import github.daneren2005.dsub.fragments.SelectPlaylistFragment;
-import github.daneren2005.dsub.service.DownloadFile;
-import github.daneren2005.dsub.service.DownloadServiceImpl;
-import github.daneren2005.dsub.util.Constants;
-import github.daneren2005.dsub.util.SilentBackgroundTask;
-import github.daneren2005.dsub.util.Util;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-public class MainActivity extends SubsonicActivity {
- private static final String TAG = MainActivity.class.getSimpleName();
- private static boolean infoDialogDisplayed;
- private ScheduledExecutorService executorService;
- private View coverArtView;
- private TextView trackView;
- private TextView artistView;
- private ImageButton startButton;
- private long lastBackPressTime = 0;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_EXIT)) {
- stopService(new Intent(this, DownloadServiceImpl.class));
- finish();
- }
- setContentView(R.layout.main);
-
- View bottomBar = findViewById(R.id.bottom_bar);
- bottomBar.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- Intent intent = new Intent();
- intent.setClass(v.getContext(), DownloadActivity.class);
- startActivity(intent);
- }
- });
- coverArtView = bottomBar.findViewById(R.id.album_art);
- trackView = (TextView) bottomBar.findViewById(R.id.track_name);
- artistView = (TextView) bottomBar.findViewById(R.id.artist_name);
-
- ImageButton previousButton = (ImageButton) findViewById(R.id.download_previous);
- previousButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- new SilentBackgroundTask<Void>(MainActivity.this) {
- @Override
- protected Void doInBackground() throws Throwable {
- if(getDownloadService() == null) {
- return null;
- }
-
- getDownloadService().previous();
- return null;
- }
-
- @Override
- protected void done(Void result) {
- update();
- }
- }.execute();
- }
- });
-
- startButton = (ImageButton) findViewById(R.id.download_start);
- startButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- new SilentBackgroundTask<Void>(MainActivity.this) {
- @Override
- protected Void doInBackground() throws Throwable {
- PlayerState state = getDownloadService().getPlayerState();
- if(state == PlayerState.STARTED) {
- getDownloadService().pause();
- } else {
- getDownloadService().start();
- }
-
- return null;
- }
-
- @Override
- protected void done(Void result) {
- update();
- }
- }.execute();
- }
- });
-
- ImageButton nextButton = (ImageButton) findViewById(R.id.download_next);
- nextButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- new SilentBackgroundTask<Void>(MainActivity.this) {
- @Override
- protected Void doInBackground() throws Throwable {
- if(getDownloadService() == null) {
- return null;
- }
-
- if (getDownloadService().getCurrentPlayingIndex() < getDownloadService().size() - 1) {
- getDownloadService().next();
- }
- return null;
- }
-
- @Override
- protected void done(Void result) {
- update();
- }
- }.execute();
- }
- });
-
- viewPager = (ViewPager) findViewById(R.id.pager);
- pagerAdapter = new TabPagerAdapter(this, viewPager);
- viewPager.setAdapter(pagerAdapter);
- viewPager.setOnPageChangeListener(pagerAdapter);
-
- addTab("Home", MainFragment.class, null);
- addTab("Library", SelectArtistFragment.class, null);
- addTab("Playlists", SelectPlaylistFragment.class, null);
- }
-
- @Override
- public void onSaveInstanceState(Bundle savedInstanceState) {
-
- }
-
- @Override
- protected void onPostCreate(Bundle bundle) {
- super.onPostCreate(bundle);
-
- getSupportActionBar().setDisplayHomeAsUpEnabled(false);
- getSupportActionBar().setHomeButtonEnabled(false);
- getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
-
- showInfoDialog();
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final Handler handler = new Handler();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- handler.post(new Runnable() {
- @Override
- public void run() {
- update();
- }
- });
- }
- };
-
- executorService = Executors.newSingleThreadScheduledExecutor();
- executorService.scheduleWithFixedDelay(runnable, 0L, 1000L, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- executorService.shutdown();
- }
-
- @Override
- public void onBackPressed() {
- if(pagerAdapter.onBackPressed()) {
- if(lastBackPressTime < (System.currentTimeMillis() - 4000)) {
- lastBackPressTime = System.currentTimeMillis();
- Util.toast(this, R.string.main_back_confirm);
- } else {
- super.onBackPressed();
- }
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- if(pagerAdapter != null) {
- com.actionbarsherlock.view.MenuInflater menuInflater = getSupportMenuInflater();
- pagerAdapter.onCreateOptionsMenu(menu, menuInflater);
- }
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
- return pagerAdapter.onOptionsItemSelected(item);
- }
-
- private void update() {
- if (getDownloadService() == null) {
- return;
- }
-
- DownloadFile current = getDownloadService().getCurrentPlaying();
- if(current == null) {
- trackView.setText("Title");
- artistView.setText("Artist");
- getImageLoader().loadImage(coverArtView, null, false, false);
- return;
- }
-
- MusicDirectory.Entry song = current.getSong();
- trackView.setText(song.getTitle());
- artistView.setText(song.getArtist());
- getImageLoader().loadImage(coverArtView, song, false, false);
- startButton.setImageResource((getDownloadService().getPlayerState() == PlayerState.STARTED) ? R.drawable.media_pause : R.drawable.media_start);
- }
-
- 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);
- }
- }
- }
-}
+package github.daneren2005.dsub.activity;
+
+import android.app.AlertDialog;
+import android.app.PendingIntent;
+import android.content.ComponentName;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.view.Menu;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.TextView;
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.PlayerState;
+import github.daneren2005.dsub.fragments.MainFragment;
+import github.daneren2005.dsub.fragments.SelectArtistFragment;
+import github.daneren2005.dsub.fragments.SelectPlaylistFragment;
+import github.daneren2005.dsub.service.DownloadFile;
+import github.daneren2005.dsub.service.DownloadServiceImpl;
+import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.SilentBackgroundTask;
+import github.daneren2005.dsub.util.Util;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+public class MainActivity extends SubsonicActivity {
+ private static final String TAG = MainActivity.class.getSimpleName();
+ private static boolean infoDialogDisplayed;
+ private ScheduledExecutorService executorService;
+ private View coverArtView;
+ private TextView trackView;
+ private TextView artistView;
+ private ImageButton startButton;
+ private long lastBackPressTime = 0;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_EXIT)) {
+ stopService(new Intent(this, DownloadServiceImpl.class));
+ finish();
+ }
+ setContentView(R.layout.main);
+
+ View bottomBar = findViewById(R.id.bottom_bar);
+ bottomBar.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Intent intent = new Intent();
+ intent.setClass(v.getContext(), DownloadActivity.class);
+ startActivity(intent);
+ }
+ });
+ coverArtView = bottomBar.findViewById(R.id.album_art);
+ trackView = (TextView) bottomBar.findViewById(R.id.track_name);
+ artistView = (TextView) bottomBar.findViewById(R.id.artist_name);
+
+ ImageButton previousButton = (ImageButton) findViewById(R.id.download_previous);
+ previousButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new SilentBackgroundTask<Void>(MainActivity.this) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ if(getDownloadService() == null) {
+ return null;
+ }
+
+ getDownloadService().previous();
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ update();
+ }
+ }.execute();
+ }
+ });
+
+ startButton = (ImageButton) findViewById(R.id.download_start);
+ startButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new SilentBackgroundTask<Void>(MainActivity.this) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ PlayerState state = getDownloadService().getPlayerState();
+ if(state == PlayerState.STARTED) {
+ getDownloadService().pause();
+ } else {
+ getDownloadService().start();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ update();
+ }
+ }.execute();
+ }
+ });
+
+ ImageButton nextButton = (ImageButton) findViewById(R.id.download_next);
+ nextButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ new SilentBackgroundTask<Void>(MainActivity.this) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ if(getDownloadService() == null) {
+ return null;
+ }
+
+ if (getDownloadService().getCurrentPlayingIndex() < getDownloadService().size() - 1) {
+ getDownloadService().next();
+ }
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ update();
+ }
+ }.execute();
+ }
+ });
+
+ viewPager = (ViewPager) findViewById(R.id.pager);
+ pagerAdapter = new TabPagerAdapter(this, viewPager);
+ viewPager.setAdapter(pagerAdapter);
+ viewPager.setOnPageChangeListener(pagerAdapter);
+
+ addTab("Home", MainFragment.class, null);
+ addTab("Library", SelectArtistFragment.class, null);
+ addTab("Playlists", SelectPlaylistFragment.class, null);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+
+ }
+
+ @Override
+ protected void onPostCreate(Bundle bundle) {
+ super.onPostCreate(bundle);
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+ getSupportActionBar().setHomeButtonEnabled(false);
+ getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+
+ showInfoDialog();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ final Handler handler = new Handler();
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ update();
+ }
+ });
+ }
+ };
+
+ executorService = Executors.newSingleThreadScheduledExecutor();
+ executorService.scheduleWithFixedDelay(runnable, 0L, 1000L, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ executorService.shutdown();
+ }
+
+ @Override
+ public void onBackPressed() {
+ if(pagerAdapter.onBackPressed()) {
+ if(lastBackPressTime < (System.currentTimeMillis() - 4000)) {
+ lastBackPressTime = System.currentTimeMillis();
+ Util.toast(this, R.string.main_back_confirm);
+ } else {
+ super.onBackPressed();
+ }
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ if(pagerAdapter != null) {
+ com.actionbarsherlock.view.MenuInflater menuInflater = getSupportMenuInflater();
+ pagerAdapter.onCreateOptionsMenu(menu, menuInflater);
+ }
+ return true;
+ }
+ @Override
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ return pagerAdapter.onOptionsItemSelected(item);
+ }
+
+ private void update() {
+ if (getDownloadService() == null) {
+ return;
+ }
+
+ DownloadFile current = getDownloadService().getCurrentPlaying();
+ if(current == null) {
+ trackView.setText("Title");
+ artistView.setText("Artist");
+ getImageLoader().loadImage(coverArtView, null, false, false);
+ return;
+ }
+
+ MusicDirectory.Entry song = current.getSong();
+ trackView.setText(song.getTitle());
+ artistView.setText(song.getArtist());
+ getImageLoader().loadImage(coverArtView, song, false, false);
+ startButton.setImageResource((getDownloadService().getPlayerState() == PlayerState.STARTED) ? R.drawable.media_pause : R.drawable.media_start);
+ }
+
+ 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);
+ }
+ }
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index 5e89fbe6..a56cffba 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -21,7 +21,7 @@ import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.fragments.SubsonicTabFragment;
+import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.updates.Updater;
@@ -225,7 +225,7 @@ public class SubsonicActivity extends SherlockFragmentActivity {
private SherlockFragmentActivity activity;
private ViewPager pager;
private ActionBar actionBar;
- private SubsonicTabFragment currentFragment;
+ private SubsonicFragment currentFragment;
private List tabs = new ArrayList();
private List frags = new ArrayList();
private int currentPosition;
@@ -246,7 +246,7 @@ public class SubsonicActivity extends SherlockFragmentActivity {
fragStack.add(frag);
frags.add(i, fragStack);
if(currentFragment == null) {
- currentFragment = (SubsonicTabFragment) frag;
+ currentFragment = (SubsonicFragment) frag;
currentFragment.setPrimaryFragment(true);
}
return frag;
@@ -295,7 +295,7 @@ public class SubsonicActivity extends SherlockFragmentActivity {
currentFragment.setPrimaryFragment(false);
}
List fragStack = (List)frags.get(position);
- currentFragment = (SubsonicTabFragment) fragStack.get(fragStack.size() - 1);
+ currentFragment = (SubsonicFragment) fragStack.get(fragStack.size() - 1);
if(currentFragment != null) {
currentFragment.setPrimaryFragment(true);
}
@@ -316,7 +316,7 @@ public class SubsonicActivity extends SherlockFragmentActivity {
notifyDataSetChanged();
}
- public void replaceCurrent(SubsonicTabFragment fragment, int id) {
+ public void replaceCurrent(SubsonicFragment fragment, int id) {
if(currentFragment != null) {
currentFragment.setPrimaryFragment(false);
}
@@ -339,7 +339,7 @@ public class SubsonicActivity extends SherlockFragmentActivity {
List fragStack = (List)frags.get(currentPosition);
Fragment oldFrag = (Fragment)fragStack.remove(fragStack.size() - 1);
- currentFragment = (SubsonicTabFragment) fragStack.get(fragStack.size() - 1);
+ currentFragment = (SubsonicFragment) fragStack.get(fragStack.size() - 1);
currentFragment.setPrimaryFragment(true);
activity.invalidateOptionsMenu();
@@ -366,7 +366,7 @@ public class SubsonicActivity extends SherlockFragmentActivity {
public void invalidate() {
for (int i = 0; i < frags.size(); i++) {
List fragStack = (List)frags.get(i);
- SubsonicTabFragment frag = (SubsonicTabFragment)fragStack.get(fragStack.size() - 1);
+ SubsonicFragment frag = (SubsonicFragment)fragStack.get(fragStack.size() - 1);
frag.invalidate();
}
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
index 390f92fc..427c5098 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -29,7 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class MainFragment extends SubsonicTabFragment {
+public class MainFragment extends SubsonicFragment {
private LayoutInflater inflater;
private static final int MENU_GROUP_SERVER = 10;
@@ -231,7 +231,7 @@ public class MainFragment extends SubsonicTabFragment {
}
private void showAlbumList(String type) {
- SubsonicTabFragment fragment = new SelectDirectoryFragment();
+ SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, type);
args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 20);
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java
index 82c44913..ff12ac22 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -17,12 +17,11 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.net.Uri;
+import android.support.v4.app.FragmentTransaction;
import android.view.ViewGroup;
import com.actionbarsherlock.view.Menu;
import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.activity.HelpActivity;
import github.daneren2005.dsub.activity.SearchActivity;
-import github.daneren2005.dsub.activity.SettingsActivity;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.SearchCritera;
@@ -32,6 +31,7 @@ import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.view.ArtistAdapter;
import github.daneren2005.dsub.util.BackgroundTask;
+import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.view.EntryAdapter;
import github.daneren2005.dsub.util.MergeAdapter;
import github.daneren2005.dsub.util.TabBackgroundTask;
@@ -261,18 +261,23 @@ public class SearchFragment extends SubsonicFragment {
}
private void onArtistSelected(Artist artist) {
- /*Intent intent = new Intent(context, SelectAlbumActivity.class);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
- Util.startActivityWithoutTransition(context, intent);*/
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle();
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
+ args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, R.id.search_layout);
}
private void onAlbumSelected(MusicDirectory.Entry album, boolean autoplay) {
- /*Intent intent = new Intent(context, SelectAlbumActivity.class);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, album.getId());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, album.getTitle());
- intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, autoplay);
- Util.startActivityWithoutTransition(context, intent);*/
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle();
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, album.getId());
+ args.putString(Constants.INTENT_EXTRA_NAME_NAME, album.getTitle());
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, R.id.search_layout);
}
private void onSongSelected(MusicDirectory.Entry song, boolean save, boolean append, boolean autoplay, boolean playNext) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index dba70ce8..df49086d 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -30,7 +30,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
-public class SelectArtistFragment extends SubsonicTabFragment implements AdapterView.OnItemClickListener {
+public class SelectArtistFragment extends SubsonicFragment implements AdapterView.OnItemClickListener {
private static final String TAG = SelectArtistFragment.class.getSimpleName();
private static final int MENU_GROUP_MUSIC_FOLDER = 10;
@@ -158,7 +158,7 @@ public class SelectArtistFragment extends SubsonicTabFragment implements Adapter
selectFolder();
} else {
Artist artist = (Artist) parent.getItemAtPosition(position);
- SubsonicTabFragment fragment = new SelectDirectoryFragment();
+ SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index a12adff3..04d4fc65 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -42,7 +42,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-public class SelectDirectoryFragment extends SubsonicTabFragment implements AdapterView.OnItemClickListener {
+public class SelectDirectoryFragment extends SubsonicFragment implements AdapterView.OnItemClickListener {
private static final String TAG = SelectDirectoryFragment.class.getSimpleName();
private DragSortListView entryList;
@@ -217,7 +217,7 @@ public class SelectDirectoryFragment extends SubsonicTabFragment implements Adap
if (position >= 0) {
MusicDirectory.Entry entry = (MusicDirectory.Entry) parent.getItemAtPosition(position);
if (entry.isDirectory()) {
- SubsonicTabFragment fragment = new SelectDirectoryFragment();
+ SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getId());
args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle());
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 79b8280a..68222385 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -31,7 +31,7 @@ import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PlaylistAdapter;
import java.util.List;
-public class SelectPlaylistFragment extends SubsonicTabFragment implements AdapterView.OnItemClickListener {
+public class SelectPlaylistFragment extends SubsonicFragment implements AdapterView.OnItemClickListener {
private static final String TAG = SelectPlaylistFragment.class.getSimpleName();
private ListView list;
@@ -92,7 +92,7 @@ public class SelectPlaylistFragment extends SubsonicTabFragment implements Adapt
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
Playlist playlist = (Playlist) list.getItemAtPosition(info.position);
- SubsonicTabFragment fragment;
+ SubsonicFragment fragment;
Bundle args;
FragmentTransaction trans;
switch (menuItem.getItemId()) {
@@ -142,7 +142,7 @@ public class SelectPlaylistFragment extends SubsonicTabFragment implements Adapt
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Playlist playlist = (Playlist) parent.getItemAtPosition(position);
- SubsonicTabFragment fragment = new SelectDirectoryFragment();
+ SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index e9da1827..67e05faa 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -72,6 +72,8 @@ public class SubsonicFragment extends SherlockFragment {
protected SubsonicActivity context;
protected CharSequence title = "DSub";
protected View rootView;
+ protected boolean primaryFragment = false;
+ protected boolean invalidated = false;
@Override
public void onCreate(Bundle bundle) {
@@ -233,6 +235,31 @@ public class SubsonicFragment extends SherlockFragment {
return true;
}
+
+ public void replaceFragment(SubsonicFragment fragment, int id) {
+ context.getPagerAdapter().replaceCurrent(fragment, id);
+ }
+
+ public void setPrimaryFragment(boolean primary) {
+ primaryFragment = primary;
+ if(primary) {
+ if(context != null) {
+ context.setTitle(title);
+ }
+ if(invalidated) {
+ invalidated = false;
+ refresh(false);
+ }
+ }
+ }
+
+ public void invalidate() {
+ if(primaryFragment) {
+ refresh(false);
+ } else {
+ invalidated = true;
+ }
+ }
public DownloadService getDownloadService() {
return context != null ? context.getDownloadService() : null;
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
deleted file mode 100644
index c4079816..00000000
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package github.daneren2005.dsub.fragments;
-
-import android.util.Log;
-import android.view.MenuItem;
-
-public class SubsonicTabFragment extends SubsonicFragment {
- private static final String TAG = SubsonicTabFragment.class.getSimpleName();
- protected boolean primaryFragment = false;
- protected boolean invalidated = false;
-
- public void replaceFragment(SubsonicTabFragment fragment, int id) {
- context.getPagerAdapter().replaceCurrent(fragment, id);
- }
-
- public void setPrimaryFragment(boolean primary) {
- primaryFragment = primary;
- if(primary) {
- if(context != null) {
- context.setTitle(title);
- }
- if(invalidated) {
- invalidated = false;
- refresh(false);
- }
- }
- }
-
- public void invalidate() {
- if(primaryFragment) {
- refresh(false);
- } else {
- invalidated = true;
- }
- }
-}