@Test public void loginByNameInBackground() throws Exception { final String userName = "Ncmb Tarou"; final String password = "dummyPassword"; NCMBUserService userService = getUserService(); userService.loginByNameInBackground(userName, password, new LoginCallback() { @Override public void done(NCMBUser user, NCMBException e) { Assert.assertEquals(e, null); Assert.assertEquals("dummyObjectId", user.getObjectId()); Assert.assertEquals(userName, user.getUserName()); callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void loginByNameInBackground(String userName, String password, LoginCallback callback) throws NCMBException { RequestParams reqParams = loginByNameParams(userName, password); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; NCMBUser user = null; try { getUserService().loginByNameCheckResponse(response); user = getUserService().postLoginProcess(response); } catch (NCMBException e) { error = e; } LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(user, error); } @Override public void handleError(NCMBException e) { LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(null, e); } }); }
NCMBUserService extends NCMBService { public void loginByNameInBackground(String userName, String password, LoginCallback callback) throws NCMBException { RequestParams reqParams = loginByNameParams(userName, password); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; NCMBUser user = null; try { getUserService().loginByNameCheckResponse(response); user = getUserService().postLoginProcess(response); } catch (NCMBException e) { error = e; } LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(user, error); } @Override public void handleError(NCMBException e) { LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(null, e); } }); } }
NCMBUserService extends NCMBService { public void loginByNameInBackground(String userName, String password, LoginCallback callback) throws NCMBException { RequestParams reqParams = loginByNameParams(userName, password); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; NCMBUser user = null; try { getUserService().loginByNameCheckResponse(response); user = getUserService().postLoginProcess(response); } catch (NCMBException e) { error = e; } LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(user, error); } @Override public void handleError(NCMBException e) { LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(null, e); } }); } NCMBUserService(NCMBContext context); }
NCMBUserService extends NCMBService { public void loginByNameInBackground(String userName, String password, LoginCallback callback) throws NCMBException { RequestParams reqParams = loginByNameParams(userName, password); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; NCMBUser user = null; try { getUserService().loginByNameCheckResponse(response); user = getUserService().postLoginProcess(response); } catch (NCMBException e) { error = e; } LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(user, error); } @Override public void handleError(NCMBException e) { LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(null, e); } }); } NCMBUserService(NCMBContext context); NCMBUser registerByName(String userName, String password); NCMBUser registerByName(String userName, String password,JSONObject otherFields); void saveByName(String userName, String password); void saveByName(String userName, String password,JSONObject otherFields); void registerByNameInBackground(String userName, String password, LoginCallback callback); void registerByNameInBackground(String userName, String password, JSONObject otherFields, LoginCallback callback); NCMBUser registerByOauth(JSONObject oauthOptions); void registerByOauthInBackground(JSONObject oauthOptions, LoginCallback callback); void inviteByMail(String mailAddress); void inviteByMailInBackground(String mailAddress, DoneCallback callback); void requestPasswordReset(String mailAddress); void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); NCMBUser fetchUser(String userId); void fetchUserInBackground(String userId, final FetchCallback callback); JSONObject updateUser(String userId, JSONObject params); void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback); NCMBUser loginByName(String userName, String password); void loginByNameInBackground(String userName, String password,
                                        LoginCallback callback); NCMBUser loginByMail(String mailAddress, String password); void loginByMailInBackground(String mailAddress, String password,
                                        LoginCallback callback); void deleteUser(String userId); void deleteUserInBackground(final String userId, ExecuteServiceCallback callback); void logout(); void logoutInBackground(DoneCallback callback); ArrayList<NCMBUser> searchUser(JSONObject conditions); void searchUserInBackground(JSONObject conditions, final SearchUserCallback callback); }
NCMBUserService extends NCMBService { public void loginByNameInBackground(String userName, String password, LoginCallback callback) throws NCMBException { RequestParams reqParams = loginByNameParams(userName, password); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { NCMBException error = null; NCMBUser user = null; try { getUserService().loginByNameCheckResponse(response); user = getUserService().postLoginProcess(response); } catch (NCMBException e) { error = e; } LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(user, error); } @Override public void handleError(NCMBException e) { LoginCallback loginCallback = (LoginCallback) mCallback; loginCallback.done(null, e); } }); } NCMBUserService(NCMBContext context); NCMBUser registerByName(String userName, String password); NCMBUser registerByName(String userName, String password,JSONObject otherFields); void saveByName(String userName, String password); void saveByName(String userName, String password,JSONObject otherFields); void registerByNameInBackground(String userName, String password, LoginCallback callback); void registerByNameInBackground(String userName, String password, JSONObject otherFields, LoginCallback callback); NCMBUser registerByOauth(JSONObject oauthOptions); void registerByOauthInBackground(JSONObject oauthOptions, LoginCallback callback); void inviteByMail(String mailAddress); void inviteByMailInBackground(String mailAddress, DoneCallback callback); void requestPasswordReset(String mailAddress); void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); NCMBUser fetchUser(String userId); void fetchUserInBackground(String userId, final FetchCallback callback); JSONObject updateUser(String userId, JSONObject params); void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback); NCMBUser loginByName(String userName, String password); void loginByNameInBackground(String userName, String password,
                                        LoginCallback callback); NCMBUser loginByMail(String mailAddress, String password); void loginByMailInBackground(String mailAddress, String password,
                                        LoginCallback callback); void deleteUser(String userId); void deleteUserInBackground(final String userId, ExecuteServiceCallback callback); void logout(); void logoutInBackground(DoneCallback callback); ArrayList<NCMBUser> searchUser(JSONObject conditions); void searchUserInBackground(JSONObject conditions, final SearchUserCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_REGISTERED; static final int HTTP_STATUS_AUTHORIZED; static final int HTTP_STATUS_REQUEST_ACCEPTED; }