Replace Singleton by AppScope

pull/157/head
Alinson S. Xavier 9 years ago
parent 7eb454788f
commit 8132188e46

@ -23,11 +23,9 @@ package org.isoron.uhabits;
import org.isoron.uhabits.models.sqlite.*;
import org.isoron.uhabits.tasks.*;
import javax.inject.*;
import dagger.*;
@Singleton
@AppScope
@Component(modules = {
AppModule.class, SingleThreadTaskRunner.class, SQLModelFactory.class
})

@ -30,11 +30,9 @@ import org.isoron.uhabits.tasks.*;
import org.isoron.uhabits.utils.*;
import org.isoron.uhabits.widgets.*;
import javax.inject.*;
import dagger.*;
@Singleton
@AppScope
@Component(modules = {
AppModule.class, AndroidTaskRunner.class, SQLModelFactory.class
})

@ -0,0 +1,25 @@
/*
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker 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.
*
* Loop Habit Tracker 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits;
import javax.inject.*;
@Scope
public @interface AppScope {}

@ -30,7 +30,7 @@ import java.util.*;
import javax.inject.*;
@Singleton
@AppScope
public class HabitLogger
{
@Inject

@ -21,6 +21,7 @@ package org.isoron.uhabits.activities.habits.list.model;
import android.support.annotation.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.commands.*;
import org.isoron.uhabits.models.*;
import org.isoron.uhabits.tasks.*;
@ -41,7 +42,7 @@ import javax.inject.*;
* Note that this class is singleton-scoped, therefore it is shared among all
* activities.
*/
@Singleton
@AppScope
public class HabitCardListCache implements CommandRunner.Listener
{
private int checkmarkCount;

@ -21,6 +21,7 @@ package org.isoron.uhabits.commands;
import android.support.annotation.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.tasks.*;
import java.util.*;
@ -33,7 +34,7 @@ import javax.inject.*;
* CommandRunners also allows objects to subscribe to it, and receive events
* whenever a command is performed.
*/
@Singleton
@AppScope
public class CommandRunner
{
private TaskRunner taskRunner;

@ -23,6 +23,7 @@ import android.content.*;
import android.net.*;
import android.support.annotation.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.*;
import org.isoron.uhabits.utils.*;
@ -30,7 +31,7 @@ import javax.inject.*;
import static android.content.ContentUris.*;
@Singleton
@AppScope
public class IntentParser
{
private HabitList habits;

@ -31,7 +31,7 @@ import javax.inject.*;
import static android.app.AlarmManager.*;
import static android.content.Context.*;
@Singleton
@AppScope
public class IntentScheduler
{
private final AlarmManager manager;

@ -32,7 +32,7 @@ import javax.inject.*;
import static android.app.PendingIntent.*;
@Singleton
@AppScope
public class PendingIntentFactory
{
private final Context context;

@ -19,24 +19,23 @@
package org.isoron.uhabits.models.memory;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.*;
import javax.inject.*;
import dagger.*;
@Module
public class MemoryModelFactory implements ModelFactory
{
@Provides
@Singleton
@AppScope
public static HabitList provideHabitList()
{
return new MemoryHabitList();
}
@Provides
@Singleton
@AppScope
public static ModelFactory provideModelFactory()
{
return new MemoryModelFactory();

@ -19,10 +19,9 @@
package org.isoron.uhabits.models.sqlite;
import org.isoron.uhabits.*;
import org.isoron.uhabits.models.*;
import javax.inject.*;
import dagger.*;
/**
@ -38,7 +37,7 @@ public class SQLModelFactory implements ModelFactory
}
@Provides
@Singleton
@AppScope
public static HabitList provideHabitList()
{
return SQLiteHabitList.getInstance(provideModelFactory());

@ -27,7 +27,7 @@ import org.isoron.uhabits.activities.*;
import javax.inject.*;
@Singleton
@AppScope
public class Preferences
implements SharedPreferences.OnSharedPreferenceChangeListener
{

@ -26,7 +26,7 @@ import org.isoron.uhabits.*;
import javax.inject.*;
@Singleton
@AppScope
public class WidgetPreferences
{
private final SharedPreferences prefs;

@ -21,14 +21,14 @@ package org.isoron.uhabits.tasks;
import android.os.*;
import java.util.*;
import org.isoron.uhabits.*;
import javax.inject.*;
import java.util.*;
import dagger.*;
@Module
@Singleton
@AppScope
public class AndroidTaskRunner implements TaskRunner
{
private final LinkedList<CustomAsyncTask> activeTasks;

@ -19,7 +19,7 @@
package org.isoron.uhabits.tasks;
import javax.inject.*;
import org.isoron.uhabits.*;
import dagger.*;
@ -27,7 +27,7 @@ import dagger.*;
public class SingleThreadTaskRunner implements TaskRunner
{
@Provides
@Singleton
@AppScope
public static TaskRunner getInstance()
{
return new SingleThreadTaskRunner();

@ -33,7 +33,7 @@ import javax.inject.*;
import static org.isoron.uhabits.utils.DateUtils.*;
@Singleton
@AppScope
public class ReminderScheduler implements CommandRunner.Listener
{
private final PendingIntentFactory pendingIntentFactory;

Loading…
Cancel
Save