本文整理匯總了Java中com.twitter.sdk.android.core.TwitterAuthConfig類的典型用法代碼示例。如果您正苦於以下問題:Java TwitterAuthConfig類的具體用法?Java TwitterAuthConfig怎麽用?Java TwitterAuthConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TwitterAuthConfig類屬於com.twitter.sdk.android.core包,在下文中一共展示了TwitterAuthConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initFabric
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的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: onCreate
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
singleton = this;
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
Stetho.initializeWithDefaults(this);
}
示例3: onCreate
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this,
new TwitterCore(
new TwitterAuthConfig(
getString(R.string.CONSUMER_KEY),
getString(R.string.CONSUMER_SECRET))),
new Digits.Builder().build());
Digits.authenticate(new AuthConfig.Builder().withAuthCallBack(new AuthCallback() {
@Override
public void success(DigitsSession session, String phoneNumber) {
Toast.makeText(TestDigitsActivity.this, "Digits sign in success " + phoneNumber,
Toast.LENGTH_LONG).show();
}
@Override
public void failure(DigitsException error) {
Toast.makeText(TestDigitsActivity.this, "Digits sign in failed ", Toast.LENGTH_LONG)
.show();
}
}).build());
}
示例4: onActivityResult
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE) {
twitterAuthClient.onActivityResult(requestCode, resultCode, data);
} else if (requestCode == ValueConstants.REQUEST_CAMERA) {
imgPath = imageUtility.compressImage(uriCamera.getPath());
imageUtility.loadImage(imgPath, imageView, R.mipmap.ic_launcher);
} else if (requestCode == ValueConstants.REQUEST_Gallery) {
imgPath = imageUtility.compressImage(imageUtility.getRealPathFromURI(data.getData()));
imageUtility.loadImage(imgPath, imageView, R.mipmap.ic_launcher);
}
}
}
示例5: getTwitterAuthConfig
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
private static TwitterAuthConfig getTwitterAuthConfig(Context context) {
final String consumerKey = getTwitterConsumerKey(context);
final String consumerSecret = getTwitterConsumerSecret(context);
if (consumerKey == null || consumerSecret == null) {
if (consumerKey == null) {
PDLog.e(PDSocialUtils.class, "Twitter Error: Please ensure you have your Twitter Consumer Key in your AndroidManifest.xml\n" +
"<meta-data android:name=\"TwitterConsumerKey\" android:value=\"YOUR_TWITTER_CONSUMER_KEY\" />");
}
if (consumerSecret == null) {
PDLog.e(PDSocialUtils.class, "Twitter Error: Please ensure you have your Twitter Consumer Secret in your AndroidManifest.xml\n" +
"<meta-data android:name=\"TwitterConsumerSecret\" android:value=\"YOUR_TWITTER_CONSUMER_SECRET\" />");
}
return null;
}
return new TwitterAuthConfig(consumerKey, consumerSecret);
}
示例6: onCreate
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
Realm.init(this);
globalContext = this.getApplicationContext();
TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_key),getString(R.string.twitter_secret));
Fabric.with(this, new Twitter(authConfig));
facebookInit();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
Dexter.initialize(this);
}
示例7: TwitterHelper
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的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();
}
示例8: onCreate
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
TwitterAuthConfig authConfig = new TwitterAuthConfig(Constants.TWITTER_KEY, Constants.TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
FacebookSdk.sdkInitialize(getApplicationContext());
boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
if (isDebuggable) {
Timber.plant(new Timber.DebugTree());
}
mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build();
mApplicationComponent.inject(this);
}
示例9: onCreate
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
setupTimber();
// Note: Your consumer key and secret should be obfuscated in your source code before shipping.
if (!TextUtils.isEmpty(BuildConfig.TWITTER_KEY)) {
TwitterAuthConfig authConfig = new TwitterAuthConfig(BuildConfig.TWITTER_KEY, BuildConfig.TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig), new Crashlytics());
} else {
Fabric.with(this, new Crashlytics());
}
FacebookSdk.sdkInitialize(getApplicationContext());
DBManager.getInstance().init(this);
mAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
String url = BuildConfig.WS_PROTOCOL + "://" + BuildConfig.WS_HOST + BuildConfig.WS_PATH;
mAppComponent.plus(new RocketModule(url)).inject(this);
}
示例10: testGetDigitClients_multipleThreads
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
public void testGetDigitClients_multipleThreads() throws Exception {
try {
Fabric.with(getContext(), new TwitterCore(new TwitterAuthConfig("", "")), new Digits());
final List<DigitsClientCallable> callables = Arrays.asList(
new DigitsClientCallable(),
new DigitsClientCallable());
final ExecutorService executorService = Executors.newFixedThreadPool(callables.size());
final List<Future<DigitsClient>> digitsClients = executorService.invokeAll(callables);
assertNotNull(digitsClients.get(0).get());
assertNotNull(digitsClients.get(1).get());
assertSame(digitsClients.get(0).get(), digitsClients.get(1).get());
} finally {
FabricTestUtils.resetFabric();
}
}
示例11: testGetDigitsClient
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
public void testGetDigitsClient() throws Exception {
try {
final Fabric fabric = new Fabric.Builder(getContext())
.kits(new Digits(), new TwitterCore(new TwitterAuthConfig("", "")))
.build();
FabricTestUtils.with(fabric);
final DigitsAuthButton authButton = new DigitsAuthButton(getContext());
assertNull(authButton.digitsClient);
authButton.setCallback(callback);
authButton.getDigitsClient();
assertNotNull(authButton.digitsClient);
} finally {
FabricTestUtils.resetFabric();
}
}
示例12: setUp
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的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);
}
示例13: ScribeClient
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
/**
* Constructor.
*
* @param context the context
* @param executor scheduled executor service for executing scribe requests on background thread
* @param scribeConfig the scribe configuration
* @param transform the scribe event transform for serializing and deserializing scribe events
* flush of all queued events as long as a network connection is available.
* @param authConfig the auth configuration
* @param sessionManager the session manager
* @param idManager the id manager used to provide the device id
*/
public ScribeClient(Context context, ScheduledExecutorService executor,
ScribeConfig scribeConfig, ScribeEvent.Transform transform,
TwitterAuthConfig authConfig,
SessionManager<? extends Session<TwitterAuthToken>> sessionManager,
GuestSessionProvider guestSessionProvider, IdManager idManager) {
this.context = context;
this.executor = executor;
this.scribeConfig = scribeConfig;
this.transform = transform;
this.authConfig = authConfig;
this.sessionManager = sessionManager;
this.guestSessionProvider = guestSessionProvider;
this.idManager = idManager;
// Set initial capacity to 2 to handle one logged in user and one logged out user.
scribeHandlers = new ConcurrentHashMap<>(2);
}
示例14: testBeginAuthorize_authHandlerCompareAndSetFails
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Test
public void testBeginAuthorize_authHandlerCompareAndSetFails() {
final AuthState authState = new AuthState();
final boolean result = authState.beginAuthorize(mockActivity,
new AuthHandler(mock(TwitterAuthConfig.class), mock(Callback.class),
TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE) {
@Override
public boolean authorize(Activity activity) {
// We use this opportunity to set authState's authHandlerRef so that we
// can verify behavior when compare and set fails. This is done because
// AtomicReference has methods that cannot be mocked.
authState.authHandlerRef.set(mock(AuthHandler.class));
return true;
}
});
assertFalse(result);
}
示例15: setUp
import com.twitter.sdk.android.core.TwitterAuthConfig; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
mockContext = mock(Context.class);
when(mockContext.getPackageName()).thenReturn(getClass().getPackage().toString());
mockTwitterCore = mock(TwitterCore.class);
mockAuthConfig = mock(TwitterAuthConfig.class);
when(mockAuthConfig.getRequestCode()).thenReturn(TEST_REQUEST_CODE);
mockSessionManager = mock(SessionManager.class);
mockAuthState = mock(AuthState.class);
mockCallback = mock(Callback.class);
mockScribeClient = mock(DefaultScribeClient.class);
authClient = new TwitterAuthClient(mockTwitterCore, mockAuthConfig, mockSessionManager,
mockAuthState);
}