org.xutils.common.Callback Java Examples

The following examples show how to use org.xutils.common.Callback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Eth.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
/**
 * 执行post请求
 *
 * @param params
 * @param blockCallback
 */
public void post(EthParams params, final BlockCallback blockCallback) {
    RequestParams requestParams = new RequestParams(EthConf.url);
    String json = params.toJson();
    requestParams.setAsJsonContent(true);
    requestParams.setBodyContent(json);
    x.http().post(requestParams, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            LogUtil.e("class Eth onSuccess >>>>>" + result);
            blockCallback.onSuccess(result);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            BlockError error = new BlockError();
            error.error = ex.toString();
            LogUtil.e("class Eth onError >>>>>" + error.error);
            blockCallback.onError(error);
        }

        @Override
        public void onCancelled(CancelledException cex) {
        }

        @Override
        public void onFinished() {
        }
    });
}
 
Example #2
Source File: Eth.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
/**
 * get请求  去访问EtherScan的api 获取列表
 *
 * @param params
 * @param callback
 */
public void get(RequestParams params, final BlockCallback callback) {
    x.http().get(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            LogUtil.e("class Eth onSuccess >>>>>" + result);
            callback.onSuccess(result);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            BlockError error = new BlockError();
            error.error = ex.toString();
            LogUtil.e("class Eth onError >>>>>" + error.error);
            callback.onError(error);
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
}
 
Example #3
Source File: Ltc.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
public void get(RequestParams params, final BlockCallback callback) {
    x.http().get(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            LogUtil.e("LTC onSuccess =" + result);
            callback.onSuccess(result);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            LogUtil.e("LTC onError =" + ex.toString());
            BlockError error = new BlockError();
            error.error = ex.toString();
            callback.onError(error);
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
}
 
Example #4
Source File: Btc.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
public void get(RequestParams params, final BlockCallback callback) {
    x.http().get(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            LogUtil.e("BTC onSuccess =" + result);
            callback.onSuccess(result);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            LogUtil.e("BTC onError =" + ex.toString());
            BlockError error = new BlockError();
            error.error = ex.toString();
            callback.onError(error);
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
}
 
Example #5
Source File: HomeActivity.java    From Google-Hosts with Apache License 2.0 5 votes vote down vote up
public void getJsonFromServer() {
    /*
    * 使用xUtils3开源框架
    * */
    //创建Request请求对象
    RequestParams params = new RequestParams(ConstantValues.URL_GET_UPDATE_MESSAGE);
    //发送request请求
    x.http().post(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            //请求成功
            Log.d("请求服务器的结果", result);
            //解析数据
            processData(result);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            //请求失败
            ex.printStackTrace();
            Log.i("请求失败的息:", ex.toString());
            //提示失败信息
            Toast.makeText(getApplicationContext(), "服务器连接失败\n请检查您的网络连接", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
}
 
Example #6
Source File: HomeActivity.java    From Google-Hosts with Apache License 2.0 5 votes vote down vote up
public void getUpdateInfoFromServer() {

        RequestParams params = new RequestParams(ConstantValues.URL_GET_NEW_APP_MESSAGE);

        //发送request请求
        x.http().post(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                //请求成功
                Log.d("请求服务器的结果", result);
                //解析数据,获取更新对象
                processAppUpdateInfo(result);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                //请求失败
                ex.printStackTrace();
                Log.i("请求失败的息:", ex.toString());
                //提示失败信息
                Toast.makeText(getApplicationContext(), "服务器连接失败\n请检查您的网络连接", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }