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
... | |
loginButton.setOnClickListener((v) -> { | |
String login = loginEditText.getText().toString().trim(); | |
if (login.matches("")) { | |
return; | |
} | |
Credentials credentials = MyApplication | |
.plusAuthComponent() | |
.getCredentials(); | |
credentials.setLogin(login); |
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
... | |
@Inject Credentials mCredentials; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
MyApplication.getAuthComponent().inject(this); | |
... |
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
... | |
logoutButton.setOnClickListener((v) -> { | |
MyApplication.clearAuthComponent(); | |
startActivity(new Intent(this, MainActivity.class)); | |
finish(); | |
}); | |
... |
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
... | |
@Scope | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface AuthScope { | |
} |
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 AuthModule { | |
@Provides | |
@AuthScope | |
static public Credentials provideCredentials(Greeting greeting) { | |
... |
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
... | |
@AuthScope | |
public interface AuthComponent { | |
... |
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 CredentialsImpl implements Credentials { | |
private String mLogin; | |
private Greeting mGreeting; | |
CredentialsImpl(Greeting greeting) { | |
mGreeting = greeting; | |
} |
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 | |
@AuthScope | |
static public Credentials provideCredentials(Greeting greeting) { | |
return new CredentialsImpl(greeting); | |
} | |
... |
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
... | |
@Subcomponent(modules = AuthModule.class) | |
@AuthScope | |
public interface AuthComponent { | |
... |
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
... | |
@Singleton | |
@Component(modules = AppModule.class) | |
public interface AppComponent { | |
AuthComponent plusAuthComponent(); | |
... |