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


Java JsonHttpResponseHandler类代码示例

本文整理汇总了Java中com.loopj.android.http.JsonHttpResponseHandler的典型用法代码示例。如果您正苦于以下问题:Java JsonHttpResponseHandler类的具体用法?Java JsonHttpResponseHandler怎么用?Java JsonHttpResponseHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonHttpResponseHandler类属于com.loopj.android.http包,在下文中一共展示了JsonHttpResponseHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setBingImg

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
private void setBingImg() {
    AsyncHttpClient client = new AsyncHttpClient();
    client.get("https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1", new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                    if (statusCode == 200) {
                        Gson gson = new Gson();
                        BingImage bingImage = gson.fromJson(response.toString(), BingImage.class);
                        List<BingImage.ImagesBean> img = bingImage.getImages();
                        if (img != null && img.size() > 0) {
                            backImgUrl = "https://cn.bing.com" + img.get(0).getUrl();
                            setBackgroundImage();
                        } else Log.d("main", "onSuccess: 没有获取到类型");

                    }
                }
            }
    );
}
 
开发者ID:TAnsz,项目名称:MyTvLauncher,代码行数:20,代码来源:MainActivity.java

示例2: onReceive

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
@Override
    public void onReceive(Context context, Intent intent) {
        String url = intent.getStringExtra("data");

        if (url != null) {
            closeNotify(context, url);
            if (MyApp.getMainActivityState()) {
                URLSpanNoUnderline.openActivityByUri(context, url, true);
            } else {
                Intent mainIntent = new Intent(context, MainActivity_.class);
                mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//                mainIntent.putExtra("mPushUrl", url);
                context.startActivity(mainIntent);
                URLSpanNoUnderline.openActivityByUri(context, url, true);
            }
        }

        String id = intent.getStringExtra("id");
        if (id != null && !id.isEmpty()) {
            AsyncHttpClient client = MyAsyncHttpClient.createClient(context);
            final String host = Global.HOST_API + "/notification/mark-read?id=%s";
            client.post(String.format(host, id), new JsonHttpResponseHandler() {
            });
        }
    }
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:26,代码来源:MyPushReceiver.java

示例3: update

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
public static void update(Context context) {
    final MyApp myApp = (MyApp) context.getApplicationContext();
    AsyncHttpClient client = MyAsyncHttpClient.createClient(context);

    client.get(Global.HOST_API + "/user/unread-count", new JsonHttpResponseHandler() {

        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            try {
                if (response.getInt("code") == 0) {
                    JSONObject json = response.getJSONObject("data");
                    Unread unread = new Unread(json);
                    MyApp.sUnread = unread;

                    UnreadNotifySubject.getInstance().notifyObserver();
                }

            } catch (Exception e) {
                Global.errorLog(e);
            }
        }
    });
}
 
开发者ID:huang303513,项目名称:Coding-Android,代码行数:24,代码来源:UnreadNotify.java

示例4: startLocation

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
/**
 * 启动定位服务
 */
public void startLocation(){
	AsyncHttpClient client = new AsyncHttpClient();
	client.get(requestUrl, new JsonHttpResponseHandler(){
		
		@Override
		public void onFailure(Throwable arg0, JSONObject arg1) {
			super.onFailure(arg0, arg1);
			onFailed();
		}
		
		@Override
		public void onSuccess(JSONObject json) {
			LocationService.this.onSuccess(json);
		}
	});
}
 
开发者ID:gizwits,项目名称:Gizwits-AirPurifier_Android,代码行数:20,代码来源:LocationService.java

示例5: GetWeather

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
/**
 * 启动定位服务
 */
public void GetWeather(String city){
	AsyncHttpClient client = new AsyncHttpClient();
	client.addHeader("X-XPG-Application-Id", "c79c8ef6002111e48a9b00163e0e2e0d");
	client.addHeader("X-XPG-REST-API-Key", "c79cd5c8002111e48a9b00163e0e2e0d");
	client.addHeader("Content-Type", "application/json");
	client.get(requestUrl+city, new JsonHttpResponseHandler(){
		
		@Override
		public void onFailure(Throwable arg0, JSONObject arg1) {
			super.onFailure(arg0, arg1);
			onFailed();
		}
		
		@Override
		public void onSuccess(JSONObject json) {
			GetPMService.this.onSuccess(json);
		}
	});
}
 
开发者ID:gizwits,项目名称:Gizwits-AirPurifier_Android,代码行数:23,代码来源:GetPMService.java

示例6: getNews

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
public static void getNews(final Context context) {
	mClient.get(NEWS_URL, new JsonHttpResponseHandler() {

		@Override
		public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
			super.onSuccess(statusCode, headers, response);
			// TODO wait for API update
			try {
				Memory.setString(context, Constant.PREF_NEWS_TITLE, response.getString(2));
				Memory.setString(context, Constant.PREF_NEWS_CONTENT, response.getString(3));
				Memory.setString(context, Constant.PREF_NEWS_URL, response.getString(4));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	});
}
 
开发者ID:kuastw,项目名称:KUAS-AP-Material,代码行数:18,代码来源:Helper.java

示例7: flagContent

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
/**
 * @param collectionId The Id of the collection.
 * @param contentId
 * @param token        The token of the logged in user.
 * @param action
 * @param parameters
 * @param handler      Response handler
 */

public static void flagContent(String collectionId, String contentId,
                               String token, LFSFlag action, RequestParams parameters,
                               JsonHttpResponseHandler handler) {

    String url = (new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("api").appendPath("v3.0").appendPath("message").appendPath("")) +
            contentId + (new Uri.Builder().appendPath("").appendPath("flag")
            .appendPath(flags[action.value()])
            .appendQueryParameter("lftoken", token)
            .appendQueryParameter("collection_id", collectionId));

    Log.d("Action SDK call", "" + url);
    Log.d("Action SDK call", "" + parameters);
    HttpClient.client.post(url, parameters, handler);
}
 
开发者ID:Livefyre,项目名称:StreamHub-Android-Comments-App,代码行数:26,代码来源:WriteClient.java

示例8: featureMessage

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
/**
 * @param action
 * @param contentId
 * @param collectionId The Id of the collection.
 * @param userToken    The token of the logged in user.
 * @param parameters
 * @param handler      Response handler
 * @throws MalformedURLException
 */

public static void featureMessage(String action, String contentId,
                                  String collectionId, String userToken,
                                  HashMap<String, Object> parameters, JsonHttpResponseHandler handler)
        throws MalformedURLException {
    RequestParams bodyParams = new RequestParams();
    bodyParams.put("lftoken", userToken);

    final Builder uriBuilder = new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("api").appendPath("v3.0").appendPath("collection")
            .appendPath(collectionId).appendPath(action)
            .appendPath(contentId).appendPath("")
            .appendQueryParameter("lftoken", userToken)
            .appendQueryParameter("collection_id", collectionId);

    Log.d("SDK", "" + uriBuilder);
    HttpClient.client.post(uriBuilder.toString(), bodyParams, handler);
}
 
开发者ID:Livefyre,项目名称:StreamHub-Android-Comments-App,代码行数:29,代码来源:WriteClient.java

示例9: postAction

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
/**
 * @param collectionId The Id of the collection.
 * @param contentId
 * @param token        The token of the logged in user.
 * @param action
 * @param parameters
 * @param handler      Response handler
 */

public static void postAction(String collectionId, String contentId,
                              String token, LFSActions action, RequestParams parameters,
                              JsonHttpResponseHandler handler) {
    // Build the URL
    String url = new Uri.Builder().scheme(LivefyreConfig.scheme)
            .authority(LivefyreConfig.quillDomain + "." + LivefyreConfig.getConfiguredNetworkID())
            .appendPath("api").appendPath("v3.0").appendPath("message").appendPath("") + contentId +
            (new Uri.Builder().appendPath(actions[action.value()]).appendPath("")
                    .appendQueryParameter("lftoken", token)
                    .appendQueryParameter("collection_id", collectionId));


    Log.d("Action SDK call", "" + url);
    Log.d("Action SDK call", "" + parameters);
    HttpClient.client.post(url, parameters, handler);
}
 
开发者ID:Livefyre,项目名称:StreamHub-Android-Comments-App,代码行数:26,代码来源:WriteClient.java

示例10: onPostExecute

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
@Override
protected void onPostExecute(final String gcmRegisterIdString) {
	super.onPostExecute(gcmRegisterIdString);
	if (gcmRegisterIdString != null) {
		VTULifeRestClient.registerGcm(gcmRegisterIdString,
				SystemFeatureChecker.getDeviceUuid(mContext),
				new JsonHttpResponseHandler() {
					@Override
					public void onSuccess(int statusCode,
							JSONObject response) {
						super.onSuccess(statusCode, response);
						Settings.storeRegistrationIdWithAppVersion(
								mContext, gcmRegisterIdString);
						((VTULifeMainActivity) mContext).showCrouton(
								R.string.registered_for_notification,
								Style.INFO, true);
					}
				});
	}

}
 
开发者ID:vishalvijay,项目名称:vtu-life-android,代码行数:22,代码来源:GCMRegisterManager.java

示例11: getAd

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
private void getAd(final String adID) {
  GoRestClient.get(":8080/ad/" + adID, new JsonHttpResponseHandler() {
    @Override public void onSuccess(JSONObject jsonObject) {
      Log.d(TAG, jsonObject.toString());
      Gson gson = new GsonBuilder().create();
      AdResult adResult = gson.fromJson(jsonObject.toString(), AdResult.class);
      String egg = adResult.getData().getImage1();
      String[] parts = adResult.getData().getImage1().split("_");
      tvTitle.setText(adResult.getData().getTitle());
      tvDescription.setText(adResult.getData().getDescription());
      ivImage1.setBackgroundColor(Color.parseColor("#" + parts[2]));
      if (adResult.status.equals("OK")) {
        Picasso.with(getApplicationContext())
            .load(GoRestClient.getAbsoluteUrl(":9090/egg/" + egg))
            .into(ivImage1);
      }
    }
  });
}
 
开发者ID:kamoljan,项目名称:ShopAfter,代码行数:20,代码来源:ViewActivity.java

示例12: syncCollection

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
private void syncCollection(final int nodeId, final boolean added, String regTime){
    V2EX.syncCollection(getActivity(), nodeId, regTime, added, new JsonHttpResponseHandler(){
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            if(getActivity() != null){
                try {
                    if(response.getString("result").equals("ok")){
                        mProgressDialog.setMessage("OK");
                        mAllNodesDataHelper.setCollected(added, nodeId);
                    }else if(response.getString("result").equals("fail")){
                        mProgressDialog.setMessage("Fail");
                        MessageUtils.toast(getActivity(), "Sync collections failed.");
                    }
                    mProgressDialog.dismiss();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
 
开发者ID:kyze8439690,项目名称:v2ex-daily-android,代码行数:22,代码来源:NodeFragment.java

示例13: syncCollection

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
private void syncCollection(final int nodeId, final boolean added, String regTime){
    V2EX.syncCollection(mContext, nodeId, regTime, added, new JsonHttpResponseHandler(){
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            try {
                if(response.getString("result").equals("ok")){
                    mProgressDialog.setMessage("OK");
                    mAllNodesDataHelper.setCollected(added, nodeId);
                }else if(response.getString("result").equals("fail")){
                    mProgressDialog.setMessage("Fail");
                    MessageUtils.toast(mContext, "Sync collections failed.");
                }
                mProgressDialog.dismiss();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}
 
开发者ID:kyze8439690,项目名称:v2ex-daily-android,代码行数:20,代码来源:AllNodesAdapter.java

示例14: getOnceCode

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
private void getOnceCode(){
    mProgressDialog = ProgressDialog.show(LoginActivity.this, null, "Get Once Code...", true, true);
    V2EX.getOnceCode(this, "https://www.v2ex.com/signin", new JsonHttpResponseHandler(){
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            if(LoginActivity.this != null){
                try {
                    if(response.getString("result").equals("ok")){
                        int onceCode = response.getJSONObject("content").getInt("once");
                        mProgressDialog.setMessage("Login...");
                        login(onceCode);
                    }else{
                        MessageUtils.toast(LoginActivity.this, "get once code fail");
                    }
                } catch (JSONException e) {
                    MessageUtils.toast(LoginActivity.this, "json error");
                    e.printStackTrace();
                }
            }
        }
    });
}
 
开发者ID:kyze8439690,项目名称:v2ex-daily-android,代码行数:23,代码来源:LoginActivity.java

示例15: login

import com.loopj.android.http.JsonHttpResponseHandler; //导入依赖的package包/类
private void login(int onceCode){
    V2EX.login(LoginActivity.this, mUsername.getText().toString(), mPassword.getText().toString(), onceCode, new JsonHttpResponseHandler(){
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            if(LoginActivity.this != null){
                try {
                    if(response.getString("result").equals("ok")){
                        mProgressDialog.setMessage("Get userinfo...");
                        getUserInfo();
                    }else if(response.getString("result").equals("fail")){
                        String errorContent = response.getJSONObject("content").getString("error_msg");
                        MessageUtils.toast(LoginActivity.this, errorContent);
                        mProgressDialog.dismiss();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
 
开发者ID:kyze8439690,项目名称:v2ex-daily-android,代码行数:22,代码来源:LoginActivity.java


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