Stop scrollable widget update service

pull/253/head
Alex Baker 10 years ago
parent dd97040005
commit add0edd175

@ -21,12 +21,6 @@ public final class Constants {
*/
public static final MarketStrategy MARKET_STRATEGY = new MarketStrategy.AndroidMarketStrategy();
/**
* Interval to update the widget (in order to detect hidden tasks
* becoming visible)
*/
public static final long WIDGET_UPDATE_INTERVAL = 30 * 60 * 1000L;
// --- task list activity source strings
public static final int SOURCE_OTHER = -1;

@ -59,7 +59,12 @@ public class WidgetUpdateService extends InjectingService {
}).start();
}
public void startServiceInBackgroundThread(Intent intent) {
@Override
public IBinder onBind(Intent intent) {
return null;
}
private void startServiceInBackgroundThread(Intent intent) {
ComponentName thisWidget = new ComponentName(this,
TasksWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
@ -88,12 +93,7 @@ public class WidgetUpdateService extends InjectingService {
stopSelf();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public RemoteViews buildUpdate(Context context, int widgetId) {
private RemoteViews buildUpdate(Context context, int widgetId) {
RemoteViews views = getThemedRemoteViews(context);
int numberOfTasks = NUM_VISIBLE_TASKS;

@ -26,6 +26,13 @@ public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService {
@Inject TagDataDao tagDataDao;
@Inject Preferences preferences;
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
stopSelf();
}
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
if (intent == null) {

@ -34,30 +34,19 @@ import org.tasks.R;
import org.tasks.preferences.ActivityPreferences;
import org.tasks.preferences.Preferences;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static com.todoroo.andlib.utility.AndroidUtilities.preIceCreamSandwich;
@Singleton
public class WidgetHelper {
public static int flags = FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK;
public static void startWidgetService(Context context) {
Class widgetServiceClass = preIceCreamSandwich()
? WidgetUpdateService.class
: ScrollableWidgetUpdateService.class;
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, widgetServiceClass);
PendingIntent pendingIntent = PendingIntent.getService(context,
0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setInexactRepeating(AlarmManager.RTC, 0,
Constants.WIDGET_UPDATE_INTERVAL, pendingIntent);
}
public static void triggerUpdate(Context context) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
if (appWidgetManager == null) {
@ -81,7 +70,10 @@ public class WidgetHelper {
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public RemoteViews createScrollableWidget(Context context, int id) {
startWidgetService(context);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, ScrollableWidgetUpdateService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setInexactRepeating(AlarmManager.RTC, 0, TimeUnit.MINUTES.toMillis(30), pendingIntent);
Filter filter = getFilter(context, id);
Intent rvIntent = new Intent(context, ScrollableWidgetUpdateService.class);

Loading…
Cancel
Save