Skip to content

Commit 4ae5ca9

Browse files
committed
Set min SDK to 14
1 parent 5db272d commit 4ae5ca9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66

77
defaultConfig {
88
applicationId "worldline.com.foldablelayout"
9-
minSdkVersion 16
9+
minSdkVersion 14
1010
targetSdkVersion 23
1111
versionCode 1
1212
versionName "1.0"

foldablelayout/src/main/java/worldline/com/foldablelayout/FoldableLayout.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,18 @@ public boolean onTouchEvent(MotionEvent event) {
189189
}
190190

191191
private void clearImageView(ImageView imageView) {
192-
imageView.setBackground(null);
192+
setImageBackground(imageView, null);
193193
imageView.setImageDrawable(null);
194194
}
195195

196+
private void setImageBackground(ImageView imageView, Drawable drawable) {
197+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
198+
imageView.setBackground(drawable);
199+
} else {
200+
imageView.setBackgroundDrawable(drawable);
201+
}
202+
}
203+
196204
/**
197205
* Fold the layout without animations.
198206
*/
@@ -277,8 +285,8 @@ public void onAnimationStart(Animator animation) {
277285
mContentLayout.setRotationX(180);
278286
mViewGroupDetail.setVisibility(GONE);
279287
mImageViewAbove.setImageDrawable(belowShadow);
280-
mImageViewAbove.setBackground(new BitmapDrawable(getResources(), rotatedAboveBitmap));
281-
mImageViewBelow.setBackground(new BitmapDrawable(getResources(), mDetailTopBitmap));
288+
setImageBackground(mImageViewAbove, new BitmapDrawable(getResources(), rotatedAboveBitmap));
289+
setImageBackground(mImageViewBelow, new BitmapDrawable(getResources(), mDetailTopBitmap));
282290
mImageViewBelow.setImageDrawable(aboveShadow);
283291
}
284292

@@ -340,7 +348,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
340348
if (animation.getAnimatedFraction() >= 0.5 && !mReplaceDone) {
341349
mReplaceDone = true;
342350
mViewGroupCover.setVisibility(GONE);
343-
mImageViewAbove.setBackground(new BitmapDrawable(getResources(), rotatedAboveBitmap));
351+
setImageBackground(mImageViewAbove, new BitmapDrawable(getResources(), rotatedAboveBitmap));
344352
mImageViewAbove.setImageDrawable(aboveShadow);
345353
}
346354
mContentLayout.setRotationX((Float) animation.getAnimatedValue());
@@ -358,7 +366,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
358366
public void onAnimationStart(Animator animation) {
359367
mFoldListener.onUnFoldStart();
360368
mIsAnimating = true;
361-
mImageViewBelow.setBackground(new BitmapDrawable(getResources(), mDetailTopBitmap));
369+
setImageBackground(mImageViewBelow, new BitmapDrawable(getResources(), mDetailTopBitmap));
362370
mImageViewBelow.setImageDrawable(belowShadow);
363371
}
364372

0 commit comments

Comments
 (0)