Remove ServiceComponent

pull/437/head
Alex Baker 8 years ago
parent 1804e00568
commit 91e7748263

@ -1,8 +0,0 @@
package org.tasks.injection;
import dagger.Subcomponent;
@Subcomponent(modules = ServiceModule.class)
public interface ServiceComponent extends BaseServiceComponent {
}

@ -1,8 +0,0 @@
package org.tasks.injection;
import dagger.Subcomponent;
@Subcomponent(modules = ServiceModule.class)
public interface ServiceComponent extends BaseServiceComponent {
}

@ -13,8 +13,7 @@ import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import org.tasks.R;
import org.tasks.injection.InjectingDashClockExtension;
import org.tasks.injection.ServiceComponent;
import org.tasks.injection.InjectingApplication;
import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences;
@ -24,7 +23,7 @@ import javax.inject.Inject;
import timber.log.Timber;
public class DashClockExtension extends InjectingDashClockExtension {
public class DashClockExtension extends com.google.android.apps.dashclock.api.DashClockExtension {
@Inject DefaultFilterProvider defaultFilterProvider;
@Inject TaskDao taskDao;
@ -41,6 +40,10 @@ public class DashClockExtension extends InjectingDashClockExtension {
public void onCreate() {
super.onCreate();
((InjectingApplication) getApplication())
.getComponent()
.inject(this);
registerReceiver(refreshReceiver, new IntentFilter(AstridApiConstants.BROADCAST_EVENT_REFRESH));
}
@ -56,11 +59,6 @@ public class DashClockExtension extends InjectingDashClockExtension {
refresh();
}
@Override
protected void inject(ServiceComponent component) {
component.inject(this);
}
private void refresh() {
if (preferences.hasPurchase(R.string.p_purchased_dashclock)) {
final String filterPreference = preferences.getStringValue(R.string.p_dashclock_filter);

@ -1,9 +1,13 @@
package org.tasks.injection;
import org.tasks.dashclock.DashClockExtension;
import dagger.Component;
@ApplicationScope
@Component(modules = ApplicationModule.class)
public interface ApplicationComponent extends BaseApplicationComponent {
SyncAdapterComponent plus(SyncAdapterModule syncAdapterModule);
void inject(DashClockExtension dashClockExtension);
}

@ -1,16 +0,0 @@
package org.tasks.injection;
import com.google.android.apps.dashclock.api.DashClockExtension;
public abstract class InjectingDashClockExtension extends DashClockExtension {
@Override
public void onCreate() {
super.onCreate();
inject(((InjectingApplication) getApplication())
.getComponent()
.plus(new ServiceModule()));
}
protected abstract void inject(ServiceComponent component);
}

@ -1,10 +0,0 @@
package org.tasks.injection;
import org.tasks.dashclock.DashClockExtension;
import dagger.Subcomponent;
@Subcomponent(modules = ServiceModule.class)
public interface ServiceComponent extends BaseServiceComponent {
void inject(DashClockExtension dashClockExtension);
}

@ -1,15 +1,16 @@
package org.tasks.injection;
import org.tasks.Tasks;
import org.tasks.widget.ScrollableWidgetUpdateService;
public interface BaseApplicationComponent {
Tasks inject(Tasks tasks);
void inject(Tasks tasks);
void inject(ScrollableWidgetUpdateService scrollableWidgetUpdateService);
ActivityComponent plus(ActivityModule module);
BroadcastComponent plus(BroadcastModule module);
IntentServiceComponent plus(IntentServiceModule module);
ServiceComponent plus(ServiceModule serviceModule);
}

@ -1,9 +0,0 @@
package org.tasks.injection;
import org.tasks.widget.ScrollableWidgetUpdateService;
import dagger.Subcomponent;
public interface BaseServiceComponent {
void inject(ScrollableWidgetUpdateService scrollableWidgetUpdateService);
}

@ -1,16 +0,0 @@
package org.tasks.injection;
import android.widget.RemoteViewsService;
public abstract class InjectingRemoteViewsService extends RemoteViewsService {
@Override
public void onCreate() {
super.onCreate();
inject(((InjectingApplication) getApplication())
.getComponent()
.plus(new ServiceModule()));
}
protected abstract void inject(ServiceComponent component);
}

@ -1,7 +0,0 @@
package org.tasks.injection;
import dagger.Module;
@Module
public class ServiceModule {
}

@ -3,13 +3,13 @@ package org.tasks.widget;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RemoteViewsService;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.subtasks.SubtasksHelper;
import org.tasks.injection.InjectingRemoteViewsService;
import org.tasks.injection.ServiceComponent;
import org.tasks.injection.InjectingApplication;
import org.tasks.locale.Locale;
import org.tasks.preferences.DefaultFilterProvider;
import org.tasks.preferences.Preferences;
@ -18,7 +18,7 @@ import org.tasks.ui.WidgetCheckBoxes;
import javax.inject.Inject;
public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService {
public class ScrollableWidgetUpdateService extends RemoteViewsService {
@Inject Database database;
@Inject TaskService taskService;
@ -29,6 +29,15 @@ public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService {
@Inject ThemeCache themeCache;
@Inject Locale locale;
@Override
public void onCreate() {
super.onCreate();
((InjectingApplication) getApplication())
.getComponent()
.inject(this);
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
@ -51,9 +60,4 @@ public class ScrollableWidgetUpdateService extends InjectingRemoteViewsService {
return new ScrollableViewsFactory(subtasksHelper, preferences, locale.createConfigurationContext(getApplicationContext()),
widgetId, database, taskService, defaultFilterProvider, widgetCheckBoxes, themeCache);
}
@Override
protected void inject(ServiceComponent component) {
component.inject(this);
}
}

Loading…
Cancel
Save