Skip to content

Commit

Permalink
Better exit animation for share intents.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Nov 20, 2015
1 parent f657d7c commit 08a4a3f
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion app/src/main/java/io/plaidapp/ui/PostNewDesignerNewsStory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.plaidapp.ui;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
Expand Down Expand Up @@ -117,7 +119,7 @@ public void onScrolled(int scrollY) {
});

// check for share intent
if (getIntent() != null && Intent.ACTION_SEND.equals(getIntent().getAction())) {
if (isShareIntent()) {
ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
url.setText(intentReader.getText());
title.setText(intentReader.getSubject());
Expand Down Expand Up @@ -151,6 +153,26 @@ protected void onPause() {
super.onPause();
}

@Override
public void onBackPressed() {
if (isShareIntent()) {
bottomSheetContent.animate()
.translationY(bottomSheetContent.getHeight())
.setDuration(160L)
.setInterpolator(AnimationUtils.loadInterpolator(
PostNewDesignerNewsStory.this,
android.R.interpolator.fast_out_linear_in))
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
finishAfterTransition();
}
});
} else {
super.onBackPressed();
}
}

@OnClick(R.id.bottom_sheet)
protected void dismiss() {
finishAfterTransition();
Expand Down Expand Up @@ -200,6 +222,10 @@ protected void postNewStory() {
}
}

private boolean isShareIntent() {
return getIntent() != null && Intent.ACTION_SEND.equals(getIntent().getAction());
}

private void setPostButtonState() {
post.setEnabled(!TextUtils.isEmpty(title.getText())
&& (!TextUtils.isEmpty(url.getText())
Expand Down

0 comments on commit 08a4a3f

Please sign in to comment.