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


Java User类代码示例

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


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

示例1: fetchTwitterUserData

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
private void fetchTwitterUserData(final IOperationFinishWithDataCallback profileFetched) {
    TwitterSession session =
            Twitter.getSessionManager().getActiveSession();
    Twitter.getApiClient(session).getAccountService()
            .verifyCredentials(true, false, new Callback<User>() {
                @Override
                public void success(Result<User> userResult) {
                    User user = userResult.data;
                    userProfile = new UserProfile();
                    userProfile.setName(user.screenName);
                    String profileImage = user.profileImageUrlHttps;
                    profileImage = profileImage.replace("_normal", "");
                    userProfile.setProfileImageUrl(profileImage);
                    profileFetched.operationFinished(userProfile);
                }

                @Override
                public void failure(TwitterException e) {

                }
            });
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:23,代码来源:LoginMaster.java

示例2: requestTwitterUserData

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
@Override
public void requestTwitterUserData() {
    TwitterSession session = Twitter.getSessionManager().getActiveSession();
    Twitter.getApiClient(session).getAccountService().verifyCredentials(true, false, new Callback<User>() {
        @Override
        public void success(Result<User> userResult) {
            User user = userResult.data;
            final String fullName = user.name;
            final String userImage = user.profileImageUrl.replace("_normal", "");
            loginAsGuestPresenter.twitterUserDataSuccess(fullName, userImage);
        }

        @Override
        public void failure(TwitterException e) {

        }
    });
}
 
开发者ID:belatrix,项目名称:AndroidAllStars,代码行数:19,代码来源:LoginAsGuestFragment.java

示例3: extractUserFromSession

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
/**
 * If an active session is in SessionManager, the method extract the current user associated at
 * this.
 */
public static void extractUserFromSession(){
    Twitter.getApiClient(Twitter.getSessionManager().getActiveSession()).getAccountService()
            .verifyCredentials(true, false, new Callback<User>() {
                @Override
                public void success(Result<User> userResult) {
                    TwitterUserTask.CURRENT_USER.set(userResult.data);
                }

                @Override
                public void failure(TwitterException e) {
                    Log.d("TwitterSession", "Can't found the current user from active session");
                }

            });
}
 
开发者ID:mdamis,项目名称:journal,代码行数:20,代码来源:TwitterUserInfoFragment.java

示例4: TwitterFollowersService

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
/**
 * Constructor of TwitterFollowersService
 * @param session, the current session
 */
public TwitterFollowersService(TwitterSession session) {

    JournalTwitterApiClient client = new JournalTwitterApiClient(session);
    client.getCustomService().show(session.getUserId(), null, true, true, 100, new Callback<Followers>() {
        @Override
        public void success(Result<Followers> result) {
            for (User user : result.data.users) {
                users.add(user);
            }
            TwitterFollowersTask.FOLLOWERS_DOWNLOADED.set(true);
        }

        @Override
        public void failure(TwitterException e) {
            Log.e("Twitter followers", "Failure of request");
        }
    });
}
 
开发者ID:mdamis,项目名称:journal,代码行数:23,代码来源:TwitterFollowersService.java

示例5: follow

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
private void follow(String userHandle) {
    MyTwitterApiClient mtac = new MyTwitterApiClient(TwitterCore.getInstance().getSessionManager().getActiveSession());
    Call<User> call = mtac.getFriendshipsService().create(userHandle, null, false);
    call.enqueue(new Callback<User>() {
        @Override
        public void success(Result<User> result) {
            Toast.makeText(MainActivity.this,
                    getResources().getString(R.string.toast_follow_user_success) + " @" + result.data.screenName,
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void failure(TwitterException e) {
            Toast.makeText(MainActivity.this,
                    getResources().getString(R.string.toast_follow_user_error),
                    Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:twitterdev,项目名称:live-event-android,代码行数:20,代码来源:MainActivity.java

示例6: createPhotoTweet

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
static Tweet createPhotoTweet(long id, User user, String text, String timestamp,
        String photoUrlHttps) {
    final MediaEntity photoEntity = new MediaEntity("", "", "", 0, 0, 0L, null, null,
            photoUrlHttps, createMediaEntitySizes(100, 100), 0L, null, "photo", null, "");
    final ArrayList<MediaEntity> mediaEntities = new ArrayList<>();
    mediaEntities.add(photoEntity);
    final TweetEntities entities = new TweetEntities(null, null, mediaEntities, null, null);
    return new TweetBuilder()
            .setId(id)
            .setUser(user)
            .setText(text)
            .setCreatedAt(timestamp)
            .setEntities(entities)
            .setExtendedEntities(entities)
            .build();
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:17,代码来源:TestFixtures.java

示例7: createMultiplePhotosTweet

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
static Tweet createMultiplePhotosTweet(int count, long id, User user, String text,
                                              String timestamp, String photoUrlHttps) {
    final ArrayList<MediaEntity> mediaEntities = new ArrayList<>();
    for (int x = 0; x < count; x++) {
        final MediaEntity photoEntity = new MediaEntity("", "", "", 0, 0, 0L, null, null,
                photoUrlHttps, createMediaEntitySizes(100, 100), 0L, null, "photo", null, "");
        mediaEntities.add(photoEntity);
    }
    final TweetEntities entities = new TweetEntities(null, null, mediaEntities, null, null);
    return new TweetBuilder()
            .setId(id)
            .setUser(user)
            .setText(text)
            .setCreatedAt(timestamp)
            .setEntities(entities)
            .setExtendedEntities(entities)
            .build();
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:19,代码来源:TestFixtures.java

示例8: getProfileImageUrlHttps

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
public static String getProfileImageUrlHttps(User user, AvatarSize size) {
    if (user != null && user.profileImageUrlHttps != null) {
        final String url = user.profileImageUrlHttps;
        if (size == null || url == null) {
            return url;
        }

        switch (size) {
            case NORMAL:
            case BIGGER:
            case MINI:
            case ORIGINAL:
            case REASONABLY_SMALL:
                return url
                        .replace(AvatarSize.NORMAL.getSuffix(), size.getSuffix());
            default:
                return url;
        }
    } else {
        return null;
    }
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:23,代码来源:UserUtils.java

示例9: requestEmail

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
/**
 * Requests the user's email address.
 *
 * @param session the user session
 * @param callback The callback interface to invoke when the request completes. If the user
 *                 denies access to the email address, or the email address is not available,
 *                 an error is returned.
 * @throws java.lang.IllegalArgumentException if session or callback are null.
 */
public void requestEmail(TwitterSession session, final Callback<String> callback) {
    scribeRequestEmail();
    final Call<User> verifyRequest = twitterCore.getApiClient(session).getAccountService()
            .verifyCredentials(false, false, true);

    verifyRequest.enqueue(new Callback<User>() {
        @Override
        public void success(Result<User> result) {
            callback.success(new Result<>(result.data.email, null));
        }

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

示例10: testRequestEmail_withSuccess

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
@Test
public void testRequestEmail_withSuccess() {
    final User user = new UserBuilder().setEmail(TEST_EMAIL).build();
    final Call<User> call = Calls.response(user);
    setupMockAccountService(call);

    authClient.requestEmail(mock(TwitterSession.class), new Callback<String>() {
        @Override
        public void success(Result<String> result) {
            assertEquals(TEST_EMAIL, result.data);
        }

        @Override
        public void failure(TwitterException exception) {
            fail("Expected Callback#success to be called");
        }
    });
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:19,代码来源:TwitterAuthClientTest.java

示例11: testRequestEmail_withFailure

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
@Test
public void testRequestEmail_withFailure() {
    final IOException networkException = new IOException("Network failure");
    final Call<User> call = Calls.failure(networkException);
    setupMockAccountService(call);

    authClient.requestEmail(mock(TwitterSession.class), new Callback<String>() {
        @Override
        public void success(Result<String> result) {
            fail("Expected Callback#failure to be called");
        }

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

示例12: testRequestEmail_scribesImpression

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
@Test
public void testRequestEmail_scribesImpression() {
    final IOException networkException = new IOException("Network failure");
    final Call<User> call = Calls.failure(networkException);
    setupMockAccountService(call);

    final TwitterSession mockSession = mock(TwitterSession.class);
    when(mockSession.getId()).thenReturn(TestFixtures.USER_ID);
    authClient = new TwitterAuthClient(mockTwitterCore, mockAuthConfig, mockSessionManager,
            mockAuthState) {
        @Override
        protected DefaultScribeClient getScribeClient() {
            return mockScribeClient;
        }
    };

    authClient.requestEmail(mockSession, mock(Callback.class));

    verify(mockScribeClient).scribe(any(EventNamespace.class));
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:21,代码来源:TwitterAuthClientTest.java

示例13: onCreateView

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.tweetui_fragment_unique_tweet, container,
            false);

    final LinearLayout tweetRegion = v.findViewById(R.id.tweet_region);

    // Tweet object already present, construct a TweetView
    final Tweet knownTweet = new TweetBuilder()
            .setId(3L)
            .setUser(new UserBuilder()
                            .setId(User.INVALID_ID)
                            .setName("name")
                            .setScreenName("namename")
                            .setVerified(false)
                            .build()
            )
            .setText("Preloaded text of a Tweet that couldn't be loaded.")
            .setCreatedAt("Wed Jun 06 20:07:10 +0000 2012")
            .build();
    final TweetView knownTweetView = new TweetView(getActivity(), knownTweet);
    tweetRegion.addView(knownTweetView);

    return v;
}
 
开发者ID:twitter,项目名称:twitter-kit-android,代码行数:27,代码来源:UniqueTweetActivity.java

示例14: success

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
@Override
public void success(final Result<TwitterSession> sessionResult) {
    TwitterCore.getInstance()
            .getApiClient()
            .getAccountService()
            .verifyCredentials(false, false, true)
            .enqueue(new Callback<User>() {
                @Override
                public void success(Result<User> result) {
                    User user = result.data;
                    mCallbackObject.onSuccess(createIdpResponse(
                            sessionResult.data,
                            user.email,
                            user.name,
                            Uri.parse(user.profileImageUrlHttps)));
                }

                @Override
                public void failure(TwitterException exception) {
                    mCallbackObject.onFailure();
                }
            });
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:24,代码来源:TwitterProvider.java

示例15: getMyDetails

import com.twitter.sdk.android.core.models.User; //导入依赖的package包/类
public Observable<com.zedeff.twittererer.models.User> getMyDetails() {
    return Observable.create(subscriber -> {
        Callback<User> callback = new Callback<User>() {
            @Override
            public void success(Result<User> result) {
                Log.i(TAG, "Got your details, pal!");
                subscriber.onNext(new com.zedeff.twittererer.models.User(result.data.name, result.data.screenName, result.data.profileImageUrl));
            }

            @Override
            public void failure(TwitterException e) {
                Log.e(TAG, e.getMessage(), e);
                subscriber.onError(e);
            }
        };

        getService(UserService.class).show(TwitterCore.getInstance().getSessionManager().getActiveSession().getUserId()).enqueue(callback);
    });
}
 
开发者ID:zfoltin,项目名称:twittererer,代码行数:20,代码来源:TwitterServiceImpl.java


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