Search in sources :

Example 26 with GlitchRequest

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);
    }
}
Also used : GlitchRequest(com.tinyspeck.android.GlitchRequest)

Example 27 with GlitchRequest

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);
}
Also used : HashMap(java.util.HashMap) GlitchRequest(com.tinyspeck.android.GlitchRequest)

Example 28 with GlitchRequest

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);
    }
}
Also used : JSONObject(org.json.JSONObject) Button(android.widget.Button) JSONArray(org.json.JSONArray) Vector(java.util.Vector) HashMap(java.util.HashMap) Map(java.util.Map) GlitchRequest(com.tinyspeck.android.GlitchRequest)

Example 29 with GlitchRequest

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);
}
Also used : HashMap(java.util.HashMap) GlitchRequest(com.tinyspeck.android.GlitchRequest)

Example 30 with GlitchRequest

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);
    }
}
Also used : GlitchRequest(com.tinyspeck.android.GlitchRequest)

Aggregations

GlitchRequest (com.tinyspeck.android.GlitchRequest)46 HashMap (java.util.HashMap)33 Vector (java.util.Vector)3 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 OnTouchListener (android.view.View.OnTouchListener)1 Button (android.widget.Button)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 Glitch (com.tinyspeck.android.Glitch)1 BaseFragment.skillAvailable (com.tinyspeck.glitchhq.BaseFragment.skillAvailable)1 Map (java.util.Map)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1