小编Kac*_*hał的帖子

Oreo上的Toast重叠问题(8.1)

我有祝酒问题.对于API 26及以下的吐司正确显示(下一个toast正在等待之前消失)但在Android 8.1(API 27)上它们相互覆盖.我的通知频道设置如下:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
    NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, 
                        NOTIFICATION_CHANNEL_NAME, 
                        NotificationManager.IMPORTANCE_DEFAULT);
    notificationManager.createNotificationChannel(notificationChannel);
    builder.setChannelId(NOTIFICATION_CHANNEL_ID);
}
Run Code Online (Sandbox Code Playgroud)

这为我修复了8.0的祝酒词,但在8.1上它们仍然重叠 喜欢这张照片

有没有办法解决这个问题而不是记住上次使用过的吐司并手动取消它?

编辑:

此线程的解决方法不起作用

/**
 * <strong>public void showAToast (String st)</strong></br>
 * this little method displays a toast on the screen.</br>
 * it checks if a toast is currently visible</br>
 * if so </br>
 * ... it "sets" the new text</br>
 * else</br>
 * ... it "makes" the new text</br>
 * and "shows" either or  
 * @param st the string …
Run Code Online (Sandbox Code Playgroud)

android android-8.1-oreo

11
推荐指数
1
解决办法
1266
查看次数

自定义Spring注释未调用

在我的Spring Boot项目中,我创建了一个带有验证器的自定义批注,扩展ConstraintValidator了验证器以验证RequestBody中的某些字段。对于非嵌套字段,注释可以正常工作,但对于嵌套字段,则不调用验证器。

我的注释如下:

@Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
@Constraint(validatedBy = [CustomValidator::class])
@Suppress("unused")
@MustBeDocumented
annotation class CustomValidation(
    val message: String = "validation failed",
    val groups: Array<KClass<*>> = [],
    val payload: Array<KClass<out Payload>> = []
)
Run Code Online (Sandbox Code Playgroud)

我的验证器类:

@Component
class CustomValidator : ConstraintValidator<CustomValidation, String> {

    override fun isValid(field: String?, context: ConstraintValidatorContext?): Boolean {
        if (field != "example") {
            return false
        }
        return true
    }
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,它可以正常工作:

data class MyRequest(
// validator works perfectly here
    @JsonProperty("example") @CustomValidation val example: String? = null,
    @JsonProperty("locale") val locale: …
Run Code Online (Sandbox Code Playgroud)

java spring annotations kotlin spring-boot

6
推荐指数
1
解决办法
92
查看次数