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

Java 7 implementation of the bomAfterDays() method #1

Closed
MrHeart opened this issue Mar 21, 2017 · 1 comment
Closed

Java 7 implementation of the bomAfterDays() method #1

MrHeart opened this issue Mar 21, 2017 · 1 comment

Comments

@MrHeart
Copy link

MrHeart commented Mar 21, 2017

Hi @kibotu,

Thanks for a nice work on this project.

Please can you write Java 7 equivalent of the above method. It seems to crash apps that use Java 7. I notice that it is only that method that doesn't work well with that Java 7.

Any help will be greatly appreciated. Below is the method:

`public static long bombAfterDays(Context context, long buildTime, int days) {
SimpleDateFormat sdf1 = new SimpleDateFormat("dd.MM.yyyy");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(buildTime);
Date buildDate = calendar.getTime();
Date today = new Date();
long difference = daysBetween(buildDate, today);

    long timeLeft = days - difference;
    if (enableLogging)
        Log.v(TAG, "[bombAfterDays] Bomb in " + timeLeft + "d Build Date=" + sdf1.format(buildDate) + " Today=" + sdf1.format(today) + " Passed Days=" + difference);

    if (difference < days)
        return timeLeft;

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(R.string.time_bomb_message)
            .setCancelable(false);

    Dialog dialog = builder.create();
    dialog.setOnShowListener(dialog1 -> {
        ((AlertDialog) dialog1).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
        ((AlertDialog) dialog1).getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(false);
    });
    dialog.show();

    return timeLeft;
}

`

@kibotu
Copy link
Owner

kibotu commented Mar 21, 2017

hello, thanks for the feedback. however the lambda should be covered due to retrolambda.

@kibotu kibotu closed this as completed Sep 25, 2019
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

2 participants