use of android.support.annotation.RequiresApi in project AndroidUtilLib by SiberiaDante.
the class SDDateUtil method getStrToSDFTime.
/**
* 支持输出各种格式的日期、时间
*
* @param str 时间戳
* @param format
* @return 日期、时间格式
*/
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
public static String getStrToSDFTime(String str, String format) {
// 判断时间戳是否为空
if (str == null || str.isEmpty() || str.equals("null")) {
return "";
}
// 未指定format格式时默认输出yyyy-MM-dd HH:mm:ss
if (format == null || format.isEmpty()) {
format = "yyyy-MM-dd HH:mm:ss";
}
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
Long strLong = Long.valueOf(str);
return sdf.format(new Date(strLong * 1000));
}
use of android.support.annotation.RequiresApi in project xabber-android by redsolution.
the class NotificationManager method createNotificationChannel.
@RequiresApi(api = Build.VERSION_CODES.O)
public String createNotificationChannel() {
String channelId = "xabber_notification";
String channelName = "Xabber Notification";
@SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(channelId, channelName, android.app.NotificationManager.IMPORTANCE_HIGH);
android.app.NotificationManager service = (android.app.NotificationManager) Application.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
if (service != null)
service.createNotificationChannel(channel);
return channelId;
}
use of android.support.annotation.RequiresApi in project vlc-android by videolan.
the class NotificationHelper method createNotificationChannels.
@RequiresApi(api = Build.VERSION_CODES.O)
public static void createNotificationChannels(Context appCtx) {
final NotificationManager notificationManager = (NotificationManager) appCtx.getSystemService(Context.NOTIFICATION_SERVICE);
// Playback channel
CharSequence name = appCtx.getString(R.string.playback);
String description = appCtx.getString(R.string.playback_controls);
NotificationChannel channel = new NotificationChannel("vlc_playback", name, NotificationManager.IMPORTANCE_LOW);
channel.setDescription(description);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(channel);
// Scan channel
name = appCtx.getString(R.string.medialibrary_scan);
description = appCtx.getString(R.string.Medialibrary_progress);
channel = new NotificationChannel("vlc_medialibrary", name, NotificationManager.IMPORTANCE_LOW);
channel.setDescription(description);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(channel);
// Recommendations channel
if (AndroidDevices.isAndroidTv) {
name = appCtx.getString(R.string.recommendations);
description = appCtx.getString(R.string.recommendations_desc);
channel = new NotificationChannel("vlc_recommendations", name, NotificationManager.IMPORTANCE_LOW);
channel.setDescription(description);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(channel);
}
}
use of android.support.annotation.RequiresApi in project vlc-android by videolan.
the class UiTools method blurBitmap.
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap blurBitmap(Bitmap bitmap, float radius) {
if (bitmap == null || bitmap.getConfig() == null)
return null;
// Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
// Instantiate a new Renderscript
RenderScript rs = RenderScript.create(VLCApplication.getAppContext());
// Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
// Create the Allocations (in/out) with the Renderscript and the in/out bitmaps
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
// Set the radius of the blur
blurScript.setRadius(radius);
// Perform the Renderscript
blurScript.setInput(allIn);
blurScript.forEach(allOut);
// Copy the final bitmap created by the out Allocation to the outBitmap
allOut.copyTo(outBitmap);
// After finishing everything, we destroy the Renderscript.
rs.destroy();
return outBitmap;
}
use of android.support.annotation.RequiresApi in project vlc-android by videolan.
the class TvUtil method updateBackground.
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public static void updateBackground(final BackgroundManager bm, Object item) {
if (bm == null)
return;
if (item instanceof MediaLibraryItem) {
final boolean crop = ((MediaLibraryItem) item).getItemType() != MediaLibraryItem.TYPE_MEDIA || ((MediaWrapper) item).getType() == MediaWrapper.TYPE_AUDIO;
final String artworkMrl = ((MediaLibraryItem) item).getArtworkMrl();
if (!TextUtils.isEmpty(artworkMrl)) {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
if (bm == null)
return;
Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(artworkMrl), 512);
if (cover == null)
return;
if (crop)
cover = BitmapUtil.centerCrop(cover, cover.getWidth(), cover.getWidth() * 10 / 16);
final Bitmap blurred = UiTools.blurBitmap(cover, 10f);
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
if (bm == null)
return;
bm.setColor(0);
bm.setDrawable(new BitmapDrawable(VLCApplication.getAppResources(), blurred));
}
});
}
});
return;
}
}
clearBackground(bm);
}
Aggregations