diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-10-07 19:23:48 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-10-07 19:23:48 -0700 |
commit | 118e56a51b35ac7262b4de38d0ac0e00f8952b20 (patch) | |
tree | 09b97cbc8d7388fc57c079fb96a3545c867d1cd1 /src/github | |
parent | 50292a33938016f410effcb8f0aca1c6263e8410 (diff) | |
parent | 72f9f2bf4f431b790490fe1ddb8820c478a66801 (diff) | |
download | dsub-118e56a51b35ac7262b4de38d0ac0e00f8952b20.tar.gz dsub-118e56a51b35ac7262b4de38d0ac0e00f8952b20.tar.bz2 dsub-118e56a51b35ac7262b4de38d0ac0e00f8952b20.zip |
Merge branch 'Transition'
Diffstat (limited to 'src/github')
3 files changed, 48 insertions, 25 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index fc0cbcdc..6d1a9330 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -45,6 +45,7 @@ import android.view.View; import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
+import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
@@ -371,8 +372,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte @Override
public void setTitle(CharSequence title) {
- getSupportActionBar().setTitle(title);
- recreateSpinner();
+ if(!title.equals(getSupportActionBar().getTitle())) {
+ getSupportActionBar().setTitle(title);
+ recreateSpinner();
+ }
}
public void setSubtitle(CharSequence title) {
getSupportActionBar().setSubtitle(title);
@@ -542,6 +545,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(secondaryContainer == null) {
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
trans.hide(oldFragment);
trans.add(R.id.fragment_container, fragment, tag + "");
trans.commit();
@@ -555,12 +559,16 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(backStack.size() > 1) {
// Move old right to left if there is a backstack already
SubsonicFragment newLeftFragment = backStack.get(backStack.size() - 1);
+ if(replaceCurrent) {
+ // trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
+ }
trans.remove(newLeftFragment);
// Only move right to left if replaceCurrent is false
if(!replaceCurrent) {
SubsonicFragment oldLeftFragment = backStack.get(backStack.size() - 2);
oldLeftFragment.setSecondaryFragment(false);
+ // trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
trans.hide(oldLeftFragment);
// Make sure remove is finished before adding
@@ -568,6 +576,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte getSupportFragmentManager().executePendingTransactions();
trans = getSupportFragmentManager().beginTransaction();
+ // trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
trans.add(R.id.fragment_container, newLeftFragment, newLeftFragment.getSupportTag() + "");
} else {
backStack.remove(backStack.size() - 1);
@@ -594,6 +603,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(secondaryContainer == null) {
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
trans.remove(oldFrag);
trans.show(currentFragment);
trans.commit();
@@ -601,10 +611,12 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
// Remove old right fragment
+ // trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
trans.remove(oldFrag);
// Only switch places if there is a backstack, otherwise primary container is correct
if(backStack.size() > 0) {
+ // trans.setCustomAnimations(0, 0, 0, 0);
// Add current left fragment to right side
trans.remove(currentFragment);
@@ -613,12 +625,14 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte getSupportFragmentManager().executePendingTransactions();
trans = getSupportFragmentManager().beginTransaction();
+ // trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
trans.add(R.id.fragment_second_container, currentFragment, currentFragment.getSupportTag() + "");
SubsonicFragment newLeftFragment = backStack.get(backStack.size() - 1);
newLeftFragment.setSecondaryFragment(true);
trans.show(newLeftFragment);
} else {
+ // secondaryContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.exit_to_right));
secondaryContainer.setVisibility(View.GONE);
}
@@ -641,6 +655,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
protected void recreateSpinner() {
+ if(currentFragment.getTitle() == null) {
+ return;
+ }
+
if(backStack.size() > 0) {
spinnerAdapter.clear();
for(int i = 0; i < backStack.size(); i++) {
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index cb357976..7b1276b9 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -634,22 +634,21 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter protected Pair<MusicDirectory, Boolean> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
MusicDirectory dir = load(musicService);
- boolean valid = musicService.isLicenseValid(context, this);
- return new Pair<MusicDirectory, Boolean>(dir, valid);
+ licenseValid = musicService.isLicenseValid(context, this);
+
+ albums = dir.getChildren(true, false);
+ if(largeAlbums) {
+ entries = dir.getChildren(false, true);
+ } else {
+ entries = dir.getChildren();
+ }
+
+ return new Pair<MusicDirectory, Boolean>(dir, licenseValid);
}
@Override
protected void done(Pair<MusicDirectory, Boolean> result) {
- if(largeAlbums) {
- albums = result.getFirst().getChildren(true, false);
- entries = result.getFirst().getChildren(false, true);
- } else {
- albums = result.getFirst().getChildren(true, false);
- entries = result.getFirst().getChildren();
- }
- licenseValid = result.getSecond();
- finishLoading();
-
+ finishLoading();
currentTask = null;
}
}
@@ -665,7 +664,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } else {
showHeader = false;
if(!"root".equals(id) && (entries.size() == 0 || !largeAlbums && albums.size() == entries.size())) {
- hideButtons = true;
+ hideButtons = true;
}
}
@@ -718,7 +717,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter if(validData) {
entryList.setVisibility(View.VISIBLE);
}
- context.supportInvalidateOptionsMenu();
+ context.supportInvalidateOptionsMenu();
if(lookupEntry != null) {
for(int i = 0; i < entries.size(); i++) {
@@ -730,12 +729,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}
- Bundle args = getArguments();
- boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
- if (playAll && !restoredInstance) {
- playAll(args.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false), false);
- }
- }
+ Bundle args = getArguments();
+ boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
+ if (playAll && !restoredInstance) {
+ playAll(args.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false), false);
+ }
+ }
private void setupAlbumList() {
albumList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 0ad7cd4c..70a3b027 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -102,7 +102,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR private int tag;
protected SubsonicActivity context;
- protected CharSequence title = "DSub";
+ protected CharSequence title = null;
protected CharSequence subtitle = null;
protected View rootView;
protected boolean primaryFragment = false;
@@ -114,6 +114,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR protected boolean artist = false;
protected boolean artistOverride = false;
protected SwipeRefreshLayout refreshLayout;
+ protected boolean firstRun;
public SubsonicFragment() {
super();
@@ -130,6 +131,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR title = name;
}
}
+ firstRun = true;
}
@Override
@@ -141,7 +143,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override
public void onResume() {
super.onResume();
- UpdateView.triggerUpdate();
+ if(firstRun) {
+ firstRun = false;
+ } else {
+ UpdateView.triggerUpdate();
+ }
}
@Override
@@ -480,7 +486,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void setPrimaryFragment(boolean primary) {
primaryFragment = primary;
if(primary) {
- if(context != null) {
+ if(context != null && title != null) {
context.setTitle(title);
context.setSubtitle(subtitle);
}
|