diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-04-30 21:21:58 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-04-30 21:21:58 -0700 |
commit | 7dc30aa70593f6dfc612f681ff9b1f3b14d62e4a (patch) | |
tree | 038685648da35da67b9cc42f2a4cce45d70c71d8 /subsonic-android/src | |
parent | 9f396015bf6cbf538871305dc8458d288b2ebd9a (diff) | |
download | dsub-7dc30aa70593f6dfc612f681ff9b1f3b14d62e4a.tar.gz dsub-7dc30aa70593f6dfc612f681ff9b1f3b14d62e4a.tar.bz2 dsub-7dc30aa70593f6dfc612f681ff9b1f3b14d62e4a.zip |
Fix flat stack fragment option menu callbacks
Diffstat (limited to 'subsonic-android/src')
4 files changed, 40 insertions, 23 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 2504d040..53fb35ba 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -199,19 +199,6 @@ public class MainActivity extends SubsonicActivity { } } - @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; diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java index 7d2280e2..ec19057c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java @@ -22,21 +22,20 @@ package github.daneren2005.dsub.activity; import github.daneren2005.dsub.R; import android.content.Intent; import android.os.Bundle; +import android.util.Log; import github.daneren2005.dsub.fragments.SearchFragment; import github.daneren2005.dsub.util.Constants; -import github.daneren2005.dsub.util.MergeAdapter; +import com.actionbarsherlock.view.MenuItem; public class SearchActivity extends SubsonicActivity { - SearchFragment fragment; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.download_activity); if (findViewById(R.id.download_container) != null && savedInstanceState == null) { - fragment = new SearchFragment(); - getSupportFragmentManager().beginTransaction().add(R.id.download_container, fragment).commit(); + currentFragment = new SearchFragment(); + getSupportFragmentManager().beginTransaction().add(R.id.download_container, currentFragment).commit(); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -51,15 +50,28 @@ public class SearchActivity extends SubsonicActivity { boolean requestsearch = intent.getBooleanExtra(Constants.INTENT_EXTRA_REQUEST_SEARCH, false); if (query != null) { - fragment.search(query, autoplay); + ((SearchFragment)currentFragment).search(query, autoplay); } else { - fragment.populateList(); + ((SearchFragment)currentFragment).populateList(); if (requestsearch) { onSearchRequested(); } } } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if(item.getItemId() == android.R.id.home) { + Intent i = new Intent(); + i.setClass(this, MainActivity.class); + i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(i); + return true; + } else { + return super.onOptionsItemSelected(item); + } + } + public void onSupportNewIntent(Intent intent) { onNewIntent(intent); } diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 8e9c147d..8b48d74e 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -74,6 +74,26 @@ public class SubsonicActivity extends SherlockFragmentActivity { super.finish();
Util.disablePendingTransition(this);
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ com.actionbarsherlock.view.MenuInflater menuInflater = getSupportMenuInflater();
+ if(pagerAdapter != null) {
+ pagerAdapter.onCreateOptionsMenu(menu, menuInflater);
+ } else if(currentFragment != null) {
+ currentFragment.onCreateOptionsMenu(menu, menuInflater);
+ }
+ return true;
+ }
+ @Override
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ if(pagerAdapter != null) {
+ return pagerAdapter.onOptionsItemSelected(item);
+ } else if(currentFragment != null) {
+ return currentFragment.onOptionsItemSelected(item);
+ }
+ return true;
+ }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
@@ -120,7 +140,7 @@ public class SubsonicActivity extends SherlockFragmentActivity { if(currentFragment != null) {
currentFragment.setPrimaryFragment(false);
}
- backStack.add(fragment);
+ backStack.add(currentFragment);
currentFragment = fragment;
currentFragment.setPrimaryFragment(true);
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java index 39bc4617..725f84bd 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -71,8 +71,6 @@ public class SearchFragment extends SubsonicFragment { @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
rootView = inflater.inflate(R.layout.search, container, false);
- setHasOptionsMenu(true);
-
setTitle(R.string.search_title);
View buttons = inflater.inflate(R.layout.search_buttons, null);
|