Java Code Examples for com.twitter.sdk.android.core.Twitter#initialize()
The following examples show how to use
com.twitter.sdk.android.core.Twitter#initialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactTwitterKitPackage.java From react-native-twitterkit with MIT License | 6 votes |
public void initFabric(Context reactContext) { if (consumerKey == null || consumerSecret == null) { return; } TwitterAuthConfig authConfig = new TwitterAuthConfig(consumerKey, consumerSecret); final TwitterConfig config = new TwitterConfig.Builder(reactContext) .twitterAuthConfig(authConfig) .debug(true) .build(); Twitter.initialize(config); new Thread(new Runnable() { @Override public void run() { TweetUi.getInstance(); Log.i("ReactTwitterKit", "TweetUi instance initialized"); } }).start(); }
Example 2
Source File: LoginActivity.java From Simple-Blog-App with MIT License | 6 votes |
private void twitter() { TwitterConfig config = new TwitterConfig.Builder(this) .logger(new DefaultLogger(Log.DEBUG)) .twitterAuthConfig(new TwitterAuthConfig(getResources().getString(R.string.com_twitter_sdk_android_CONSUMER_KEY), getResources().getString(R.string.com_twitter_sdk_android_CONSUMER_SECRET))) .debug(true) .build(); Twitter.initialize(config); twitterLoginButton.setCallback(new Callback<TwitterSession>() { @Override public void success(Result<TwitterSession> result) { Log.d(TAG, "twitterLogin:success" + result); handleTwitterSession(result.data); } @Override public void failure(TwitterException exception) { Log.w(TAG, "twitterLogin:failure", exception); } }); }
Example 3
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 6 votes |
public void testGetTwitterAuthClient_duplicateCalls() throws Exception { try { Twitter.initialize(new TwitterConfig.Builder(getContext()) .executorService(mock(ExecutorService.class)) .build()); final TwitterLoginButton button = new TwitterLoginButton(getContext()) { @Override protected Activity getActivity() { return mock(Activity.class); } }; final TwitterAuthClient client = button.getTwitterAuthClient(); final TwitterAuthClient client2 = button.getTwitterAuthClient(); assertSame(client, client2); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 4
Source File: TweetUiTestCase.java From twitter-kit-android with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { super.setUp(); createMocks(); // Initialize Fabric with mock executor so that kit#doInBackground() will not be called // during kit initialization. final TwitterConfig config = new TwitterConfig.Builder(getContext()) .logger(new DefaultLogger(Log.DEBUG)) .executorService(mock(ThreadPoolExecutor.class)) .build(); Twitter.initialize(config); final TwitterCore twitterCore = TwitterCoreTestUtils.createTwitterCore( new TwitterAuthConfig("", ""), clients, apiClient); tweetUi = TweetUi.getInstance(); final TweetRepository tweetRepository = new TweetRepository(mainHandler, mock(SessionManager.class), twitterCore); tweetUi.setTweetRepository(tweetRepository); tweetUi.setImageLoader(picasso); }
Example 5
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 6 votes |
public void testGetTwitterAuthClient() throws Exception { try { Twitter.initialize(new TwitterConfig.Builder(getContext()) .executorService(mock(ExecutorService.class)) .build()); final TwitterLoginButton button = new TwitterLoginButton(getContext()) { @Override protected Activity getActivity() { return mock(Activity.class); } }; final TwitterAuthClient client = button.getTwitterAuthClient(); assertNotNull(client); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 6
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 6 votes |
public void testConstructor_twitterStarted() throws Exception { try { Twitter.initialize(setUpLogTest()); final TwitterLoginButton button = new TwitterLoginButton(getContext()) { @Override protected Activity getActivity() { return mock(Activity.class); } }; final Logger logger = Twitter.getLogger(); verify(logger, never()).e(eq(TwitterLoginButton.TAG), anyString()); assertTrue(button.isEnabled()); } finally { TwitterTestUtils.resetTwitter(); } }
Example 7
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 6 votes |
public void testOnClick_activityFinishingDebuggableFalse() throws Exception { Twitter.initialize(setUpLogTest()); loginButton = new TwitterLoginButton(getContext(), null, 0, mockAuthClient) { // This is to allow us to test TwitterLoginButton without having to set up a real // activity. @Override protected Activity getActivity() { final Activity mockActivity = mock(Activity.class); when(mockActivity.isFinishing()).thenReturn(true); return mockActivity; } }; loginButton.setCallback(mockCallback); try { loginButton.performClick(); assertLogMessage(TwitterLoginButton.ERROR_MSG_NO_ACTIVITY); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 8
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 6 votes |
public void testOnClick_activityNullDebuggableFalse() throws Exception { Twitter.initialize(setUpLogTest()); loginButton = new TwitterLoginButton(getContext(), null, 0, mockAuthClient) { // This is to allow us to test TwitterLoginButton without having to set up a real // activity. @Override protected Activity getActivity() { return null; } }; loginButton.setCallback(mockCallback); try { loginButton.performClick(); assertLogMessage(TwitterLoginButton.ERROR_MSG_NO_ACTIVITY); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 9
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 6 votes |
public void testOnClick_activityNullDebuggableTrue() throws Exception { Twitter.initialize(new TwitterConfig.Builder(getContext()) .executorService(mock(ExecutorService.class)) .debug(true) .build()); loginButton = new TwitterLoginButton(getContext(), null, 0, mockAuthClient) { // This is to allow us to test TwitterLoginButton without having to set up a real // activity. @Override protected Activity getActivity() { return null; } }; loginButton.setCallback(mockCallback); try { loginButton.performClick(); fail("onClick should throw an exception when called and there is no activity"); } catch (IllegalStateException e) { assertEquals(TwitterLoginButton.ERROR_MSG_NO_ACTIVITY, e.getMessage()); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 10
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 5 votes |
public void testOnClick_callbackNullDebuggableTrue() throws Exception { Twitter.initialize(new TwitterConfig.Builder(getContext()) .executorService(mock(ExecutorService.class)) .debug(true) .build()); try { loginButton.performClick(); fail("onClick should throw an exception when called and there is no callback"); } catch (IllegalStateException e) { assertEquals("Callback must not be null, did you call setCallback?", e.getMessage()); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 11
Source File: App.java From twittererer with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); JodaTimeAndroid.init(this); Fabric.with(this, new Crashlytics()); Twitter.initialize(new TwitterConfig.Builder(this).twitterAuthConfig(new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET)).build()); applicationComponent = DaggerApp_ApplicationComponent.builder() .applicationModule(new ApplicationModule(this)) .build(); }
Example 12
Source File: TweetComposerTest.java From twitter-kit-android with Apache License 2.0 | 5 votes |
public void setUp() throws Exception { super.setUp(); Twitter.initialize(new TwitterConfig.Builder(getContext()) .executorService(mock(ThreadPoolExecutor.class)) .build()); tweetComposer = new TweetComposer(); tweetComposer.instance = tweetComposer; }
Example 13
Source File: OAuthActivityTest.java From twitter-kit-android with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); context = getInstrumentation().getTargetContext(); Twitter.initialize(new TwitterConfig.Builder(context) .executorService(mock(ExecutorService.class)) .build()); mockController = mock(TestOAuthController.class); }
Example 14
Source File: TwitterLoginButtonTest.java From twitter-kit-android with Apache License 2.0 | 5 votes |
public void testOnClick_callbackNullDebuggableFalse() throws Exception { Twitter.initialize(setUpLogTest()); try { loginButton.performClick(); assertLogMessage("Callback must not be null, did you call setCallback?"); } finally { TwitterCoreTestUtils.resetTwitterCore(); TwitterTestUtils.resetTwitter(); } }
Example 15
Source File: TweetUiTest.java From twitter-kit-android with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); Twitter.initialize(new TwitterConfig.Builder(getContext()) .executorService(mock(ExecutorService.class)) .build()); tweetUi = new TweetUi(); }
Example 16
Source File: TweetUiBackgroundTest.java From twitter-kit-android with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); // Set a mock thread pool executor so we can run these tests knowing that doInBackground // has not been run. Twitter.initialize(new TwitterConfig.Builder(getInstrumentation().getTargetContext()) .executorService(mock(ThreadPoolExecutor.class)) .build()); }
Example 17
Source File: TwitterNetwork.java From EasyLogin with MIT License | 5 votes |
public TwitterNetwork(Activity activity, String consumerKey, String consumerSecret) { TwitterAuthConfig authConfig = new TwitterAuthConfig(consumerKey, consumerSecret); TwitterConfig config = new TwitterConfig.Builder(activity.getApplicationContext()) .logger(new DefaultLogger(Log.DEBUG)) .twitterAuthConfig(authConfig) .build(); Twitter.initialize(config); }
Example 18
Source File: SocialMediaSignUp.java From socialmediasignup with MIT License | 5 votes |
private void initTwitter(Context appContext) { String consumerKey = SocialMediaSignUpUtils.getMetaDataValue(appContext, appContext.getString(R.string.com_ahmedadel_socialmediasignup_twitterConsumerKey)); String consumerSecret = SocialMediaSignUpUtils.getMetaDataValue(appContext, appContext.getString(R.string.com_ahmedadel_socialmediasignup_twitterConsumerSecret)); if (consumerKey != null && consumerSecret != null) { TwitterConfig twitterConfig = new TwitterConfig.Builder(appContext) .twitterAuthConfig(new TwitterAuthConfig(consumerKey, consumerSecret)) .build(); Twitter.initialize(twitterConfig); } }
Example 19
Source File: TwitterLoginInstance.java From ShareLoginPayUtil with Apache License 2.0 | 5 votes |
public TwitterLoginInstance(Activity activity, final LoginListener listener, final boolean fetchUserInfo) { super(activity, listener, fetchUserInfo); TwitterConfig config = new TwitterConfig.Builder(activity) .logger(new DefaultLogger(Log.DEBUG)) .twitterAuthConfig(new TwitterAuthConfig(ShareManager.CONFIG.getTwitterConsumerKey(), ShareManager.CONFIG.getTwitterConsumerSecret())) .debug(BuildConfig.DEBUG).build(); Twitter.initialize(config); mTwitterAuthClient = new TwitterAuthClient(); }
Example 20
Source File: ThirdLoginManager.java From FimiX8-RE with MIT License | 4 votes |
public static final void initThirdLogin(Context context) { Twitter.initialize(context); Twitter.initialize(new Builder(context).logger(new DefaultLogger(3)).twitterAuthConfig(new TwitterAuthConfig(context.getResources().getString(R.string.twitter_CONSUMER_KEY), context.getResources().getString(R.string.twitter_CONSUMER_SECRET))).debug(true).build()); }