This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Singleton | |
| public class ActivityNotLeakerISwear implements Application.ActivityLifecycleCallbacks { | |
| private static final Logger LOGGER = LoggerFactory.getLogger(URLHandler.class); | |
| @Nullable | |
| private Activity currentActivity; | |
| @Inject | |
| public ActivityNotLeakerISwear() { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class Injector { | |
| private static final String INJECTOR_SERVICE = "ACTIVITY_COMPONENT"; | |
| private static final String INJECTOR_SERVICE_APP = "INJECTOR_SERVICE_APP"; | |
| private Injector() { | |
| } | |
| public static AppComponent obtainAppComponent(Context context) { | |
| //noinspection ResourceType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client = mock(Client.class); | |
| Lazy<Client> lazyClient = mock(Lazy.class); | |
| when(client.get()).thenReturn(client); | |
| assetStore = new AssetStore(lazyClient); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| allprojects { | |
| repositories { | |
| mavenLocal() | |
| maven { | |
| url 'https://plugins.gradle.org/m2/' | |
| } | |
| maven { | |
| url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ToDoApplication extends Application implements HasActivityInjector { | |
| @Inject | |
| DispatchingAndroidInjector<Activity> activityInjector; | |
| @Override | |
| public void onCreate() { | |
| super.onCreate(); | |
| DaggerAppComponent.builder().application(this).build().inject(this); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright 2013 Chris Banes | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //MIKE: I am sorry for following code, the reason we need this is that slf4j adds the impl in our compile tasks | |
| //test tasks then add no-op slf4j but the impl one stil gets chosen as it is first on the classpath | |
| def testConfig = false | |
| configurations.all { configInner -> | |
| if (configInner.name.contains("Unit")) | |
| testConfig = true | |
| } | |
| configurations.all { config -> | |
| if (testConfig && (config.name.contains("Unit") || config.name.contains('googleDebugCompile'))) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun setLocaleFromEdition(activity: Activity) { | |
| // At startup, check to see if edition is Espanol. If not, switch it, | |
| // in order to ensure a full spanish experience. AND-5113 | |
| if (appPreferences.getPreference(activity.resources.getString(R.string.key_edition), "") == activity.resources.getString(R.string.espanol_edition_value)) { | |
| setLocale(activity.baseContext, Locale("es")) | |
| } else { | |
| // Since we don't support any other languages other than English or Spanish, set the | |
| // Locale to english here to avoid language specific date and other formatting issues... | |
| setLocale(activity.baseContext, Locale("en")) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun parse(dataResponse: ProgramQuery.Data): Program { | |
| val programBuilder = ImmutableProgram.builder() | |
| val moreBlocksBuilder = ImmutableList.builder<BlockItem>() | |
| dataResponse.program_beta()?.apply { | |
| latestNews()?.fragments()?.block()?.let { | |
| programBuilder.briefings(it.asBriefingViewModel()) | |
| programBuilder.latestNews(it.asLatestNewsViewModel()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class BaseActivity : AppCompatActivity() { | |
| val activityComponent: ActivityComponent by unsafeLazy { | |
| Injector.create(this) | |
| } | |
| }` | |
| class MyActivity : BaseActivity() { | |
| @Inject lateinit var foo: Foo | |
| override fun onCreate(savedInstanceState: Bundle?) { |