Skip to content

Instantly share code, notes, and snippets.

@maydin
Created November 12, 2016 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maydin/bc7728026cc654b4a7ce40e32eba9057 to your computer and use it in GitHub Desktop.
Save maydin/bc7728026cc654b4a7ce40e32eba9057 to your computer and use it in GitHub Desktop.
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@Inject UserService userService;
Button login;
Button logout;
TextView status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((App) getApplication()).getUserComponent().inject(this);
login = (Button) this.findViewById(R.id.login_button);
login.setOnClickListener(this);
logout = (Button) this.findViewById(R.id.logout_button);
logout.setOnClickListener(this);
status = (TextView) this.findViewById(R.id.status_text);
}
@Override
public void onClick(View v) {
if(v == login)
status.setText(userService.login());
else
status.setText(userService.logout());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment