From 1db598efd5e2175c3173278aa6cab1b77f155f3f Mon Sep 17 00:00:00 2001 From: Baptiste Date: Thu, 26 Mar 2015 12:50:50 +0100 Subject: [PATCH] Commit change to respect PMD and Ignore Lint issue du to TargetApi support checked by If conditions --- lib/build.gradle | 2 +- .../blurdialogfragment/BlurDialogEngine.java | 66 ++++++++++--------- sample/build.gradle | 2 +- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/lib/build.gradle b/lib/build.gradle index fd20931..ae52eab 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -6,7 +6,7 @@ def version = '1.1.0' android { compileSdkVersion 22 - buildToolsVersion "22" + buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 9 diff --git a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java index fedbe47..cf0e9d0 100644 --- a/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java +++ b/lib/src/main/java/fr/tvbarthel/lib/blurdialogfragment/BlurDialogEngine.java @@ -2,6 +2,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.content.res.Resources; @@ -158,31 +159,33 @@ public void onResume(boolean retainedInstance) { /** * Must be linked to the original lifecycle. */ + @SuppressLint("NewApi") public void onDismiss() { //remove blurred background and clear memory, could be null if dismissed before blur effect //processing ends if (mBlurredBackgroundView != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mBlurredBackgroundView - .animate() - .alpha(0f) - .setDuration(mAnimationDuration) - .setInterpolator(new AccelerateInterpolator()) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - removeBlurredView(); - } - - @Override - public void onAnimationCancel(Animator animation) { - super.onAnimationCancel(animation); - removeBlurredView(); - } - }).start(); - else + .animate() + .alpha(0f) + .setDuration(mAnimationDuration) + .setInterpolator(new AccelerateInterpolator()) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + removeBlurredView(); + } + + @Override + public void onAnimationCancel(Animator animation) { + super.onAnimationCancel(animation); + removeBlurredView(); + } + }).start(); + } else { removeBlurredView(); + } } //cancel async task @@ -550,22 +553,25 @@ protected Void doInBackground(Void... params) { } @Override + @SuppressLint("NewApi") protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { mBlurredBackgroundView.setAlpha(0f); - mHoldingActivity.getWindow().addContentView( - mBlurredBackgroundView, - mBlurredBackgroundLayoutParams - ); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + mHoldingActivity.getWindow().addContentView( + mBlurredBackgroundView, + mBlurredBackgroundLayoutParams + ); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mBlurredBackgroundView - .animate() - .alpha(1f) - .setDuration(mAnimationDuration) - .setInterpolator(new LinearInterpolator()) - .start(); + .animate() + .alpha(1f) + .setDuration(mAnimationDuration) + .setInterpolator(new LinearInterpolator()) + .start(); + } mBackgroundView = null; mBackground = null; } diff --git a/sample/build.gradle b/sample/build.gradle index 0266eb5..a16bac9 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 22 - buildToolsVersion "22" + buildToolsVersion "22.0.1" defaultConfig { applicationId "fr.tvbarthel.lib.blurdialogfragment.sample"