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
@ProducerModule(includes = { PlayerRepositoryModule.class, GamesRepositoryModule.class, PlayerNameModule.class, StatisticsModule.class } ) | |
final class MainRequestModule { | |
@Produces | |
static ListenableFuture<Player> player(PlayerRepository playerRepository, String username) { | |
return playerRepository.retrieve(username); | |
} | |
@Produces | |
static ListenableFuture<Games> games(GamesRepository gamesRepository, Player player) { |
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
@ProductionComponent(modules = { MainRequestModule.class, ExecutorModule.class }) | |
interface MainRequestComponent { | |
ListenableFuture<Statistics> statistics(); | |
} |
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
void showStatistics(String playerName) { | |
MainRequestComponent component = DaggerMainRequestComponent | |
.builder() | |
.playerNameModule(new PlayerNameModule(playerName)) | |
.build(); | |
ListenableFuture<Statistics> futureStatistics = component.statistics(); | |
//TODO: show games using the view inside a callback | |
} |
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 void onRegisterClick(View v) { | |
progressBar.setVisibility(View.VISIBLE); | |
progressBar.animate().alpha(1).setDuration(500).start(); | |
final String username = usernameEditText.getText().toString(); | |
final String password = passwordEditText.getText().toString(); | |
RegistrationDTO dto = new RegistrationDTO(username, password); | |
registrationService.callback(new Callback() { | |
@Override | |
public void onResponse(Call<RegistrationDTO> call, Response<RegistrationResult> response) { | |
progressBar.setVisibility(View.GONE); |
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 RegistrationContract { | |
interface View { | |
void showBusy(boolean isBusy); | |
void showAlertDialog(String message); | |
void showNextActivity(); |
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 RegistrationActivity implements RegistrationContract.View { | |
public void onCreate(Bundle savedInstanceState) { | |
//similar to before... | |
} | |
@Override | |
public void showBusy(boolean isBusy) { | |
if (isBusy) { | |
progressBar.setVisibility(View.VISIBLE); |
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 RegistrationContract { | |
interface Presenter { | |
void takeView(View v); | |
void dropView(); | |
void register(String username, String password); |
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 RegistrationPresenter implements RegistrationContract.Presenter { | |
private final RegistrationService registrationService; | |
private final Storage storage; | |
@Nullable | |
private RegistrationContract.View view; | |
public RegistrationPresenter(RegistrationService registrationService, Storage storage) { |
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 RegistrationContract { | |
interface Interactor { | |
void onRegisterButtonClick(String username, String password); | |
} | |
} |
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 RegistrationInteractor implements RegistrationContract.Interactor { | |
private final RegistrationContract.Presenter presenter; | |
RegistrationInteractor(RegistrationContract.presenter presenter); { | |
this.presenter = presenter; | |
} | |
@Override | |
public void onRegisterButtonClick(String username, String password) { |