当前位置: 首页>>代码示例>>Java>>正文


Java TwitterApiClient类代码示例

本文整理汇总了Java中com.twitter.sdk.android.core.TwitterApiClient的典型用法代码示例。如果您正苦于以下问题:Java TwitterApiClient类的具体用法?Java TwitterApiClient怎么用?Java TwitterApiClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TwitterApiClient类属于com.twitter.sdk.android.core包,在下文中一共展示了TwitterApiClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    anyIds.add(anyId);
    mockTwitterCore = mock(TwitterCore.class);
    mockApiClient = mock(TwitterApiClient.class);
    mockStatusesService = mock(StatusesService.class, Mockito.RETURNS_MOCKS);
    when(mockApiClient.getStatusesService()).thenReturn(mockStatusesService);
    mockFavoriteService = mock(FavoriteService.class, Mockito.RETURNS_MOCKS);
    when(mockApiClient.getFavoriteService()).thenReturn(mockFavoriteService);
    when(mockTwitterCore.getApiClient(any(TwitterSession.class))).thenReturn(mockApiClient);
    when(mockTwitterCore.getApiClient()).thenReturn(mockApiClient);
    mockSessionManager = mock(SessionManager.class);
    when(mockSessionManager.getActiveSession()).thenReturn(mock(TwitterSession.class));
    mockHandler = mock(Handler.class);
    tweetRepository = new TweetRepository(mockHandler, mockSessionManager, mockTwitterCore);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:17,代码来源:TweetRepositoryTest.java

示例2: uploadTweetWithMedia

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
void uploadTweetWithMedia(TwitterSession session, String text, String mediaId) {
    final TwitterApiClient client = dependencyProvider.getTwitterApiClient(session);

    client.getStatusesService().update(text, null, null, null, null, null, null, true, mediaId)
            .enqueue(
                    new Callback<Tweet>() {
                        @Override
                        public void success(Result<Tweet> result) {
                            sendSuccessBroadcast(result.data.getId());
                            stopSelf();
                        }

                        @Override
                        public void failure(TwitterException exception) {
                            fail(exception);
                        }
                    });
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:19,代码来源:TweetUploadService.java

示例3: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mockComposerView = mock(ComposerView.class);
    mockContext = mock(Context.class);
    when(mockComposerView.getContext()).thenReturn(mockContext);

    mockFinisher = mock(ComposerActivity.Finisher.class);
    mockAuthToken = mock(TwitterAuthToken.class);
    mockTwitterSession = mock(TwitterSession.class);
    when(mockTwitterSession.getAuthToken()).thenReturn(mockAuthToken);

    final TwitterApiClient mockTwitterApiClient = mock(TwitterApiClient.class);
    mockAccountService = mock(AccountService.class);
    when(mockAccountService
            .verifyCredentials(any(Boolean.class), any(Boolean.class), any(Boolean.class)))
            .thenReturn(mock(Call.class));
    when(mockTwitterApiClient.getAccountService()).thenReturn(mockAccountService);

    mockComposerScribeClient = mock(ComposerScribeClient.class);

    mockDependencyProvider = mock(ComposerController.DependencyProvider.class);
    when(mockDependencyProvider.getApiClient(any(TwitterSession.class)))
            .thenReturn(mockTwitterApiClient);
    when(mockDependencyProvider.getTweetValidator()).thenReturn(new Validator());
    when(mockDependencyProvider.getScribeClient()).thenReturn(mockComposerScribeClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:27,代码来源:ComposerControllerTest.java

示例4: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    context = RuntimeEnvironment.application;
    mockMediaService = mock(MediaService.class);
    mockStatusesService = mock(StatusesService.class);
    tweet =  new TweetBuilder().setId(123L).setText(EXPECTED_TWEET_TEXT).build();
    when(mockMediaService
            .upload(any(RequestBody.class), any(RequestBody.class), any(RequestBody.class)))
            .thenReturn(mock(Call.class));
    when(mockStatusesService.update(anyString(), isNull(Long.class), isNull(Boolean.class),
            isNull(Double.class), isNull(Double.class), isNull(String.class),
            isNull(Boolean.class), eq(true), isNull(String.class)))
            .thenReturn(Calls.response(tweet));

    mockTwitterApiClient = mock(TwitterApiClient.class);
    when(mockTwitterApiClient.getStatusesService()).thenReturn(mockStatusesService);
    when(mockTwitterApiClient.getMediaService()).thenReturn(mockMediaService);

    mockDependencyProvider = mock(TweetUploadService.DependencyProvider.class);
    when(mockDependencyProvider.getTwitterApiClient(any(TwitterSession.class)))
            .thenReturn(mockTwitterApiClient);

    service = spy(Robolectric.buildService(TweetUploadService.class).create().get());
    service.dependencyProvider = mockDependencyProvider;
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:26,代码来源:TweetUploadServiceTest.java

示例5: updateStatus

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
public void updateStatus(View view){
    EditText editText = (EditText) findViewById(R.id.editText);
    TwitterApiClient apiClient = TwitterCore.getInstance().getApiClient();
    StatusesService statusesService = apiClient.getStatusesService();
    statusesService.update(editText.getText().toString(), 1l, false, 0d, 0d, "", false, false, new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> tweetResult) {
            Log.d(TAG, "posté");
            Toast.makeText(TweetActivity.this, "Posté", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void failure(TwitterException e) {
            Log.d(TAG, "Erreur");
            Toast.makeText(TweetActivity.this, "Erreur", Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:jacquesgiraudel,项目名称:TP-Formation-Android,代码行数:19,代码来源:TweetActivity.java

示例6: importExistingTwitterPosts

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
private void importExistingTwitterPosts(final String uid) {
    TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
    StatusesService statusesService = twitterApiClient.getStatusesService();
    statusesService
            .userTimeline(TwitterCore
                            .getInstance()
                            .getSessionManager()
                            .getActiveSession()
                            .getUserId(),
                    null, null, null, null, null, null, null, null)
            .enqueue(new ImportExistingTwitterPostsCallback(uid));
}
 
开发者ID:cache117,项目名称:social-journal,代码行数:13,代码来源:MainActivity.java

示例7: getUserData

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
/**
 * Load twitter user profile.
 */
private void getUserData() {
    TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
    AccountService statusesService = twitterApiClient.getAccountService();
    Call<User> call = statusesService.verifyCredentials(true, true, true);
    call.enqueue(new Callback<User>() {
        @Override
        public void success(Result<User> userResult) {
            //Do something with result

            //parse the response
            TwitterUser user = new TwitterUser();
            user.name = userResult.data.name;
            user.email = userResult.data.email;
            user.description = userResult.data.description;
            user.pictureUrl = userResult.data.profileImageUrl;
            user.bannerUrl = userResult.data.profileBannerUrl;
            user.language = userResult.data.lang;
            user.id = userResult.data.id;

            mListener.onTwitterProfileReceived(user);
        }

        public void failure(TwitterException exception) {
            //Do something on failure
        }
    });
}
 
开发者ID:multidots,项目名称:android-social-signin-helper,代码行数:31,代码来源:TwitterHelper.java

示例8: createMocks

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
private void createMocks() {
    mainHandler = mock(Handler.class);
    picasso = MockUtils.mockPicasso(mock(Picasso.class), mock(RequestCreator.class));

    scribeClient = mock(TweetScribeClient.class);

    apiClient = mock(TwitterApiClient.class);
    MockUtils.mockApiClient(apiClient);

    clients = mock(ConcurrentHashMap.class);
    MockUtils.mockClients(clients, apiClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:13,代码来源:TweetUiTestCase.java

示例9: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() {
    twitterCore = mock(TwitterCore.class);
    apiClient = mock(TwitterApiClient.class);
    listService = mock(ListService.class, new MockCallAnswer());

    when(apiClient.getListService()).thenReturn(listService);
    when(twitterCore.getApiClient()).thenReturn(apiClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:10,代码来源:TwitterListTimelineTest.java

示例10: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() {
    twitterCore = mock(TwitterCore.class);
    apiClient = mock(TwitterApiClient.class);
    statusesService = mock(StatusesService.class, new MockCallAnswer());

    when(apiClient.getStatusesService()).thenReturn(statusesService);
    when(twitterCore.getApiClient()).thenReturn(apiClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:10,代码来源:UserTimelineTest.java

示例11: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    testUserMap.put(TEST_USER_1.id, TEST_USER_1);
    testUserMap.put(TEST_USER_2.id, TEST_USER_2);
    testTweetMap.put(TEST_TWEET_1.id, TEST_TWEET_1);
    testTweetMap.put(TEST_TWEET_2.id, TEST_TWEET_2);
    testTweetMap.put(TEST_TWEET_QUOTE.id, TEST_TWEET_QUOTE);
    // testItems order Test Tweet 1, then 2
    testItems.add(new TwitterCollection.TimelineItem(
            new TwitterCollection.TimelineItem.TweetItem(5858L)));
    testItems.add(new TwitterCollection.TimelineItem(
            new TwitterCollection.TimelineItem.TweetItem(8585L)));
    testItems.add(new TwitterCollection.TimelineItem(
            new TwitterCollection.TimelineItem.TweetItem(858909L)));
    // testItemsRev orders Test Tweet 2, then 1
    testItemsRev.add(new TwitterCollection.TimelineItem(
            new TwitterCollection.TimelineItem.TweetItem(858909L)));
    testItemsRev.add(new TwitterCollection.TimelineItem(
            new TwitterCollection.TimelineItem.TweetItem(8585L)));
    testItemsRev.add(new TwitterCollection.TimelineItem(
            new TwitterCollection.TimelineItem.TweetItem(5858L)));

    twitterCore = mock(TwitterCore.class);
    apiClient = mock(TwitterApiClient.class);
    collectionService = mock(CollectionService.class, new MockCallAnswer());

    when(apiClient.getCollectionService()).thenReturn(collectionService);
    when(twitterCore.getApiClient()).thenReturn(apiClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:30,代码来源:CollectionTimelineTest.java

示例12: setUp

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
@Before
public void setUp() {
    twitterCore = mock(TwitterCore.class);
    apiClient = mock(TwitterApiClient.class);
    searchService = mock(SearchService.class, new MockCallAnswer());

    when(apiClient.getSearchService()).thenReturn(searchService);
    when(twitterCore.getApiClient()).thenReturn(apiClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:10,代码来源:SearchTimelineTest.java

示例13: setupMockAccountService

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
private void setupMockAccountService(Call<User> call) {
    final AccountService mockAccountService = mock(AccountService.class);
    when(mockAccountService.verifyCredentials(anyBoolean(), anyBoolean(), eq(true)))
            .thenReturn(call);
    final TwitterApiClient mockApiClient = mock(TwitterApiClient.class);
    when(mockApiClient.getAccountService()).thenReturn(mockAccountService);
    when(mockTwitterCore.getApiClient(any(TwitterSession.class))).thenReturn(mockApiClient);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:9,代码来源:TwitterAuthClientTest.java

示例14: uploadMedia

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
void uploadMedia(TwitterSession session, Uri imageUri, Callback<Media> callback) {
    final TwitterApiClient client = dependencyProvider.getTwitterApiClient(session);

    final String path = FileUtils.getPath(TweetUploadService.this, imageUri);
    if (path == null) {
        fail(new TwitterException("Uri file path resolved to null"));
        return;
    }
    final File file = new File(path);
    final String mimeType = FileUtils.getMimeType(file);
    final RequestBody media = RequestBody.create(MediaType.parse(mimeType), file);

    client.getMediaService().upload(media, null, null).enqueue(callback);
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:15,代码来源:TweetUploadService.java

示例15: getTweet

import com.twitter.sdk.android.core.TwitterApiClient; //导入依赖的package包/类
private static void getTweet(final Long id, final String fname){
    showFetchingTweetNoti();

    TwitterApiClient twitterApiClient= TwitterCore.getInstance().getApiClient();
    StatusesService statusesService=twitterApiClient.getStatusesService();
    Call<Tweet> tweetCall=statusesService.show(id,null,null,null);
    tweetCall.enqueue(new Callback<Tweet>() {
        @Override
        public void success(Result<Tweet> result) {

            //Check if media is present
            if (result.data.extendedEtities==null && result.data.entities.media==null){
                alertNoMedia();
            }
            //Check if gif or mp4 present in the file
            else if (!(result.data.extendedEtities.media.get(0).type).equals("video") && !(result.data.extendedEtities.media.get(0).type).equals("animated_gif")){
                alertNoVideo();
            }
            else {
                String filename=fname;
                String url;

                //Set filename to gif or mp4
                if ((result.data.extendedEtities.media.get(0).type).equals("video")) {
                    filename = filename + ".mp4";
                }else {
                    filename = filename + ".gif";
                }

                int i=0;
                url = result.data.extendedEtities.media.get(0).videoInfo.variants.get(i).url;
                while (!url.endsWith(".mp4")){
                    if(result.data.extendedEtities.media.get(0).videoInfo.variants.get(i)!=null) {
                        url = result.data.extendedEtities.media.get(0).videoInfo.variants.get(i).url;
                        i += 1;
                    }
                }

                downloadVideo(url,filename);
            }
        }

        @Override
        public void failure(TwitterException exception) {
            Toast.makeText(c, "Request Failed: Check your internet connection", Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:emmanuelkehinde,项目名称:TwittaSave-Android,代码行数:49,代码来源:ServiceUtil.java


注:本文中的com.twitter.sdk.android.core.TwitterApiClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。