org.xutils.http.RequestParams Java Examples

The following examples show how to use org.xutils.http.RequestParams. 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: EthBlockExplorer.java    From BlockExplorer with Apache License 2.0 6 votes vote down vote up
@Override
public void getTransactionsByAddress(String address, int page, BlockCallback callback) {
    String url = "http://api.etherscan.io/api";// 分页加载
    RequestParams params = new RequestParams(url);
    params.addQueryStringParameter("module", "account");
    params.addQueryStringParameter("action", "txlist");
    params.addQueryStringParameter("address", address);
    params.addQueryStringParameter("startblock", "0");
    params.addQueryStringParameter("endblock", "99999999");
    params.addQueryStringParameter("page", String.valueOf(page));
    params.addQueryStringParameter("offset", "10");//每页十条信息
    params.addQueryStringParameter("sort", "asc");
    params.addQueryStringParameter("apikey", "YourApiKeyToken");
    LogUtil.e("ETH Url =" + params.getUri());
    get(params, callback);
}
 
Example #2
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
@Override
public void getTransactionsByAddress(String address, int page, BlockCallback callback) {
    RequestParams params = new RequestParams(URL+BtcConf.GET_TXS.replace("{address}", address));
    int from = page * 10;
    int to = from + 10;//TODO:test
    params.addQueryStringParameter("from", String.valueOf(from));//默认每次取10条
    params.addQueryStringParameter("to", String.valueOf(to));
    params.addQueryStringParameter("noAsm", "1");
    params.addQueryStringParameter("noScriptSig", "1");
    params.addQueryStringParameter("noSpent", "1");
    LogUtil.e("BTC Url =" + params.getUri());
    get(params, callback);
}
 
Example #3
Source File: XUtil3HttpUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 下载文件
 * @param <T>
 */
public static <T> Cancelable DownLoadFile(String url,String filepath,CommonCallback<T> callback){
	RequestParams params=new RequestParams(url);
	//设置断点续传
	params.setAutoResume(true);
	params.setSaveFilePath(filepath);
	Cancelable cancelable = x.http().get(params, callback);
	return cancelable;
}
 
Example #4
Source File: XUtil3HttpUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 上传文件
 * @param <T>
 */
public static <T> Cancelable UpLoadFile(String url,Map<String,Object> map,CommonCallback<T> callback){
	RequestParams params=new RequestParams(url);
	if(null!=map){
		for(Map.Entry<String, Object> entry : map.entrySet()){
			params.addParameter(entry.getKey(), entry.getValue());
		}
	}
	params.setMultipart(true);
	Cancelable cancelable = x.http().get(params, callback);
	return cancelable;
}
 
Example #5
Source File: XUtil3HttpUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 发送post请求
 * @param <T>
 */
public static <T> Cancelable Post(String url,Map<String,Object> map,CommonCallback<T> callback){
	RequestParams params=new RequestParams(url);
	if(null!=map){
		for(Map.Entry<String, Object> entry : map.entrySet()){
			params.addParameter(entry.getKey(), entry.getValue());
		}
	}
	Cancelable cancelable = x.http().get(params, callback);
	return cancelable;
}
 
Example #6
Source File: XUtil3HttpUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 发送get请求
 * @param <T>
 */
public static <T> Cancelable Get(String url,Map<String,String> map,CommonCallback<T> callback){
	RequestParams params=new RequestParams(url);
	if(null!=map){
		for(Map.Entry<String, String> entry : map.entrySet()){
			params.addQueryStringParameter(entry.getKey(), entry.getValue());
		}
	}
	Cancelable cancelable = x.http().get(params, callback);
	return cancelable;
}
 
Example #7
Source File: StreamService.java    From DelegateAdapter with Apache License 2.0 5 votes vote down vote up
public org.xutils.common.Callback.Cancelable download (String url, final String output,
                                                       org.xutils.common.Callback.CommonCallback<File> callback) {

    Log.v(TAG, "download url=" + url + " output=" + output);
    File outputFile = new File(output);
    if (!outputFile.getParentFile().exists()) {
        outputFile.getParentFile().mkdirs();
    }
    RequestParams params = new RequestParams(url);
    params.setAutoResume(true);
    params.setSaveFilePath(output);
    return x.http().get(params, callback);
}
 
Example #8
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() {

            }
        });
    }
 
Example #9
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 #10
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
@Override
public void getTransactionCount(String address, BlockCallback callback) {
    //可以直接用 getTransactionsByAddress 接口返回参数中有交易总数
    RequestParams params = new RequestParams(URL+BtcConf.GET_TXS.replace("{address}", address));
    params.addQueryStringParameter("from", "0");//默认每次取10条
    params.addQueryStringParameter("to", "1");
    params.addQueryStringParameter("noAsm", "1");
    params.addQueryStringParameter("noScriptSig", "1");
    params.addQueryStringParameter("noSpent", "1");
    get(params, callback);
}
 
Example #11
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 #12
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 #13
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 #14
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 #15
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 4 votes vote down vote up
@Override
public void getBlockByHash(String hash, BlockCallback callback) {
    RequestParams params = new RequestParams(URL+BtcConf.GET_BLOCK.replace("{hash}", hash));
    LogUtil.e("BTC Url =" + params.getUri());
    get(params, callback);
}
 
Example #16
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 4 votes vote down vote up
@Override
public void getBalance(String address, BlockCallback callback) {
    RequestParams params = new RequestParams(URL+BtcConf.GET_BALANCE.replace("{address}", address));
    LogUtil.e("BTC Url =" + params.getUri());
    get(params, callback);
}
 
Example #17
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 4 votes vote down vote up
@Override
public void getTransactionByHash(String hash, BlockCallback callback) {
    RequestParams params = new RequestParams(URL+BtcConf.GET_TX.replace("{hash}", hash));
    LogUtil.e("BTC Url =" + params.getUri());
    get(params, callback);
}
 
Example #18
Source File: LtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 4 votes vote down vote up
@Override
public void getTransactionByHash(String hash, BlockCallback callback) {
    String url = LtcConf.url.replace("{address}", hash);
    RequestParams params = new RequestParams(url);
    get(params, callback);
}
 
Example #19
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 2 votes vote down vote up
/**
 * 获取某个地址下接收总量
 *
 * @param address
 * @param callback
 */
public void getTransactionTotalReceived(String address, BlockCallback callback) {
    RequestParams params = new RequestParams(URL+BtcConf.GET_TOTALRECEIVED.replace("{address}", address));
    LogUtil.e("BTC Url =" + params.getUri());
    get(params, callback);
}
 
Example #20
Source File: BtcBlockExplorer.java    From BlockExplorer with Apache License 2.0 2 votes vote down vote up
/**
 * 获取某个地址下的发送总量
 *
 * @param address
 * @param callback
 */
public void getTransactionTotalSent(String address, BlockCallback callback) {
    RequestParams params = new RequestParams(URL+BtcConf.GET_TOTALSENT.replace("{address}", address));
    LogUtil.e("BTC Url =" + params.getUri());
    get(params, callback);
}