Example usage for org.json JSONObject optString

List of usage examples for org.json JSONObject optString

Introduction

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

Prototype

public String optString(String key) 

Source Link

Document

Get an optional string associated with a key.

Usage

From source file:com.bt.heliniumstudentapp.UpdateClass.java

@Override
protected void onPostExecute(String html) {
    if (html != null) {
        try {/* w  w w.j a  va2  s .  c o m*/
            final JSONObject json = (JSONObject) new JSONTokener(html).nextValue();

            versionName = json.optString("version_name");
            final int versionCode = json.optInt("version_code");

            try {
                final int currentVersionCode = context.getPackageManager()
                        .getPackageInfo(context.getPackageName(), 0).versionCode;

                if (versionCode > currentVersionCode) {
                    if (!settings)
                        updateDialog.show();

                    updateDialog.setTitle(context.getString(R.string.update) + ' ' + versionName);

                    final TextView contentTV = (TextView) updateDialog.findViewById(R.id.tv_content_du);
                    contentTV.setTextColor(ContextCompat.getColor(context, MainActivity.themePrimaryTextColor));
                    contentTV.setText(Html.fromHtml(json.optString("content"), null, new Html.TagHandler() {

                        @Override
                        public void handleTag(boolean opening, String tag, Editable output,
                                XMLReader xmlReader) {
                            if ("li".equals(tag))
                                if (opening)
                                    output.append(" \u2022 ");
                                else
                                    output.append("\n");
                        }
                    }));

                    updateDialog.setCanceledOnTouchOutside(true);

                    updateDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);

                    updateDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                            .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
                } else if (settings) {
                    updateDialog.setTitle(context.getString(R.string.update_no));

                    final TextView contentTV = (TextView) updateDialog.findViewById(R.id.tv_content_du);
                    contentTV.setTextColor(ContextCompat.getColor(context, MainActivity.themePrimaryTextColor));
                    contentTV.setText(Html.fromHtml(json.optString("content"), null, new Html.TagHandler() {

                        @Override
                        public void handleTag(boolean opening, String tag, Editable output,
                                XMLReader xmlReader) {
                            if ("li".equals(tag))
                                if (opening)
                                    output.append(" \u2022 ");
                                else
                                    output.append("\n");
                        }
                    }));

                    updateDialog.setCanceledOnTouchOutside(true);
                }
            } catch (NameNotFoundException e) {
                Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
            }
        } catch (JSONException e) {
            Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show();
        }
    } else if (settings) {
        updateDialog.cancel();

        final AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder(
                new ContextThemeWrapper(context, MainActivity.themeDialog));

        updateDialogBuilder.setTitle(context.getString(R.string.update));

        updateDialogBuilder.setMessage(R.string.error_update);

        updateDialogBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                downloadAPK();
            }
        });

        updateDialogBuilder.setNegativeButton(android.R.string.no, null);

        final AlertDialog updateDialog = updateDialogBuilder.create();

        updateDialog.setCanceledOnTouchOutside(true);
        updateDialog.show();

        updateDialog.getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
        updateDialog.getButton(AlertDialog.BUTTON_NEGATIVE)
                .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor));
    }
}

From source file:com.bojie.weatherbo.ui.inappbilling.SkuDetails.java

public SkuDetails(final String itemType, final String jsonSkuDetails) throws JSONException {
    mItemType = itemType;//ww  w .  j  a  va  2s. c  o m
    mJson = jsonSkuDetails;
    final JSONObject o = new JSONObject(mJson);
    mSku = o.optString("productId");
    mType = o.optString("type");
    mPrice = o.optString("price");
    mTitle = o.optString("title");
    mDescription = o.optString("description");
}

From source file:com.example.administrator.datarequest.ningworld.HttpHeaders.java

@Override
public void setJSONString(String jsonString) throws JSONException {
    mSource.clear();//from  w w w  .  j  a  v a2s . c o m
    JSONObject jsonObject = new JSONObject(jsonString);
    Iterator<String> keySet = jsonObject.keys();
    while (keySet.hasNext()) {
        String key = keySet.next();
        String value = jsonObject.optString(key);
        JSONArray values = new JSONArray(value);
        if (values != null)
            for (int i = 0; i < values.length(); i++)
                add(key, values.optString(i));
    }
}

From source file:com.chaosinmotion.securechat.server.commands.GetMessages.java

public static ReturnResult processRequest(Login.UserInfo userinfo, JSONObject requestParams)
        throws ClassNotFoundException, SQLException, IOException {
    String deviceid = requestParams.optString("deviceid");
    MessageReturnResult mrr = new MessageReturnResult();

    /*/*  w w  w .j ava 2  s.com*/
     * Save message to the database.
     */

    Connection c = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        /*
         * Get the device ID for this device. Verify it belongs to the
         * user specified
         */
        c = Database.get();
        ps = c.prepareStatement("SELECT deviceid " + "FROM Devices " + "WHERE deviceuuid = ? AND userid = ?");
        ps.setString(1, deviceid);
        ps.setInt(2, userinfo.getUserID());
        rs = ps.executeQuery();

        int deviceID = 0;
        if (rs.next()) {
            deviceID = rs.getInt(1);
        }

        rs.close();
        ps.close();
        if (deviceID == 0) {
            return new ReturnResult(Errors.ERROR_UNKNOWNDEVICE, "Unknown device");
        }

        /*
         * Run query to get messages
         */

        ps = c.prepareStatement("SELECT Messages.messageid, " + "    Messages.senderid, "
                + "    Users.username, " + "    Messages.toflag, " + "    Messages.received, "
                + "    Messages.message " + "FROM Messages, Users " + "WHERE Messages.deviceid = ? "
                + "  AND Messages.senderid = Users.userid");
        ps.setInt(1, deviceID);

        rs = ps.executeQuery();
        while (rs.next()) {
            int messageID = rs.getInt(1);
            int senderID = rs.getInt(2);
            String senderName = rs.getString(3);
            boolean toflag = rs.getBoolean(4);
            Timestamp received = rs.getTimestamp(5);
            byte[] message = rs.getBytes(6);

            mrr.addMessage(messageID, senderID, senderName, toflag, received, message);
        }

        /*
         * Return messages
         */
        return mrr;
    } finally {
        if (rs != null)
            rs.close();
        if (ps != null)
            ps.close();
        if (c != null)
            c.close();
    }
}

From source file:com.phelps.liteweibo.model.weibo.ErrorInfo.java

public static ErrorInfo parse(String jsonString) {
    if (TextUtils.isEmpty(jsonString)) {
        return null;
    }/*  w w w  .j a  va  2 s  . c o  m*/

    ErrorInfo errorInfo = new ErrorInfo();
    try {
        JSONObject jsonObject = new JSONObject(jsonString);
        errorInfo.error = jsonObject.optString("error");
        errorInfo.error_code = jsonObject.optString("error_code");
        errorInfo.request = jsonObject.optString("request");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return errorInfo;
}

From source file:plugin.google.iap.v3.util.SkuDetails.java

public SkuDetails(String itemType, String jsonSkuDetails) throws JSONException {
    mItemType = itemType;/*w  ww. j  a  va  2s . c  om*/
    mJson = jsonSkuDetails;
    JSONObject o = new JSONObject(mJson);
    mSku = o.optString("productId");
    mType = o.optString("type");
    mPrice = o.optString("price");
    mTitle = o.optString("title");
    mDescription = o.optString("description");
    mPriceCurrencyCode = o.optString("price_currency_code");
    mPriceAmountMicros = o.optString("price_amount_micros");
}

From source file:com.util.httpHistorial.java

public List<Llamadas> getHistorial(String idAccount, String page, String max, String startDate, String endDate,
        String destination) {// www .j av  a  2s .  c o m

    // String idAccount = "2";
    // String page = "1";
    // String max = "10";
    //String startDate = "2016-09-20 00:00:00";
    // String endDate = "2016-10-30 23:59:59";
    // String destination = "";
    System.out.println("OBTENER SOLO UN ARRAY DE CADENA JSON");
    String myURL = "http://192.168.5.44/app_dev.php/cus/cdrs/history/" + idAccount + ".json";
    System.out.println("Requested URL:" + myURL);
    StringBuilder sb = new StringBuilder();
    URLConnection urlConn = null;
    InputStreamReader in = null;
    try {
        URL url = new URL(myURL);
        urlConn = url.openConnection();
        if (urlConn != null) {
            urlConn.setReadTimeout(60 * 1000);
            urlConn.setDoOutput(true);
            String data = URLEncoder.encode("page", "UTF-8") + "=" + URLEncoder.encode(page, "UTF-8");
            data += "&" + URLEncoder.encode("max", "UTF-8") + "=" + URLEncoder.encode(max, "UTF-8");
            data += "&" + URLEncoder.encode("startDate", "UTF-8") + "=" + URLEncoder.encode(startDate, "UTF-8");
            data += "&" + URLEncoder.encode("endDate", "UTF-8") + "=" + URLEncoder.encode(endDate, "UTF-8");
            data += "&" + URLEncoder.encode("destination", "UTF-8") + "="
                    + URLEncoder.encode(destination, "UTF-8");
            System.out.println("los Datos a enviar por POST son " + data);

            try ( //obtenemos el flujo de escritura
                    OutputStreamWriter wr = new OutputStreamWriter(urlConn.getOutputStream())) {
                //escribimos
                wr.write(data);
                wr.flush();
                //cerramos la conexin
            }
        }
        if (urlConn != null && urlConn.getInputStream() != null) {
            in = new InputStreamReader(urlConn.getInputStream(), Charset.defaultCharset());

            BufferedReader bufferedReader = new BufferedReader(in);
            if (bufferedReader != null) {
                int cp;
                while ((cp = bufferedReader.read()) != -1) {
                    sb.append((char) cp);
                }
                bufferedReader.close();
            }
        }
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Exception while calling URL:" + myURL, e);
    }
    String jsonResult = sb.toString();
    System.out.println("DATOS ENVIADOS DEL SERVIDOR " + sb.toString());

    System.out.println(
            "\n\n--------------------OBTENEMOS OBJETO JSON NATIVO DE LA PAGINA, USAMOS EL ARRAY DATA---------------------------\n\n");
    JSONObject objJason = new JSONObject(jsonResult);
    // JSONArray dataJson = new JSONArray();
    //  dataJson = objJason.getJSONArray("data");
    String jdata = objJason.optString("data");
    String mensaje = objJason.optString("message");
    System.out.println("\n\n MENSAJE DEL SERVIDOR " + mensaje);
    //System.out.println(" el objeto jdata es "+jdata);
    objJason = new JSONObject(jdata);
    //  System.out.println("objeto normal 1 " + objJason.toString());
    //
    jdata = objJason.optString("items");
    // System.out.println("\n\n el objeto jdata es " + jdata);
    JSONArray jsonArray = new JSONArray();
    Gson gson = new Gson();
    //objJason = gson.t
    jsonArray = objJason.getJSONArray("items");
    // System.out.println("\n\nEL ARRAY FINAL ES " + jsonArray.toString());

    List<Llamadas> llamadas = new ArrayList<Llamadas>();

    for (int i = 0; i < jsonArray.length(); i++) {
        Llamadas llamada = new Llamadas();
        llamada.setNo(i + 1);
        llamada.setInicioLLamada(jsonArray.getJSONObject(i).getString("callstart"));
        llamada.setNumero(jsonArray.getJSONObject(i).getString("callednum"));
        llamada.setPais_operador(jsonArray.getJSONObject(i).getString("notes"));
        llamada.setDuracionSegundos(String.valueOf(jsonArray.getJSONObject(i).getBigDecimal("billseconds")));
        llamada.setCostoTotal(String.valueOf(jsonArray.getJSONObject(i).getBigDecimal("cost")));
        llamada.setCostoMinuto(String.valueOf(jsonArray.getJSONObject(i).getBigDecimal("rate_cost")));

        long minutos = Long.parseLong(llamada.getDuracionSegundos()) / 60;
        llamada.setDuracionMinutos(minutos);

        llamadas.add(llamada);

    }

    for (int i = 0; i < llamadas.size(); i++) {
        System.out.print("\n\nNo" + llamadas.get(i).getNo());
        System.out.print("  Fecna " + llamadas.get(i).getInicioLLamada());
        System.out.print("  Numero " + llamadas.get(i).getNumero());
        System.out.print("  Pais-Operador " + llamadas.get(i).getPais_operador());
        System.out.print("  Cantidad de segundos " + llamadas.get(i).getDuracionSegundos());
        System.out.print("  Costo total " + llamadas.get(i).getCostoTotal());
        System.out.print("  costo por minuto " + llamadas.get(i).getCostoMinuto());
        System.out.print("  costo por minuto " + llamadas.get(i).getDuracionMinutos());

    }

    /**
     * List<String> list = new ArrayList<String>(); for (int i = 0; i <
     * jsonArray.length(); i++) { list.add(String.valueOf(i));
     * list.add(jsonArray.getJSONObject(i).getString("callstart"));
     * list.add(jsonArray.getJSONObject(i).getString("callednum"));
     * list.add(jsonArray.getJSONObject(i).getString("notes"));
     * list.add(String.valueOf(jsonArray.getJSONObject(i).getBigDecimal("cost")));
     * list.add(String.valueOf(jsonArray.getJSONObject(i).getBigDecimal("billseconds")));
     * list.add(String.valueOf(jsonArray.getJSONObject(i).getBigDecimal("rate_cost")));
     * } System.out.println("\n\nel array java contiene " +
     * list.toString());
     *
     */
    return llamadas;
}

From source file:com.bojie.weatherbo.ui.inappbilling.Purchase.java

public Purchase(final String itemType, final String jsonPurchaseInfo, final String signature)
        throws JSONException {
    mItemType = itemType;//from  w  w  w  .jav  a2 s.  c om
    mOriginalJson = jsonPurchaseInfo;
    final JSONObject o = new JSONObject(mOriginalJson);
    mOrderId = o.optString("orderId");
    mPackageName = o.optString("packageName");
    mSku = o.optString("productId");
    mPurchaseTime = o.optLong("purchaseTime");
    mPurchaseState = o.optInt("purchaseState");
    mDeveloperPayload = o.optString("developerPayload");
    mToken = o.optString("token", o.optString("purchaseToken"));
    mSignature = signature;
}

From source file:net.portalblockz.portalbot.urlshorteners.GooGl.java

@Override
public String shorten(String url) {
    StringBuilder response = new StringBuilder();
    try {/*from   w  ww  . j a  va2s  .  co m*/
        URL req = new URL("https://www.googleapis.com/urlshortener/v1/url");

        HttpsURLConnection con = (HttpsURLConnection) req.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json");
        con.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes("{\"longUrl\": \"" + url + "\"}");
        wr.flush();
        wr.close();

        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        JSONObject res = new JSONObject(response.toString());
        if (res.optString("id") != null)
            return res.getString("id");

    } catch (Exception ignored) {
        ignored.printStackTrace();
        System.out.print(response.toString());
    }
    return null;
}

From source file:at.alladin.rmbt.android.views.ResultGraphView.java

private void redraw(JSONArray result) {
    try {/*from   w  w  w  .  ja  v  a 2s  . co  m*/
        JSONObject curve = result.getJSONObject(0).getJSONObject("speed_curve");
        if (curve != null) {
            uploadArray = curve.getJSONArray("upload");
            downloadArray = curve.getJSONArray("download");
            signalArray = curve.getJSONArray("signal");
        }

        //System.out.println(signalArray);

        long maxTimeUpload = result.getJSONObject(0).optLong("time_ul_ms")
                + result.getJSONObject(0).optLong("duration_upload_ms");
        long timeElapsed = Math.round((double) maxTimeUpload / 1000);

        if (signalGraph != null && signalArray != null && signalArray.length() > 0
                && signalGraph.getGraphs().size() < 1) {
            Log.d("ResultGraphView", "DRAWING SIGNAL GRAPH\n" + signalArray);

            final long maxTimeSignal = signalArray.optJSONObject(signalArray.length() - 1)
                    .optLong("time_elapsed");
            final long timeElapsedMs = Math.max(maxTimeSignal, maxTimeUpload);
            timeElapsed = Math.round((double) timeElapsedMs / 1000);

            signalGraph.getLabelHMaxList().clear();
            signalGraph.addLabelHMax(String.valueOf(timeElapsed < 7 ? 7 : timeElapsed));
            signalGraph.updateGrid((int) timeElapsed, 4);
            /* [{"network_type":"WLAN","time_elapsed":0,"signal_strength":-56},
             * {"network_type":"WLAN","time_elapsed":10121,"signal_strength":-55},
             * {"network_type":"WLAN","time_elapsed":37478,"signal_strength":-57}]
             */
            MinMax<Integer> signalBoundsRsrp = NetworkUtil
                    .getSignalStrengthBounds(InformationCollector.SINGAL_TYPE_RSRP);
            MinMax<Integer> signalBoundsWlan = NetworkUtil
                    .getSignalStrengthBounds(InformationCollector.SINGAL_TYPE_WLAN);
            MinMax<Integer> signalBoundsMobile = NetworkUtil
                    .getSignalStrengthBounds(InformationCollector.SINGAL_TYPE_MOBILE);

            List<GraphService> signalList = new ArrayList<GraphService>();

            boolean has4G = false;
            boolean has3G = false;
            boolean hasWlan = false;
            String lastNetworkType = "";
            String lastCatTechnology = "";

            GraphService curGraph = null;

            double prevValue = 0d;

            boolean hasSignalCategoryChanged = false;
            double lastLabelYPosition = -1d;
            double time = 0d;
            double signalChangeStartTime = 0d;
            double value = 0d;
            double oldValidValue = 0d;

            System.out.println("MAXTIME: " + timeElapsedMs);

            for (int i = 0; i < signalArray.length(); i++) {
                JSONObject signalObject = signalArray.getJSONObject(i);
                String networkType = signalObject.optString("network_type");
                String catTechnology = signalObject.optString("cat_technology");
                //set proper signal strength attribute
                String signalAttribute = "signal_strength";
                String signalColor = "#ffffff";

                time = i > 0 ? ((double) signalObject.getInt("time_elapsed") / (double) timeElapsedMs) : 0d;

                oldValidValue = value > 0d ? value : oldValidValue;

                if ("LTE".equals(networkType)) {
                    if (!lastNetworkType.equals(networkType) && !lastCatTechnology.equals(catTechnology)) {
                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }

                        GraphService newGraph = StaticGraph.addGraph(signalGraph,
                                Color.parseColor(COLOR_SIGNAL_4G), signalArray.length() == 1 ? true : false);
                        signalList.add(newGraph);
                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }
                        signalChangeStartTime = time;
                        hasSignalCategoryChanged = true;
                        curGraph = newGraph;
                    }
                    has4G = true;
                    signalAttribute = "lte_rsrp";
                    signalColor = COLOR_SIGNAL_4G;
                    value = getRelativeSignal(signalBoundsRsrp, signalAttribute, signalObject);
                } else if ("WLAN".equals(networkType)) {
                    if (!lastNetworkType.equals(networkType) && !lastCatTechnology.equals(catTechnology)) {
                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }

                        GraphService newGraph = StaticGraph.addGraph(signalGraph,
                                Color.parseColor(COLOR_SIGNAL_WLAN), signalArray.length() == 1 ? true : false);
                        signalList.add(newGraph);

                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }
                        signalChangeStartTime = time;
                        hasSignalCategoryChanged = true;
                        curGraph = newGraph;
                    }
                    hasWlan = true;
                    signalAttribute = "signal_strength";
                    signalColor = COLOR_SIGNAL_WLAN;
                    value = getRelativeSignal(signalBoundsWlan, signalAttribute, signalObject);
                } else {
                    if (!lastNetworkType.equals(networkType)) {
                        signalChangeStartTime = time;
                        hasSignalCategoryChanged = true;

                        if (curGraph != null) {
                            curGraph.addValue((1 - prevValue), time);
                        }

                        if ((!lastCatTechnology.equals(catTechnology)) && ("4G".equals(lastCatTechnology)
                                || "WLAN".equals(lastCatTechnology) || "".equals(lastCatTechnology))) {

                            GraphService newGraph = StaticGraph.addGraph(signalGraph,
                                    Color.parseColor(COLOR_SIGNAL_3G),
                                    signalArray.length() == 1 ? true : false);

                            signalList.add(newGraph);
                            if (curGraph != null) {
                                curGraph.addValue((1 - prevValue), time);
                            }
                            curGraph = newGraph;
                        }
                    }
                    has3G = true;
                    signalAttribute = "signal_strength";
                    signalColor = COLOR_SIGNAL_3G;
                    value = getRelativeSignal(signalBoundsMobile, signalAttribute, signalObject);
                }

                if (value > 0d) {
                    System.out.println("SIGNAL: " + value + "@" + time + " = " + signalObject);
                    if (value >= 0d && curGraph != null) {
                        if (hasSignalCategoryChanged) {
                            curGraph.addValue((1 - value), signalChangeStartTime);
                            hasSignalCategoryChanged = false;

                            if (lastLabelYPosition == -1d) {
                                lastLabelYPosition = (float) (1 - (value > 0d ? value : prevValue));
                            } else {
                                if (Math.abs(signalChangeStartTime - time) < .125d) {
                                    float curPosition = (float) (1 - (value > 0d ? value : prevValue));
                                    if (Math.abs(curPosition - lastLabelYPosition) <= .11d) {
                                        lastLabelYPosition = curPosition
                                                + (curPosition > lastLabelYPosition ? +.1d : -.1d);
                                    } else {
                                        lastLabelYPosition = curPosition;
                                    }
                                } else {
                                    lastLabelYPosition = (float) (1 - (value > 0d ? value : prevValue));
                                }
                            }

                            //lastLabelXPosition = (float) time;                        
                            double labelDiff = lastLabelYPosition - (1 - value);

                            System.out.println("i" + i + " -> " + lastLabelYPosition + " : " + (1 - value)
                                    + " diff: " + Math.abs(labelDiff) + " istoolow (<.09d)? "
                                    + (Math.abs(labelDiff) < .09d));
                            if (Math.abs(labelDiff) < .09d && i == 0) {
                                if (labelDiff < 0d) {
                                    lastLabelYPosition = lastLabelYPosition < .50d ? lastLabelYPosition - .075d
                                            : lastLabelYPosition + .075d;
                                } else {
                                    lastLabelYPosition = lastLabelYPosition < .50d ? lastLabelYPosition + .075d
                                            : lastLabelYPosition - .075d;
                                }
                            }

                            signalGraph.addLabel((float) signalChangeStartTime, (float) lastLabelYPosition,
                                    networkType, signalColor);
                        }

                        //System.out.println("ADDING VALUE TO GRAPH " + (1 - value) + " on: " + time);
                        curGraph.addValue((1 - value), time);
                        prevValue = value;
                    }
                }

                lastNetworkType = networkType;
                lastCatTechnology = catTechnology;
            }

            //draw signal graph to the end
            if (prevValue > 0 && curGraph != null) {
                curGraph.addValue((1 - prevValue), 1f);
            }

            signalGraph.clearLabels(CustomizableGraphView.LABELLIST_VERTICAL_MAX);
            signalGraph.clearLabels(CustomizableGraphView.LABELLIST_VERTICAL_MIN);

            if (has3G) {
                signalGraph.addLabelVMax(String.valueOf(signalBoundsMobile.max), COLOR_SIGNAL_3G);
                signalGraph.addLabelVMin(String.valueOf(signalBoundsMobile.min), COLOR_SIGNAL_3G);
            }
            if (has4G) {
                signalGraph.addLabelVMax(String.valueOf(signalBoundsRsrp.max), COLOR_SIGNAL_4G);
                signalGraph.addLabelVMin(String.valueOf(signalBoundsRsrp.min), COLOR_SIGNAL_4G);
            }
            if (hasWlan) {
                signalGraph.addLabelVMax(String.valueOf(signalBoundsWlan.max), COLOR_SIGNAL_WLAN);
                signalGraph.addLabelVMin(String.valueOf(signalBoundsWlan.min), COLOR_SIGNAL_WLAN);
            }
            //signalGraph.repaint(getContext());
        } else if (signalGraph != null && signalGraph.getGraphs().size() > 0) {
            Log.d("ResultGraphView", "REDRAWING SIGNAL GRAPH");
            //signalGraph.repaint(getContext());
            signalGraph.invalidate();
        }

        signalProgress.setVisibility(View.GONE);

        if (uploadArray != null && uploadArray != null && uploadArray.length() > 0
                && ulGraph.getGraphs().size() < 1) {
            Log.d("ResultGraphView", "DRAWING UL GRAPH");
            drawCurve(uploadArray, ulGraph, COLOR_UL_GRAPH, String
                    .valueOf(Math.round(result.getJSONObject(0).optDouble("duration_upload_ms") / 1000d)));

            addStaticMarker(signalArray, signalGraph, COLOR_UL_GRAPH, 70,
                    result.getJSONObject(0).optDouble("time_ul_ms"),
                    result.getJSONObject(0).optDouble("time_ul_ms")
                            + result.getJSONObject(0).optDouble("duration_upload_ms"),
                    timeElapsed * 1000);

            double timeUl = result.getJSONObject(0).optDouble("duration_upload_ms");
            long timeElapsedUl = Math.round(timeUl / 1000);
            ulGraph.setRowLinesLabelList(SPEED_LABELS);
            ulGraph.updateGrid((int) timeElapsedUl, 4.5f);
        } else if (uploadArray.length() > 0 && ulGraph != null && ulGraph.getGraphs().size() > 0) {
            Log.d("ResultGraphView", "REDRAWING UL GRAPH");
            //ulGraph.repaint(getContext());
            ulGraph.invalidate();
        }

        ulProgress.setVisibility(View.GONE);

        if (downloadArray != null && downloadArray != null && downloadArray.length() > 0
                && dlGraph.getGraphs().size() < 1) {
            Log.d("ResultGraphView", "DRAWING DL GRAPH");
            drawCurve(downloadArray, dlGraph, COLOR_DL_GRAPH, String
                    .valueOf(Math.round(result.getJSONObject(0).optDouble("duration_download_ms") / 1000d)));
            addStaticMarker(signalArray, signalGraph, COLOR_DL_GRAPH, 70,
                    result.getJSONObject(0).optDouble("time_dl_ms"),
                    result.getJSONObject(0).optDouble("time_dl_ms")
                            + result.getJSONObject(0).optDouble("duration_download_ms"),
                    timeElapsed * 1000);

            double timeDl = result.getJSONObject(0).optDouble("duration_download_ms");
            long timeElapsedDl = Math.round(timeDl / 1000);
            dlGraph.setRowLinesLabelList(SPEED_LABELS);
            dlGraph.updateGrid((int) timeElapsedDl, 4.5f);
        } else if (downloadArray.length() > 0 && dlGraph != null && dlGraph.getGraphs().size() > 0) {
            Log.d("ResultGraphView", "REDRAWING DL GRAPH");
            //dlGraph.repaint(getContext());
            dlGraph.invalidate();
        }

        dlProgress.setVisibility(View.GONE);

    } catch (Exception e) {
        if (signalGraph != null) {
            signalGraph.invalidate();
        }
        if (ulGraph != null) {
            ulGraph.invalidate();
        }
        if (dlGraph != null) {
            dlGraph.invalidate();
        }
        e.printStackTrace();
        //TODO show no data available view 
    }
}