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

Fix trying start the timer more then one if you closed the project and open a new one issue #12

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.intellij.notification.NotificationType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import lombok.val;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand All @@ -18,11 +19,11 @@
public class AyahStartupActivity implements StartupActivity {
@Override
public void runActivity(@NotNull final Project project) {
final var basmalhOnStartSettingsState = AyahSettingsState.getInstance().getBasmalhOnStart();
val basmalhOnStartSettingsState = AyahSettingsState.getInstance().getBasmalhOnStart();
// Basmalh on start
if (basmalhOnStartSettingsState.isActive()) {
try {
final var bassmalh = Ayah.getAyah(1,
val bassmalh = Ayah.getAyah(1,
basmalhOnStartSettingsState.getEdition().getEditionIdentifier());
NotificationGroupManager.getInstance()
.getNotificationGroup("Basmalh on Start")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ public enum NotificationTimer {

private final Timer timer;
private final NotificationTimerTask notificationTimerTask;
private boolean isRunning;

NotificationTimer() {
timer = new Timer();
notificationTimerTask = new NotificationTimerTask();
isRunning = false;
}
public void start(@NotNull Project project) {
if (isRunning) {
return;
}
notificationTimerTask.setProject(project);
schedule(AyahSettingsState.getInstance().getIntervalTimeBetweenNotifications());
isRunning = true;

}

public void updateIntervalTimeBetweenNotifications(final int intervalTimeBetweenNotifications) {
Expand Down