Inject StartupService

pull/189/head
Alex Baker 12 years ago
parent 14d4a26fb0
commit 643ec6f594

@ -41,6 +41,8 @@ import com.todoroo.astrid.voice.VoiceRecognizer;
import org.tasks.R; import org.tasks.R;
import org.tasks.injection.InjectingActionBarActivity; import org.tasks.injection.InjectingActionBarActivity;
import javax.inject.Inject;
/** /**
* This wrapper activity contains all the glue-code to handle the callbacks between the different * This wrapper activity contains all the glue-code to handle the callbacks between the different
* fragments that could be visible on the screen in landscape-mode. * fragments that could be visible on the screen in landscape-mode.
@ -86,13 +88,14 @@ public class AstridActivity extends InjectingActionBarActivity
.findFragmentByTag(CommentsFragment.TAG_UPDATES_FRAGMENT); .findFragmentByTag(CommentsFragment.TAG_UPDATES_FRAGMENT);
} }
@Inject StartupService startupService;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ContextManager.setContext(this); ContextManager.setContext(this);
new StartupService().onStartupApplication(this); startupService.onStartupApplication(this);
} }
@Override @Override

@ -72,6 +72,7 @@ public class EditPreferences extends InjectingTodorooPreferenceActivity {
// --- instance variables // --- instance variables
@Inject StartupService startupService;
@Inject TaskService taskService; @Inject TaskService taskService;
private VoiceInputAssistant voiceInputAssistant; private VoiceInputAssistant voiceInputAssistant;
@ -98,7 +99,7 @@ public class EditPreferences extends InjectingTodorooPreferenceActivity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new StartupService().onStartupApplication(this); startupService.onStartupApplication(this);
ContextManager.setContext(this); ContextManager.setContext(this);
PreferenceScreen screen = getPreferenceScreen(); PreferenceScreen screen = getPreferenceScreen();

@ -51,6 +51,7 @@ public class MissedCallActivity extends InjectingActivity {
// Prompt user to ignore all missed calls after this many ignore presses // Prompt user to ignore all missed calls after this many ignore presses
private static final int IGNORE_PROMPT_COUNT = 3; private static final int IGNORE_PROMPT_COUNT = 3;
@Inject StartupService startupService;
@Inject TaskService taskService; @Inject TaskService taskService;
private final OnClickListener dismissListener = new OnClickListener() { private final OnClickListener dismissListener = new OnClickListener() {
@ -105,8 +106,8 @@ public class MissedCallActivity extends InjectingActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
new StartupService().onStartupApplication(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
startupService.onStartupApplication(this);
setContentView(R.layout.missed_call_activity); setContentView(R.layout.missed_call_activity);

@ -48,6 +48,7 @@ public class CalendarReminderActivity extends InjectingActivity {
// Prompt user to ignore all missed calls after this many ignore presses // Prompt user to ignore all missed calls after this many ignore presses
private static final int IGNORE_PROMPT_COUNT = 3; private static final int IGNORE_PROMPT_COUNT = 3;
@Inject StartupService startupService;
@Inject TagDataService tagDataService; @Inject TagDataService tagDataService;
private String eventName; private String eventName;
@ -106,9 +107,10 @@ public class CalendarReminderActivity extends InjectingActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
new StartupService().onStartupApplication(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
startupService.onStartupApplication(this);
setContentView(R.layout.calendar_reminder_activity); setContentView(R.layout.calendar_reminder_activity);
Intent intent = getIntent(); Intent intent = getIntent();

@ -21,9 +21,7 @@ import android.widget.Toast;
import com.todoroo.andlib.data.DatabaseDao.ModelUpdateListener; import com.todoroo.andlib.data.DatabaseDao.ModelUpdateListener;
import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
@ -56,39 +54,41 @@ import org.tasks.R;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
/** /**
* Service which handles jobs that need to be run when Astrid starts up. * Service which handles jobs that need to be run when Astrid starts up.
* *
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Singleton
public class StartupService { public class StartupService {
private static final Logger log = LoggerFactory.getLogger(StartupService.class); private static final Logger log = LoggerFactory.getLogger(StartupService.class);
static {
AstridDependencyInjector.initialize();
}
public StartupService() {
DependencyInjectionService.getInstance().inject(this);
}
// --- application startup // --- application startup
@Autowired UpgradeService upgradeService; private final UpgradeService upgradeService;
private final TaskService taskService;
@Autowired TaskService taskService; private final TagDataDao tagDataDao;
private final Database database;
@Autowired TagDataDao tagDataDao; private final GtasksPreferenceService gtasksPreferenceService;
private final GtasksSyncService gtasksSyncService;
@Autowired MetadataService metadataService;
@Inject
@Autowired Database database; public StartupService(UpgradeService upgradeService, TaskService taskService,
TagDataDao tagDataDao, Database database,
@Autowired GtasksPreferenceService gtasksPreferenceService; GtasksPreferenceService gtasksPreferenceService,
GtasksSyncService gtasksSyncService) {
@Autowired GtasksSyncService gtasksSyncService; this.upgradeService = upgradeService;
this.taskService = taskService;
this.tagDataDao = tagDataDao;
this.database = database;
this.gtasksPreferenceService = gtasksPreferenceService;
this.gtasksSyncService = gtasksSyncService;
}
/** /**
* bit to prevent multiple initializations * bit to prevent multiple initializations

Loading…
Cancel
Save