use of com.tinyspeck.android.GlitchRequest in project glitch-hq-android by tinyspeck.
the class EncyclopediaItemCategoriesFragment method getEncyclopediaItemCategories.
public void getEncyclopediaItemCategories() {
if (m_application != null) {
GlitchRequest request = m_application.glitch.getRequest("items.getCategories");
request.execute(this);
m_requestCount = 1;
((HomeScreen) getActivity()).showSpinner(true);
}
}
use of com.tinyspeck.android.GlitchRequest in project glitch-hq-android by tinyspeck.
the class EncyclopediaItemDetailFragment method getEncyclopediaItem.
public void getEncyclopediaItem() {
Map<String, String> params = new HashMap<String, String>();
params.put("item_class", m_item.class_id);
GlitchRequest request = m_application.glitch.getRequest("items.info", params);
request.execute(this);
m_requestCount = 1;
((HomeScreen) getActivity()).showSpinner(true);
}
use of com.tinyspeck.android.GlitchRequest in project glitch-hq-android by tinyspeck.
the class EncyclopediaStreetDetailFragment method onRequestBack.
@Override
public void onRequestBack(String method, JSONObject response) {
if (method == "locations.canTeleport") {
JSONObject teleport = response.optJSONObject("teleport");
if (teleport != null) {
m_teleportInfo = new TeleportInfo();
m_teleportInfo.canTeleport = teleport.optBoolean("can_teleport");
m_teleportInfo.mapTokensUsed = teleport.optInt("map_tokens_used");
m_teleportInfo.mapTokensMax = teleport.optInt("map_tokens_max");
m_teleportInfo.tokensRemaining = teleport.optInt("tokens_remaining");
if (m_teleportInfo.canTeleport) {
showTeleportButton();
} else {
Button teleportBtn = (Button) m_root.findViewById(R.id.street_detail_teleport_btn);
teleportBtn.setVisibility(View.GONE);
}
}
onRequestComplete();
} else if (method == "locations.streetInfo") {
m_root.setVisibility(View.VISIBLE);
m_hub = new glitchLocationHub();
JSONObject hub = response.optJSONObject("hub");
m_hub.hub_id = hub.optInt("id");
m_hub.name = hub.optString("name");
m_street.activeProject = response.optBoolean("active_project");
JSONArray features = response.optJSONArray("features");
if (features != null) {
m_street.features = new Vector<String>();
for (int i = 0; i < features.length(); i++) {
String feature = features.optString(i);
m_street.features.add(feature);
}
}
JSONObject visits = response.optJSONObject("visits");
if (visits != null) {
m_street.visits = visits.optInt("total");
m_street.lastVisit = visits.optInt("last");
}
JSONObject image = response.optJSONObject("image");
if (image != null) {
m_street.image = image.optString("url");
m_street.imageHeight = image.optInt("h");
m_street.imageWidth = image.optInt("w");
}
showEncyclopediaStreetPage();
onRequestComplete();
} else if (method == "locations.setAsDestination") {
int result = response.optInt("ok");
if (result == 0) {
String error = response.optString("error");
Util.shortToast(getActivity(), error);
} else {
String msg = response.optString("msg");
Util.shortToast(getActivity(), msg);
}
} else if (method == "locations.teleport") {
int result = response.optInt("ok");
if (result == 0) {
String error = response.optString("error");
Util.shortToast(getActivity(), error);
} else {
String msg = response.optString("msg");
Util.shortToast(getActivity(), msg);
}
// want to refresh information about teleporting
Map<String, String> params = new HashMap<String, String>();
params.put("street_tsid", m_street.tsid);
GlitchRequest request = m_application.glitch.getRequest("locations.streetInfo", params);
request.execute(this);
}
}
use of com.tinyspeck.android.GlitchRequest in project glitch-hq-android by tinyspeck.
the class EncyclopediaStreetDetailFragment method getEncyclopediaStreet.
private void getEncyclopediaStreet() {
Map<String, String> params = new HashMap<String, String>();
params.put("street_tsid", m_street.tsid);
GlitchRequest request1 = m_application.glitch.getRequest("locations.streetInfo", params);
request1.execute(this);
GlitchRequest request2 = m_application.glitch.getRequest("locations.canTeleport", params);
request2.execute(this);
m_requestCount = 2;
((HomeScreen) getActivity()).showSpinner(true);
}
use of com.tinyspeck.android.GlitchRequest in project glitch-hq-android by tinyspeck.
the class FriendsFragment method getFriends.
private void getFriends() {
if (m_application != null) {
GlitchRequest request1 = m_application.glitch.getRequest("friends.list");
request1.execute(this);
m_requestCount = 1;
((HomeScreen) getActivity()).showSpinner(true);
}
}
Aggregations