• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Callback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: registerToJUPS

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * Register PushRegistrar to server to receive push notifications from the specified service
 *
 * @param context   Application context
 * @param registrar PushRegistrar configured for specific application variant
 * @throws RegistrationException
 */
private static void registerToJUPS(final Context context, final PushRegistrar registrar)
        throws RegistrationException {
    registrar.register(context, new Callback<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            Log.i(TAG, "JUPS registration successful");
            RegistrarManager.registerBackgroundThreadHandler(messageHandler);
        }

        @Override
        public void onFailure(Exception e) {
            Log.w(TAG, "Registration to JUPS failed: " + e);
        }
    });
}
 
开发者ID:SLAMon,项目名称:SLAMon,代码行数:23,代码来源:SLAMonPushNotificationManager.java


示例2: unregisterFromJUPS

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * Unregister from receiving push notifications from JBoss Unified Push Server for specified application variant
 *
 * @param context    Application context
 * @param configName Variant config name to unregister
 */
private static void unregisterFromJUPS(final Context context, final String configName) {
    PushRegistrar registrar = RegistrarManager.getRegistrar(configName);
    registrar.unregister(context, new Callback<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            Log.i(TAG, "Successfully unregistered from JUPS");
            RegistrarManager.unregisterBackgroundThreadHandler(messageHandler);
        }

        @Override
        public void onFailure(Exception e) {
            Log.i(TAG, "Failed to unregister from JUPS: " + e);
        }
    });
}
 
开发者ID:SLAMon,项目名称:SLAMon,代码行数:22,代码来源:SLAMonPushNotificationManager.java


示例3: open

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
public void open(final Callback<EncryptedSQLStore<T>> onReady) {
    new AsyncTask<Void, Void, Void>() {
        private Exception exception;

        @Override
        protected Void doInBackground(Void... params) {
            try {
                EncryptedSQLStore.this.database = getWritableDatabase();
            } catch (Exception e) {
                this.exception = e;
                Log.e(TAG, "There was an error loading the database", e);
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            if (exception != null) {
                onReady.onFailure(exception);
            } else {
                onReady.onSuccess(EncryptedSQLStore.this);
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:26,代码来源:EncryptedSQLStore.java


示例4: open

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
public void open(final Callback<SQLStore<T>> onReady) {
    new AsyncTask<Void, Void, Void>() {
        private Exception exception;

        @Override
        protected Void doInBackground(Void... params) {
            try {
                SQLStore.this.database = getWritableDatabase();
            } catch (Exception e) {
                this.exception = e;
                Log.e(TAG, "There was an error loading the database", e);
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            if (exception != null) {
                onReady.onFailure(exception);
            } else {
                onReady.onSuccess(SQLStore.this);
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:26,代码来源:SQLStore.java


示例5: testSuccessCallback

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@Test
public void testSuccessCallback() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(2);
    ((SQLStore) store).open(new Callback<SQLStore<Data>>() {
        @Override
        public void onSuccess(SQLStore<Data> data) {
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            throw new RuntimeException(e);
        }
    });

    Assert.assertFalse("OnSuccess should be called exactly once!", latch.await(5, TimeUnit.SECONDS));

}
 
开发者ID:aerogear,项目名称:aerogear-android-store,代码行数:19,代码来源:SQLStoreTest.java


示例6: requestAccess

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@Override
public void requestAccess(final Activity activity, final Callback<String> callback) {

    final String state = UUID.randomUUID().toString();

    final OAuth2AuthzService.AGAuthzServiceConnection connection = new OAuth2AuthzService.AGAuthzServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName className, IBinder iBinder) {
            super.onServiceConnected(className, iBinder);
            doRequestAccess(state, activity, callback, this);
        }

    };

    activity.bindService(new Intent(activity.getApplicationContext(), OAuth2AuthzService.class
            ), connection, Context.BIND_AUTO_CREATE
            );

}
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:21,代码来源:OAuth2WebViewAuthzModule.java


示例7: requestAccess

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@Override
public void requestAccess(final Activity activity, final Callback<String> callback) {
    final String state = UUID.randomUUID().toString();

    final OAuth2AuthzService.AGAuthzServiceConnection connection = new OAuth2AuthzService.AGAuthzServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName className, IBinder iBinder) {
            super.onServiceConnected(className, iBinder);
            doRequestAccess(state, activity, callback, this);
        }

    };

    activity.bindService(new Intent(activity.getApplicationContext(), OAuth2AuthzService.class
    ), connection, Context.BIND_AUTO_CREATE
    );
}
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:19,代码来源:OAuth2IntentAuthzModule.java


示例8: testRequestAccess

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@SuppressWarnings("WrongConstant")
@Test
public void testRequestAccess() {
    OAuth2AuthorizationConfiguration config = AuthorizationManager.config("name", OAuth2AuthorizationConfiguration.class);
    config.setBaseURL(BASE_URL);
    OAuth2AuthzModule module = (OAuth2AuthzModule) config.asModule();
    
    Activity mockActivity = mock(Activity.class);
    Callback mockCallback = mock(Callback.class);
    when(mockActivity.bindService(any(Intent.class), any(ServiceConnection.class), any(Integer.class))).thenReturn(Boolean.TRUE);
    when(mockActivity.getApplicationContext()).thenReturn(mockActivity);
    module.requestAccess(mockActivity, mockCallback);

    Mockito.verify(mockActivity, times(1)).bindService((Intent) any(), (ServiceConnection) any(), any(Integer.class));

}
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:17,代码来源:OAuth2AuthzModuleTest.java


示例9: testIntentPutsAccountOnModule

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * If the OAuth2 Config Object has withIntent set then asModule should return
 * a OAuth2IntentAuthzModule instance.
 */
@Test
public void testIntentPutsAccountOnModule() throws Exception {
    OAuth2AuthorizationConfiguration config = AuthorizationManager.config("name", OAuth2AuthorizationConfiguration.class);
    config.setBaseURL(BASE_URL);
    config.setAccountId("ignore");
    config.setWithIntent(true);
    AuthzModule module = config.asModule();
    Assert.assertNull(UnitTestUtils.getSuperPrivateField(module, "account"));

    Method doRequestAccessMethod = OAuth2IntentAuthzModule.class.getDeclaredMethod("doRequestAccess", String.class, Activity.class, Callback.class, OAuth2AuthzService.AGAuthzServiceConnection.class);
    OAuth2AuthzService.AGAuthzServiceConnection mockConnection = mock(OAuth2AuthzService.AGAuthzServiceConnection.class);
    OAuth2AuthzService mockService = mock(OAuth2AuthzService.class);
    
    Mockito.doReturn(mock(OAuth2AuthzSession.class)).when(mockService).getAccount(any(String.class));
    Mockito.doReturn(true).when(mockService).hasAccount(any(String.class));
    Mockito.doReturn("testToken").when(mockService).fetchAccessToken(any(String.class), any(OAuth2Properties.class));
    
    Mockito.doReturn(mockService).when(mockConnection).getService();
    Looper.prepare();
    
    doRequestAccessMethod.setAccessible(true);
    doRequestAccessMethod.invoke(module, "ignore", mock(Activity.class), mock(Callback.class), mockConnection);
    Assert.assertNotNull(UnitTestUtils.getSuperPrivateField(module, "account"));
    
}
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:30,代码来源:IntentOAuth2AuthzModuleTest.java


示例10: read

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@Override
public void read(final String id, final Callback<T> callback) {
    THREAD_POOL_EXECUTOR.execute(new Runnable() {
        T result = null;
        Exception exception = null;

        @Override
        public void run() {
            try {
                HeaderAndBody response = restRunner.onRawRead(RestAdapter.this, id);
                List<T> resultList = getResponseParser().handleResponse(response, klass);
                this.result = resultList.get(0);
            } catch (Exception e) {
                Log.e(TAG, e.getMessage(), e);
                this.exception = e;
            }
            if (exception == null) {
                callback.onSuccess(this.result);
            } else {
                callback.onFailure(exception);
            }
        }
    });
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:25,代码来源:RestAdapter.java


示例11: remove

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void remove(final String id, final Callback<Void> callback) {

    THREAD_POOL_EXECUTOR.execute(new Runnable() {
        Exception exception = null;

        @Override
        public void run() {
            try {
                RestAdapter.this.restRunner.onRemove(id);
            } catch (Exception e) {
                exception = e;
            }
            if (exception == null) {
                callback.onSuccess(null);
            } else {
                callback.onFailure(exception);
            }
        }
    });

}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:26,代码来源:RestAdapter.java


示例12: runRemove

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * Runs a remove method, returns the result of the call back and makes sure
 * no exceptions are thrown
 */
private <T> void runRemove(Pipe<T> restPipe, String id)
        throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean hasException = new AtomicBoolean(false);

    restPipe.remove(id, new Callback<Void>() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSuccess(Void data) {
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            hasException.set(true);
            Logger.getLogger(LoaderAdapterTest.class.getSimpleName())
                    .log(Level.SEVERE, e.getMessage(), e);
            latch.countDown();
        }
    });

    latch.await(2, TimeUnit.SECONDS);
    Assert.assertFalse(hasException.get());
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:30,代码来源:LoaderAdapterTest.java


示例13: runSave

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
private void runSave(Pipe<ListClassId> restPipe)
        throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean hasException = new AtomicBoolean(false);

    restPipe.save(new ListClassId(true),
            new Callback<ListClassId>() {
                private static final long serialVersionUID = 1L;

                @Override
                public void onSuccess(ListClassId data) {
                    latch.countDown();
                }

                @Override
                public void onFailure(Exception e) {
                    hasException.set(true);
                    Logger.getLogger(LoaderAdapterTest.class.getSimpleName())
                            .log(Level.SEVERE, e.getMessage(), e);
                    latch.countDown();
                }
            });

    latch.await(2, TimeUnit.SECONDS);
    Assert.assertFalse(hasException.get());
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:27,代码来源:LoaderAdapterTest.java


示例14: runRead

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * Runs a read method, returns the result of the call back and makes sure no
 * exceptions are thrown
 *
 * @param restPipe
 */
private <T> List<T> runRead(Pipe<T> restPipe, ReadFilter readFilter) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean hasException = new AtomicBoolean(false);
    final AtomicReference<List<T>> resultRef = new AtomicReference<List<T>>();

    restPipe.read(readFilter, new Callback<List<T>>() {
        @Override
        public void onSuccess(List<T> data) {
            resultRef.set(data);
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            hasException.set(true);
            Logger.getLogger(RestAdapterTest.class.getSimpleName()).log(Level.SEVERE, e.getMessage(), e);
            latch.countDown();
        }
    });

    latch.await(2, TimeUnit.SECONDS);
    Assert.assertFalse(hasException.get());

    return resultRef.get();
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:32,代码来源:RestAdapterTest.java


示例15: runReadForException

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
/**
 * Runs a read method, returns the result of the call back and rethrows the
 * underlying exception
 *
 * @param restPipe
 */
private <T> List<T> runReadForException(Pipe<T> restPipe, ReadFilter readFilter) throws InterruptedException, Exception {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean hasException = new AtomicBoolean(false);
    final AtomicReference<Exception> exceptionref = new AtomicReference<Exception>();
    restPipe.read(readFilter, new Callback<List<T>>() {
        @Override
        public void onSuccess(List<T> data) {
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            hasException.set(true);
            exceptionref.set(e);
            latch.countDown();
        }
    });

    latch.await(2, TimeUnit.SECONDS);
    Assert.assertTrue(hasException.get());

    throw exceptionref.get();
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:30,代码来源:RestAdapterTest.java


示例16: testNext

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testNext() {
    Pipe pipe = mock(Pipe.class);
    ReadFilter next = new ReadFilter();
    List delegate = new ArrayList();
    ReadFilter previous = new ReadFilter();

    next.setLinkUri(URI.create("./next"));
    previous.setLinkUri(URI.create("./previous"));

    WrappingPagedList list = new WrappingPagedList(pipe, delegate, next, previous);
    list.next(mock(Callback.class));
    list.previous(mock(Callback.class));

    verify(pipe).read(eq(next), any(Callback.class));
    verify(pipe).read(eq(previous), any(Callback.class));

}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:20,代码来源:PagedListTest.java


示例17: doAuthorization

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
private void doAuthorization(OAuth2Properties config, final Callback<String> callback) throws UnsupportedEncodingException, MalformedURLException {

        URL baseURL = config.getBaseURL();
        Uri redirectURL = Uri.parse(config.getRedirectURL());
        
        URL authzURL = OAuth2Utils.buildAuthzURL(config, state);

        final OAuthWebViewDialog dialog = OAuthWebViewDialog.newInstance(authzURL, redirectURL);
        dialog.setReceiver(new OAuthWebViewDialog.OAuthReceiver() {
            @Override
            public void receiveOAuthCode(String code) {
                dialog.removeReceive();
                dialog.dismiss();
                callback.onSuccess(code);
            }

            @Override
            public void receiveOAuthError(final String error) {
                dialog.removeReceive();
                dialog.dismiss();
                callback.onFailure(new OAuth2AuthorizationException(error));
            }
        });

        dialog.setStyle(android.R.style.Theme_Light_NoTitleBar, 0);
        dialog.show(activity.getFragmentManager(), "TAG");
    }
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:28,代码来源:OAuth2WebFragmentFetchAutorization.java


示例18: testOAuth2AuthorizationCallback

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@UiThreadTest
public void testOAuth2AuthorizationCallback() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException, NoSuchFieldException, OAuth2AuthorizationException, InterruptedException {

    OAuth2AuthzService mockService = mock(OAuth2AuthzService.class);
    Activity mockActivity = mock(Activity.class);
    ServiceConnection mockServiceConnection = mock(ServiceConnection.class);

    ArgumentCaptor<OAuth2AuthzSession> sessionCaptor = ArgumentCaptor.forClass(OAuth2AuthzSession.class);

    OAuth2AuthorizationConfiguration config = AuthorizationManager.config("name", OAuth2AuthorizationConfiguration.class);
    config.setAccountId("testAccountId");
    config.setBaseURL(BASE_URL);

    OAuth2AuthzModule module = (OAuth2AuthzModule) config.asModule();
    Class<?> callbackClass = Class.forName("org.jboss.aerogear.android.authorization.oauth2.webview.OAuth2WebViewAuthzModule$OAuth2AuthorizationCallback");
    Constructor<?> constructor = callbackClass.getDeclaredConstructor(OAuth2WebViewAuthzModule.class, Activity.class, Callback.class, ServiceConnection.class);
    constructor.setAccessible(true);

    Callback callback = (Callback) constructor.newInstance(module, mockActivity, new VoidCallback(), mockServiceConnection);

    UnitTestUtils.setPrivateField(module, "service", mockService);

    callback.onSuccess("testCode");

    Mockito.verify(mockService, times(1)).addAccount(sessionCaptor.capture());
    OAuth2AuthzSession account = sessionCaptor.getValue();
    Assert.assertEquals("testCode", account.getAuthorizationCode());
}
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:30,代码来源:OAuth2AuthzModuleTest.java


示例19: testOAuth2AccessCallback

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
@UiThreadTest
public void testOAuth2AccessCallback() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
    OAuth2AuthzService mockService = mock(OAuth2AuthzService.class);
    Activity mockActivity = mock(Activity.class);
    ServiceConnection mockServiceConnection = mock(ServiceConnection.class);
    OAuth2AuthzSession account = new OAuth2AuthzSession();
    account.setAccessToken("testToken");

    when(mockService.getAccount(matches("testAccountId"))).thenReturn(account);

    OAuth2AuthorizationConfiguration config = AuthorizationManager.config("name", OAuth2AuthorizationConfiguration.class);
    config.setAccountId("testAccountId");
    config.setBaseURL(BASE_URL);

    OAuth2AuthzModule module = (OAuth2AuthzModule) config.asModule();
    Class<?> callbackClass = Class.forName("org.jboss.aerogear.android.authorization.oauth2.webview.OAuth2WebViewAuthzModule$OAuth2AccessCallback");
    Constructor<?> constructor = callbackClass.getDeclaredConstructor(OAuth2WebViewAuthzModule.class, Activity.class, Callback.class, ServiceConnection.class);
    constructor.setAccessible(true);

    Callback callback = (Callback) constructor.newInstance(module, mockActivity, new VoidCallback(), mockServiceConnection);

    UnitTestUtils.setPrivateField(module, "service", mockService);

    callback.onSuccess("testToken");

    Mockito.verify(mockActivity, times(1)).unbindService(eq(mockServiceConnection));
    Assert.assertEquals("testToken", ((OAuth2AuthzSession) UnitTestUtils.getSuperPrivateField(module, "account")).getAccessToken());
}
 
开发者ID:aerogear,项目名称:aerogear-android-authz,代码行数:30,代码来源:OAuth2AuthzModuleTest.java


示例20: ReadLoader

import org.jboss.aerogear.android.core.Callback; //导入依赖的package包/类
public ReadLoader(Context context, Callback<List<T>> callback,
                  PipeHandler<T> runner, ReadFilter filter, Pipe<T> pipe) {
    super(context, callback);
    this.filter = filter;
    this.runner = runner;
    this.requestingPipe = pipe;
}
 
开发者ID:aerogear,项目名称:aerogear-android-pipe,代码行数:8,代码来源:ReadLoader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Query类代码示例发布时间:2022-05-23
下一篇:
Java ReadableInterval类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap