Example usage for org.json JSONObject getDouble

List of usage examples for org.json JSONObject getDouble

Introduction

In this page you can find the example usage for org.json JSONObject getDouble.

Prototype

public double getDouble(String key) throws JSONException 

Source Link

Document

Get the double value associated with a key.

Usage

From source file:com.goliathonline.android.kegbot.io.RemoteTapHandler.java

/** {@inheritDoc} */
@Override/*from  w w w .  ja v  a  2s  .c o  m*/
public ArrayList<ContentProviderOperation> parse(JSONObject parser, ContentResolver resolver)
        throws JSONException, IOException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();

    if (parser.has("result")) {
        JSONObject events = parser.getJSONObject("result");
        JSONArray resultArray = events.getJSONArray("taps");
        int numKegs = resultArray.length();

        JSONObject taps;
        for (int i = 0; i < numKegs; i++) {
            taps = resultArray.getJSONObject(i);

            JSONObject keg = taps.getJSONObject("keg");
            JSONObject tap = taps.getJSONObject("tap");
            JSONObject beer = taps.getJSONObject("beer_type");
            JSONObject image = beer.getJSONObject("image");

            final String tapId = sanitizeId(tap.getString("id"));
            final Uri tapUri = Taps.buildTapUri(tapId);

            // Check for existing details, only update when changed
            final ContentValues values = queryTapDetails(tapUri, resolver);
            final long localUpdated = values.getAsLong(SyncColumns.UPDATED);
            final long serverUpdated = 500; //entry.getUpdated();
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "found tap " + tapId);
                Log.v(TAG, "found localUpdated=" + localUpdated + ", server=" + serverUpdated);
            }

            // Clear any existing values for this session, treating the
            // incoming details as authoritative.
            batch.add(ContentProviderOperation.newDelete(tapUri).build());

            final ContentProviderOperation.Builder builder = ContentProviderOperation
                    .newInsert(Taps.CONTENT_URI);

            builder.withValue(SyncColumns.UPDATED, serverUpdated);
            builder.withValue(Taps.TAP_ID, tapId);

            if (tap.has("name"))
                builder.withValue(Taps.TAP_NAME, tap.getString("name"));

            if (tap.has("current_keg_id"))
                builder.withValue(Taps.KEG_ID, tap.getDouble("current_keg_id"));

            if (keg.has("status"))
                builder.withValue(Taps.STATUS, keg.getString("status"));

            if (keg.has("percent_full"))
                builder.withValue(Taps.PERCENT_FULL, keg.getString("percent_full"));

            if (keg.has("size_name"))
                builder.withValue(Taps.SIZE_NAME, keg.getString("size_name"));

            if (keg.has("volume_ml_remain"))
                builder.withValue(Taps.VOL_REMAIN, keg.getDouble("volume_ml_remain"));

            if (keg.has("size_volume_ml"))
                builder.withValue(Taps.VOL_SIZE, keg.getDouble("size_volume_ml"));

            if (beer.has("name"))
                builder.withValue(Taps.BEER_NAME, beer.getString("name"));

            if (keg.has("description"))
                builder.withValue(Taps.DESCRIPTION, keg.getString("description"));

            JSONObject last_temp = tap.getJSONObject("last_temperature");

            if (last_temp.has("temperature_c"))
                builder.withValue(Taps.LAST_TEMP, last_temp.getString("temperature_c"));

            if (last_temp.has("record_time"))
                builder.withValue(Taps.LAST_TEMP_TIME, last_temp.getString("record_time"));

            if (image.has("url"))
                builder.withValue(Taps.IMAGE_URL, image.getString("url"));

            // Normal tap details ready, write to provider
            batch.add(builder.build());
        }
    }

    return batch;
}

From source file:es.curso.android.arduino.Main.java

private void showData(JSONObject json) {
    String msg = "";

    msg = "Switch: ";
    if (json.has("switch")) {
        try {/*from  w w w . j av  a 2  s .co  m*/
            Integer value = json.getInt("switch");
            if (value == 1)
                msg += "ON";
            else
                msg += "OFF";

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    msg += " - Temp: ";
    if (json.has("temp")) {
        try {
            Double value = json.getDouble("temp");
            msg += value.toString();

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    final String msgFinal = msg;

    Main.this.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            tvStatus.setText(msgFinal);
        }
    });
}

From source file:mp.teardrop.Song.java

static Song fromJsonObject(JSONObject jsonBourne) {

    try {// w  w  w  . ja va 2 s. c  om

        Song song = new Song(jsonBourne.getBoolean("isCloudSong"), jsonBourne.getString("path"),
                jsonBourne.getString("title"), jsonBourne.getString("album"), jsonBourne.getString("artist"),
                jsonBourne.getInt("trackNumber"));

        if (song.isCloudSong) {
            song.id = -1337;
            song.albumId = -1337;
            song.artistId = -1337;
            song.dbPath = jsonBourne.getString("dbPath");
            song.rgTrack = //TODO: make sure there isn't any loss of precision
                    jsonBourne.has("rgTrack") ? new Float(jsonBourne.getDouble("rgTrack")) : null;
            song.rgAlbum = jsonBourne.has("rgAlbum") ? new Float(jsonBourne.getDouble("rgAlbum")) : null;
        } else {
            song.id = jsonBourne.getLong("id");
            song.artistId = jsonBourne.getLong("artistId");
            song.albumId = jsonBourne.getLong("albumId");
            song.dbPath = null;
        }

        return song;

    } catch (JSONException e) {
        return null;
    }

}

From source file:edu.mbl.jif.imaging.mmtiff.OMEMetadata.java

private void startSeriesMetadata(JSONObject firstImageTags, int seriesIndex, String baseFileName)
        throws JSONException, MMScriptException {
    series_.put(seriesIndex, new Indices());
    //Last one is samples per pixel
    JSONObject summaryMD = mptStorage_.getSummaryMetadata();
    MetadataTools.populateMetadata(metadata_, seriesIndex, baseFileName,
            MultipageTiffWriter.BYTE_ORDER.equals(ByteOrder.LITTLE_ENDIAN),
            mptStorage_.slicesFirst() ? "XYZCT" : "XYCZT", "uint" + (MDUtils.isGRAY8(summaryMD) ? "8" : "16"),
            MDUtils.getWidth(summaryMD), MDUtils.getHeight(summaryMD), MDUtils.getNumSlices(summaryMD),
            MDUtils.getNumChannels(summaryMD), MDUtils.getNumFrames(summaryMD), 1);

    if (summaryMD.has("PixelSize_um") && !summaryMD.isNull("PixelSize_um")) {
        double pixelSize = summaryMD.getDouble("PixelSize_um");
        if (pixelSize > 0) {
            metadata_.setPixelsPhysicalSizeX(new PositiveFloat(pixelSize), seriesIndex);
            metadata_.setPixelsPhysicalSizeY(new PositiveFloat(pixelSize), seriesIndex);
        }//www.  j a  v  a  2 s  .  c o m
    }
    if (summaryMD.has("z-step_um") && !summaryMD.isNull("z-step_um")) {
        double zStep = summaryMD.getDouble("z-step_um");
        if (zStep > 0) {
            metadata_.setPixelsPhysicalSizeZ(new PositiveFloat(zStep), seriesIndex);
        }
    }

    String positionName;
    try {
        positionName = MDUtils.getPositionName(firstImageTags);
    } catch (JSONException ex) {
        ReportingUtils.logError("Couldn't find position name in image metadata");
        positionName = "pos" + MDUtils.getPositionIndex(firstImageTags);
    }
    metadata_.setStageLabelName(positionName, seriesIndex);

    String instrumentID = MetadataTools.createLSID("Microscope");
    metadata_.setInstrumentID(instrumentID, 0);
    // link Instrument and Image
    metadata_.setImageInstrumentRef(instrumentID, seriesIndex);

    JSONObject comments = mptStorage_.getDisplayAndComments().getJSONObject("Comments");
    if (comments.has("Summary") && !comments.isNull("Summary")) {
        metadata_.setImageDescription(comments.getString("Summary"), seriesIndex);
    }

    JSONArray channels = mptStorage_.getDisplayAndComments().getJSONArray("Channels");
    for (int channelIndex = 0; channelIndex < channels.length(); channelIndex++) {
        JSONObject channel = channels.getJSONObject(channelIndex);
        metadata_.setChannelColor(new Color(channel.getInt("Color")), seriesIndex, channelIndex);
        metadata_.setChannelName(channel.getString("Name"), seriesIndex, channelIndex);
    }
    //used to estimate the final length of the OME xml string
    if (omeXMLBaseLength_ == -1) {
        try {
            OMEXMLService service = new ServiceFactory().getInstance(OMEXMLService.class);
            omeXMLBaseLength_ = service.getOMEXML(metadata_).length();
        } catch (Exception ex) {
            ReportingUtils.logError("Unable to calculate OME XML Base length");
        }
    }
}

From source file:edu.mbl.jif.imaging.mmtiff.OMEMetadata.java

public void addImageTagsToOME(JSONObject tags, int ifdCount, String baseFileName, String currentFileName)
        throws JSONException, MMScriptException {
    int seriesIndex;
    try {/*from   w  ww.j  a v a  2 s  .c  o m*/
        seriesIndex = MDUtils.getPositionIndex(tags);
    } catch (Exception e) {
        seriesIndex = 0;
    }
    if (!series_.containsKey(seriesIndex)) {
        startSeriesMetadata(tags, seriesIndex, baseFileName);
        try {
            //Add these tags in only once, but need to get them from image rather than summary metadata
            setOMEDetectorMetadata(tags);
            if (tags.has("Time") && !tags.isNull("Time")) {
                metadata_.setImageAcquisitionDate(
                        new Timestamp(DateTools.formatDate(tags.getString("Time"), "yyyy-MM-dd HH:mm:ss")),
                        seriesIndex);
            }
        } catch (Exception e) {
            ReportingUtils.logError("Problem adding System state cahce metadata to OME Metadata");
        }
    }

    Indices indices = series_.get(seriesIndex);

    //Required tags: Channel, slice, and frame index
    try {
        int slice = MDUtils.getSliceIndex(tags);
        int frame = MDUtils.getFrameIndex(tags);
        int channel = MDUtils.getChannelIndex(tags);

        //New tiff data if unexpected index, or new file
        boolean newTiffData = !mptStorage_.hasExpectedImageOrder() || ifdCount == 0
                || indices.tiffDataPlaneCount_ == 0;
        // ifdCount is 0 when a new file started, tiff data plane count is 0 at a new position
        if (newTiffData) { //create new tiff data element
            indices.tiffDataIndex_++;
            metadata_.setTiffDataFirstZ(new NonNegativeInteger(slice), seriesIndex, indices.tiffDataIndex_);
            metadata_.setTiffDataFirstC(new NonNegativeInteger(channel), seriesIndex, indices.tiffDataIndex_);
            metadata_.setTiffDataFirstT(new NonNegativeInteger(frame), seriesIndex, indices.tiffDataIndex_);
            metadata_.setTiffDataIFD(new NonNegativeInteger(ifdCount), seriesIndex, indices.tiffDataIndex_);
            metadata_.setUUIDFileName(currentFileName, seriesIndex, indices.tiffDataIndex_);
            indices.tiffDataPlaneCount_ = 1;
        } else { //continue adding to previous tiffdata element
            indices.tiffDataPlaneCount_++;
        }
        metadata_.setTiffDataPlaneCount(new NonNegativeInteger(indices.tiffDataPlaneCount_), seriesIndex,
                indices.tiffDataIndex_);

        metadata_.setPlaneTheZ(new NonNegativeInteger(slice), seriesIndex, indices.planeIndex_);
        metadata_.setPlaneTheC(new NonNegativeInteger(channel), seriesIndex, indices.planeIndex_);
        metadata_.setPlaneTheT(new NonNegativeInteger(frame), seriesIndex, indices.planeIndex_);
    } catch (JSONException ex) {
        ReportingUtils.showError("Image Metadata missing ChannelIndex, SliceIndex, or FrameIndex");
    } catch (Exception e) {
        ReportingUtils.logError("Couldn't add to OME metadata");
    }

    //Optional tags
    try {

        if (tags.has("Exposure-ms") && !tags.isNull("Exposure-ms")) {
            metadata_.setPlaneExposureTime(tags.getDouble("Exposure-ms") / 1000.0, seriesIndex,
                    indices.planeIndex_);
        }
        if (tags.has("XPositionUm") && !tags.isNull("XPositionUm")) {
            metadata_.setPlanePositionX(tags.getDouble("XPositionUm"), seriesIndex, indices.planeIndex_);
            if (indices.planeIndex_ == 0) { //should be set at start, but dont have position coordinates then
                metadata_.setStageLabelX(tags.getDouble("XPositionUm"), seriesIndex);
            }
        }
        if (tags.has("YPositionUm") && !tags.isNull("YPositionUm")) {
            metadata_.setPlanePositionY(tags.getDouble("YPositionUm"), seriesIndex, indices.planeIndex_);
            if (indices.planeIndex_ == 0) {
                metadata_.setStageLabelY(tags.getDouble("YPositionUm"), seriesIndex);
            }
        }
        if (tags.has("ZPositionUm") && !tags.isNull("ZPositionUm")) {
            metadata_.setPlanePositionZ(tags.getDouble("ZPositionUm"), seriesIndex, indices.planeIndex_);
        }
        if (tags.has("ElapsedTime-ms") && !tags.isNull("ElapsedTime-ms")) {
            metadata_.setPlaneDeltaT(tags.getDouble("ElapsedTime-ms") / 1000.0, seriesIndex,
                    indices.planeIndex_);
        }

    } catch (JSONException e) {
        ReportingUtils.logError("Problem adding tags to OME Metadata");
    }

    indices.planeIndex_++;

    //This code is used is estimating the length of OME XML to be added in, so
    //images arent written into file space reserved for it
    if (omeXMLImageLength_ == -1) {
        //This is the first image plane to be written, so calculate the change in length from the base OME
        //XML length to estimate the approximate memory needed per an image plane
        try {
            OMEXMLService service = new ServiceFactory().getInstance(OMEXMLService.class);
            omeXMLImageLength_ = (int) (1.1 * (service.getOMEXML(metadata_).length() - omeXMLBaseLength_));
        } catch (Exception ex) {
            ReportingUtils.logError("Unable to calculate OME XML Image length");
        }
    }
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP070402DataImpl.java

public static EEP070402DataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP070402DataImpl(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, null);

    try {// w w  w.  j  a va  2 s  .c  o  m
        float supplyVoltage = (float) lastKnownData.getDouble("supplyVoltage");
        float temperature = (float) lastKnownData.getDouble("temperature");
        float relativeHumidity = (float) lastKnownData.getDouble("relativeHumidity");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP070402DataImpl(supplyVoltage, temperature, relativeHumidity, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP070402DataImpl(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, null);
    }
}

From source file:com.qualisys.parkassist.FetchWeatherTask.java

/**
 * Take the String representing the complete forecast in JSON Format and
 * pull out the data we need to construct the Strings needed for the wireframes.
 * <p/>//  w  w w . j  ava 2  s  .c o m
 * Fortunately parsing is easy:  constructor takes the JSON string and converts it
 * into an Object hierarchy for us.
 */
private String[] getWeatherDataFromJson(String forecastJsonStr, int numDays, String locationSetting)
        throws JSONException {

    // These are the names of the JSON objects that need to be extracted.

    // Location information
    final String OWM_CITY = "city";
    final String OWM_CITY_NAME = "name";
    final String OWM_COORD = "coord";
    final String OWM_COORD_LAT = "lat";
    final String OWM_COORD_LONG = "lon";

    // Weather information.  Each day's forecast info is an element of the "list" array.
    final String OWM_LIST = "list";

    final String OWM_DATETIME = "dt";
    final String OWM_PRESSURE = "pressure";
    final String OWM_HUMIDITY = "humidity";
    final String OWM_WINDSPEED = "speed";
    final String OWM_WIND_DIRECTION = "deg";

    // All temperatures are children of the "temp" object.
    final String OWM_TEMPERATURE = "temp";
    final String OWM_MAX = "max";
    final String OWM_MIN = "min";

    final String OWM_WEATHER = "weather";
    final String OWM_DESCRIPTION = "main";
    final String OWM_WEATHER_ID = "id";

    JSONObject forecastJson = new JSONObject(forecastJsonStr);
    JSONArray weatherArray = forecastJson.getJSONArray(OWM_LIST);

    JSONObject cityJson = forecastJson.getJSONObject(OWM_CITY);
    String cityName = cityJson.getString(OWM_CITY_NAME);
    JSONObject coordJSON = cityJson.getJSONObject(OWM_COORD);
    double cityLatitude = coordJSON.getLong(OWM_COORD_LAT);
    double cityLongitude = coordJSON.getLong(OWM_COORD_LONG);

    Log.v(LOG_TAG, cityName + ", with coord: " + cityLatitude + " " + cityLongitude);

    // Insert the location into the database.
    long locationID = addLocation(locationSetting, cityName, cityLatitude, cityLongitude);

    Vector<ContentValues> cVVector = new Vector<ContentValues>(weatherArray.length());
    String[] resultStrs = new String[numDays];

    for (int i = 0; i < weatherArray.length(); i++) {
        // These are the values that will be collected.

        long dateTime;
        double pressure;
        int humidity;
        double windSpeed;
        double windDirection;

        double high;
        double low;

        String description;
        int weatherId;

        // Get the JSON object representing the day
        JSONObject dayForecast = weatherArray.getJSONObject(i);

        // The date/time is returned as a long.  We need to convert that
        // into something human-readable, since most people won't read "1400356800" as
        // "this saturday".
        dateTime = dayForecast.getLong(OWM_DATETIME);

        pressure = dayForecast.getDouble(OWM_PRESSURE);
        humidity = dayForecast.getInt(OWM_HUMIDITY);
        windSpeed = dayForecast.getDouble(OWM_WINDSPEED);
        windDirection = dayForecast.getDouble(OWM_WIND_DIRECTION);

        // Description is in a child array called "weather", which is 1 element long.
        // That element also contains a weather code.
        JSONObject weatherObject = dayForecast.getJSONArray(OWM_WEATHER).getJSONObject(0);
        description = weatherObject.getString(OWM_DESCRIPTION);
        weatherId = weatherObject.getInt(OWM_WEATHER_ID);

        // Temperatures are in a child object called "temp".  Try not to name variables
        // "temp" when working with temperature.  It confuses everybody.
        JSONObject temperatureObject = dayForecast.getJSONObject(OWM_TEMPERATURE);
        high = temperatureObject.getDouble(OWM_MAX);
        low = temperatureObject.getDouble(OWM_MIN);

        ContentValues weatherValues = new ContentValues();
        /*
                    weatherValues.put(WeatherEntry.COLUMN_LOC_KEY, locationID);
                    weatherValues.put(WeatherEntry.COLUMN_DATETEXT, WeatherContract.getDbDateString(new Date(dateTime * 1000L)));
                    weatherValues.put(WeatherEntry.COLUMN_HUMIDITY, humidity);
                    weatherValues.put(WeatherEntry.COLUMN_PRESSURE, pressure);
                    weatherValues.put(WeatherEntry.COLUMN_WIND_SPEED, windSpeed);
                    weatherValues.put(WeatherEntry.COLUMN_DEGREES, windDirection);
                    weatherValues.put(WeatherEntry.COLUMN_MAX_TEMP, high);
                    weatherValues.put(WeatherEntry.COLUMN_MIN_TEMP, low);
                    weatherValues.put(WeatherEntry.COLUMN_SHORT_DESC, description);
                    weatherValues.put(WeatherEntry.COLUMN_WEATHER_ID, weatherId);
        */
        cVVector.add(weatherValues);

        String highAndLow = formatHighLows(high, low);
        String day = getReadableDateString(dateTime);
        resultStrs[i] = day + " - " + description + " - " + highAndLow;
    }

    ContentValues[] contentValuesToBulkInsert = new ContentValues[cVVector.size()];
    cVVector.toArray(contentValuesToBulkInsert);
    /*
    mContext.getContentResolver().bulkInsert(WeatherEntry.CONTENT_URI, contentValuesToBulkInsert);
    */
    return resultStrs;
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEP0706xxDataImpl.java

public static EEP0706xxDataImpl constructDataFromRecord(JSONObject lastKnownData) {
    if (lastKnownData == null)
        return new EEP0706xxDataImpl(Float.MIN_VALUE, -1, null);

    try {/*from www.j  a v  a  2s  .  c  om*/
        float supplyVoltage = (float) lastKnownData.getDouble("supplyVoltage");
        int illumination = lastKnownData.getInt("illumination");
        Date date = new Date(lastKnownData.getLong("date"));

        return new EEP0706xxDataImpl(supplyVoltage, illumination, date);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEP0706xxDataImpl(Float.MIN_VALUE, -1, null);
    }
}

From source file:com.cleanwiz.applock.ui.activity.SplashActivity.java

public void checkVersion() {
    requestQueue = Volley.newRequestQueue(this);
    String url = "http://www.toolwiz.com/android/checkfiles.php";
    final String oldVersionString = getApplicationVersion();
    Locale locale = getResources().getConfiguration().locale;
    String language = locale.getLanguage();
    Uri.Builder builder = Uri.parse(url).buildUpon();
    builder.appendQueryParameter("uid", AndroidUtil.getUdid(this));
    builder.appendQueryParameter("version", oldVersionString);
    builder.appendQueryParameter("action", "checkfile");
    builder.appendQueryParameter("app", "locklocker");
    builder.appendQueryParameter("language", language);

    jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, builder.toString(), null,
            new Response.Listener<JSONObject>() {

                @SuppressLint("NewApi")
                @Override//from w ww  .j a  v  a2  s .  co m
                public void onResponse(JSONObject arg0) {
                    // TODO Auto-generated method stub
                    LogUtil.e("colin", "success");
                    if (arg0.has("status")) {
                        try {
                            String status = arg0.getString("status");
                            if (Integer.valueOf(status) == 1) {
                                JSONObject msgJsonObject = arg0.getJSONObject("msg");
                                double version = msgJsonObject.getDouble("version");
                                downLoadFileUrl = msgJsonObject.getString("url");
                                fileSize = msgJsonObject.getString("size");
                                if (Double.valueOf(oldVersionString) < version && !downLoadFileUrl.isEmpty()) {
                                    // ???
                                    String intro = msgJsonObject.getString("intro");
                                    LogUtil.e("colin", "........" + intro);
                                    showUpdateDialog(intro);
                                } else {
                                    LogUtil.e("colin", "check update status is same not to update");
                                    SplashHandler handler = new SplashHandler();
                                    Message msg = new Message();
                                    msg.what = CHECKVERSION_EOOR;
                                    handler.sendMessage(msg);
                                }
                            } else {
                                LogUtil.e("colin", "check update status is error");
                                SplashHandler handler = new SplashHandler();
                                Message msg = new Message();
                                msg.what = CHECKVERSION_EOOR;
                                handler.sendMessage(msg);
                            }
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            SplashHandler handler = new SplashHandler();
                            Message msg = new Message();
                            msg.what = CHECKVERSION_EOOR;
                            handler.sendMessage(msg);
                            e.printStackTrace();
                        }
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError arg0) {
                    // TODO Auto-generated method stub
                    SplashHandler handler = new SplashHandler();
                    Message msg = new Message();
                    msg.what = CHECKVERSION_EOOR;
                    handler.sendMessage(msg);
                }
            });
    requestQueue.add(jsonObjectRequest);
}

From source file:org.achtern.AchternEngine.core.resource.loader.json.MaterialLoader.java

@Override
public Material get() throws Exception {
    final JSONObject json = getJsonObject();

    final Material material = new Material();

    // Start with the simplest one
    if (json.has("wireframe")) {
        material.asWireframe(json.getBoolean("wireframe"));
    }/*from w w  w  .j a v  a 2  s . com*/

    // All Floats
    if (json.has("float")) {
        JSONObject floats = json.getJSONObject("float");

        for (Object oKey : floats.keySet()) {
            String key = (String) oKey;

            material.addFloat(key, (float) floats.getDouble(key));

        }
    }

    // All Colors
    if (json.has("Color")) {
        JSONObject colors = json.getJSONObject("Color");

        for (Object oKey : colors.keySet()) {
            String key = (String) oKey;

            material.addColor(key, getColor(colors.getJSONObject(key)));

        }
    }

    if (json.has("Texture")) {
        // All Textures
        JSONObject textures = json.getJSONObject("Texture");

        for (Object oKey : textures.keySet()) {
            String key = (String) oKey;

            material.addTexture(key, getTexture(textures.getJSONObject(key)));

        }
    }

    return material;
}