第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

牙簽不會(huì)在注入的實(shí)例中注入依賴項(xiàng)

牙簽不會(huì)在注入的實(shí)例中注入依賴項(xiàng)

慕哥6287543 2022-05-21 13:47:17
我為 Toothpick 和 Authenticator 創(chuàng)建了 Activity、ViewModel、Modules。@Singletonpublic class GetSmsViewModel {    @Inject Application app;    @Inject Authenticator authenticator;...}public class GetSmsActivity extends AppCompatActivity {    private Scope appScope;    @Inject GetSmsViewModel mGetSmsViewModel;...    @Override    protected void onCreate(Bundle savedInstanceState) {        appScope = Toothpick.openScope(getApplication());        appScope.installModules(new DIModule(getApplication()), new DataModule());        super.onCreate(savedInstanceState);        Toothpick.inject(this, appScope);   ...   }}public class DIModule extends Module {    public MagicDeliveryMainModule(Application application) {        bind(GetSmsViewModel.class).toInstance(new GetSmsViewModel());        bind(Application.class).toInstance(application);        bind(Authenticator.class).toInstance(new Authenticator());    }}在 Toothpick 的文檔中寫道:“如果 Toothpick 創(chuàng)建一個(gè)實(shí)例,它將始終注入其依賴項(xiàng)?!?, 但在 Toothpick.inject(this, appScope); 之后mGetSmsViewModel.app == null 和 mGetSmsViewModel.authenticator == null 。在 Toothpick.inject(mGetSmsViewModel, appScope); 之后 app 和 authenticationator 字段被注入。應(yīng)該是這樣嗎?
查看完整描述

1 回答

?
至尊寶的傳說

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊

在您的示例中,牙簽沒有創(chuàng)建實(shí)例,您正在創(chuàng)建實(shí)例并綁定它。

要讓牙簽創(chuàng)建實(shí)例,需要綁定目標(biāo)實(shí)現(xiàn)類并提供注入構(gòu)造函數(shù)。


查看完整回答
反對(duì) 回復(fù) 2022-05-21
  • 1 回答
  • 0 關(guān)注
  • 98 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)