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


Java DataResponse类代码示例

本文整理汇总了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);
        }
    });
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:20,代码来源:BridgeDataProvider.java

示例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()));
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:20,代码来源:BridgeDataProvider.java

示例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);
        }
    });
}
 
开发者ID:ResearchStack,项目名称:MoleMapperAndroid,代码行数:19,代码来源:BridgeDataProvider.java

示例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()));
}
 
开发者ID:ResearchStack,项目名称:MoleMapperAndroid,代码行数:23,代码来源:BridgeDataProvider.java

示例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());
        }
    });
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:15,代码来源:BridgeDataProvider.java

示例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());
    });
}
 
开发者ID:ResearchStack,项目名称:MoleMapperAndroid,代码行数:41,代码来源:BridgeDataProvider.java

示例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());
    });
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:42,代码来源:BridgeDataProvider.java

示例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));
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:6,代码来源:BridgeDataProvider.java

示例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);
}
 
开发者ID:daviszhou,项目名称:BeaconTrackerAndroid,代码行数:7,代码来源:BridgeDataProvider.java


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