本文整理汇总了Java中com.twitter.sdk.android.core.Twitter.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java Twitter.initialize方法的具体用法?Java Twitter.initialize怎么用?Java Twitter.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.twitter.sdk.android.core.Twitter
的用法示例。
在下文中一共展示了Twitter.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initFabric
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
示例2: initializeTwitterLogin
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
void initializeTwitterLogin() {
Twitter.initialize(LoginActivity.this);
mLoginButton = (TwitterLoginButton) findViewById(R.id.login_button);
mLoginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
// Do something with result, which provides a TwitterSession for making API calls
Log.d(TAG, "twitterLogin:success" + result);
handleTwitterSession(result.data);
}
@Override
public void failure(TwitterException exception) {
Log.w(TAG, "twitterLogin:failure", exception);
}
});
}
示例3: TwitterHelper
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
/**
* Public constructor. This will initialize twitter sdk.
*
* @param twitterApiKey twitter api key
* @param twitterSecreteKey twitter secrete key
* @param response {@link TwitterResponse} response listener.
* @param context instance of the caller.
*/
public TwitterHelper(@StringRes final int twitterApiKey,
@StringRes final int twitterSecreteKey,
@NonNull TwitterResponse response,
@NonNull Activity context) {
//noinspection ConstantConditions
if (response == null) throw new IllegalArgumentException("TwitterResponse cannot be null.");
mActivity = context;
mListener = response;
//initialize sdk
TwitterConfig authConfig = new TwitterConfig.Builder(context)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(new TwitterAuthConfig(context.getResources().getString(twitterApiKey),
context.getResources().getString(twitterSecreteKey)))
.debug(true)
.build();
Twitter.initialize(authConfig);
mAuthClient = new TwitterAuthClient();
}
示例4: setUp
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
@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);
}
示例5: testConstructor_twitterStarted
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
}
示例6: testOnClick_activityNullDebuggableTrue
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
}
示例7: testOnClick_activityNullDebuggableFalse
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
}
示例8: testOnClick_activityFinishingDebuggableFalse
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
}
示例9: testGetTwitterAuthClient
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
}
示例10: testGetTwitterAuthClient_duplicateCalls
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
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();
}
}
示例11: onCreate
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
Twitter.initialize(this);
DCSharedPreferences.initialize(this);
}
示例12: initializeTwitterSDK
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
private static void initializeTwitterSDK(TwitterConfig config) {
com.twitter.sdk.android.core.TwitterConfig twitterConfig = new com.twitter.sdk.android.core.TwitterConfig.Builder(mContext)
.twitterAuthConfig(new TwitterAuthConfig(config.getConsumerKey(), config.getConsumerSecret()))
.build();
Twitter.initialize(twitterConfig);
}
示例13: onCreate
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
sInstance = this;
Fabric.with(this, new Crashlytics());
StringsManager.initialize();
TwitterConfig config = new TwitterConfig.Builder(this)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET))
.debug(true)
.build();
Twitter.initialize(config);
//Create Notification channel in Android O
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (notificationManager != null) {
NotificationChannel mChannel = new NotificationChannel("referendum",
StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH);
mChannel.setDescription(StringsManager.getString("notification_channel_description"));
mChannel.enableLights(true);
mChannel.setLightColor(Color.RED);
notificationManager.createNotificationChannel(mChannel);
}
}
}
示例14: onCreate
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = initializeToolbar();
initializeDrawer(toolbar);
initializeNavigationView();
Twitter.initialize(this);
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
if (mFirebaseUser != null) {
mDatabase = FirebaseDatabase.getInstance();
syncUserProfiles();
if (mFirebaseUser.getPhotoUrl() != null) {
mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();
}
posts = new ArrayList<>();
attachPostListeners();
onBoarding();
setUpRecyclerView();
}
}
示例15: onCreate
import com.twitter.sdk.android.core.Twitter; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Twitter.initialize(this);
setContentView(R.layout.activity_login);
PreferenceManager.setDefaultValues(this, R.xml.pref_data_sync, false);
initializeFirebaseAuth();
new FacebookAuthMethods().initializeFacebookLogin();
new TwitterAuthMethods().initializeTwitterLogin();
}