Skip to content

Commit 781176f

Browse files
committed
sample temp fix
1 parent eb97d54 commit 781176f

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

sample/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ dependencies {
2626
compile project(':cardstackview')
2727
compile 'com.android.support:cardview-v7:24.2.1'
2828
compile 'com.jaeger.statusbaruitl:library:1.3.0'
29+
compile 'com.makeramen:roundedimageview:2.2.1'
2930
}

sample/src/main/java/me/brucezz/sample/DetailActivity.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.os.Bundle;
44
import android.support.annotation.Nullable;
5+
import android.support.v4.content.ContextCompat;
56
import android.support.v7.app.AppCompatActivity;
67
import android.view.View;
78
import android.widget.ImageView;
@@ -31,7 +32,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3132
mContent = findViewById(R.id.detail_content);
3233

3334
Card card = getIntent().getParcelableExtra("card");
34-
mImageView.setImageResource(card.mImage);
35+
int padding = getIntent().getIntExtra("padding", 0);
36+
mImageView.getLayoutParams().height -= padding;
37+
mImageView.setImageDrawable(ContextCompat.getDrawable(this, card.mImage));
3538
StatusBarUtil.setColor(this, card.mBgColor);
3639
mTextView.setText(card.mTitle);
3740

@@ -45,7 +48,7 @@ private void animContent() {
4548

4649
@Override
4750
public void onBackPressed() {
48-
//setResult(RESULT_OK);
51+
setResult(RESULT_OK);
4952
finish();
5053
overridePendingTransition(0, 0);
5154
}

sample/src/main/java/me/brucezz/sample/MainActivity.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,23 @@ private class AnimationHelper {
150150
public int startBottom;
151151
public int endBottom;
152152

153+
public int startPaddingLeft;
154+
public int endPaddingLeft;
155+
public int startPaddingRight;
156+
public int endPaddingRight;
157+
public int startPaddingTop;
158+
public int endPaddingTop;
159+
public int startPaddingBottom;
160+
public int endPaddingBottom;
161+
153162
public float startRadius;
154163
public float endRadius;
155164

156165
public @ColorInt int startColor;
157166
public @ColorInt int endColor;
158167
private ArgbEvaluator mArgbEvaluator = new ArgbEvaluator();
159168

160-
public static final long ANIMATION_DURATION_CARD = 5000L;
169+
public static final long ANIMATION_DURATION_CARD = 500L;
161170
public static final long ANIMATION_DURATION_ALPHA = 300L;
162171

163172
public AnimationHelper(View view, int index) {
@@ -171,10 +180,17 @@ public AnimationHelper(View view, int index) {
171180
startTop = mCardView.getTop();
172181
startBottom = mCardView.getBottom();
173182

174-
endLeft = 0;
175-
endRight = mCardView.getWidth() + 2 * mCardView.getLeft();
176-
endTop = 0;
177-
endBottom = mCardView.getHeight();
183+
endLeft = -mCardView.getPaddingLeft();
184+
endRight = mCardView.getWidth() + 2 * mCardView.getLeft() + mCardView.getPaddingRight();
185+
endTop = -mCardView.getPaddingTop();
186+
endBottom = mCardView.getHeight() - mCardView.getPaddingTop();
187+
188+
startPaddingLeft = mCardView.getPaddingLeft();
189+
startPaddingRight = mCardView.getPaddingRight();
190+
startPaddingTop = mCardView.getPaddingTop();
191+
startPaddingBottom = mCardView.getPaddingBottom();
192+
193+
endPaddingLeft = endPaddingRight = endPaddingTop = endPaddingBottom = 0;
178194

179195
startRadius = mCardView.getRadius();
180196
endRadius = 1f;// radius 减到 0 会自动产生透明度变化
@@ -221,6 +237,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
221237
animator.addListener(new Animator.AnimatorListener() {
222238
@Override
223239
public void onAnimationStart(Animator animation) {
240+
mCardStackView.setSkipLayout(true);
224241
if (!reverse) {
225242
mTitle.animate().alpha(0f).setDuration(ANIMATION_DURATION_ALPHA).start();
226243
mToolbar.animate().alpha(0f).setDuration(ANIMATION_DURATION_ALPHA).start();
@@ -237,9 +254,16 @@ public void onAnimationEnd(Animator animation) {
237254
} else {
238255
Intent intent = new Intent(MainActivity.this, DetailActivity.class);
239256
intent.putExtra("card", mCards.get(mIndex));
257+
intent.putExtra("padding", startPaddingBottom);
240258
startActivityForResult(intent, REQ_DETAIL);
241259
overridePendingTransition(0, 0);
242260
}
261+
mCardStackView.post(new Runnable() {
262+
@Override
263+
public void run() {
264+
mCardStackView.setSkipLayout(false);
265+
}
266+
});
243267
}
244268

245269
@Override
@@ -273,7 +297,6 @@ public void resetViews() {
273297
}
274298

275299
update(0f);
276-
//mImageView.postInvalidate();
277300
mTitle.setAlpha(1f);
278301
mToolbar.setAlpha(1f);
279302
}

sample/src/main/res/layout/activity_detail.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
android:layout_width="match_parent"
1111
android:layout_height="192dp"
1212
android:scaleType="centerCrop"
13-
tools:src="@drawable/calendar"
13+
tools:src="@drawable/knowledge"
1414
/>
1515

1616
<TextView

0 commit comments

Comments
 (0)