com.loopj.android.http.AsyncHttpResponseHandler Java Examples

The following examples show how to use com.loopj.android.http.AsyncHttpResponseHandler. 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: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP POST request with cookies which are defined in hashmap
 *
 * @param context
 * @param url
 * @param hashMap
 * @param responseHandler
 */
public static void postUseCookie(Context context, String url, HashMap hashMap, AsyncHttpResponseHandler responseHandler) {
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    if (BasicUtils.judgeNotNull(hashMap)) {
        Iterator iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            Cookie cookie = new BasicClientCookie(key.toString(), value.toString());
            myCookieStore.addCookie(cookie);
        }
    }
    AsyncHttpClient client = new AsyncHttpClient();
    client.setCookieStore(myCookieStore);
    client.post(getAbsoluteUrl(url), responseHandler);
}
 
Example #2
Source File: DevicesApi.java    From freeiot-android with MIT License 6 votes vote down vote up
/**
 * set device status (/v1/devices/{identifier}/status)
 * @param context
 * @param accessToken
 * @param identifier
 * @param responseHandler
 */
public static void setDeviceCurrentState(Context context, String accessToken,
      String identifier,String jsonBody, AsyncHttpResponseHandler responseHandler)
{
    List<Header> headerList = new ArrayList<Header>();
    headerList.add(new BasicHeader(ApiKey.HeadKey.ACCESS_TOKEN, accessToken));

    try
    {
        put(context, String.format(getApiServerUrl() + DEVICE_SET_CURRENT_STATUS, identifier),
                headerList, jsonBody, responseHandler);
    }
    catch (Exception e)
    {
        e.printStackTrace();
        responseHandler.onFailure(INNER_ERROR_CODE, null, null, e);
    }
}
 
Example #3
Source File: DevicesApi.java    From freeiot-android with MIT License 6 votes vote down vote up
/**
 * /v1/devices/{identifier}/commands
    *
 * @param context
 * @param accessToken
 * @param identifier
 * @param jsonBody
 * @param responseHandler
 */
public static void sendCommands(Context context, String accessToken,
		String identifier, String jsonBody, AsyncHttpResponseHandler responseHandler) {
	List<Header> headerList = new ArrayList<Header>();
	headerList.add(new BasicHeader(ApiKey.HeadKey.ACCESS_TOKEN, accessToken));
	try {
		if (DEBUG) {
			LogUtils.d(jsonBody);
		}
		post(context,
                   String.format(getApiServerUrl() + DEVICE_SEND_COMMANDS, identifier)
                   , headerList, jsonBody, responseHandler);
	}  catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
}
 
Example #4
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP GET request with cookie which generate by own context
 *
 * @param context
 * @param url
 * @param responseHandler
 */
public static void getWithCookie(Context context, String url, AsyncHttpResponseHandler responseHandler) {
    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    //  myCookieStore.clear();
    client.setCookieStore(myCookieStore);
    client.get(getAbsoluteUrl(url), responseHandler);

}
 
Example #5
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a HTTP GET request with cookies which are defined in hashmap
 *
 * @param context
 * @param url
 * @param hashMap
 * @param responseHandler
 */
public static void getUseCookie(Context context, String url, HashMap hashMap, AsyncHttpResponseHandler responseHandler) {
    PersistentCookieStore myCookieStore = new PersistentCookieStore(context);
    if (BasicUtils.judgeNotNull(hashMap)) {
        Iterator iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            Cookie cookie = new BasicClientCookie(key.toString(), value.toString());
            myCookieStore.addCookie(cookie);
        }
    }
    AsyncHttpClient client = new AsyncHttpClient();
    client.setCookieStore(myCookieStore);
    client.get(getAbsoluteUrl(url), responseHandler);
}
 
Example #6
Source File: FlowAsyncClient.java    From flow-android with MIT License 6 votes vote down vote up
public static void get(HashMap<String, String> headers, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    final AsyncHttpClient specialClient = new AsyncHttpClient();

    for (String key : headers.keySet()) {
        specialClient.addHeader(key, headers.get(key));
    }
    specialClient.get(getAbsoluteUrl(url), params, responseHandler);
}
 
Example #7
Source File: TokenRegistry.java    From pusher-websocket-android with MIT License 6 votes vote down vote up
private void update(String token, String cachedId) throws JSONException {
    String url = options.buildNotificationURL("/clients/" + cachedId + "/token");
    AsyncHttpClient client = factory.newHttpClient();
    StringEntity params = createRegistrationJSON(token);

    AsyncHttpResponseHandler handler = factory.newTokenUpdateHandler(
            cachedId, params, context, listenerStack, this
    );
    client.put(context, url, params, "application/json", handler);
}
 
Example #8
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public static void sendLoginResult(LoginInfo logininfo, String s, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = new RequestParams();
    requestparams.put("access_token", (new StringBuilder()).append("").append(logininfo.accessToken).toString());
    requestparams.put("expiresIn", logininfo.expiresIn);
    requestparams.put("mac_token", logininfo.macToken);
    requestparams.put("miid", logininfo.miid);
    requestparams.put("aliasNick", logininfo.aliasNick);
    requestparams.put("miliaoNick", logininfo.miliaoNick);
    String s1;
    if (logininfo.miliaoIcon_320 != null && logininfo.miliaoIcon_320.length() > 0)
    {
        requestparams.put("miliaoIcon", logininfo.miliaoIcon_320);
    } else
    {
        requestparams.put("miliaoIcon", logininfo.miliaoIcon);
    }
    requestparams.put("friends", logininfo.friends);
    requestparams.put("deviceid", s);
    requestparams.put("devicetype", "0");
    s1 = BraceletHttpClient.getUrl("huami.health.apklogin.json");
    Debug.i(TAG, (new StringBuilder()).append("send login url= ").append(s1).toString());
    BraceletHttpClient.client.post(s1, requestparams, asynchttpresponsehandler);
}
 
Example #9
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public static void getGameBriefInfo(AsyncHttpResponseHandler asynchttpresponsehandler)
{
    LoginData logindata = Keeper.readLoginData();
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    String s = BraceletHttpClient.getUrl("huami.health.gethuodongconfig.json");
    HashMap hashmap = new HashMap();
    hashmap.put("userid", (new StringBuilder()).append("").append(logindata.uid).toString());
    hashmap.put("security", logindata.security);
    hashmap.put("v", "1.0");
    hashmap.put("appid", (new StringBuilder()).append("").append(ClientConstant.CLIENT_ID).toString());
    hashmap.put("callid", (new StringBuilder()).append("").append(System.currentTimeMillis()).toString());
    hashmap.put("lang", Locale.getDefault().getLanguage());
    BraceletHttpClient.getParamString(hashmap);
    Debug.i(TAG, (new StringBuilder()).append("game url =").append(s).toString());
    BraceletHttpClient.syncClient.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #10
Source File: AsyncHttpUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 上传文件
 *
 * @return
 */
public static void upLoadFile(String url, File file, AsyncHttpResponseHandler handler) throws FileNotFoundException {
    RequestParams params = new RequestParams();
    params.put("username", "张鸿洋");
    params.put("password", "123");
    params.put("mFile", file);
    AsyncHttpClient client = getHttpClient();
    client.addHeader("Content-disposition", "mFile=\"" + file.getName() + "\"");
    client.addHeader("APP-Key", "APP-Secret222");
    client.addHeader("APP-Secret", "APP-Secret111");
    client.post(url, params, handler);
}
 
Example #11
Source File: WelcomeActivity.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * 更新APP
 */
private void updateApp() {
    startTime = System.currentTimeMillis(); // 获取系统当前的时间
    // 判断手机是否可以联网
    if (!NetStateUtil.isConnected(this)) {
        ToastUtil.show(WelcomeActivity.this, "网络异常!");
        toLoginPager();
    } else {
        String updateUrl = ApiRequestUrl.UPDATE; // 获取联网请求更新应用的路径
        // 使用AsyncHttpClient实现联网获取版本信息
        AsyncHttpClient client = new AsyncHttpClient();
        client.post(updateUrl, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(String json) {
                LogUtils.json(TAG, json);
                // 使用fastJson解析json数据
                updateInfo = JSON.parseObject(json, UpdateInfo.class);
                handler.sendEmptyMessage(WHAT_DOWNLOAD_VERSION_SUCCESS);
            }

            @Override
            public void onFailure(Throwable error, String content) {
                LogUtils.e(TAG, "Throwable:" + error.getMessage() + ",content:" + content);
                ToastUtil.show(WelcomeActivity.this, "联网获取更新数据失败!");
                toLoginPager();
            }
        });
    }
}
 
Example #12
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void getGameRegisterInfo(AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(Keeper.readLoginData());
    String s = BraceletHttpClient.getUrl("huami.health.detectuserwhetherjoinhuodong.json");
    Debug.i(TAG, (new StringBuilder()).append("game register url =").append(s).toString());
    BraceletHttpClient.syncClient.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #13
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void getWeixinQR(LoginData logindata, String s, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("deviceid", s);
    String s1 = BraceletHttpClient.getUrl("huami.health.createwxqr.json");
    BraceletHttpClient.client.post(s1, requestparams, asynchttpresponsehandler);
}
 
Example #14
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void getUserInfo(LoginData logindata, long l, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("uid", (new StringBuilder()).append("").append(l).toString());
    String s = BraceletHttpClient.getUrl("huami.health.getUserInfo.json");
    BraceletHttpClient.client.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #15
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void sendFeedback(LoginData logindata, String s, String s1, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("message", s);
    requestparams.put("email", s1);
    String s2 = BraceletHttpClient.getUrl("huami.health.report.json");
    BraceletHttpClient.client.post(s2, requestparams, asynchttpresponsehandler);
}
 
Example #16
Source File: HttpUtilsAsync.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Upload file with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param file
 * @param responseHandler
 * @throws FileNotFoundException
 */
public static void uploadFile(String url, List<NameValuePair> paramsList, String fileParams, File file, AsyncHttpResponseHandler responseHandler) throws FileNotFoundException {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();
    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(file))
        params.put(fileParams, file);
    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
 
Example #17
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void syncSummaryToServer(LoginData logindata, String s, int i, int j, String s1, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("data_json", s1);
    requestparams.put("deviceid", s);
    requestparams.put("data_type", (new StringBuilder()).append("").append(i).toString());
    requestparams.put("source", (new StringBuilder()).append("").append(j).toString());
    requestparams.put("data_len", (new StringBuilder()).append("").append(s1.length()).toString());
    requestparams.put("uuid", Keeper.readUUID());
    String s2 = BraceletHttpClient.getUrl("huami.health.updateSummary.json");
    Debug.i(TAG, (new StringBuilder()).append("Url : ").append(s2).toString());
    BraceletHttpClient.client.post(s2, requestparams, asynchttpresponsehandler);
}
 
Example #18
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void syncToServer(LoginData logindata, String s, int i, int j, String s1, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("data_json", s1);
    requestparams.put("deviceid", s);
    requestparams.put("data_type", (new StringBuilder()).append("").append(i).toString());
    requestparams.put("source", (new StringBuilder()).append("").append(j).toString());
    requestparams.put("data_len", (new StringBuilder()).append("").append(s1.length()).toString());
    requestparams.put("uuid", Keeper.readUUID());
    String s2 = BraceletHttpClient.getUrl("huami.health.receiveData.json");
    BraceletHttpClient.client.post(s2, requestparams, asynchttpresponsehandler);
}
 
Example #19
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void updateProfile(LoginData logindata, HashMap hashmap, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    HashMap hashmap1 = BraceletHttpClient.getSysHm(logindata);
    hashmap1.putAll(hashmap);
    String s = BraceletHttpClient.getUrl("huami.health.bindProfile.json");
    String s1 = (String)hashmap.get("icon_path");
    hashmap1.remove("icon_path");
    RequestParams requestparams = new RequestParams();
    java.util.Map.Entry entry;
    for (Iterator iterator = hashmap1.entrySet().iterator(); iterator.hasNext(); requestparams.put((String)entry.getKey(), (String)entry.getValue()))
    {
        entry = (java.util.Map.Entry)iterator.next();
    }

    if (s1 == null || s1.length() < 1)
    {
        BraceletHttpClient.client.post(s, requestparams, asynchttpresponsehandler);
        return;
    }
    try
    {
        requestparams.put("icon", new File(s1));
    }
    catch (FileNotFoundException filenotfoundexception)
    {
        BraceletHttpClient.client.post(s, requestparams, asynchttpresponsehandler);
        return;
    }
    BraceletHttpClient.client.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #20
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void statisticBracelet(LoginData logindata, String s, String s1, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    requestparams.put("deviceid", s);
    requestparams.put("statistic_bracelet", s1);
    String s2 = BraceletHttpClient.getUrl("huami.health.uploadcollectdata.json");
    BraceletHttpClient.client.post(s2, requestparams, asynchttpresponsehandler);
}
 
Example #21
Source File: DevicesApi.java    From freeiot-android with MIT License 5 votes vote down vote up
/**
 * query device real-time status (/v1/devices/%s/status/current)
 * @param context
 * @param accessToken
 * @param identifier
 * @param responseHandler
 */
public static void getDeviceCurrentState(Context context, String accessToken,
           String identifier, AsyncHttpResponseHandler responseHandler) {
    List<Header> headerList = new ArrayList<Header>();
    headerList.add(new BasicHeader(ApiKey.HeadKey.ACCESS_TOKEN, accessToken));

    get(context,
            String.format(getApiServerUrl() + DEVICE_CURRENT_STATUS, identifier),
            headerList, null, responseHandler);
}
 
Example #22
Source File: UserPubGoodsActivity.java    From school_shop with MIT License 5 votes vote down vote up
private void loadData() {
	loadingProgressDialog.show();
	RequestParams params = new RequestParams();
	if (!isMe) {
		params.add("otherUserId", otherUserId);
	}
	params.add("userId", MyApplication.userInfo[1]);
	params.add("authCode", MyApplication.userInfo[0]);
	params.add("type", type);
	networkHelper.getNetJson(URLs.USER_PUB_GOODS, params, new AsyncHttpResponseHandler(){
		
		@Override
		public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
			Gson gson = new Gson();
			DataJson dataJson = gson.fromJson(new String(responseBody), DataJson.class);
			if(dataJson.isSuccess()){
				 if(type.equals("userGoods")||type.equals("like")){
					 goodsList = gson.fromJson(gson.toJson(dataJson.getData()), new TypeToken<List<GoodsEntity>>(){}.getType());
					 if(goodsList!=null) initAdapter(); else showButtomToast(getStringByRId(R.string.dataError));
				 }else if (type.equals("userShare")) {
					 shareList = gson.fromJson(gson.toJson(dataJson.getData()), new TypeToken<List<ShareEntity>>(){}.getType());
					 if(shareList!=null) initAdapter(); else showButtomToast(getStringByRId(R.string.dataError));
				}
			}else {
				showButtomToast(getStringByRId(R.string.dataError));
			}
			loadingProgressDialog.dismiss();
		}
		
		@Override
		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
			loadingProgressDialog.dismiss();
		}
	});
}
 
Example #23
Source File: UserApi.java    From freeiot-android with MIT License 5 votes vote down vote up
/**
 * user logout (/v1/users/logout)
 * @param context
 * @param accessToken
 * @param responseHandler
 */
public static void logout(Context context, String accessToken, AsyncHttpResponseHandler responseHandler) {
    List<Header> headerList = new ArrayList<Header>();
    headerList.add(new BasicHeader(ApiKey.HeadKey.ACCESS_TOKEN, accessToken));
    try {
        post(context, getApiServerUrl() + USER_LOGOUT, headerList, null, responseHandler);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        responseHandler.onFailure(INNER_ERROR_CODE, null, null, e);
    }
}
 
Example #24
Source File: MarkSubmitActivity.java    From school_shop with MIT License 5 votes vote down vote up
private void initQiniuToken(){
	MarketPubActivity.qiniuToken = null;
	networkHelper.getNetString(URLs.QINIU_TOKEN, new AsyncHttpResponseHandler() {
		
		@Override
		public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
			MarketPubActivity.qiniuToken = new String(responseBody);
		}
		
		@Override
		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
		}
	});
}
 
Example #25
Source File: SetPasswordActivity.java    From school_shop with MIT License 5 votes vote down vote up
public void postData(){
	RequestParams params = new RequestParams();
	params.put("authCode", MyApplication.userInfo[0]);
	params.put("userId", MyApplication.userInfo[1]);
	params.put("phone", MyApplication.userInfo[3]);
	try {
           String oldPwd = oldPassword.getText().toString();
           String newPwd = newPassword.getText().toString();
           String confirmPwd = confirmPassword.getText().toString();
           if (passwordFormatError(oldPwd, newPwd, confirmPwd)) {
               return;
           }
           params.put("oldPassword", PBEUtil.encrypt(oldPwd, PBEUtil.passwordkey, PBEUtil.getStaticSalt()));
           params.put("newPassword", PBEUtil.encrypt(newPwd, PBEUtil.passwordkey,PBEUtil.getStaticSalt()));
           networkHelper.getNetJson(URLs.USER_RESETPWD, params, new AsyncHttpResponseHandler(){
           	
           	@Override
			public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
           		Gson gson = new Gson();
   				DataJson dataJson = gson.fromJson(new String(responseBody), DataJson.class);
   				if (dataJson.isSuccess()) {
   					showButtomToast("密码修改成功");
   					popDialog();
   				}else {
   					showButtomToast(dataJson.getMsg());
				}
			}

			@Override
			public void onFailure(int arg0, Header[] arg1, byte[] arg2,
					Throwable arg3) {
			}

           });
       } catch (Exception e) {
       	showButtomToast(e.toString());
       }
}
 
Example #26
Source File: MarketPubActivity.java    From school_shop with MIT License 5 votes vote down vote up
private void initQiniuToken(){
	networkHelper.getNetString(URLs.QINIU_TOKEN, new AsyncHttpResponseHandler() {
		
		@Override
		public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
			qiniuToken = new String(responseBody);
		}
		
		@Override
		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
		}
	});
}
 
Example #27
Source File: BaseClient.java    From monolog-android with MIT License 5 votes vote down vote up
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    if (!AppContext.getInstance().isConnected()) {
        ToastUtils.show(AppContext.getInstance(), AppContext.getInstance().getString(R.string.error_no_network));
        return;
    }
    client.get(getAbsoluteUrl(url), params, responseHandler);
}
 
Example #28
Source File: UserDetailActivity.java    From school_shop with MIT License 5 votes vote down vote up
private void initQiniuToken(){
	MarketPubActivity.qiniuToken = null;
	networkHelper.getNetString(URLs.QINIU_TOKEN, new AsyncHttpResponseHandler() {
		
		@Override
		public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
			MarketPubActivity.qiniuToken = new String(responseBody);
		}
		
		@Override
		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
		}
	});
}
 
Example #29
Source File: WebAPI.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public static void uploadLogFileBlock(LoginData logindata, File file, AsyncHttpResponseHandler asynchttpresponsehandler)
{
    RequestParams requestparams = BraceletHttpClient.getSysRp(logindata);
    String s;
    try
    {
        requestparams.put("log_file_name", file.getName());
        requestparams.put("log_file", file);
    }
    catch (FileNotFoundException filenotfoundexception) { }
    s = BraceletHttpClient.getUrl("huami.health.uploadlogdata.json");
    BraceletHttpClient.syncClient.post(s, requestparams, asynchttpresponsehandler);
}
 
Example #30
Source File: UserReplyActivity.java    From school_shop with MIT License 5 votes vote down vote up
private void getNetData() {
	RequestParams params = new RequestParams();
	params.add("userId", MyApplication.userInfo[1]);
	params.add("authCode", MyApplication.userInfo[0]);
	String url = null;
	if(choose==0) {
		url=URLs.USERRELY;
		isMe = false;
	}else {
		url=URLs.USERJOINTHEME;
		isMe = true;
	}
	networkHelper.getNetJson(url, params, new AsyncHttpResponseHandler(){
		
		@Override
		public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
			Gson gson = new Gson();
			DataJson dataJson = gson.fromJson(new String(responseBody), DataJson.class);
			if (dataJson.isSuccess()) {
				list = gson.fromJson(gson.toJson(dataJson.getData()), new TypeToken<List<GoodsCommentEntity>>(){}.getType());
				initAdapter();
			}else {
				showButtomToast("用户信息有误");
			}
			loadingProgressDialog.dismiss();
		}
		
		@Override
		public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
			loadingProgressDialog.dismiss();
		}
	});
}