當前位置: 首頁>>代碼示例>>Java>>正文


Java TwitterException類代碼示例

本文整理匯總了Java中com.twitter.sdk.android.core.TwitterException的典型用法代碼示例。如果您正苦於以下問題:Java TwitterException類的具體用法?Java TwitterException怎麽用?Java TwitterException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TwitterException類屬於com.twitter.sdk.android.core包,在下文中一共展示了TwitterException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadTweet

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
    }
  });
}
 
開發者ID:netceteragroup,項目名稱:react-native-twitterkit,代碼行數:21,代碼來源:TweetView.java

示例2: onLogin

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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);
        }
    });
}
 
開發者ID:WindSekirun,項目名稱:SocialLogin,代碼行數:23,代碼來源:TwitterLogin.java

示例3: onCreate

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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
        }
    });
}
 
開發者ID:beraldofilippo,項目名稱:TWStreaming,代碼行數:27,代碼來源:LandingActivity.java

示例4: onCreate

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
        }
    });
}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:25,代碼來源:LoginActivity.java

示例5: handleTweet

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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");
        }
    });
}
 
開發者ID:cache117,項目名稱:social-journal,代碼行數:26,代碼來源:SocialJournalAdapter.java

示例6: initializeTwitterLogin

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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);
        }
    });
}
 
開發者ID:cache117,項目名稱:social-journal,代碼行數:18,代碼來源:LoginActivity.java

示例7: fetchTwitterUserData

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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

示例8: login

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
}
 
開發者ID:tkporter,項目名稱:react-native-fabric-twitterkit,代碼行數:25,代碼來源:FabricTwitterKitModule.java

示例9: loginWithTwitter

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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) {

            }
        });
    }
 
開發者ID:saveendhiman,項目名稱:BackgroundTwitterSharing,代碼行數:17,代碼來源:TwitterSharingActivity.java

示例10: onRefresh

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
        }
    });
}
 
開發者ID:Gnzlt,項目名稱:UCOmove,代碼行數:17,代碼來源:TwitterFragment.java

示例11: requestTwitterUserData

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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

示例12: requestTwitterEmail

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
        }
    });
}
 
開發者ID:belatrix,項目名稱:AndroidAllStars,代碼行數:17,代碼來源:LoginAsGuestFragment.java

示例13: loginTwitter

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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());
            }
        }
    });
}
 
開發者ID:Popdeem,項目名稱:Popdeem-SDK-Android,代碼行數:26,代碼來源:PDUISocialMultiLoginFragment.java

示例14: onCreate

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
        }
    });
}
 
開發者ID:manishpatelgt,項目名稱:MyTwitterRepo,代碼行數:18,代碼來源:TweetListActivity.java

示例15: loadAllTweets

import com.twitter.sdk.android.core.TwitterException; //導入依賴的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();
                }
            });

        }
    }
 
開發者ID:manishpatelgt,項目名稱:MyTwitterRepo,代碼行數:27,代碼來源:MyReTweetsActivity.java


注:本文中的com.twitter.sdk.android.core.TwitterException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。