Animate ActionBarDrawerToggle when entering details view. Don't animate on drawer open, it's useless as it is immediatelly covered by the drawer
This commit is contained in:
parent
05179ff7b4
commit
771d6e383e
|
@ -149,6 +149,7 @@ public class AddonsActivity extends BaseActivity
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private boolean drawerIndicatorIsArrow = false;
|
||||
private void setupActionBar(String addonTitle) {
|
||||
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -157,10 +158,16 @@ public class AddonsActivity extends BaseActivity
|
|||
if (actionBar == null) return;
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
if (addonTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
if (!drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(true);
|
||||
drawerIndicatorIsArrow = true;
|
||||
}
|
||||
actionBar.setTitle(addonTitle);
|
||||
} else {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(true);
|
||||
if (drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(false);
|
||||
drawerIndicatorIsArrow = false;
|
||||
}
|
||||
actionBar.setTitle(R.string.addons);
|
||||
}
|
||||
}
|
||||
|
@ -194,6 +201,7 @@ public class AddonsActivity extends BaseActivity
|
|||
fragTrans.replace(R.id.fragment_container, addonDetailsFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
setupActionBar(selectedAddonTitle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,6 +154,7 @@ public class MoviesActivity extends BaseActivity
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private boolean drawerIndicatorIsArrow = false;
|
||||
private void setupActionBar(String movieTitle) {
|
||||
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -162,10 +163,16 @@ public class MoviesActivity extends BaseActivity
|
|||
if (actionBar == null) return;
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
if (movieTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
if (!drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(true);
|
||||
drawerIndicatorIsArrow = true;
|
||||
}
|
||||
actionBar.setTitle(movieTitle);
|
||||
} else {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(true);
|
||||
if (drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(false);
|
||||
drawerIndicatorIsArrow = false;
|
||||
}
|
||||
actionBar.setTitle(R.string.movies);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,30 +207,40 @@ public class MusicActivity extends BaseActivity
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private boolean drawerIndicatorIsArrow = false;
|
||||
private void setupActionBar(String albumTitle, String artistName, String genreTitle,
|
||||
String musicVideoTitle) {
|
||||
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar == null) return;
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
if (albumTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
actionBar.setTitle(albumTitle);
|
||||
} else if (artistName != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
actionBar.setTitle(artistName);
|
||||
} else if (genreTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
actionBar.setTitle(genreTitle);
|
||||
} else if (musicVideoTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
actionBar.setTitle(musicVideoTitle);
|
||||
} else {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(true);
|
||||
actionBar.setTitle(R.string.music);
|
||||
}
|
||||
|
||||
if ((albumTitle != null) || (artistName != null) || (genreTitle != null) || (musicVideoTitle != null)) {
|
||||
if (!drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(true);
|
||||
drawerIndicatorIsArrow = true;
|
||||
}
|
||||
} else {
|
||||
if (drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(false);
|
||||
drawerIndicatorIsArrow = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onArtistSelected(int artistId, String artistName) {
|
||||
|
@ -245,6 +255,7 @@ public class MusicActivity extends BaseActivity
|
|||
.replace(R.id.fragment_container, albumListFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
navigationDrawerFragment.animateDrawerToggle(true);
|
||||
setupActionBar(null, artistName, null, null);
|
||||
}
|
||||
|
||||
|
@ -269,7 +280,7 @@ public class MusicActivity extends BaseActivity
|
|||
}
|
||||
|
||||
fragTrans.replace(R.id.fragment_container, albumDetailsFragment)
|
||||
.addToBackStack(null)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
setupActionBar(albumTitle, null, null, null);
|
||||
}
|
||||
|
@ -310,7 +321,7 @@ public class MusicActivity extends BaseActivity
|
|||
}
|
||||
|
||||
fragTrans.replace(R.id.fragment_container, detailsFragment)
|
||||
.addToBackStack(null)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
setupActionBar(null, null, null, musicVideoTitle);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.xbmc.kore.ui;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -33,6 +35,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
@ -250,10 +253,31 @@ public class NavigationDrawerFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
//mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
selectedItemId = getItemIdFromActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates the drawerToggle from the hamburger to an arrow or vice versa
|
||||
* @param toArrow True, hamburger to arrow, false arrow to hamburger
|
||||
*/
|
||||
public void animateDrawerToggle(final boolean toArrow) {
|
||||
float start = toArrow ? 0.0f : 1.0f,
|
||||
end = 1.0f - start;
|
||||
|
||||
ValueAnimator anim = ValueAnimator.ofFloat(start, end);
|
||||
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
float slideOffset = (Float) valueAnimator.getAnimatedValue();
|
||||
mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset);
|
||||
}
|
||||
});
|
||||
anim.setInterpolator(new DecelerateInterpolator());
|
||||
anim.setDuration(500);
|
||||
anim.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary method to show/hide the drawer indicator
|
||||
* @param isEnabled Show/hide enable drawer indicator
|
||||
|
|
|
@ -152,6 +152,7 @@ public class PVRActivity extends BaseActivity
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private boolean drawerIndicatorIsArrow = false;
|
||||
private void setupActionBar(String channelTitle) {
|
||||
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -161,10 +162,16 @@ public class PVRActivity extends BaseActivity
|
|||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (channelTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
if (!drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(true);
|
||||
drawerIndicatorIsArrow = true;
|
||||
}
|
||||
actionBar.setTitle(channelTitle);
|
||||
} else {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(true);
|
||||
if (drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(false);
|
||||
drawerIndicatorIsArrow = false;
|
||||
}
|
||||
actionBar.setTitle(R.string.pvr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ public class TVShowsActivity extends BaseActivity
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
private boolean drawerIndicatorIsArrow = false;
|
||||
private void setupActionBar(String tvshowTitle) {
|
||||
Toolbar toolbar = (Toolbar)findViewById(R.id.default_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -174,10 +175,16 @@ public class TVShowsActivity extends BaseActivity
|
|||
if (actionBar == null) return;
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
if (tvshowTitle != null) {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(false);
|
||||
if (!drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(true);
|
||||
drawerIndicatorIsArrow = true;
|
||||
}
|
||||
actionBar.setTitle(tvshowTitle);
|
||||
} else {
|
||||
navigationDrawerFragment.setDrawerIndicatorEnabled(true);
|
||||
if (drawerIndicatorIsArrow) {
|
||||
navigationDrawerFragment.animateDrawerToggle(false);
|
||||
drawerIndicatorIsArrow = false;
|
||||
}
|
||||
actionBar.setTitle(R.string.tv_shows);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,6 +109,11 @@
|
|||
<item name="circleGapWidth">6dp</item>
|
||||
</style>
|
||||
|
||||
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
|
||||
<item name="spinBars">true</item>
|
||||
<item name="color">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="ButtonBar">
|
||||
<item name="android:background">?attr/buttonBarBackgroundColor</item>
|
||||
</style>
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
<item name="android:windowBackground">@color/dark_background</item>
|
||||
<!--<item name="android:windowActionBarOverlay">true</item>-->
|
||||
|
||||
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
|
||||
|
||||
<!-- Set AppCompat’s color theming attrs -->
|
||||
<!--<item name="colorPrimary">@color/light_green_800</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/light_green_900</item>-->
|
||||
|
@ -147,6 +149,8 @@
|
|||
<item name="android:colorBackground">@color/light_background</item>
|
||||
<item name="android:windowBackground">@color/light_background</item>
|
||||
|
||||
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
|
||||
|
||||
<!-- Set AppCompat’s color theming attrs -->
|
||||
<item name="colorPrimary">@color/deep_orange_500</item>
|
||||
<item name="colorPrimaryDark">@color/deep_orange_700</item>
|
||||
|
@ -156,7 +160,7 @@
|
|||
|
||||
<!-- CAREFUL with this. This is so that the drawer toggle arrow
|
||||
is set to white but can have unintended consequences. Watch it -->
|
||||
<item name="colorControlNormal">@color/white</item>
|
||||
<!--<item name="colorControlNormal">@color/white</item>-->
|
||||
|
||||
<item name="appTextColorPrimary">@color/black_dim_87pct</item>
|
||||
<item name="appTextColorSecondary">@color/black_dim_54pct</item>
|
||||
|
|
Loading…
Reference in New Issue