package com.kfzs.duanduan.utils.net;

import com.android.volleyplus.Response;
import com.kfzs.duanduan.proto.ApiResponseOuterClass;

/**
 * Created by HooRang on 2017/3/1.
 */
public abstract class ResponseNetworkTask implements Response.Listener<ApiResponseOuterClass.ApiResponse> {

    @Override
    public void onResponse(ApiResponseOuterClass.ApiResponse apiResponse) {
        int code = apiResponse.getCodeValue();
        switch (code) {
            case ApiResponseOuterClass.Codes.Success_VALUE:
                onSuccess(apiResponse);
                break;

            default:
                onFail(code, apiResponse.getMsg());
                break;
        }

    }

    public abstract void onSuccess(ApiResponseOuterClass.ApiResponse apiResponse);


    public abstract void onFail(int code, String msg);
}
