mirror of
https://github.com/anas-elgarhy/Ayah-intellij.git
synced 2024-08-15 00:43:43 +00:00
Merge pull request #12 from anas-elgarhy/dev
Fix trying start the timer more then one if you closed the project and open a new one issue
This commit is contained in:
commit
a8c4a59c02
2 changed files with 10 additions and 2 deletions
|
@ -7,6 +7,7 @@ import com.intellij.notification.NotificationGroupManager;
|
||||||
import com.intellij.notification.NotificationType;
|
import com.intellij.notification.NotificationType;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.startup.StartupActivity;
|
import com.intellij.openapi.startup.StartupActivity;
|
||||||
|
import lombok.val;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -18,11 +19,11 @@ import java.io.IOException;
|
||||||
public class AyahStartupActivity implements StartupActivity {
|
public class AyahStartupActivity implements StartupActivity {
|
||||||
@Override
|
@Override
|
||||||
public void runActivity(@NotNull final Project project) {
|
public void runActivity(@NotNull final Project project) {
|
||||||
final var basmalhOnStartSettingsState = AyahSettingsState.getInstance().getBasmalhOnStart();
|
val basmalhOnStartSettingsState = AyahSettingsState.getInstance().getBasmalhOnStart();
|
||||||
// Basmalh on start
|
// Basmalh on start
|
||||||
if (basmalhOnStartSettingsState.isActive()) {
|
if (basmalhOnStartSettingsState.isActive()) {
|
||||||
try {
|
try {
|
||||||
final var bassmalh = Ayah.getAyah(1,
|
val bassmalh = Ayah.getAyah(1,
|
||||||
basmalhOnStartSettingsState.getEdition().getEditionIdentifier());
|
basmalhOnStartSettingsState.getEdition().getEditionIdentifier());
|
||||||
NotificationGroupManager.getInstance()
|
NotificationGroupManager.getInstance()
|
||||||
.getNotificationGroup("Basmalh on Start")
|
.getNotificationGroup("Basmalh on Start")
|
||||||
|
|
|
@ -16,14 +16,21 @@ public enum NotificationTimer {
|
||||||
|
|
||||||
private final Timer timer;
|
private final Timer timer;
|
||||||
private final NotificationTimerTask notificationTimerTask;
|
private final NotificationTimerTask notificationTimerTask;
|
||||||
|
private boolean isRunning;
|
||||||
|
|
||||||
NotificationTimer() {
|
NotificationTimer() {
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
notificationTimerTask = new NotificationTimerTask();
|
notificationTimerTask = new NotificationTimerTask();
|
||||||
|
isRunning = false;
|
||||||
}
|
}
|
||||||
public void start(@NotNull Project project) {
|
public void start(@NotNull Project project) {
|
||||||
|
if (isRunning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
notificationTimerTask.setProject(project);
|
notificationTimerTask.setProject(project);
|
||||||
schedule(AyahSettingsState.getInstance().getIntervalTimeBetweenNotifications());
|
schedule(AyahSettingsState.getInstance().getIntervalTimeBetweenNotifications());
|
||||||
|
isRunning = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateIntervalTimeBetweenNotifications(final int intervalTimeBetweenNotifications) {
|
public void updateIntervalTimeBetweenNotifications(final int intervalTimeBetweenNotifications) {
|
||||||
|
|
Loading…
Reference in a new issue