Skip to content

Commit

Permalink
移除未用的方法,以便能在低于23的SDK版本上编译
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Dec 21, 2016
1 parent c9b89b9 commit 37c5b0c
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.annotation.StyleRes;
import android.view.View;
import android.widget.TextView;

/**
* 兼容旧版&新版
Expand All @@ -30,16 +25,6 @@ public static void setBackground(View view, Drawable drawable) {
}
}

@TargetApi(Build.VERSION_CODES.M)
public static void setTextAppearance(TextView view, @StyleRes int appearanceRes) {
if (Build.VERSION.SDK_INT < 23) {
//noinspection deprecation
view.setTextAppearance(view.getContext(), appearanceRes);
} else {
view.setTextAppearance(appearanceRes);
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Drawable getDrawable(Context context, @DrawableRes int drawableRes) {
if (Build.VERSION.SDK_INT < 21) {
Expand All @@ -50,25 +35,4 @@ public static Drawable getDrawable(Context context, @DrawableRes int drawableRes
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static String getString(Context context, @StringRes int stringRes) {
if (Build.VERSION.SDK_INT < 21) {
//noinspection deprecation
return context.getResources().getString(stringRes);
} else {
return context.getString(stringRes);
}
}

@TargetApi(Build.VERSION_CODES.M)
@ColorInt
public static int getColor(Context context, @ColorRes int colorRes) {
if (Build.VERSION.SDK_INT < 23) {
//noinspection deprecation
return context.getResources().getColor(colorRes);
} else {
return context.getResources().getColor(colorRes, null);
}
}

}

0 comments on commit 37c5b0c

Please sign in to comment.