本文整理汇总了Java中org.researchstack.skin.DataResponse类的典型用法代码示例。如果您正苦于以下问题:Java DataResponse类的具体用法?Java DataResponse怎么用?Java DataResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataResponse类属于org.researchstack.skin包,在下文中一共展示了DataResponse类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> initialize(Context context)
{
return Observable.defer(() -> {
userSessionInfo = loadUserSession(context);
signedIn = userSessionInfo != null;
buildRetrofitService(userSessionInfo);
return Observable.just(new DataResponse(true, null));
}).doOnNext(response -> {
// will crash if the user hasn't created a pincode yet, need to fix needsAuth()
if(StorageAccess.getInstance().hasPinCode(context))
{
checkForTempConsentAndUpload(context);
uploadPendingFiles(context);
}
});
}
示例2: withdrawConsent
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> withdrawConsent(Context context, String reason)
{
return service.withdrawConsent(getStudyId(), new WithdrawalBody(reason))
.compose(ObservableUtils.applyDefault())
.doOnNext(response -> {
if(response.isSuccess())
{
userSessionInfo.setConsented(false);
saveUserSession(context, userSessionInfo);
buildRetrofitService(userSessionInfo);
}
else
{
handleError(context, response.code());
}
})
.map(response -> new DataResponse(response.isSuccess(), response.message()));
}
示例3: initialize
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> initialize(Context context)
{
return Observable.defer(() -> {
userSessionInfo = loadUserSession(context);
signedIn = userSessionInfo != null;
buildRetrofitService(userSessionInfo);
return Observable.just(new DataResponse(true, null));
}).doOnNext(response -> {
// will crash if the user hasn't created a pincode yet, need to fix needsAuth()
if(StorageAccess.getInstance().hasPinCode(context))
{
uploadPendingFiles(context);
}
});
}
示例4: withdrawConsent
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> withdrawConsent(Context context, String reason)
{
return service.withdrawConsent(MOLE_MAPPER_SUBPOPULATION_GUID, new WithdrawalBody(reason))
.compose(ObservableUtils.applyDefault())
.doOnNext(response -> {
if(response.isSuccess())
{
// setting everything as if they had skipped consent
clearUserSession(context);
userSessionInfo = null;
signedIn = false;
AppPrefs.getInstance(context).setSkippedOnboarding(true);
buildRetrofitService(userSessionInfo);
}
else
{
handleError(context, response.code());
}
})
.map(response -> new DataResponse(response.isSuccess(), response.message()));
}
示例5: forgotPassword
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> forgotPassword(Context context, String email)
{
return service.requestResetPassword(new EmailBody(getStudyId(), email)).map(response -> {
if(response.isSuccess())
{
return new DataResponse(true, response.body().getMessage());
}
else
{
return new DataResponse(false, response.message());
}
});
}
示例6: signIn
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> signIn(Context context, String username, String password)
{
SignInBody body = new SignInBody(getStudyId(), username, password);
// response 412 still has a response body, so catch all http errors here
return service.signIn(body).doOnNext(response -> {
if(response.code() == 200)
{
userSessionInfo = response.body();
}
else if(response.code() == 412)
{
try
{
String errorBody = response.errorBody().string();
userSessionInfo = gson.fromJson(errorBody, UserSessionInfo.class);
}
catch(IOException e)
{
throw new RuntimeException("Error deserializing server sign in response");
}
}
if(userSessionInfo != null)
{
// if we are direct from signing in, we need to load the user profile object
// from the server. that wouldn't work right now
signedIn = true;
saveUserSession(context, userSessionInfo);
buildRetrofitService(userSessionInfo);
uploadPendingFiles(context);
}
}).map(response -> {
boolean success = response.isSuccess() || response.code() == 412;
return new DataResponse(success, response.message());
});
}
示例7: signIn
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> signIn(Context context, String username, String password)
{
SignInBody body = new SignInBody(getStudyId(), username, password);
// response 412 still has a response body, so catch all http errors here
return service.signIn(body).doOnNext(response -> {
if(response.code() == 200)
{
userSessionInfo = response.body();
}
else if(response.code() == 412)
{
try
{
String errorBody = response.errorBody().string();
userSessionInfo = gson.fromJson(errorBody, UserSessionInfo.class);
}
catch(IOException e)
{
throw new RuntimeException("Error deserializing server sign in response");
}
}
if(userSessionInfo != null)
{
// if we are direct from signing in, we need to load the user profile object
// from the server. that wouldn't work right now
signedIn = true;
saveUserSession(context, userSessionInfo);
buildRetrofitService(userSessionInfo);
checkForTempConsentAndUpload(context);
uploadPendingFiles(context);
}
}).map(response -> {
boolean success = response.isSuccess() || response.code() == 412;
return new DataResponse(success, response.message());
});
}
示例8: signOut
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> signOut(Context context)
{
return service.signOut().map(response -> new DataResponse(response.isSuccess(), null));
}
示例9: resendEmailVerification
import org.researchstack.skin.DataResponse; //导入依赖的package包/类
@Override
public Observable<DataResponse> resendEmailVerification(Context context, String email)
{
EmailBody body = new EmailBody(getStudyId(), email);
return service.resendEmailVerification(body);
}