#1466 use ActivityScope

This commit is contained in:
Sean Mac Gillicuddy 2019-09-16 10:32:47 +01:00
parent 12dd1a8e45
commit 23439b3ca4
12 changed files with 37 additions and 63 deletions

View File

@ -2,11 +2,11 @@ package org.kiwix.kiwixmobile.bookmark;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
@Module
public class BookmarksModule {
@PerActivity
@ActivityScope
@Provides
BookmarksContract.Presenter provideBookmarksPresenter(BookmarksPresenter presenter) {
return presenter;

View File

@ -10,11 +10,11 @@ import java.util.List;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.base.BasePresenter;
import org.kiwix.kiwixmobile.data.DataSource;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
import org.kiwix.kiwixmobile.di.qualifiers.Computation;
import org.kiwix.kiwixmobile.di.qualifiers.MainThread;
@PerActivity
@ActivityScope
class BookmarksPresenter extends BasePresenter<BookmarksContract.View>
implements BookmarksContract.Presenter {

View File

@ -1,26 +0,0 @@
/*
* Kiwix Android
* Copyright (C) 2018 Kiwix <android.kiwix.org>
*
* This program 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.
*
* This program 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.kiwix.kiwixmobile.di;
import java.lang.annotation.Retention;
import javax.inject.Scope;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Scope @Retention(RUNTIME) public @interface PerActivity {
}

View File

@ -4,7 +4,7 @@ import dagger.Module;
import dagger.android.ContributesAndroidInjector;
import org.kiwix.kiwixmobile.bookmark.BookmarksActivity;
import org.kiwix.kiwixmobile.bookmark.BookmarksModule;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
import org.kiwix.kiwixmobile.error.ErrorActivity;
import org.kiwix.kiwixmobile.help.HelpActivity;
import org.kiwix.kiwixmobile.history.HistoryActivity;
@ -24,56 +24,56 @@ import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity;
/**
* Dagger.Android annotation processor will create the sub-components. We also specify the modules
* to be used by each sub-components and make Dagger.Android aware of a scope annotation
* {@link PerActivity}.
* {@link ActivityScope}.
*/
@Module
public abstract class ActivityBindingModule {
@PerActivity
@ActivityScope
@ContributesAndroidInjector(modules = MainModule.class)
public abstract MainActivity provideMainActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract KiwixSettingsActivity provideKiwixSettingsActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract ZimManageActivity provideZimManageActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract SearchActivity provideSearchActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector(modules = BookmarksModule.class)
public abstract BookmarksActivity provideBookmarksActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract ErrorActivity provideErrorActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector(modules = IntroModule.class)
public abstract IntroActivity provideIntroActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract SplashActivity provideSplashActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract LanguageActivity provideLanguageActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector(modules = HistoryModule.class)
public abstract HistoryActivity provideHistoryActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector
public abstract HelpActivity provideHelpActivity();
@PerActivity
@ActivityScope
@ContributesAndroidInjector(modules = ZimHostModule.class)
public abstract ZimHostActivity provideZimHostActivity();
}

View File

@ -2,11 +2,11 @@ package org.kiwix.kiwixmobile.history;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
@Module
public class HistoryModule {
@PerActivity
@ActivityScope
@Provides
HistoryContract.Presenter provideHistoryPresenter(HistoryPresenter presenter) {
return presenter;

View File

@ -11,11 +11,11 @@ import java.util.List;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.base.BasePresenter;
import org.kiwix.kiwixmobile.data.DataSource;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
import org.kiwix.kiwixmobile.di.qualifiers.Computation;
import org.kiwix.kiwixmobile.di.qualifiers.MainThread;
@PerActivity
@ActivityScope
class HistoryPresenter extends BasePresenter<HistoryContract.View>
implements HistoryContract.Presenter {

View File

@ -2,11 +2,11 @@ package org.kiwix.kiwixmobile.intro;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
@Module
public class IntroModule {
@PerActivity
@ActivityScope
@Provides
IntroContract.Presenter provideIntroPresenter(IntroPresenter presenter) {
return presenter;

View File

@ -2,10 +2,10 @@ package org.kiwix.kiwixmobile.intro;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.base.BasePresenter;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil;
@PerActivity
@ActivityScope
class IntroPresenter extends BasePresenter<IntroContract.View> implements IntroContract.Presenter {
private final SharedPreferenceUtil preferences;

View File

@ -2,11 +2,11 @@ package org.kiwix.kiwixmobile.main;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
@Module
public class MainModule {
@PerActivity
@ActivityScope
@Provides
MainContract.Presenter provideMainPresenter(MainPresenter mainPresenter) {
return mainPresenter;

View File

@ -9,7 +9,7 @@ import javax.inject.Inject;
import org.kiwix.kiwixmobile.base.BasePresenter;
import org.kiwix.kiwixmobile.bookmark.BookmarkItem;
import org.kiwix.kiwixmobile.data.DataSource;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
import org.kiwix.kiwixmobile.history.HistoryListItem;
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
@ -17,7 +17,7 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskList
* Presenter for {@link MainActivity}.
*/
@PerActivity
@ActivityScope
class MainPresenter extends BasePresenter<MainContract.View> implements MainContract.Presenter {
private static final String TAG = "MainPresenter";

View File

@ -3,29 +3,29 @@ package org.kiwix.kiwixmobile.webserver;
import android.app.Activity;
import dagger.Module;
import dagger.Provides;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
@Module
public class ZimHostModule {
@PerActivity
@ActivityScope
@Provides
ZimHostContract.Presenter provideZimHostPresenter(ZimHostPresenter zimHostPresenter) {
return zimHostPresenter;
}
@PerActivity
@ActivityScope
@Provides Activity providesActivity(ZimHostActivity zimHostActivity) {
return zimHostActivity;
}
@PerActivity
@ActivityScope
@Provides LocationServicesHelper providesLocationServicesHelper(ZimHostActivity activity,
LocationCallbacks locationCallbacks) {
return new LocationServicesHelper(activity, locationCallbacks);
}
@PerActivity
@ActivityScope
@Provides LocationCallbacks providesLocationCallbacks(ZimHostActivity activity) {
return activity;
}

View File

@ -7,10 +7,10 @@ import java.util.List;
import javax.inject.Inject;
import org.kiwix.kiwixmobile.base.BasePresenter;
import org.kiwix.kiwixmobile.data.DataSource;
import org.kiwix.kiwixmobile.di.PerActivity;
import org.kiwix.kiwixmobile.di.ActivityScope;
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
@PerActivity
@ActivityScope
class ZimHostPresenter extends BasePresenter<ZimHostContract.View>
implements ZimHostContract.Presenter {