This file contains 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 HistoryPresenter @Inject constructor(var paymentManager: PaymentRepository) : HistoryContract.Presenter { | |
lateinit var context: Context | |
lateinit var view: HistoryContract.View | |
override fun bindView(context: Context, view: HistoryContract.View) { | |
this.context = context | |
this.view = view | |
} | |
override fun loadHistory() { |
This file contains 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
@Provides | |
public UsuarioContrato proverUsuario() { | |
return new NovaImplementacaoUsuario(); | |
} |
This file contains 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
dependencies { | |
compile 'com.google.dagger:dagger:2.x' | |
annotationProcessor 'com.google.dagger:dagger-compiler:2.x' | |
} |
This file contains 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 Exemplo(UsuarioContrato usuario) { | |
this.usuario = usuario; | |
} |
This file contains 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 interface UsuarioContrato { | |
public List<Pedido> listarPedidos(); | |
} |
This file contains 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 class MainActivity extends AppCompatActivity { | |
@Inject //anotação utilizada pelo dagger para injetar uma dependência | |
ExemploContrato exemplo; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
} |
This file contains 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 class MainApplication extends android.app.Application { | |
private static ComponenteExemplo component; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
initDagger(); | |
} | |
private void initDagger() { |
This file contains 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
@Component(modules = {ClasseModulo.class})//modulos acessíveis por esse componente | |
interface ComponenteExemplo { | |
public void inject(MainActivity activity)//quem pode utilizar esse módulos | |
} |
This file contains 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
@Provides | |
public UsuarioContrato proverUsuario() { | |
return new Usuario(); | |
} |
This file contains 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
@Module | |
public class ClassModulo { | |
@Provides | |
public ExemploContrato proverExemplo(UsuarioContrato usuario) { | |
return new Exemplo(usuario); | |
} | |
} |
NewerOlder