]> iEval git - fonbot.git/blobdiff - src/ro/ieval/fonbot/FonBotMainService.java
Convert HashSet to EnumSet for better performance
[fonbot.git] / src / ro / ieval / fonbot / FonBotMainService.java
index a751d231c434173188b16dcd6a6037273eb83430..47fdafc38ee290e07b07662f947314f75efa7f82 100644 (file)
@@ -4,7 +4,7 @@ import static ro.ieval.fonbot.R.string.*;
 import static ro.ieval.fonbot.Utils.toNonNull;
 
 import java.util.Collections;
-import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.Nullable;
@@ -70,6 +70,8 @@ public final class FonBotMainService extends Service {
         * Broadcast action: remove an ongoing event
         */
        public static final String ACTION_DELETE_ONGOING="ro.ieval.fonbot.FonBotMainService.ACTION_DELETE_ONGOING";
+       /** Broadcast action: trigger a server poll */
+       public static final String ACTION_TRIGGER_POLL="ro.ieval.fonbot.FonBotMainService.ACTION_TRIGGER_POLL";
        /**
         * Extra: ongoing event id
         *
@@ -100,7 +102,7 @@ public final class FonBotMainService extends Service {
        /**
         * Set of ongoing events.
         */
-       private final Set<OngoingEvent> ongoing=new HashSet<OngoingEvent>(10);
+       private final Set<OngoingEvent> ongoing=EnumSet.noneOf(OngoingEvent.class);
 
        /**
         * Get the set of ongoing events.
@@ -139,6 +141,9 @@ public final class FonBotMainService extends Service {
                        LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_ONGOING_UPDATE));
                }
 
+               if(intent!=null && intent.getAction()==ACTION_TRIGGER_POLL)
+                       Utils.pollServer(this);
+
                final boolean runForeground=PreferenceManager.getDefaultSharedPreferences(this).getBoolean("foreground", false);
                if(!runForeground)
                        stopForeground(true);
This page took 0.024011 seconds and 4 git commands to generate.