From: Marius Gavrilescu Date: Tue, 26 Mar 2013 10:55:05 +0000 (+0200) Subject: Remove LocalBroadcastReceiver X-Git-Tag: 0.000_001~42 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=c0c92599e4794433ad69fffcfcd3af677a37b03a;p=fonbot.git Remove LocalBroadcastReceiver Since adding FonBotMainService#ACTION_TRIGGER_POLL, LocalBroadcastReceiver became useless, as the alarm can directly poll via the service. --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f9e15c2..1030534 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -188,13 +188,6 @@ - - - - - \ No newline at end of file diff --git a/src/ro/ieval/fonbot/Heavy.java b/src/ro/ieval/fonbot/Heavy.java index 6e91f2f..f734437 100644 --- a/src/ro/ieval/fonbot/Heavy.java +++ b/src/ro/ieval/fonbot/Heavy.java @@ -1519,9 +1519,9 @@ final class Heavy { */ public static void poll(final Context context, final Address replyTo, final long ms){ final AlarmManager man=(AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - final Intent pollAlarm=new Intent(context, LocalBroadcastReceiver.class); - pollAlarm.setAction(LocalBroadcastReceiver.ACTION_POLL_ALARM); - final PendingIntent intent=PendingIntent.getBroadcast(context, 0, pollAlarm, 0); + final Intent pollAlarm=new Intent(context, FonBotMainService.class); + pollAlarm.setAction(FonBotMainService.ACTION_TRIGGER_POLL); + final PendingIntent intent=PendingIntent.getService(context, 0, pollAlarm, 0); if(ms==0){ Utils.unregisterOngoing(context, toNonNull(OngoingEvent.POLL)); man.cancel(intent); diff --git a/src/ro/ieval/fonbot/LocalBroadcastReceiver.java b/src/ro/ieval/fonbot/LocalBroadcastReceiver.java deleted file mode 100644 index 163310e..0000000 --- a/src/ro/ieval/fonbot/LocalBroadcastReceiver.java +++ /dev/null @@ -1,49 +0,0 @@ -package ro.ieval.fonbot; - -import org.eclipse.jdt.annotation.Nullable; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -/* - * Copyright © 2013 Marius Gavrilescu - * - * This file is part of FonBot. - * - * FonBot is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * FonBot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with FonBot. If not, see . - */ - -/** - * BroadcastReceiver that receives appwide local broadcasts. - * - * @author Marius Gavrilescu - */ -public final class LocalBroadcastReceiver extends BroadcastReceiver { - /** - * Broadcast action: the poll alarm has fired, the app should poll the server - */ - public static final String ACTION_POLL_ALARM="ro.ieval.fonbot.SystemEventReceiver.ACTION_POLL_ALARM"; - - @Override - public void onReceive(final @Nullable Context context, final @Nullable Intent intent) { - if(context==null || intent==null) - return; - - final String action=intent.getAction(); - if(action.equals(LocalBroadcastReceiver.ACTION_POLL_ALARM)) - Utils.safePollServer(context); - } - -}