Skip to content

Commit

Permalink
Tweaked posting DN story anim.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Jan 26, 2016
1 parent 71971a5 commit e84ec07
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public Story(long id,

protected Story(Parcel in) {
super(in.readLong(), in.readString(), in.readString());
dataSource = in.readString();
comment = in.readString();
comment_html = in.readString();
comment_count = in.readInt();
Expand Down Expand Up @@ -230,6 +231,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(title);
dest.writeString(url);
dest.writeString(dataSource);
dest.writeString(comment);
dest.writeString(comment_html);
dest.writeInt(comment_count);
Expand Down
39 changes: 29 additions & 10 deletions app/src/main/java/io/plaidapp/ui/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.WindowInsets;
Expand Down Expand Up @@ -315,7 +316,6 @@ public void onReceive(Context context, Intent intent) {
@Override
public void run() {
fabPosting.setVisibility(View.GONE);
fab.setVisibility(View.VISIBLE);
}
}, 2100); // length of R.drawable.avd_upload_complete

Expand All @@ -333,16 +333,11 @@ public void run() {
fabPosting.animate()
.alpha(0f)
.rotation(90f)
.setStartDelay(2000L) // leave error on screen for a while before hiding
.setDuration(200L)
.setStartDelay(2000L) // leave error on screen briefly
.setDuration(300L)
.setInterpolator(AnimationUtils.loadInterpolator(
HomeActivity.this, android.R.interpolator.fast_out_linear_in))
HomeActivity.this, android.R.interpolator.fast_out_slow_in))
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
fab.setVisibility(View.VISIBLE);
}

@Override
public void onAnimationEnd(Animator animation) {
fabPosting.setVisibility(View.GONE);
Expand Down Expand Up @@ -370,8 +365,32 @@ private void unregisterPostStoryResultListener() {

private void showPostingProgress() {
ensurePostingProgressInflated();
fab.setVisibility(View.INVISIBLE);
fabPosting.setVisibility(View.VISIBLE);
// if stub has just been inflated then it will not have been laid out yet
if (fabPosting.isLaidOut()) {
revealPostingProgress();
} else {
fabPosting.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int l, int t, int r, int b,
int oldL, int oldT, int oldR, int oldB) {
fabPosting.removeOnLayoutChangeListener(this);
revealPostingProgress();
}
});
}
}

private void revealPostingProgress() {
Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting,
(int) fabPosting.getPivotX(),
(int) fabPosting.getPivotY(),
0f,
fabPosting.getWidth() / 2)
.setDuration(600L);
reveal.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.interpolator.fast_out_linear_in));
reveal.start();
AnimatedVectorDrawable uploading =
(AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading);
fabPosting.setImageDrawable(uploading);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/posting_progress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
android:background="@drawable/fab"
android:clickable="true"
android:elevation="@dimen/z_fab"
android:outlineProvider="none"
android:src="@drawable/avd_uploading"
tools:showIn="@layout/activity_home" />

0 comments on commit e84ec07

Please sign in to comment.