當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。