Skip to content

If setRemindInterval is set to 25 or more, the number of days is not set correctly #138

@yuna-yano

Description

@yuna-yano

I'm sorry, my English is not good.

If "setRemindInterval" is set to 25 or more, the number of days is not set correctly.
Looking at the point calculated using this value, it seems that the int is overflowing.

// it this "threshold" is "remindInterval".
    private static boolean isOverDate(long targetDate, int threshold) {
        return new Date().getTime() - targetDate >= threshold * 24 * 60 * 60 * 1000;
    }

Casting "threshold" to a long type solves the problem.

    private static boolean isOverDate(long targetDate, int threshold) {
        return new Date().getTime() - targetDate >= (long)threshold * 24 * 60 * 60 * 1000;
    }

I would like to send you a pull request, so thank you.


英語がうまくなくてすみません、日本語でもコメントさせていただきます。

setRemindIntervalの値を25日以上で設定すると、正しく日数が設定されません。
(25日で設定した場合、ボタンを押したにも関わらず毎回ダイアログが表示されるようになります)

設定値を使用している箇所をみると、引数thresholdがint型であり、その型のまま計算しているためintの最大値を超えて桁が溢れているようでした。
long型にキャストすることで正しく動作することを確認しました。

後ほどプルリクエストを送らせていただきたと思いますので、
どうぞよろしくお願いします。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions