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


Java Callback.success方法代碼示例

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


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

示例1: testCallbackWrapperSuccess_iOException

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Test
public void testCallbackWrapperSuccess_iOException() throws IOException {
    final Callback<OAuthResponse> callback = new Callback<OAuthResponse>() {
        @Override
        public void success(Result<OAuthResponse> result) {
            fail();
        }

        @Override
        public void failure(TwitterException exception) {
            assertNotNull(exception);
        }
    };
    final Callback<ResponseBody> callbackWrapper = service.getCallbackWrapper(callback);
    final ResponseBody responseBody = ResponseBody.create(MediaType.parse("application/json"), "");
    callbackWrapper.success(new Result<>(responseBody, Response.success(responseBody)));
}
 
開發者ID:twitter,項目名稱:twitter-kit-android,代碼行數:18,代碼來源:OAuth1aServiceTest.java

示例2: usersAndUploadedBy

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void usersAndUploadedBy(@Query("cursor") String cursor,
                               @Query("count") Integer count, Callback<Contacts> cb) {
    final Contacts data;

    if (cursor == null) {
        // First page:
        data = getContactsPages().get("");
    } else {
        // Subsequent pages
        data = getContactsPages().get(cursor);
    }

    final Response response = new Response("/1.1/contacts/users_and_uploaded_by.json", 200,
            "ok", Collections.<Header>emptyList(), new TypedByteArray("application/json",
            new Gson().toJson(data).getBytes()));
    cb.success(data, response);

}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:20,代碼來源:MockApiInterface.java

示例3: testExecuteRequest_successWithEmailRequestSessionHasEmail

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
public void testExecuteRequest_successWithEmailRequestSessionHasEmail() throws Exception {
    final DigitsSessionResponse response = TestConstants.DIGITS_USER;
    final Result<DigitsSessionResponse> result = new Result(response, null);
    final Result<VerifyAccountResponse> resultEmailRequest = new Result(
            TestConstants.getVerifyAccountResponse(), null);
    controller = new DummyPinCodeController(resultReceiver, sendButton, phoneEditText,
            sessionManager, digitsClient, REQUEST_ID, USER_ID, PHONE_WITH_COUNTRY_CODE, errors,
            new ActivityClassManagerImp(), digitsEventCollector, true,
            digitsEventDetailsBuilder);

    final DigitsCallback<DigitsSessionResponse> callback = executeRequest();
    callback.success(result);
    verify(controller.getAccountService()).verifyAccount(callbackArgumentCaptor.capture());
    final Callback<VerifyAccountResponse> emailRequestCallback = callbackArgumentCaptor
            .getValue();
    emailRequestCallback.success(resultEmailRequest);
    verify(digitsEventCollector)
            .twoFactorPinVerificationSuccess(digitsEventDetailsArgumentCaptor.capture());
    final DigitsEventDetails digitsEventDetails = digitsEventDetailsArgumentCaptor.getValue();
    assertNotNull(digitsEventDetails.language);
    assertNotNull(digitsEventDetails.country);
    assertNotNull(digitsEventDetails.elapsedTimeInMillis);
    final DigitsSession session = DigitsSession.create(
            TestConstants.getVerifyAccountResponse());
    verifyEmailRequest(session);
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:27,代碼來源:PinCodeControllerTests.java

示例4: testExecuteRequest_successWithEmailRequestSessionHasEmail

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
public void testExecuteRequest_successWithEmailRequestSessionHasEmail() throws Exception {
    final DigitsSessionResponse response = TestConstants.DIGITS_USER;
    final Result<DigitsSessionResponse> result = new Result(response, null);
    final Result<VerifyAccountResponse> resultEmailRequest = new Result(
            TestConstants.getVerifyAccountResponse(), null);
    controller = new DummyLoginCodeController(resultReceiver, sendButton, resendButton,
            callMeButton, phoneEditText, sessionManager, digitsClient, REQUEST_ID, USER_ID,
            PHONE_WITH_COUNTRY_CODE, errors, new ActivityClassManagerImp(),
            digitsEventCollector, true, timerTextView, digitsEventDetailsBuilder);

    final DigitsCallback<DigitsSessionResponse> callback = executeRequest();
    callback.success(result);
    verify(controller.getAccountService()).verifyAccount(callbackArgumentCaptor.capture());
    final Callback<VerifyAccountResponse> emailRequestCallback = callbackArgumentCaptor
            .getValue();
    emailRequestCallback.success(resultEmailRequest);
    verify(digitsEventCollector).loginCodeSuccess(digitsEventDetailsArgumentCaptor.capture());
    final DigitsEventDetails digitsEventDetails = digitsEventDetailsArgumentCaptor.getValue();
    assertNotNull(digitsEventDetails.elapsedTimeInMillis);
    final DigitsSession session = DigitsSession.create(
            TestConstants.getVerifyAccountResponse());
    verifyEmailRequest(session);
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:24,代碼來源:LoginCodeControllerTests.java

示例5: testLoginSuccess

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Test
public void testLoginSuccess() {
    LoginOrSignupComposer loginOrSignupComposer = new LoginOrSignupComposer(context,
            digitsClient, sessionManager, PHONE_WITH_COUNTRY_CODE, Verification.sms, true,
            resultReceiver, activityClassManager, digitsEventDetailsBuilder){
        @Override
        public void success(final Intent intent){
            assertExpectedLoginIntent(intent);
        }

        @Override
        public void failure(DigitsException digitsException) {
            assertTrue(false);
        }
    };

    loginOrSignupComposer.start();

    //Simulate Auth success
    verify(digitsClient).authDevice(anyString(), any(Verification.class),
            callbackCaptor.capture());
    final Callback loginCallback = callbackCaptor.getValue();
    loginCallback.success(new Result(authResponse, null));
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:25,代碼來源:LoginOrSignupComposerTest.java

示例6: account

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void account(@Field("phone_number") String phoneNumber,
                    @Field("numeric_pin") String numericPin, Callback<DigitsUser> cb) {
    final DigitsUser user = new DigitsUser(1, "1");
    final Response response = new Response("/1/sdk/account", 200, "ok",
            Collections.<Header>emptyList(), new TypedByteArray("application/json",
            new Gson().toJson(user).getBytes()));
    cb.success(user, response);
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:10,代碼來源:MockApiInterface.java

示例7: next

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void next(Long sinceId, Callback<TimelineResult<Tweet>> cb) {
    final List<Tweet> tweets = TestFixtures.getTweetList(numItems);
    final TimelineCursor timelineCursor = new TimelineCursor(tweets);
    final TimelineResult<Tweet> timelineResult
            = new TimelineResult<>(timelineCursor, tweets);
    cb.success(new Result<>(timelineResult, null));
}
 
開發者ID:twitter,項目名稱:twitter-kit-android,代碼行數:9,代碼來源:TweetTimelineRecyclerViewAdapterTest.java

示例8: verifyAccount

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void verifyAccount(Callback<VerifyAccountResponse> cb) {
    final VerifyAccountResponse data = createVerifyAccountResponse();
    final Response response = new Response("/1.1/sdk/account.json", 200, "ok",
            Collections.<Header>emptyList(), new TypedByteArray("application/json",
            new Gson().toJson(data).getBytes()));
    cb.success(data, response);
    }
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:9,代碼來源:MockApiInterface.java

示例9: register

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void register(@Field("raw_phone_number") String rawPhoneNumber,
                     @Field("text_key") String textKey,
                     @Field("send_numeric_pin") Boolean sendNumericPin,
                     @Field("lang") String lang, @Field("client_identifier_string") String id,
                     @Field("verification_type") String verificationType,
                     Callback<DeviceRegistrationResponse> cb) {
    final DeviceRegistrationResponse data = createDeviceRegistrationResponse();
    final Response response = new Response("/1.1/device/register.json", 200, "ok",
            Collections.<Header>emptyList(), new TypedByteArray("application/json",
            new Gson().toJson(data).getBytes()));
    cb.success(data, response);
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:14,代碼來源:MockApiInterface.java

示例10: deleteAll

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void deleteAll(@Body String body, Callback<Response> cb) {
    final Response response = new Response("/1.1/contacts/destroy/all.json", 200, "ok",
            Collections.<Header>emptyList(), new TypedByteArray("application/json",
    new Gson().toJson("response").getBytes()));
    final Result data = new Result(null, response);
    cb.success(data);
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:9,代碼來源:MockApiInterface.java

示例11: setupCallbackWrapperTest

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
private void setupCallbackWrapperTest(String responseStr,
                                      Callback<OAuthResponse> authResponseCallback) throws IOException {
    final Callback<ResponseBody> callbackWrapper = service.getCallbackWrapper(authResponseCallback);
    final ResponseBody responseBody = ResponseBody.create(MediaType.parse("application/json"), responseStr);
    final Response<ResponseBody> response = Response.success(responseBody);

    callbackWrapper.success(new Result<>(responseBody, response));
}
 
開發者ID:twitter,項目名稱:twitter-kit-android,代碼行數:9,代碼來源:OAuth1aServiceTest.java

示例12: next

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void next(Long sinceId, Callback<TimelineResult<TestItem>> cb) {
    final List<TestItem> testItems = new ArrayList<>();
    TestItem.populateList(testItems, numItems);
    final TimelineResult<TestItem> timelineResult
            = new TimelineResult<>(new TimelineCursor(minPosition, maxPosition), testItems);
    cb.success(new Result<>(timelineResult, null));
}
 
開發者ID:twitter,項目名稱:twitter-kit-android,代碼行數:9,代碼來源:TimelineDelegateTest.java

示例13: previous

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Override
public void previous(Long maxId, Callback<TimelineResult<TestItem>> cb) {
    final List<TestItem> testItems = new ArrayList<>();
    TestItem.populateList(testItems, numItems);
    final TimelineResult<TestItem> timelineResult
            = new TimelineResult<>(new TimelineCursor(minPosition, maxPosition), testItems);
    cb.success(new Result<>(timelineResult, null));
}
 
開發者ID:twitter,項目名稱:twitter-kit-android,代碼行數:9,代碼來源:TimelineDelegateTest.java

示例14: testSignupSuccess

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Test
public void testSignupSuccess() {
    LoginOrSignupComposer loginOrSignupComposer = new LoginOrSignupComposer(context,
            digitsClient, sessionManager, PHONE_WITH_COUNTRY_CODE, Verification.sms, true,
            resultReceiver, activityClassManager, digitsEventDetailsBuilder){
        @Override
        public void success(final Intent intent){
            assertExpectedSignupIntent(intent);
        }

        @Override
        public void failure(DigitsException digitsException) {
            assertTrue(false);
        }
    };

    loginOrSignupComposer.start();

    //Simulate Auth failure
    verify(digitsClient).authDevice(anyString(), any(Verification.class),
            callbackCaptor.capture());
    final Callback loginCallback = callbackCaptor.getValue();
    loginCallback.failure(couldNotAuthenticateException);

    //Simulate Signup success
    verify(digitsClient).registerDevice(anyString(), any(Verification.class),
            callbackCaptor.capture());
    final Callback signupCallback = callbackCaptor.getValue();
    signupCallback.success(new Result(deviceRegistrationResponse, null));
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:31,代碼來源:LoginOrSignupComposerTest.java

示例15: testLoginSuccess_authConfigNull

import com.twitter.sdk.android.core.Callback; //導入方法依賴的package包/類
@Test
public void testLoginSuccess_authConfigNull() {
    authResponse.authConfig = null;
    LoginOrSignupComposer loginOrSignupComposer = new LoginOrSignupComposer(context,
            digitsClient, sessionManager, PHONE_WITH_COUNTRY_CODE, Verification.sms, true,
            resultReceiver, activityClassManager, digitsEventDetailsBuilder){
        @Override
        public void success(final Intent intent){
            assertEquals(true, intent.getBooleanExtra(DigitsClient.EXTRA_EMAIL, false));
            assertNull(intent.getParcelableExtra(DigitsClient.EXTRA_AUTH_CONFIG));
            assertEquals(PHONE_WITH_COUNTRY_CODE,
                    intent.getStringExtra(DigitsClient.EXTRA_PHONE));
        }

        @Override
        public void failure(DigitsException digitsException) {
            assertTrue(false);
        }
    };

    loginOrSignupComposer.start();

    //Simulate Auth success
    verify(digitsClient).authDevice(anyString(), any(Verification.class),
            callbackCaptor.capture());
    final Callback loginCallback = callbackCaptor.getValue();
    loginCallback.success(new Result(authResponse, null));
}
 
開發者ID:crashlytics,項目名稱:digits-android,代碼行數:29,代碼來源:LoginOrSignupComposerTest.java


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