Fix shared element transition
This commit is contained in:
parent
698fec921f
commit
c49777e5cc
2 changed files with 25 additions and 23 deletions
|
|
@ -2,9 +2,7 @@ package com.kabouzeid.gramophone.ui.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
@ -15,7 +13,6 @@ import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -30,8 +27,6 @@ import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView;
|
import com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView;
|
||||||
import com.kabouzeid.appthemehelper.ATH;
|
|
||||||
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
|
||||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||||
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
import com.kabouzeid.appthemehelper.util.MaterialValueHelper;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
|
@ -61,9 +56,8 @@ import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||||
import com.kabouzeid.gramophone.util.PhonographColorUtil;
|
import com.kabouzeid.gramophone.util.PhonographColorUtil;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
@ -151,12 +145,13 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements
|
||||||
scrollY += headerViewHeight;
|
scrollY += headerViewHeight;
|
||||||
|
|
||||||
// Change alpha of overlay
|
// Change alpha of overlay
|
||||||
float headerAlpha = Math.max(0, Math.min(1, (float) 2*scrollY/headerViewHeight));
|
float headerAlpha = Math.max(0, Math.min(1, (float) 2 * scrollY / headerViewHeight));
|
||||||
headerOverlay.setBackgroundColor(ColorUtil.withAlpha(toolbarColor, headerAlpha));
|
headerOverlay.setBackgroundColor(ColorUtil.withAlpha(toolbarColor, headerAlpha));
|
||||||
|
|
||||||
// Translate name text
|
// Translate name text
|
||||||
headerView.setTranslationY(Math.max(-scrollY, -headerViewHeight));
|
headerView.setTranslationY(Math.max(-scrollY, -headerViewHeight));
|
||||||
headerOverlay.setTranslationY(Math.max(-scrollY, -headerViewHeight));
|
headerOverlay.setTranslationY(Math.max(-scrollY, -headerViewHeight));
|
||||||
|
albumArtImageView.setTranslationY(Math.max(-scrollY, -headerViewHeight));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,7 @@
|
||||||
android:dividerHeight="0dp"
|
android:dividerHeight="0dp"
|
||||||
android:scrollbars="none" />
|
android:scrollbars="none" />
|
||||||
|
|
||||||
<View
|
<FrameLayout
|
||||||
android:id="@+id/header_overlay"
|
|
||||||
android:elevation="@dimen/toolbar_elevation"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/title_view_height" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
@ -65,15 +59,11 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:ignore="UnusedAttribute">
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
<ImageView
|
<!--placeholder image view, the actual image view can't go here or the shared element transition won't work right-->
|
||||||
android:id="@+id/image"
|
<View
|
||||||
android:layout_width="144dp"
|
android:layout_width="144dp"
|
||||||
android:layout_height="144dp"
|
android:layout_height="144dp"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp" />
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/default_album_art"
|
|
||||||
android:transitionName="@string/transition_album_art"
|
|
||||||
tools:ignore="ContentDescription,UnusedAttribute" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -211,7 +201,24 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/transparent" />
|
android:background="@android:color/transparent" />
|
||||||
|
|
||||||
</LinearLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image"
|
||||||
|
android:layout_width="144dp"
|
||||||
|
android:layout_height="144dp"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/default_album_art"
|
||||||
|
android:transitionName="@string/transition_album_art"
|
||||||
|
tools:ignore="ContentDescription,UnusedAttribute" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/header_overlay"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/title_view_height"
|
||||||
|
android:elevation="@dimen/toolbar_elevation"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue