本文整理匯總了Java中com.twitter.sdk.android.core.Result類的典型用法代碼示例。如果您正苦於以下問題:Java Result類的具體用法?Java Result怎麽用?Java Result使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Result類屬於com.twitter.sdk.android.core包,在下文中一共展示了Result類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadTweet
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
private void loadTweet() {
LogUtils.d(TAG, "loadTweet, tweetId = " + tweetId);
TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
@Override
public void success(Result<Tweet> result) {
LogUtils.d(TAG, "loadTweet, success");
Tweet selectedTweet = result.data;
setTweet(selectedTweet);
handleSuccess();
}
@Override
public void failure(TwitterException exception) {
LogUtils.d(TAG, "loadTweet, failure");
// TODO send message
handleError();
}
});
}
示例2: onLogin
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@Override
public void onLogin() {
twitterAuthClient.authorize(activity, new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
Map<UserInfoType, String> userInfoMap = new HashMap<>();
String id = String.valueOf(result.data.getUserId());
String name = result.data.getUserName();
userInfoMap.put(UserInfoType.ID, id);
userInfoMap.put(UserInfoType.NAME, name);
responseListener.onResult(SocialType.TWITTER, ResultType.SUCCESS, userInfoMap);
}
@Override
public void failure(TwitterException exception) {
responseListener.onResult(SocialType.TWITTER, ResultType.FAILURE, null);
}
});
}
示例3: onCreate
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_landing);
// Intent to start the content activity
final Intent i = new Intent(this, HomeActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (App.getApplicationInstance().getTwitterSession() != null)
startActivity(i);
loginButton = (TwitterLoginButton) findViewById(R.id.login_button);
loginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
// Show contents activity
startActivity(i);
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
}
示例4: onCreate
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
if (Twitter.getSessionManager().getActiveSession() != null){
navigateToMainScreen();
}
twitterLoginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
navigateToMainScreen();
}
@Override
public void failure(TwitterException e) {
String msgError = String.format(getString(R.string.login_error_message),
e.getLocalizedMessage());
Snackbar.make(container, msgError, Snackbar.LENGTH_SHORT).show();
}
});
}
示例5: handleTweet
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
/**
* Handles adding a tweet to the view.
*
* @param holder the holder for hte tweet.
* @param post the post that contains the Id for the tweet.
* @see CompactTweetView
* @see TweetUtils#loadTweet(long, Callback)
* @see Tweet
*/
private void handleTweet(ViewHolder holder, Post post) {
final TwitterViewHolder twitterViewHolder = (TwitterViewHolder) holder;
TwitterPost twitterPost = (TwitterPost) post;
TweetUtils.loadTweet(twitterPost.tweetId, new Callback<Tweet>() {
@Override
public void success(Result<Tweet> result) {
//Unlike the other posts, we have to add a delivered TweetView to the card view.
twitterViewHolder.mCardView.addView(new CompactTweetView(mContext, result.data));
}
@Override
public void failure(TwitterException exception) {
Log.d(TAG, "Failed to handle tweet properly in adapter");
}
});
}
示例6: initializeTwitterLogin
import com.twitter.sdk.android.core.Result; //導入依賴的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);
}
});
}
示例7: fetchTwitterUserData
import com.twitter.sdk.android.core.Result; //導入依賴的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) {
}
});
}
示例8: login
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@ReactMethod
public void login(final Callback callback) {
loginButton = new TwitterLoginButton(getCurrentActivity());
loginButton.setCallback(new com.twitter.sdk.android.core.Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> sessionResult) {
WritableMap result = new WritableNativeMap();
result.putString("authToken", sessionResult.data.getAuthToken().token);
result.putString("authTokenSecret",sessionResult.data.getAuthToken().secret);
result.putString("userID", sessionResult.data.getUserId()+"");
result.putString("userName", sessionResult.data.getUserName());
callback.invoke(null, result);
}
@Override
public void failure(TwitterException exception) {
exception.printStackTrace();
callback.invoke(exception.getMessage());
}
});
loginButton.performClick();
}
示例9: loginWithTwitter
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
public void loginWithTwitter(TwitterAuthClient mTwitterAuthClient) {
mTwitterAuthClient.authorize(activity, new com.twitter.sdk.android.core.Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> twitterSessionResult) {
// Success
shareOnTwitter(imgPath, etsharing_text.getText().toString());
}
@Override
public void failure(TwitterException e) {
}
});
}
示例10: onRefresh
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@Override
public void onRefresh() {
mBinding.swipe.setRefreshing(true);
mAdapter.refresh(new Callback<TimelineResult<Tweet>>() {
@Override
public void success(Result<TimelineResult<Tweet>> result) {
mBinding.swipe.setRefreshing(false);
}
@Override
public void failure(TwitterException exception) {
mBinding.swipe.setRefreshing(false);
Toast.makeText(getContext(), exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
示例11: requestTwitterUserData
import com.twitter.sdk.android.core.Result; //導入依賴的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) {
}
});
}
示例12: requestTwitterEmail
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@Override
public void requestTwitterEmail() {
TwitterSession session = Twitter.getSessionManager().getActiveSession();
twitterAuthClient.requestEmail(session, new Callback<String>() {
@Override
public void success(Result<String> result) {
String email = result.data;
loginAsGuestPresenter.twitterEmailSuccess(email);
}
@Override
public void failure(TwitterException exception) {
loginAsGuestPresenter.onGettingEmailError();
}
});
}
示例13: loginTwitter
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
/**
* Twitter
*/
private void loginTwitter() {
Log.i(TAG, "loginTwitter: Activity = " + getActivity().getClass().getSimpleName());
PDSocialUtils.loginWithTwitter(getActivity(), new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
if (result.data != null) {
Log.i(TAG, "success: Twitter Data present");
registerTwitterAccount(result.data);
} else {
showGenericAlert();
}
}
@Override
public void failure(TwitterException e) {
if (getActivity() != null) {
PDUIDialogUtils.showBasicOKAlertDialog(getActivity(), R.string.pd_claim_twitter_button_text, e.getMessage());
}
}
});
}
示例14: onCreate
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tweetlist);
setListAdapter(adapter);
adapter.setTweetIds(tweetIds, new Callback<List<Tweet>>() {
@Override
public void success(Result<List<Tweet>> result) {
// my custom actions
}
@Override
public void failure(TwitterException exception) {
// Toast.makeText(...).show();
}
});
}
示例15: loadAllTweets
import com.twitter.sdk.android.core.Result; //導入依賴的package包/類
private void loadAllTweets(){
for(final Long tweetId: tweetIds){
TweetUtils.loadTweet(tweetId, new Callback<Tweet>() {
@Override
public void success(Result<Tweet> result) {
//Tweet tweet = result.data;
TweetView tweetView = new TweetView(MyReTweetsActivity.this, result.data,
R.style.tw__TweetLightWithActionsStyle);
View breakLine = getLayoutInflater().inflate(R.layout.tweet_view_layout, null);
tweetView.setOnActionCallback(actionCallback);
myLayout.addView(tweetView);
myLayout.addView(breakLine);
}
@Override
public void failure(TwitterException exception) {
// Toast.makeText(...).show();
}
});
}
}