use of android.annotation.SuppressLint in project UltimateAndroid by cymcsg.
the class AnimationAdapter method calculateAnimationDelay.
@SuppressLint("NewApi")
private long calculateAnimationDelay() {
long delay;
int lastVisiblePosition = getAbsListView().getLastVisiblePosition();
int firstVisiblePosition = getAbsListView().getFirstVisiblePosition();
int numberOfItemsOnScreen = lastVisiblePosition - firstVisiblePosition;
int numberOfAnimatedItems = mLastAnimatedPosition - mFirstAnimatedPosition;
if (numberOfItemsOnScreen + 1 < numberOfAnimatedItems) {
delay = getAnimationDelayMillis();
if (getAbsListView() instanceof GridView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
delay += getAnimationDelayMillis() * ((mLastAnimatedPosition + 1) % ((GridView) getAbsListView()).getNumColumns());
}
} else {
long delaySinceStart = (mLastAnimatedPosition - mFirstAnimatedPosition + 1) * getAnimationDelayMillis();
delay = mAnimationStartMillis + getInitialDelayMillis() + delaySinceStart - System.currentTimeMillis();
}
return Math.max(0, delay);
}
use of android.annotation.SuppressLint in project MaterialProgressBar by DreaminginCodeZH.
the class HorizontalProgressDrawable method updateSecondaryProgressTint.
@SuppressLint("NewApi")
private void updateSecondaryProgressTint() {
if (mHasSecondaryProgressTintColor) {
int tintColor = mSecondaryProgressTintColor;
if (!getShowBackground()) {
// Alpha of tintColor may not be mBackgroundAlpha because we modulated it in
// setTint().
float backgroundAlpha = (float) Color.alpha(tintColor) / 0xFF;
tintColor = ColorUtils.setAlphaComponent(tintColor, Math.round(0xFF * compositeAlpha(backgroundAlpha, backgroundAlpha)));
}
mSecondaryProgressDrawable.setTint(tintColor);
} else if (mHasSecondaryProgressTint) {
ColorStateList tint = mSecondaryProgressTint;
if (!getShowBackground()) {
// Composite alpha so that the secondary progress looks as before.
tint = tint.withAlpha(Math.round(0xFF * compositeAlpha(mBackgroundAlpha, mBackgroundAlpha)));
}
mSecondaryProgressDrawable.setTintList(tint);
}
}
use of android.annotation.SuppressLint in project MaterialProgressBar by DreaminginCodeZH.
the class HorizontalProgressDrawable method setTint.
/**
* {@inheritDoc}
*/
@Override
@SuppressLint("NewApi")
public void setTint(@ColorInt int tintColor) {
// Modulate alpha of tintColor against mBackgroundAlpha.
int backgroundTintColor = ColorUtils.setAlphaComponent(tintColor, Math.round(Color.alpha(tintColor) * mBackgroundAlpha));
mBackgroundDrawable.setTint(backgroundTintColor);
setSecondaryProgressTint(backgroundTintColor);
mProgressDrawable.setTint(tintColor);
}
use of android.annotation.SuppressLint in project AndroidUtilCode by Blankj.
the class AppUtils method getAppSignature.
/**
* 获取App签名
*
* @param context 上下文
* @param packageName 包名
* @return App签名
*/
@SuppressLint("PackageManagerGetSignatures")
public static Signature[] getAppSignature(Context context, String packageName) {
if (StringUtils.isSpace(packageName))
return null;
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
return pi == null ? null : pi.signatures;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return null;
}
}
use of android.annotation.SuppressLint in project AndroidUtilCode by Blankj.
the class ConvertUtils method millis2FitTimeSpan.
/**
* 毫秒时间戳转合适时间长度
*
* @param millis 毫秒时间戳
* <p>小于等于0,返回null</p>
* @param precision 精度
* <ul>
* <li>precision = 0,返回null</li>
* <li>precision = 1,返回天</li>
* <li>precision = 2,返回天和小时</li>
* <li>precision = 3,返回天、小时和分钟</li>
* <li>precision = 4,返回天、小时、分钟和秒</li>
* <li>precision >= 5,返回天、小时、分钟、秒和毫秒</li>
* </ul>
* @return 合适时间长度
*/
@SuppressLint("DefaultLocale")
public static String millis2FitTimeSpan(long millis, int precision) {
if (millis <= 0 || precision <= 0)
return null;
StringBuilder sb = new StringBuilder();
String[] units = { "天", "小时", "分钟", "秒", "毫秒" };
int[] unitLen = { 86400000, 3600000, 60000, 1000, 1 };
precision = Math.min(precision, 5);
for (int i = 0; i < precision; i++) {
if (millis >= unitLen[i]) {
long mode = millis / unitLen[i];
millis -= mode * unitLen[i];
sb.append(mode).append(units[i]);
}
}
return sb.toString();
}
Aggregations