From 11f3c6e12cc742405708e32af28f8b981ff66c6d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 30 May 2013 20:41:18 -0700 Subject: Fix Show Album not working --- .../daneren2005/dsub/activity/MainActivity.java | 14 ++++++++++++++ .../daneren2005/dsub/activity/SubsonicActivity.java | 19 ++++++++++++++++++- .../daneren2005/dsub/fragments/DownloadFragment.java | 7 +++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 44ee3b4b..9a118e32 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -21,7 +21,9 @@ import github.daneren2005.dsub.domain.PlayerState; import github.daneren2005.dsub.fragments.ChatFragment; import github.daneren2005.dsub.fragments.MainFragment; import github.daneren2005.dsub.fragments.SelectArtistFragment; +import github.daneren2005.dsub.fragments.SelectDirectoryFragment; import github.daneren2005.dsub.fragments.SelectPlaylistFragment; +import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadServiceImpl; import github.daneren2005.dsub.updates.Updater; @@ -191,6 +193,18 @@ public class MainActivity extends SubsonicActivity { }); } }; + + if(getIntent().hasExtra(Constants.INTENT_EXTRA_VIEW_ALBUM)) { + viewPager.setCurrentItem(1); + + SubsonicFragment fragment = new SelectDirectoryFragment(); + Bundle args = new Bundle(); + args.putString(Constants.INTENT_EXTRA_NAME_ID, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID)); + args.putString(Constants.INTENT_EXTRA_NAME_NAME, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME)); + fragment.setArguments(args); + + pagerAdapter.queueFragment(fragment, R.id.select_artist_layout); + } executorService = Executors.newSingleThreadScheduledExecutor(); executorService.scheduleWithFixedDelay(runnable, 0L, 1000L, TimeUnit.MILLISECONDS); diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 80f4ffc0..2a06b5c6 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -392,6 +392,7 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem private SubsonicFragment currentFragment; private List tabs = new ArrayList(); private List> frags = new ArrayList>(); + private List queue = new ArrayList(); private int currentPosition; public TabPagerAdapter(SherlockFragmentActivity activity, ViewPager pager) { @@ -431,6 +432,13 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem public void onCreateOptionsMenu(Menu menu, com.actionbarsherlock.view.MenuInflater menuInflater) { if(currentFragment != null) { currentFragment.onCreateOptionsMenu(menu, menuInflater); + + for(QueuedFragment addFragment: queue) { + replaceFragment(addFragment.fragment, addFragment.id, currentFragment.getSupportTag()); + currentFragment = addFragment.fragment; + } + currentFragment.setPrimaryFragment(true); + queue.clear(); } } public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { @@ -489,7 +497,12 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem actionBar.addTab(tab); notifyDataSetChanged(); } - + public void queueFragment(SubsonicFragment fragment, int id) { + QueuedFragment frag = new QueuedFragment(); + frag.fragment = fragment; + frag.id = id; + queue.add(frag); + } public void replaceCurrent(SubsonicFragment fragment, int id, int tag) { if(currentFragment != null) { currentFragment.setPrimaryFragment(false); @@ -612,5 +625,9 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem this.args = args; } } + private class QueuedFragment { + public SubsonicFragment fragment; + public int id; + } } } diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java index e734fedf..9ccc136f 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -58,6 +58,7 @@ import java.util.ArrayList; import java.util.concurrent.ScheduledFuture; import com.mobeta.android.dslv.*; import github.daneren2005.dsub.activity.EqualizerActivity; +import github.daneren2005.dsub.activity.MainActivity; import github.daneren2005.dsub.activity.SubsonicActivity; public class DownloadFragment extends SubsonicFragment implements OnGestureListener { @@ -518,10 +519,12 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe private boolean menuItemSelected(int menuItemId, final DownloadFile song) { switch (menuItemId) { case R.id.menu_show_album: - /*Intent intent = new Intent(context, SelectAlbumActivity.class); + Intent intent = new Intent(context, MainActivity.class); + intent.putExtra(Constants.INTENT_EXTRA_VIEW_ALBUM, true); intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, song.getSong().getParent()); intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, song.getSong().getAlbum()); - Util.startActivityWithoutTransition(context, intent);*/ + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + Util.startActivityWithoutTransition(context, intent); return true; case R.id.menu_lyrics: SubsonicFragment fragment = new LyricsFragment(); -- cgit v1.2.3