| author | Da Risk <da_risk@geekorum.com> |
| Tue, 28 May 2019 11:37:55 -0700 | |
| changeset 197 | 304a57b89da3 |
| parent 137 | 5464f07a306c |
| child 216 | 1cace0058630 |
| permissions | -rw-r--r-- |
|
66
f67bb871a52f
providers: Use Dagger android injection
Da Risk <da_risk@geekorum.com>
parents:
63
diff
changeset
|
1 |
/* |
| 0 | 2 |
* Geekttrss is a RSS feed reader application on the Android Platform. |
3 |
* |
|
|
137
5464f07a306c
Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents:
131
diff
changeset
|
4 |
* Copyright (C) 2017-2019 by Frederic-Charles Barthelery. |
| 0 | 5 |
* |
6 |
* This file is part of Geekttrss. |
|
7 |
* |
|
8 |
* Geekttrss is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* Geekttrss is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with Geekttrss. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
*/ |
|
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
21 |
package com.geekorum.ttrss |
| 0 | 22 |
|
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
23 |
import com.geekorum.geekdroid.dagger.AppInitializer |
|
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
24 |
import com.geekorum.geekdroid.dagger.initialize |
| 131 | 25 |
import com.geekorum.ttrss.debugtools.StrictModeInitializer |
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
26 |
import com.geekorum.ttrss.di.ApplicationComponent |
|
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
27 |
import com.geekorum.ttrss.di.DaggerApplicationComponent |
|
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
28 |
import dagger.android.support.DaggerApplication |
| 0 | 29 |
|
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
30 |
import javax.inject.Inject |
| 0 | 31 |
|
32 |
/** |
|
33 |
* Initialize global component for the TTRSS application. |
|
34 |
*/ |
|
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
35 |
open class Application : DaggerApplication() {
|
| 0 | 36 |
|
37 |
@Inject |
|
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
38 |
lateinit var appInitializers: MutableSet<AppInitializer> |
| 0 | 39 |
|
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
40 |
override fun onCreate() {
|
|
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
41 |
super.onCreate() |
|
197
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
42 |
// a few initializers need to be set up before others |
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
43 |
sortAppInitializers(appInitializers).initialize(this) |
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
44 |
} |
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
45 |
|
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
46 |
protected open fun sortAppInitializers(initializers: Set<AppInitializer>): List<AppInitializer> {
|
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
47 |
val result = mutableListOf<AppInitializer>() |
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
48 |
val strictModeInitializer = initializers.find { it is StrictModeInitializer }
|
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
49 |
strictModeInitializer?.let { result.add(it) }
|
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
50 |
result.addAll(initializers) |
|
304a57b89da3
AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
51 |
return result.distinct() |
| 0 | 52 |
} |
53 |
||
|
77
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
54 |
override fun applicationInjector(): ApplicationComponent {
|
|
961585710d33
Add DefaultNightModeInitializer
Da Risk <da_risk@geekorum.com>
parents:
74
diff
changeset
|
55 |
return DaggerApplicationComponent.builder().bindApplication(this).build() |
| 0 | 56 |
} |
57 |
} |