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


Java DoneCallback类代码示例

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


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

示例1: createThreadWithUsers

import org.jdeferred.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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.DoneCallback; //导入依赖的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: CRUD

import org.jdeferred.DoneCallback; //导入依赖的package包/类
@Test
public void CRUD() {

    Code code = new Code();

    try {

        code.save().then(new DoneCallback<Response>() {
            @Override
            public void onDone(Response result) {
                int status = result.getStatus();

            }

        });
    } catch (ModelStateError modelStateError) {
        modelStateError.printStackTrace();
    }
}
 
开发者ID:EhsanMashhadi,项目名称:RepositoryPattern,代码行数:20,代码来源:CodeTest.java

示例10: setListPreferenceData

import org.jdeferred.DoneCallback; //导入依赖的package包/类
protected static void setListPreferenceData(final ListPreference lp, Promise p) {
    p.done(new DoneCallback() {
        @Override
        public void onDone(Object result) {
            Map<String, Country> countries = (Map<String, Country>) result;

            List<String> entries = new ArrayList<>();
            for (Country c : countries.values()) {
                if (c.getNativeName().equals(c.getName())) {
                    entries.add(c.getNativeName());
                } else {
                    entries.add(c.getNativeName() + " (" + c.getName() + ")");
                }
            }

            lp.setEntries(entries.toArray(new CharSequence[entries.size()]));
            lp.setEntryValues(countries.keySet().toArray(new CharSequence[entries.size()]));
            lp.setDefaultValue("AT");
            bindPreferenceSummaryToValue(lp);
        }
    });
}
 
开发者ID:feberhard,项目名称:LLAMA,代码行数:23,代码来源:SettingsActivity.java

示例11: setDataOnView

import org.jdeferred.DoneCallback; //导入依赖的package包/类
@Override
public void setDataOnView(Message msg, IUserService userService) {
    this.msg = msg;
    if (this.preferedLanguage != null && !msg.getLanguage().equals(this.preferedLanguage)) {
        this.radioGroup.setVisibility(View.VISIBLE);
    }

    Map<String, String> translations = msg.getTranslations();
    if (translations != null && translations.containsKey(preferedLanguage)) {
        txtMessage.setText(translations.get(preferedLanguage));
        this.radioGroup.check(R.id.message_btnLanguage);
    } else {
        txtMessage.setText(msg.getMessage());
    }

    userService.getUserInfo(msg.getUser()).done(new DoneCallback() {
        @Override
        public void onDone(Object result) {
            txtUsername.setText(((User) result).getName());
        }
    });

    txtTimestamp.setText(msg.getTimeString());
}
 
开发者ID:feberhard,项目名称:LLAMA,代码行数:25,代码来源:MessageViewHolder.java

示例12: writeCharacteristicSuccessfully

import org.jdeferred.DoneCallback; //导入依赖的package包/类
@Test
public void writeCharacteristicSuccessfully() throws Exception {
    mBletia.writeCharacteristic(mCharacteristic)
            .then(new DoneCallback<BluetoothGattCharacteristic>() {
                @Override
                public void onDone(BluetoothGattCharacteristic result) {
                    assertThat(result.getUuid()).isEqualTo(mCharacteristic.getUuid());
                    mLatch.countDown();
                }
            }).fail(mNeverCalledFailCallback);

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

示例13: readCharacteristicSuccessfully

import org.jdeferred.DoneCallback; //导入依赖的package包/类
@Test
public void readCharacteristicSuccessfully() throws Exception {
    mBletia.readCharacteristic(mCharacteristic)
            .then(new DoneCallback<BluetoothGattCharacteristic>() {
                @Override
                public void onDone(BluetoothGattCharacteristic result) {
                    assertThat(result.getUuid()).isEqualTo(mCharacteristic.getUuid());
                    mLatch.countDown();
                }
            }).fail(mNeverCalledFailCallback);

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

示例14: readDescriptorSuccessfully

import org.jdeferred.DoneCallback; //导入依赖的package包/类
@Test
public void readDescriptorSuccessfully() throws Exception {
    mBletia.readDescriptor(mDescriptor)
            .then(new DoneCallback<BluetoothGattDescriptor>() {
                @Override
                public void onDone(BluetoothGattDescriptor result) {
                    assertThat(result.getUuid()).isEqualTo(mDescriptor.getUuid());
                    mLatch.countDown();
                }
            })
            .fail(mNeverCalledFailCallback);

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

示例15: disableNotificationSuccessfully

import org.jdeferred.DoneCallback; //导入依赖的package包/类
@Test
public void disableNotificationSuccessfully() throws Exception {
    mBletia.enableNotification(mCharacteristic, false)
            .done(new DoneCallback<BluetoothGattCharacteristic>() {
                @Override
                public void onDone(BluetoothGattCharacteristic result) {
                    mLatch.countDown();
                }
            })
            .fail(mNeverCalledFailCallback);

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


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