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


Java FailCallback类代码示例

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


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

示例1: createThreadWithUsers

import org.jdeferred.FailCallback; //导入依赖的package包/类
/** Create or fetch chat for users. Opens the chat if wanted.*/
protected Promise<BThread, BError, Void>  createThreadWithUsers(String name, final boolean openChatWhenDone, BUser... users) {
    return getNetworkAdapter().createThreadWithUsers(name, users)
            .done(new DoneCallback<BThread>() {
                @Override
                public void onDone(BThread thread) {
                    if (thread != null) {
                        if (openChatWhenDone)
                            startChatActivityForID(thread.getId());
                    }
                }
            })
            .fail(new FailCallback<BError>() {
                @Override
                public void onFail(BError error) {
                    if (isOnMainThread())
                        showAlertToast(getString(R.string.create_thread_with_users_fail_toast));
                    else getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showAlertToast(getString(R.string.create_thread_with_users_fail_toast));
                        }
                    });
                }
            });
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:27,代码来源:ChatSDKBaseFragment.java

示例2: call

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Override
public Object call() throws Exception {
    getNetworkAdapter().deleteThreadWithEntityID(threadID)
            .done(new DoneCallback<Void>() {
                @Override
                public void onDone(Void aVoid) {
                    showToast( getString(R.string.delete_thread_success_toast) );
                    refreshOnBackground();
                }
            })
            .fail(new FailCallback<BError>() {
                @Override
                public void onFail(BError error) {
                    showAlertToast(  getString(R.string.delete_thread_fail_toast)  );
                }
            });

    return null;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:20,代码来源:ChatSDKBaseFragment.java

示例3: uploadImageWithoutThumbnail

import org.jdeferred.FailCallback; //导入依赖的package包/类
public Promise<String, BError, SaveImageProgress> uploadImageWithoutThumbnail(final Bitmap image) {

        if(image == null) return reject();

        final Deferred<String, BError, SaveImageProgress> deferred = new DeferredObject<String, BError, SaveImageProgress>();

        uploadHandler.uploadFile(ImageUtils.getImageByteArray(image), "image.jpg", "image/jpeg")
                .done(new DoneCallback<String>() {
                    @Override
                    public void onDone(String url) {
                        deferred.resolve(url);
                    }
                })
                .fail(new FailCallback<BError>() {
                    @Override
                    public void onFail(BError error) {
                        deferred.reject(error);
                    }
                });

        return deferred.promise();
    }
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:23,代码来源:AbstractNetworkAdapter.java

示例4: passwordLogin

import org.jdeferred.FailCallback; //导入依赖的package包/类
public void passwordLogin(){
    if (!checkFields())
        return;

    showProgDialog(getString(R.string.connecting));

    Map<String, Object> data = AbstractNetworkAdapter.getMap(
            new String[]{BDefines.Prefs.LoginTypeKey, BDefines.Prefs.LoginEmailKey, BDefines.Prefs.LoginPasswordKey},
            BDefines.BAccountType.Password, etEmail.getText().toString(), etPass.getText().toString());

    BNetworkManager.sharedManager().getNetworkAdapter()
            .authenticateWithMap(data).done(new DoneCallback<Object>() {
        @Override
        public void onDone(Object o) {
            afterLogin();
        }
    }).fail(new FailCallback<BError>() {
        @Override
        public void onFail(BError bError) {
            toastErrorMessage(bError, true);
            dismissProgDialog();
        }
    });
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:25,代码来源:ChatSDKAbstractLoginActivity.java

示例5: register

import org.jdeferred.FailCallback; //导入依赖的package包/类
public void register(){
    if (!checkFields())
        return;
    showProgDialog(getString(R.string.registering));

    Map<String, Object> data = AbstractNetworkAdapter.getMap(
            new String[]{BDefines.Prefs.LoginTypeKey, BDefines.Prefs.LoginEmailKey, BDefines.Prefs.LoginPasswordKey },
            BDefines.BAccountType.Register, etEmail.getText().toString(), etPass.getText().toString());

    BNetworkManager.sharedManager().getNetworkAdapter()
            .authenticateWithMap(data).done(new DoneCallback<Object>() {
        @Override
        public void onDone(Object o) {
            afterLogin();
        }
    }).fail(new FailCallback<BError>() {
        @Override
        public void onFail(BError bError) {
            toastErrorMessage(bError, false);
            dismissProgDialog();
        }
    });
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:24,代码来源:ChatSDKAbstractLoginActivity.java

示例6: anonymosLogin

import org.jdeferred.FailCallback; //导入依赖的package包/类
public void anonymosLogin(){
    showProgDialog(getString(R.string.connecting));

    Map<String, Object> data = new HashMap<String, Object>();
    data.put(BDefines.Prefs.LoginTypeKey, BDefines.BAccountType.Anonymous);

    BNetworkManager.sharedManager().getNetworkAdapter()
            .authenticateWithMap(data).done(new DoneCallback<Object>() {
        @Override
        public void onDone(Object o) {
            afterLogin();
        }
    }).fail(new FailCallback<BError>() {
        @Override
        public void onFail(BError bError) {
            toastErrorMessage(bError, false);
            dismissProgDialog();
        }
    });
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:21,代码来源:ChatSDKAbstractLoginActivity.java

示例7: handleMessage

import org.jdeferred.FailCallback; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void handleMessage(Message msg) {
	CallbackMessage<?, ?, ?, ?> result = (CallbackMessage<?, ?, ?, ?>) msg.obj;
	switch (msg.what) {
	case MESSAGE_POST_DONE:
		((DoneCallback) result.callback).onDone(result.resolved);
		break;
	case MESSAGE_POST_PROGRESS:
		((ProgressCallback) result.callback)
				.onProgress(result.progress);
		break;
	case MESSAGE_POST_FAIL:
		((FailCallback) result.callback).onFail(result.rejected);
		break;
	case MESSAGE_POST_ALWAYS:
		((AlwaysCallback) result.callback).onAlways(result.state,
				result.resolved, result.rejected);
		break;
	}
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:22,代码来源:AndroidDeferredObject.java

示例8: login

import org.jdeferred.FailCallback; //导入依赖的package包/类
public Deferred login(Map<String, Object> credentials) throws AlreadyAuthenticatedError {

        if (authenticator.isAuthenticated()) {
            throw new AlreadyAuthenticatedError();
        }

        final Deferred deferred = this.request("sessions", "POST").addParameters(credentials).send();

        deferred.then(new DoneCallback<Response>() {
            @Override
            public void onDone(Response response) {
                getAuthenticator().setToken(response.getField("token"));
                deferred.resolve(response);
            }
        }).fail(new FailCallback<Response>() {
            @Override
            public void onFail(Response result) {
                deferred.reject(result);
            }
        });

        return deferred;
    }
 
开发者ID:EhsanMashhadi,项目名称:RepositoryPattern,代码行数:24,代码来源:RestAdapter.java

示例9: writeCharacteristicFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void writeCharacteristicFailure() throws Exception {
    mBletia.writeCharacteristic(mCharacteristic)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.FAILURE);
                    assertThat(result.getAction()).isInstanceOf(WriteCharacteristicAction.class);
                    mLatch.countDown();
                }
            });

    Thread.sleep(300);
    mCallbackHandler.onCharacteristicWrite(
            mBluetoothGattWrapper, mCharacteristic, BluetoothGatt.GATT_FAILURE);
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:19,代码来源:BletiaTest.java

示例10: readCharacteristicFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void readCharacteristicFailure() throws Exception {
    mBletia.readCharacteristic(mCharacteristic)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.FAILURE);
                    assertThat(result.getAction()).isInstanceOf(ReadCharacteristicAction.class);
                    mLatch.countDown();
                }
            });

    Thread.sleep(300);
    mCallbackHandler.onCharacteristicRead(
            mBluetoothGattWrapper, mCharacteristic, BluetoothGatt.GATT_FAILURE);
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:19,代码来源:BletiaTest.java

示例11: writeDescriptorFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void writeDescriptorFailure() throws Exception {
    mBletia.writeDescriptor(mDescriptor)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.FAILURE);
                    assertThat(result.getAction()).isInstanceOf(WriteDescriptorAction.class);
                    mLatch.countDown();
                }
            });

    Thread.sleep(300);
    mCallbackHandler.onDescriptorWrite(
            mBluetoothGattWrapper, mDescriptor, BluetoothGatt.GATT_FAILURE);
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:19,代码来源:BletiaTest.java

示例12: readDescriptorFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void readDescriptorFailure() throws Exception {
    mBletia.readDescriptor(mDescriptor)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.FAILURE);
                    assertThat(result.getAction()).isInstanceOf(ReadDescriptorAction.class);
                    mLatch.countDown();
                }
            });

    Thread.sleep(300);
    mCallbackHandler.onDescriptorRead(
            mBluetoothGattWrapper, mDescriptor, BluetoothGatt.GATT_FAILURE);
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:19,代码来源:BletiaTest.java

示例13: enableNotificationWhenOperationFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void enableNotificationWhenOperationFailure() throws Exception {
    mBletia.enableNotification(mCharacteristic, true)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.FAILURE);
                    assertThat(result.getAction()).isInstanceOf(EnableNotificationAction.class);
                    mLatch.countDown();
                }
            });

    Thread.sleep(300);
    verify(mBluetoothGattWrapper, times(1)).writeDescriptor(mDescriptor);
    mCallbackHandler.onDescriptorWrite(
            mBluetoothGattWrapper, mDescriptor, BluetoothGatt.GATT_FAILURE);
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:20,代码来源:BletiaTest.java

示例14: disableNotificationWhenRequestFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void disableNotificationWhenRequestFailure() throws Exception {
    when(mBluetoothGattWrapper.setCharacteristicNotification(eq(mCharacteristic), anyBoolean())).thenReturn(false);
    mBletia.enableNotification(mCharacteristic, false)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.REQUEST_FAILURE);
                    assertThat(result.getAction()).isInstanceOf(EnableNotificationAction.class);
                    mLatch.countDown();
                    mLatch.countDown();
                }
            });
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:17,代码来源:BletiaTest.java

示例15: disableNotificationWhenOperationFailure

import org.jdeferred.FailCallback; //导入依赖的package包/类
@Test
public void disableNotificationWhenOperationFailure() throws Exception {
    mBletia.enableNotification(mCharacteristic, false)
            .done(mNeverCalledDoneCallback)
            .fail(new FailCallback<BletiaException>() {
                @Override
                public void onFail(BletiaException result) {
                    assertThat(result.getType()).isEqualTo(BleErrorType.FAILURE);
                    assertThat(result.getAction()).isInstanceOf(EnableNotificationAction.class);
                    mLatch.countDown();
                }
            });

    Thread.sleep(300);
    verify(mBluetoothGattWrapper, times(1)).writeDescriptor(mDescriptor);
    mCallbackHandler.onDescriptorWrite(
            mBluetoothGattWrapper, mDescriptor, BluetoothGatt.GATT_FAILURE);
    await();
}
 
开发者ID:izumin5210,项目名称:Bletia,代码行数:20,代码来源:BletiaTest.java


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