public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount) { try { var miuiNotificationClass = Class.ForName("android.app.MiuiNotification"); var miuiNotification = miuiNotificationClass.NewInstance(); var field = miuiNotificationClass.GetDeclaredField("messageCount"); field.Accessible = true; try { field.Set(miuiNotification, String.ValueOf(badgeCount == 0 ? "" : badgeCount.ToString())); } catch (Exception) { field.Set(miuiNotification, badgeCount); } } catch (Exception) { var localIntent = new Intent(IntentAction); localIntent.PutExtra(ExtraUpdateAppComponentName, $"{componentName.PackageName}/{componentName.ClassName}"); localIntent.PutExtra(ExtraUpdateAppMsgText, String.ValueOf(badgeCount == 0 ? "" : badgeCount.ToString())); if (BroadcastHelper.CanResolveBroadcast(context, localIntent)) { context.SendBroadcast(localIntent); } } if (Build.Manufacturer.Equals("Xiaomi", StringComparison.CurrentCultureIgnoreCase)) { TryNewMiuiBadge(context, badgeCount); } }
public override void SetDataSource(string filePath) { _reader.SetDataSource(filePath); if (_reader != null) { _infoMp3.Artist = _reader.ExtractMetadata(MetadataKey.Artist) ?? _reader.ExtractMetadata(MetadataKey.Author) ?? _reader.ExtractMetadata(MetadataKey.Composer) ?? "unknown artist"; var lastFilePath = filePath.LastIndexOf("/", StringComparison.Ordinal); var name = filePath.Remove(0, lastFilePath + 1).Replace(".mp3", ""); _infoMp3.NameSong = _reader.ExtractMetadata(MetadataKey.Title) ?? name; long dur = Long.ParseLong(_reader.ExtractMetadata(MetadataKey.Duration)); var seconds = String.ValueOf((dur % 60000) / 1000); var minutes = String.ValueOf((dur / 60000)); _infoMp3.Duration = minutes + ":" + seconds; } }