Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yuna-yano opened this issue Jan 15, 2018 · 2 comments

Comments

@yuna-yano
Copy link

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型にキャストすることで正しく動作することを確認しました。

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

@hotchemi
Copy link
Owner

Oh thx! Sorry I haven't maintained this repo for a while... 🙇 Let me check.

@AlexanderLS
Copy link

@yuna-yano Fixed in Releases 1.0.9+ https://github.com/Vorlonsoft/AndroidRate/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants