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.injection.InjectingActionBarActivity;
import javax.inject.Inject;
/**
* 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.
@ -86,13 +88,14 @@ public class AstridActivity extends InjectingActionBarActivity
.findFragmentByTag(CommentsFragment.TAG_UPDATES_FRAGMENT);
}
@Inject StartupService startupService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContextManager.setContext(this);
new StartupService().onStartupApplication(this);
startupService.onStartupApplication(this);
}
@Override

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

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

@ -21,9 +21,7 @@ import android.widget.Toast;
import com.todoroo.andlib.data.DatabaseDao.ModelUpdateListener;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities;
@ -56,39 +54,41 @@ import org.tasks.R;
import java.io.File;
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.
*
* @author Tim Su <tim@todoroo.com>
*
*/
@Singleton
public class StartupService {
private static final Logger log = LoggerFactory.getLogger(StartupService.class);
static {
AstridDependencyInjector.initialize();
}
public StartupService() {
DependencyInjectionService.getInstance().inject(this);
}
// --- application startup
@Autowired UpgradeService upgradeService;
@Autowired TaskService taskService;
@Autowired TagDataDao tagDataDao;
@Autowired MetadataService metadataService;
@Autowired Database database;
@Autowired GtasksPreferenceService gtasksPreferenceService;
@Autowired GtasksSyncService gtasksSyncService;
private final UpgradeService upgradeService;
private final TaskService taskService;
private final TagDataDao tagDataDao;
private final Database database;
private final GtasksPreferenceService gtasksPreferenceService;
private final GtasksSyncService gtasksSyncService;
@Inject
public StartupService(UpgradeService upgradeService, TaskService taskService,
TagDataDao tagDataDao, Database database,
GtasksPreferenceService gtasksPreferenceService,
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

Loading…
Cancel
Save