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
interface InterfaceMethods { | |
// Métodos abstratos | |
// 1.Em classes concretas DEVEM ser sobreescritos (override) | |
// 2.Em classes abstratas a sobreescrita é opcional | |
Context getContext(); | |
// Métodos defaults (ou métodos padrões) | |
// 1.Possuem o modificador "default" | |
// 2.Possuem corpo | |
// 3.Não precisam ser sobreescritos |
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
interface InterfaceWithConstants { | |
// Atributos | |
// 1.Permitido apenas atributos constantes (static final), ou seja, | |
// precisam ser declarados com valores definidos que não podem | |
// ser alterados em tempo de execução | |
// 2.Os modificadores podem ficar implícitos, | |
// pois apenas "um" tipo de modificador é permitido | |
String BASE_URL = "https://medium.com"; | |
int MAX_TRIES = 10; | |
} |
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
interface InterfaceWithNestedClasses { | |
// Classes internas | |
// 1.Podem ter qualquer tipo de classe internamente | |
// 2.Suas classes internas são estáticas (nested classes) | |
interface MyInterface { | |
// some code here | |
} | |
enum MyEnum { |
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
// Interface usada na herança | |
interface ParentInterface { | |
void firstMethod(); | |
void secondMethod(); | |
} | |
// Interface derivada de ParentInterface | |
interface ChildInterface extends ParentInterface { | |
// Herança | |
// 1.Não é necessário sobrescrever os métodos herdados de |
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 OpenLogFileActivity extends AppCompatActivity { | |
// some Activity code here | |
private void onOpenLogButtonClick() { | |
// Usando uma classe anônima como Callback | |
new OpenFileHelper("home/log.txt", new OpenFileHelperCallback() { | |
@Override | |
public void onFileOpenSuccess(File file) { | |
// do something with file |
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 AccountManagerPresenterImpl implements AccountManagerPresenter { | |
private final ViewContract viewContract; | |
public MainPresenter(ViewContract viewContract) { | |
this.viewContract = viewContract; | |
} | |
@Override | |
public void onUpdateAccount(String newName, String newEmail) { |
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 implements ViewContract { | |
private AccountManagerPresenter presenter; | |
private Button updateAccountButton; | |
private Button removeAccountButton; | |
private EditText nameInput; | |
private EditText emailInput; | |
@Override |
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 Presenter { | |
void onUpdateAccount(String newName, String newEmail); | |
void onRemoveAccount(); | |
} |
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 LogCatLogger extends Logger { | |
} |