@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_oauth); ListView clientUserListView = (ListView) findViewById(R.id.clientUserList); ClientUserListAdapter adapter = new ClientUserListAdapter(this, 0, ClientUsers.getInstance().allUser()); clientUserListView.setAdapter(adapter); loginButton = (TwitterLoginButton) findViewById(R.id.twitter_login_button); loginButton.setCallback( new Callback<TwitterSession>() { @Override public void success(Result<TwitterSession> result) { TwitterSession session = result.data; ClientUsers.getInstance() .addClientUser( session, clientUser -> { if (clientUser == null) sendToast("このアカウントはすでに登録されています"); else adapter.add(clientUser); }); } @Override public void failure(TwitterException e) { sendToast(e.getLocalizedMessage()); } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); loginButton.onActivityResult(requestCode, resultCode, data); }