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.models.sqlite.*;
import org.isoron.uhabits.tasks.*; import org.isoron.uhabits.tasks.*;
import javax.inject.*;
import dagger.*; import dagger.*;
@Singleton @AppScope
@Component(modules = { @Component(modules = {
AppModule.class, SingleThreadTaskRunner.class, SQLModelFactory.class AppModule.class, SingleThreadTaskRunner.class, SQLModelFactory.class
}) })

@ -30,11 +30,9 @@ import org.isoron.uhabits.tasks.*;
import org.isoron.uhabits.utils.*; import org.isoron.uhabits.utils.*;
import org.isoron.uhabits.widgets.*; import org.isoron.uhabits.widgets.*;
import javax.inject.*;
import dagger.*; import dagger.*;
@Singleton @AppScope
@Component(modules = { @Component(modules = {
AppModule.class, AndroidTaskRunner.class, SQLModelFactory.class 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.*; import javax.inject.*;
@Singleton @AppScope
public class HabitLogger public class HabitLogger
{ {
@Inject @Inject

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save