我正在尝试编译https://github.com/svenjacobs/android-dagger2-example 但我遇到了与未作用域组件相关的错误,具体取决于作用域组件.(Android Studio 1.1,Gradle 2.2.1).此外,如果有人知道其他Dagger2 Android示例与FRAGMENTS我想知道他们.
更新:这是另一个非常基本的片段示例:https: //github.com/gk5885/dagger-android-sample
/Users/Mac1/android-dagger2-example-master/app/src/main/java/com/svenjacobs/dagger2/ActivityComponent.java
Error:(15, 1) error: com.svenjacobs.dagger2.ActivityComponent (unscoped) cannot depend on scoped components:
@Singleton com.svenjacobs.dagger2.ApplicationComponent
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Run Code Online (Sandbox Code Playgroud)
这是文件ActivityComponent,显然没有作用域:
import dagger.Component;
/**
* Component for all activities.
*
* @author Sven Jacobs
*/
@Component(dependencies = ApplicationComponent.class,
modules = {
MainActivityModule.class,
AModule.class,
BModule.class
})
interface ActivityComponent extends AFragment.Injector, BFragment.Injector {
void inject(MainActivity activity);
void inject(AnotherActivity activity);
}
Run Code Online (Sandbox Code Playgroud)
这是范围组件:
package com.svenjacobs.dagger2; …Run Code Online (Sandbox Code Playgroud) 我需要将Date表示为具有确切格式格式的字符串:
2015-01-20
Run Code Online (Sandbox Code Playgroud)
我看到有一个date.toIsoFormatString()但不确定在何处或如何提供上面显示的格式.
Here is my code:
var future = new Date();
future.setDate(future.getDate() + 30);
console.log(future);
Run Code Online (Sandbox Code Playgroud)
现在我希望future.toString()或future.toIsoFormatString()以YYYY-MM-DD格式显示日期.