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
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| val model: MainViewModel by viewModels() | |
| model.displayText.observe(this, Observer { text -> | |
| text_view.text = text |
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
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| val model: MainViewModel by viewModels() | |
| model.loadTextFromNetwork() | |
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
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| val model: MainViewModel by viewModels() | |
| button.setOnClickListener { | |
| model.onButtonClick() |
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
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| button.setOnClickListener { | |
| text_view.setText("I've clicked a button!") | |
| } | |
| } |
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
| class InstantTaskExecutorExtension : BeforeEachCallback, AfterEachCallback { | |
| override fun beforeEach(context: ExtensionContext?) { | |
| ArchTaskExecutor.getInstance() | |
| .setDelegate(object : TaskExecutor() { | |
| override fun executeOnDiskIO(runnable: Runnable) = runnable.run() | |
| override fun postToMainThread(runnable: Runnable) = runnable.run() | |
| override fun isMainThread(): Boolean = true |
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
| @Test | |
| @ExperimentalCoroutinesApi | |
| fun `verify method returns result, caches images, and updates offset`() = runBlocking { | |
| // Arrange | |
| val deferred = CompletableDeferred(MockJsonResponse().with(1)) | |
| every { | |
| mockPetManager.getPetListAsync("78701", null) | |
| } returns deferred |
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
| object ApplicationInjector { | |
| fun init(app: BaseApplication) { | |
| DaggerApplicationComponent.builder().application(app) | |
| .build().inject(app) | |
| app.registerActivityLifecycleCallbacks(object | |
| : Application.ActivityLifecycleCallbacks { | |
| override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { | |
| handleActivity(activity) | |
| } |
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 static void inject(Activity activity) { | |
| checkNotNull(activity, "activity"); | |
| Application application = activity.getApplication(); | |
| if (!(application instanceof HasActivityInjector)) { | |
| throw new RuntimeException( | |
| String.format( | |
| "%s does not implement %s", | |
| application.getClass().getCanonicalName(), | |
| HasActivityInjector.class.getCanonicalName())); | |
| } |
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
| class MainActivity: AppCompatActivity(), HasSupportFragmentInjector { | |
| @Inject | |
| lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment> | |
| override fun supportFragmentInjector() = dispatchingAndroidInjector | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| } |
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
| private BaseApplication injectBaseApplication(BaseApplication instance) { | |
| BaseApplication_MembersInjector.injectDispatchingAndroidInjector( | |
| instance, getDispatchingAndroidInjectorOfActivity()); | |
| return instance; | |
| } | |
| private DispatchingAndroidInjector<Activity> getDispatchingAndroidInjectorOfActivity() { | |
| return DispatchingAndroidInjector_Factory.newDispatchingAndroidInjector( | |
| getMapOfClassOfAndProviderOfFactoryOf()); | |
| } |
NewerOlder