Skip to content

Commit

Permalink
Ensure FAB is shown on dribbble shots after rotation. Fix nickbutcher#10
Browse files Browse the repository at this point in the history
.
  • Loading branch information
nickbutcher committed Nov 18, 2015
1 parent cf8db11 commit 65330ed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions app/src/main/java/io/plaidapp/ui/DribbbleShot.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.app.Activity;
Expand Down Expand Up @@ -145,7 +146,7 @@ public class DribbbleShot extends Activity {
private ElasticDragDismissFrameLayout.SystemChromeFader chromeFader;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dribbble_shot);
shot = getIntent().getParcelableExtra(EXTRA_SHOT);
Expand Down Expand Up @@ -203,7 +204,7 @@ public void onDragDismissed() {
public boolean onPreDraw() {
imageView.getViewTreeObserver().removeOnPreDrawListener(this);
calculateFabPosition();
enterAnimation();
enterAnimation(savedInstanceState != null);
startPostponedEnterTransition();
return true;
}
Expand Down Expand Up @@ -618,7 +619,7 @@ private void calculateFabPosition() {
* are within the ListView so do it manually. Also handle the FAB tanslation here so that it
* plays nicely with #calculateFabPosition
*/
private void enterAnimation() {
private void enterAnimation(boolean isOrientationChange) {
Interpolator interp = AnimationUtils.loadInterpolator(this, android.R.interpolator
.fast_out_slow_in);
int offset = title.getHeight();
Expand Down Expand Up @@ -647,6 +648,20 @@ private void enterAnimation() {
.setDuration(600)
.setInterpolator(interp)
.start();

if (isOrientationChange) {
// we rely on the window enter content transition to show the fab. This isn't run on
// orientation changes so manually show it.
Animator showFab = ObjectAnimator.ofPropertyValuesHolder(fab,
PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f),
PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f));
showFab.setStartDelay(300L);
showFab.setDuration(300L);
showFab.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.interpolator.linear_out_slow_in));
showFab.start();
}
}

private void viewEnterAnimation(View view, float offset, Interpolator interp) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/transition/dribbble_shot_enter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class="io.plaidapp.ui.transitions.Pop"
android:startDelay="300"
android:duration="300"
android:interpolator="@android:interpolator/fast_out_slow_in">
android:interpolator="@android:interpolator/linear_out_slow_in">
<targets>
<target android:targetId="@id/fab_heart" />
</targets>
Expand Down

0 comments on commit 65330ed

Please sign in to comment.