Back to project page Android-Apps.
The source code is released under:
Apache License
If you think the Android project Android-Apps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kniezrec.xbmcgear.connection; /*from w w w . j av a 2 s.co m*/ import android.util.Log; import com.kniezrec.xbmcgear.player.Player; import org.json.JSONException; import org.json.JSONObject; public class JSONRPCRequest { private static final String TAG = "JSONRPCRequest"; private int method; private JSONObject request; private JSONObject response; public JSONRPCRequest() { method = -1; } public JSONRPCRequest(int method) { this.method = method; try { switch (method) { case JSONRequestFactory.REQ_ACTIVE_PLAYERS: this.request = JSONRequestFactory.getActivPlayers(); break; case JSONRequestFactory.REQ_GET_ITEMS: this.request = JSONRequestFactory.getItems(); break; case JSONRequestFactory.REQ_GET_PROPERTIES: this.request = JSONRequestFactory.getProperties(); break; case JSONRequestFactory.REQ_GET_ITEM: this.request = JSONRequestFactory.getItem(); break; case JSONRequestFactory.REQ_GET_VERSION: this.request = JSONRequestFactory.getVersion(); break; default: break; } } catch (JSONException e) { Log.v(TAG, e.getMessage()); } } public void replaceIDs(Player player) { if (this.request != null && player != null) { JSONObject params = this.request.optJSONObject("params"); if (params != null) { try { if (params.has("playerid")) { params.put("playerid", player.getId()); } if (params.has("playlistid")) { params.put("playlistid", player.playlist.getId()); } } catch (JSONException e) { Log.v(TAG, e.getMessage()); } } } } public int getMethod() { return method; } public void setMethod(int method) { this.method = method; } public JSONObject getRequest() { return request; } public void setRequest(JSONObject request) { this.request = request; } public JSONObject getResponse() { return response; } public void setResponse(JSONObject response) { this.response = response; } }