本文整理汇总了Java中com.twitter.sdk.android.core.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于com.twitter.sdk.android.core包,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGetApiClient_withDifferentSession
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
@Test
public void testGetApiClient_withDifferentSession() {
final DigitsSession session2 = DigitsSession.create(TestConstants.LOGGED_OUT_USER, "");
final MockDigitsApiClientManager client =
new MockDigitsApiClientManager(twitterCore, executorService, mockSessionManager,
activeClient, interceptor);
// Want to ensure it returns different client
final DigitsApiClient firstClient = digitsClient.getApiClient();
final Session active = firstClient.getSession();
assertEquals(active, mockSessionManager.getActiveSession());
assertEquals(activeClient, firstClient);
mockSessionManager = mock(SessionManager.class);
when(mockSessionManager.getActiveSession()).thenReturn(session2);
activeClient = mock(DigitsApiClient.class);
when(activeClient.getSession()).thenReturn(session2);
assertNotSame(activeClient, firstClient);
final DigitsApiClient newClient = digitsClient.getApiClient();
final Session newActive = newClient.getSession();
assertEquals(newActive, mockSessionManager.getActiveSession());
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:23,代码来源:DigitsApiClientManagerTests.java
示例2: ScribeClient
import com.twitter.sdk.android.core.Session; //导入依赖的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);
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:30,代码来源:ScribeClient.java
示例3: setUp
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
mockSessionManager = mock(SessionManager.class);
mockSystemCurrentTimeProvider = mock(SystemCurrentTimeProvider.class);
mockExecutorService = mock(ExecutorService.class);
mockMonitorState = mock(SessionMonitor.MonitorState.class);
mockSessionVerifier = mock(SessionVerifier.class);
sessionMonitor = new SessionMonitor<>(mockSessionManager, mockSystemCurrentTimeProvider,
mockExecutorService, mockMonitorState, mockSessionVerifier);
monitorState = new SessionMonitor.MonitorState();
final Session testSession = mock(Session.class);
when(testSession.getId()).thenReturn(1L);
sessionMap = new HashMap<>();
sessionMap.put(1L, testSession);
when(mockSessionManager.getSessionMap()).thenReturn(sessionMap);
when(mockSessionManager.getActiveSession()).thenReturn(testSession);
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:20,代码来源:SessionMonitorTest.java
示例4: FollowersInfoViewModel
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
public FollowersInfoViewModel(@NonNull DataListener dataListener, @NonNull Context context,
Session session, User user) {
this.dataListener = dataListener;
this.context = context;
this.session = session;
this.user = user;
activityFollowersInfoRecyclerView = new ObservableInt(View.GONE);
initializeViews();
fetchTweetsList();
}
开发者ID:ahmed-adel-said,项目名称:Twitter_Client,代码行数:13,代码来源:FollowersInfoViewModel.java
示例5: TwitterApiClient
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
TwitterApiClient(TwitterAuthConfig authConfig,
Session session,
TwitterApi twitterApi,
SSLSocketFactory sslSocketFactory, ExecutorService executorService) {
if (session == null) {
throw new IllegalArgumentException("Session must not be null.");
}
this.services = new ConcurrentHashMap<>();
final Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new SafeListAdapter())
.registerTypeAdapterFactory(new SafeMapAdapter())
// Using RealmUserJsonSerializerDeserializer class for Users List
.registerTypeAdapter(new TypeToken<RealmList<User>>() {
}.getType(),
new RealmUserJsonSerializerDeserializer())
// Using RealmTweetsJsonSerializerDeserializer class for Tweets List
.registerTypeAdapter(new TypeToken<RealmList<Tweets>>() {
}.getType(),
new RealmTweetsJsonSerializerDeserializer())
.registerTypeAdapter(BindingValues.class, new BindingValuesAdapter())
.create();
apiAdapter = new RestAdapter.Builder()
.setClient(new AuthenticatedClient(authConfig, session, sslSocketFactory))
.setEndpoint(twitterApi.getBaseHostUrl())
.setConverter(new GsonConverter(gson))
.setExecutors(executorService, new MainThreadExecutor())
.build();
uploadAdapter = new RestAdapter.Builder()
.setClient(new AuthenticatedClient(authConfig, session, sslSocketFactory))
.setEndpoint(UPLOAD_ENDPOINT)
.setConverter(new GsonConverter(gson))
.setExecutors(executorService, new MainThreadExecutor())
.build();
}
开发者ID:ahmed-adel-said,项目名称:Twitter_Client,代码行数:40,代码来源:TwitterApiClient.java
示例6: DigitsGuestSessionProvider
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
DigitsGuestSessionProvider(SessionManager<DigitsSession> defaultSessionManager,
List<SessionManager<? extends Session>> sessionManagers, OAuth2Service oAuth2Service) {
super(sessionManagers);
this.defaultSessionManager = defaultSessionManager;
this.oAuth2Service = oAuth2Service;
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:8,代码来源:DigitsGuestSessionProvider.java
示例7: success
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
@Override
public void success(Result<OAuth2Token> result) {
final DigitsSession session = new DigitsSession(result.data);
// set session in manager, manager makes session active if there is no active session
sessionManager.setSession(session.getId(), session);
if (callback != null) {
callback.success(new Result<Session>(session, result.response));
}
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:10,代码来源:DigitsGuestSessionProvider.java
示例8: addClientRequest
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
protected synchronized boolean addClientRequest(final Callback<ApiInterface> callback) {
return addRequest(new Callback<Session>() {
@Override
public void success(Result<Session> result) {
callback.success(new Result<>(
apiClientManager.getApiClient().getService(), null));
}
@Override
public void failure(TwitterException exception) {
callback.failure(exception);
}
});
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:15,代码来源:DigitsAuthRequestQueue.java
示例9: verifySession
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
@Override
public void verifySession(final Session session) {
if (session instanceof DigitsSession && !((DigitsSession) session).isLoggedOutUser()) {
final ApiInterface service = getAccountService();
service.verifyAccount(verificationCallback);
}
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:8,代码来源:DigitsSessionVerifier.java
示例10: createTwitterScribeClient
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
private synchronized void createTwitterScribeClient(SessionManager sessionManager,
IdManager idManager) {
if (twitterScribeClient == null) {
final List<SessionManager<? extends Session>> sessionManagers = new ArrayList<>();
sessionManagers.add(sessionManager);
twitterScribeClient = new DefaultScribeClient(this, DigitsUserAgent.create().toString(),
sessionManagers, idManager);
}
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:11,代码来源:Digits.java
示例11: createAuthRequestQueue
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
protected DigitsAuthRequestQueue createAuthRequestQueue(SessionManager sessionManager) {
final List<SessionManager<? extends Session>> sessionManagers = new ArrayList<>(1);
sessionManagers.add(sessionManager);
final DigitsGuestSessionProvider sessionProvider =
new DigitsGuestSessionProvider(sessionManager, sessionManagers);
return new DigitsAuthRequestQueue(apiClientManager, sessionProvider);
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:8,代码来源:DigitsClient.java
示例12: testVerifySession_nonDigitsSession
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
@Test
public void testVerifySession_nonDigitsSession() throws Exception {
final Session session = mock(Session.class);
doReturn(accountService).when(verifier).getAccountService();
verifier.verifySession(session);
verifyZeroInteractions(accountService);
verifyZeroInteractions(verificationCallback);
}
开发者ID:crashlytics,项目名称:digits-android,代码行数:9,代码来源:DigitsSessionVerifierTest.java
示例13: getOkHttpClient
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
public static OkHttpClient getOkHttpClient(Session<? extends TwitterAuthToken> session,
TwitterAuthConfig authConfig) {
if (session == null) {
throw new IllegalArgumentException("Session must not be null.");
}
return addSessionAuth(new OkHttpClient.Builder(), session, authConfig).build();
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:9,代码来源:OkHttpClientHelper.java
示例14: getCustomOkHttpClient
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
public static OkHttpClient getCustomOkHttpClient(
OkHttpClient httpClient,
Session<? extends TwitterAuthToken> session,
TwitterAuthConfig authConfig) {
if (session == null) {
throw new IllegalArgumentException("Session must not be null.");
}
if (httpClient == null) {
throw new IllegalArgumentException("HttpClient must not be null.");
}
return addSessionAuth(httpClient.newBuilder(), session, authConfig)
.build();
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:16,代码来源:OkHttpClientHelper.java
示例15: addSessionAuth
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
static OkHttpClient.Builder addSessionAuth(OkHttpClient.Builder builder,
Session<? extends TwitterAuthToken> session,
TwitterAuthConfig authConfig) {
return builder
.certificatePinner(getCertificatePinner())
.addInterceptor(new OAuth1aInterceptor(session, authConfig));
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:8,代码来源:OkHttpClientHelper.java
示例16: initialize
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
/**
* Must be called on background thread
*/
public static void initialize(Context context,
SessionManager<? extends Session<TwitterAuthToken>> sessionManagers,
GuestSessionProvider guestSessionProvider, IdManager idManager, String kitName,
String kitVersion) {
final ScribeConfig config = DefaultScribeClient.getScribeConfig(kitName, kitVersion);
instance = new DefaultScribeClient(context, sessionManagers, guestSessionProvider,
idManager, config);
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:13,代码来源:TwitterCoreScribeClientHolder.java
示例17: DefaultScribeClient
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
public DefaultScribeClient(Context context,
SessionManager<? extends Session<TwitterAuthToken>> sessionManager,
GuestSessionProvider guestSessionProvider, IdManager idManager,
ScribeConfig scribeConfig) {
this(context, TwitterCore.getInstance().getAuthConfig(), sessionManager,
guestSessionProvider, idManager, scribeConfig);
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:8,代码来源:DefaultScribeClient.java
示例18: getScribeSessionId
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
long getScribeSessionId(Session activeSession) {
final long scribeSessionId;
if (activeSession != null) {
scribeSessionId = activeSession.getId();
} else {
// It's possible that we're attempting to load a tweet before we have a valid
// session. Store the scribe event locally with the logged out user id so that we can
// send it up at a later time with the logged out session.
scribeSessionId = GuestSession.LOGGED_OUT_USER_ID;
}
return scribeSessionId;
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:13,代码来源:DefaultScribeClient.java
示例19: ScribeFilesSender
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
ScribeFilesSender(Context context, ScribeConfig scribeConfig, long ownerId,
TwitterAuthConfig authConfig,
SessionManager<? extends Session<TwitterAuthToken>> sessionManager,
GuestSessionProvider guestSessionProvider, ExecutorService executorService,
IdManager idManager) {
this.context = context;
this.scribeConfig = scribeConfig;
this.ownerId = ownerId;
this.authConfig = authConfig;
this.sessionManager = sessionManager;
this.guestSessionProvider = guestSessionProvider;
this.executorService = executorService;
this.idManager = idManager;
this.scribeService = new AtomicReference<>();
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:16,代码来源:ScribeFilesSender.java
示例20: getScribeService
import com.twitter.sdk.android.core.Session; //导入依赖的package包/类
/**
* @return the api adapter, may be {@code null}
*/
synchronized ScribeService getScribeService() {
if (scribeService.get() == null) {
final Session session = getSession(ownerId);
final OkHttpClient client;
if (isValidSession(session)) {
client = new OkHttpClient.Builder()
.certificatePinner(OkHttpClientHelper.getCertificatePinner())
.addInterceptor(new ConfigRequestInterceptor(scribeConfig, idManager))
.addInterceptor(new OAuth1aInterceptor(session, authConfig))
.build();
} else {
client = new OkHttpClient.Builder()
.certificatePinner(OkHttpClientHelper.getCertificatePinner())
.addInterceptor(new ConfigRequestInterceptor(scribeConfig, idManager))
.addInterceptor(new GuestAuthInterceptor(guestSessionProvider))
.build();
}
final Retrofit retrofit = new Retrofit.Builder()
.baseUrl(scribeConfig.baseUrl)
.client(client)
.build();
scribeService.compareAndSet(null, retrofit.create(ScribeService.class));
}
return scribeService.get();
}
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:32,代码来源:ScribeFilesSender.java
注:本文中的com.twitter.sdk.android.core.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论