Slide 41
Slide 41 text
Context
自体を
Provide
するパターン
@Singleton
public class ResourceProvider {
private final Context context;
@Inject
public ResourceProvider(Context context) {
this.context = context;
}
public String getString(@StringRes int resId) {
return context.getString(resId);
}
public String getString(@StringRes int resId, Object... formatArgs) {
return context.getString(resId, formatArgs);
}
}
コンストラクタに
@Inject,
クラス定義に
@Singleton