Java Code Examples for dagger.android.AndroidInjection#inject()

The following examples show how to use dagger.android.AndroidInjection#inject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TokenFunctionActivity.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_script_view);

    viewModel = ViewModelProviders.of(this, tokenFunctionViewModelFactory)
            .get(TokenFunctionViewModel.class);
    viewModel.insufficientFunds().observe(this, this::errorInsufficientFunds);
    viewModel.invalidAddress().observe(this, this::errorInvalidAddress);
    viewModel.tokenUpdate().observe(this, this::onTokenUpdate);
    viewModel.walletUpdate().observe(this, this::onWalletUpdate);

    SystemView systemView = findViewById(R.id.system_view);
    systemView.hide();
    functionBar = findViewById(R.id.layoutButtons);
    initViews(getIntent().getParcelableExtra(TICKET));
    toolbar();
    setTitle(getString(R.string.token_function));

    viewModel.startGasPriceUpdate(token.tokenInfo.chainId);
}
 
Example 2
Source File: AddNewStockActivity.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.portfolio_activity_add_new_stock);

    addNewStockFragment = new AddNewStockFragment();
    addNewStockFragment.setViewModel(viewModel);

    setTitle("Add New Item");

    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.fragment_container_1, addNewStockFragment)
            .commit();

    viewModel.loadSaved(savedInstanceState);
    viewModel.bind(this);
}
 
Example 3
Source File: LiveDataRowsActivity.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_livedata_rows);


    if (ContextCompat.checkSelfPermission(LiveDataRowsActivity.this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

        // If the permission is not authorized in the first time. A new permission access
        // request will be created.
        if (ActivityCompat.shouldShowRequestPermissionRationale(LiveDataRowsActivity.this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            ActivityCompat.requestPermissions(LiveDataRowsActivity.this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    WRITE_PERMISSION);
        } else {
            ActivityCompat.requestPermissions(LiveDataRowsActivity.this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    WRITE_PERMISSION);
        }
    }

}
 
Example 4
Source File: StockPortfolioListViewActivity.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        AndroidInjection.inject(this);
//        getMainComponent().inject(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.portfolio_activity_stock_list);

        stockSummaryFragment = new StockSummaryFragment();
        stockSummaryFragment.setViewModel(viewModel);
        stockPortfolioListFragment = new StockPortfolioListFragment();
        stockPortfolioListFragment.setViewModel(viewModel);

        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.fragment_container_1, stockSummaryFragment)
                .replace(R.id.fragment_container_2, stockPortfolioListFragment)
                .commit();

        viewModel.loadSaved(savedInstanceState);
    }
 
Example 5
Source File: StockPortfolioListViewActivity.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        AndroidInjection.inject(this);
//        getMainComponent().inject(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.portfolio_activity_stock_list);

        stockSummaryFragment = new StockSummaryFragment();
        stockPortfolioListFragment = new StockPortfolioListFragment();
        stockPortfolioListFragment.setViewModel(viewModel);

        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.fragment_container_1, stockSummaryFragment)
                .replace(R.id.fragment_container_2, stockPortfolioListFragment)
                .commit();
        ;
        viewModel.loadSaved(savedInstanceState);
        viewModel.bind(this);
    }
 
Example 6
Source File: AddNewStockActivity.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.portfolio_activity_add_new_stock);

    addNewStockFragment = new AddNewStockFragment();
    addNewStockFragment.setViewModel(viewModel);

    setTitle("Add New Item");

    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.fragment_container_1, addNewStockFragment)
            .commit();

    viewModel.loadSaved(savedInstanceState);
    viewModel.bind(this);
}
 
Example 7
Source File: MainScreen.java    From adamant-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    appBar.setOnNavigationItemSelectedListener(menuItem -> {
        switch (menuItem.getItemId()){
            case R.id.navigation_chats: {
                presenter.onSelectedChatsScreen();
                return true;
            }
            case R.id.navigation_wallet: {
                presenter.onSelectedWalletScreen();
                return true;
            }
            case R.id.navigation_settings: {
                presenter.onSelectedSettingsScreen();
                return true;
            }
        }

        return false;
    });
}
 
Example 8
Source File: PincodeScreen.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    keyPinAdapter.setIndicator(indicator);
    keyPinAdapter.setPincodeListener(this);

    pinLockView.setAdapter(keyPinAdapter);
    pinLockView.setLayoutManager(new LTRGridLayoutManager(this, 3));
    int hSpace = (int)(getResources().getDisplayMetrics().density * 15);
    pinLockView.addItemDecoration(new ItemSpaceDecoration(hSpace, 0, 3, false));
    pinLockView.setOverScrollMode(OVER_SCROLL_NEVER);

    cancelButtonView.setPaintFlags(cancelButtonView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);

    Intent intent = getIntent();

    if (intent == null){return;}
    Bundle extras = intent.getExtras();

    if (extras == null){return;}
    MODE mode = (MODE) extras.getSerializable(PinCodeView.ARG_MODE);

    if (mode == null){return;}
    presenter.setMode(mode);

}
 
Example 9
Source File: SendFundsScreen.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    if (intent != null) {
            String companionId = getIntent().getStringExtra(ARG_COMPANION_ID);
            adapter.setCompanionId(companionId);
    }

    slider.setAdapter(adapter);
    tabs.setupWithViewPager(slider);

    for (int i = 0; i < tabs.getTabCount(); i++) {
        WalletFacade facadeItem = adapter.getFacadeItem(i);
        TabLayout.Tab tabItem = tabs.getTabAt(i);
        if (tabItem != null && facadeItem != null && facadeItem.getIconForEditText() != 0) {
            tabItem.setIcon(facadeItem.getIconForEditText());
        }
    }

    if (intent != null) {
        SupportedWalletFacadeType facadeType = (SupportedWalletFacadeType) getIntent().getSerializableExtra(ARG_WALLET_FACADE);
        if (facadeType != null) {
            int indexByFacade = adapter.getIndexByFacade(facadeType);
            slider.setCurrentItem(indexByFacade);
        }
    }

    setTitle(getString(R.string.activity_send_funds_title));
}
 
Example 10
Source File: LoginScreen.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    if (authorizeInteractor.isAuthorized()) {
        navigator.applyCommands(new Command[]{
                new Forward(Screens.WALLET_SCREEN, null)
        });
    }
    super.onCreate(savedInstanceState);

    loginFragment = (BottomLoginFragment) getSupportFragmentManager().findFragmentByTag(BOTTOM_LOGIN_TAG);

    if (loginFragment == null) {
        loginFragment = new BottomLoginFragment();
    }

    welcomeCardsSliderView.setAdapter(adapter);
    welcomeCardsSliderView.setOffscreenItems(1);
    welcomeCardsSliderView.setOverScrollEnabled(true);
    welcomeCardsSliderView.addItemDecoration(
            new SimpleDotIndicatorDecoration(
                    ContextCompat.getColor(this, R.color.secondaryDarkVariant),
                    ContextCompat.getColor(this, R.color.secondaryLightVariant),
                    20
            )
    );

    creteNewButtonView.setPaintFlags(creteNewButtonView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
 
Example 11
Source File: AuthenticationFragment.java    From android-showcase-template with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttach(Activity activity) {

    AndroidInjection.inject(this);
    super.onAttach(activity);
    if (activity instanceof AuthenticationListener) {
        authenticationListener = (AuthenticationListener) activity;
    }
}
 
Example 12
Source File: WalletsActivity.java    From trust-wallet-android-source with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
	AndroidInjection.inject(this);
	super.onCreate(savedInstanceState);

	setContentView(R.layout.activity_wallets);
	// Init toolbar
	toolbar();

	adapter = new WalletsAdapter(this::onSetWalletDefault, this::onDeleteWallet, this::onExportWallet);
	SwipeRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
	systemView = findViewById(R.id.system_view);
	backupWarning = findViewById(R.id.backup_warning);

	RecyclerView list = findViewById(R.id.list);

	list.setLayoutManager(new LinearLayoutManager(this));
	list.setAdapter(adapter);

	systemView.attachRecyclerView(list);
	systemView.attachSwipeRefreshLayout(refreshLayout);
	backupWarning.setOnPositiveClickListener(this::onNowBackup);

	viewModel = ViewModelProviders.of(this, walletsViewModelFactory)
			.get(WalletsViewModel.class);

	viewModel.error().observe(this, this::onError);
	viewModel.progress().observe(this, systemView::showProgress);
	viewModel.wallets().observe(this, this::onFetchWallet);
	viewModel.defaultWallet().observe(this, this::onChangeDefaultWallet);
	viewModel.createdWallet().observe(this, this::onCreatedWallet);
	viewModel.exportedStore().observe(this, this::openShareDialog);

	refreshLayout.setOnRefreshListener(viewModel::fetchWallets);
}
 
Example 13
Source File: ScanQrCodeScreen.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    if(TedPermission.isDenied(this, Manifest.permission.CAMERA)){
        scannerView.setVisibility(View.GONE);
        noPermissionView.setVisibility(View.VISIBLE);

        TedPermission.with(this)
                .setPermissionListener(permissionlistener)
                .setPermissions(Manifest.permission.CAMERA)
                .check();
    }
}
 
Example 14
Source File: SplashActivity.java    From trust-wallet-android-source with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    splashViewModel = ViewModelProviders.of(this, splashViewModelFactory)
            .get(SplashViewModel.class);
    splashViewModel.wallets().observe(this, this::onWallets);
}
 
Example 15
Source File: FetchIntentService.java    From android-auto-call-recorder with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    AndroidInjection.inject(this);
    super.onCreate();
}
 
Example 16
Source File: AdamantFirebaseMessagingService.java    From adamant-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
    AndroidInjection.inject(this);
    super.onCreate();
}
 
Example 17
Source File: TransactionDetailActivity.java    From alpha-wallet-android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transaction_detail);

    transaction = getIntent().getParcelableExtra(TRANSACTION);
    wallet = getIntent().getParcelableExtra(WALLET);
    if (transaction == null) {
        finish();
        return;
    }
    toolbar();
    setTitle();

    String blockNumber = transaction.blockNumber;
    TransactionOperation op = null;
    if (transaction.blockNumber != null && transaction.blockNumber.equals("0"))
    {
        blockNumber = getString(R.string.status_pending);
        findViewById(R.id.pending_spinner).setVisibility(View.VISIBLE);
    }

    setupVisibilities();

    amount = findViewById(R.id.amount);
    CopyTextView toValue = findViewById(R.id.to);
    CopyTextView fromValue = findViewById(R.id.from);
    CopyTextView txHashView = findViewById(R.id.txn_hash);
    functionBar = findViewById(R.id.layoutButtons);

    fromValue.setText(transaction.from);
    toValue.setText(transaction.to);
    txHashView.setText(transaction.hash);
    ((TextView) findViewById(R.id.txn_time)).setText(localiseUnixTime(transaction.timeStamp));

    ((TextView) findViewById(R.id.block_number)).setText(blockNumber);

    if (transaction.operations != null && transaction.operations.length > 0)
    {
        op = transaction.operations[0];
        if (op != null && op.to != null) toValue.findViewById(R.id.to);
    }

    viewModel = ViewModelProviders.of(this, transactionDetailViewModelFactory)
            .get(TransactionDetailViewModel.class);
    viewModel.latestBlock().observe(this, this::onLatestBlock);
    viewModel.prepare(transaction.chainId);

    chainName = viewModel.getNetworkName(transaction.chainId);
    ((TextView) findViewById(R.id.network)).setText(chainName);

    token = viewModel.getToken(transaction.chainId, transaction.to);
    TextView chainLabel = findViewById(R.id.text_chain_name);

    Utils.setChainColour(chainLabel, transaction.chainId);
    chainLabel.setText(chainName);

    setOperationName();

    if (!viewModel.hasEtherscanDetail(transaction)) findViewById(R.id.more_detail).setVisibility(View.GONE);
    setupWalletDetails(op);

    functionBar.setupSecondaryFunction(this, R.string.action_open_etherscan);
}
 
Example 18
Source File: BackupKeyActivity.java    From alpha-wallet-android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    alertDialog = null;
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    lockOrientation();

    BackupOperationType type = (BackupOperationType) getIntent().getSerializableExtra("TYPE");
    wallet = getIntent().getParcelableExtra(WALLET);
    if (type == null) type = BackupOperationType.UNDEFINED;

    toolbar();
    initViewModel();
    determineScreenWidth();

    switch (type) {
        case UNDEFINED:
            state = BackupState.UNDEFINED;
            DisplayKeyFailureDialog("Unknown Key operation");
            break;
        case BACKUP_HD_KEY:
            state = BackupState.ENTER_BACKUP_STATE_HD;
            setHDBackupSplash();
            break;
        case BACKUP_KEYSTORE_KEY:
            state = BackupState.ENTER_JSON_BACKUP;
            setupJSONExport();
            break;
        case SHOW_SEED_PHRASE:
            state = BackupState.SHOW_SEED_PHRASE;
            setupTestSeed();
            DisplaySeed();
            break;
        case EXPORT_PRIVATE_KEY:
            DisplayKeyFailureDialog("Export Private key not yet implemented");
            //TODO: Not yet implemented
            break;
        case UPGRADE_KEY:
            setupUpgradeKey(false);
            break;
    }
}
 
Example 19
Source File: HomeFragment.java    From android-showcase-template with Apache License 2.0 4 votes vote down vote up
@Override
public void onAttach(Activity activity) {
    AndroidInjection.inject(this);
    super.onAttach(activity);
}
 
Example 20
Source File: BaseActivity.java    From MaoWanAndoidClient with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    //必须在super.onCreate之前调用AndroidInjection.inject
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
}