Cleaning up lint warnings caused by appcompat upgrade

This commit is contained in:
anthony restaino 2017-03-26 20:08:07 -04:00
parent 8ef2f9099a
commit 3e6c228bba
5 changed files with 44 additions and 14 deletions

View File

@ -81,7 +81,6 @@ import android.widget.TextView.OnEditorActionListener;
import android.widget.VideoView;
import com.anthonycr.bonsai.Completable;
import com.anthonycr.bonsai.Observable;
import com.anthonycr.bonsai.Schedulers;
import com.anthonycr.grant.PermissionsManager;
import com.anthonycr.progress.AnimatedProgressBar;

View File

@ -15,7 +15,8 @@
*/
package acr.browser.lightning.fragment.anim;
import android.support.v4.animation.AnimatorCompatHelper;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
@ -54,6 +55,8 @@ public class HorizontalItemAnimator extends SimpleItemAnimator {
private final ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>();
private final ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>();
private TimeInterpolator mDefaultInterpolator;
private static class MoveInfo {
public final ViewHolder holder;
public final int fromX;
@ -544,10 +547,17 @@ public class HorizontalItemAnimator extends SimpleItemAnimator {
}
private void resetAnimation(ViewHolder holder) {
AnimatorCompatHelper.clearInterpolator(holder.itemView);
clearInterpolator(holder.itemView);
endAnimation(holder);
}
private void clearInterpolator(View view) {
if (mDefaultInterpolator == null) {
mDefaultInterpolator = new ValueAnimator().getInterpolator();
}
view.animate().setInterpolator(mDefaultInterpolator);
}
@Override
public boolean isRunning() {
return (!mPendingAdditions.isEmpty() ||

View File

@ -15,7 +15,8 @@
*/
package acr.browser.lightning.fragment.anim;
import android.support.v4.animation.AnimatorCompatHelper;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
@ -54,6 +55,8 @@ public class VerticalItemAnimator extends SimpleItemAnimator {
private final ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>();
private final ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>();
private TimeInterpolator mDefaultInterpolator;
private static class MoveInfo {
public final ViewHolder holder;
public final int fromX;
@ -543,10 +546,17 @@ public class VerticalItemAnimator extends SimpleItemAnimator {
}
private void resetAnimation(ViewHolder holder) {
AnimatorCompatHelper.clearInterpolator(holder.itemView);
clearInterpolator(holder.itemView);
endAnimation(holder);
}
private void clearInterpolator(View view) {
if (mDefaultInterpolator == null) {
mDefaultInterpolator = new ValueAnimator().getInterpolator();
}
view.animate().setInterpolator(mDefaultInterpolator);
}
@Override
public boolean isRunning() {
return (!mPendingAdditions.isEmpty() ||

View File

@ -12,13 +12,14 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.annotation.AttrRes;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.AppCompatDrawableManager;
import android.util.TypedValue;
import android.widget.ImageView;
@ -69,7 +70,15 @@ public class ThemeUtils {
@NonNull
private static Drawable getVectorDrawable(@NonNull Context context, int drawableId) {
Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
Drawable drawable;
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
drawable = context.getDrawable(drawableId);
} else {
drawable = context.getResources().getDrawable(drawableId);
}
Preconditions.checkNonNull(drawable);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = (DrawableCompat.wrap(drawable)).mutate();
}
@ -81,8 +90,8 @@ public class ThemeUtils {
private static Bitmap getBitmapFromVectorDrawable(@NonNull Context context, int drawableId) {
Drawable drawable = getVectorDrawable(context, drawableId);
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
@ -94,7 +103,8 @@ public class ThemeUtils {
public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) {
int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);
Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res);
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(), Bitmap.Config.ARGB_8888);
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Paint p = new Paint();
ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
p.setColorFilter(filter);
@ -115,8 +125,9 @@ public class ThemeUtils {
@NonNull
public static ColorDrawable getSelectedBackground(@NonNull Context context, boolean dark) {
@ColorInt final int color = (dark) ? ContextCompat.getColor(context, R.color.selected_dark) :
ContextCompat.getColor(context, R.color.selected_light);
@ColorInt final int color =
(dark) ? ContextCompat.getColor(context, R.color.selected_dark) : ContextCompat.getColor(
context, R.color.selected_light);
return new ColorDrawable(color);
}

View File

@ -2,12 +2,12 @@ package acr.browser.lightning.view;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatAutoCompleteTextView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.AutoCompleteTextView;
public class SearchView extends AutoCompleteTextView {
public class SearchView extends AppCompatAutoCompleteTextView {
public interface PreFocusListener {
void onPreFocus();