Example usage for org.json JSONException toString

List of usage examples for org.json JSONException toString

Introduction

In this page you can find the example usage for org.json JSONException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.cssweb.android.view.PriceView.java

public void drawIndex(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);/* ww  w.  j  ava 2  s  .  c o  m*/
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);
    this.x = 0;
    this.y = 0;
    startX = x + tips / 2;
    endX = width - tips / 2;
    canvas.drawRect(startX, DY + DY / 4, endX, height - DY / 4, tPaint);
    canvas.drawLine(startX, DY * 7 + DY / 2, endX, DY * 7 + DY / 2, tPaint);
    canvas.drawLine(startX, DY * 18 + DY / 4, endX, DY * 18 + DY / 4, tPaint);
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            double zrsp = jo.getDouble("zrsp");

            paint.setTextSize(mTextSize);
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(0, DY * 2);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("???", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("??", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("??", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            canvas.translate(width, -DY * 15.5f);
            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("a"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("b"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("govbond"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("fund"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("warrant"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorStockName);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("bond"), true), x - tips, y, paint);

            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);
            canvas.translate(0, DY * 1.5f);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText(Utils.dataFormation(zrsp, stockdigit), x - tips, y, paint);

            double zhangd = jo.getDouble("zd");
            if (zhangd < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangd > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.translate(0, DY);
            String zhangdie = Utils.dataFormation(zhangd, stockdigit);
            if (zhangdie.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangdie, x - tips, y, paint);

            double zhangf = jo.getDouble("zf");
            if (zhangf < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangf > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.translate(0, DY);
            String zhangfu = Utils.dataFormation(zhangf * 100, stockdigit);
            if (zhangfu.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangfu + "%", x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("amp") * 100, 1) + "%", x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjsl"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x - tips, y, paint);

            canvas.translate(0, DY);
            double zg = jo.getDouble("zgcj");
            setColor(paint, zg, zrsp);
            canvas.drawText(Utils.dataFormation(zg, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double zd = jo.getDouble("zdcj");
            setColor(paint, zd, zrsp);
            canvas.drawText(Utils.dataFormation(zd, stockdigit), x - tips, y, paint);

            canvas.translate(-width, DY * 1.7f);

            paint.setTextSize(mTextSize);
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(width / 2, 0);
            canvas.drawText(String.valueOf(jo.getInt("zj")), x, y, paint);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(width / 2, 0);
            canvas.drawText(String.valueOf(jo.getInt("dj")), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.cssweb.android.view.PriceView.java

public void drawHKPrice(Canvas canvas) {
    //canvas.restore();
    Paint paint = this.mPaint;
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);/*from ww w. jav a 2s  .co m*/
    this.x = 0;
    this.y = 0;
    startX = x + tips / 2;
    endX = width - tips / 2;
    canvas.drawRect(startX, DY / 4, endX, height - DY / 4, tPaint);
    //      canvas.drawLine(startX, DY+DY/4, endX, DY+DY/4, tPaint);
    canvas.drawLine(startX, DY * 5 + DY / 4, endX, DY * 5 + DY / 4, tPaint);
    canvas.drawLine(startX, DY * 10 + DY / 4, endX, DY * 10 + DY / 4, tPaint);
    canvas.drawLine(startX, DY * 16 + DY / 4, endX, DY * 16 + DY / 4, tPaint);
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            String str = "";
            double zrsp = jo.getDouble("zrsp");

            canvas.translate(0, DY);

            paint.setTypeface(Typeface.DEFAULT_BOLD);
            paint.setAntiAlias(true);
            paint.setTextSize(mTextSize);
            //            paint.setTextAlign(Paint.Align.LEFT);
            //            paint.setColor(GlobalColor.colorLabelName);
            //            canvas.drawText("", x+tips, y, paint);
            //
            //            paint.setTextAlign(Paint.Align.RIGHT);
            //            canvas.translate(width/2, 0);
            //            if(jo.getDouble("wb")<0)
            //               paint.setColor(GlobalColor.colorPriceDown);
            //            else if(jo.getDouble("wb")>0)
            //               paint.setColor(GlobalColor.colorpriceUp);
            //            else 
            //               paint.setColor(GlobalColor.colorPriceEqual);
            //            canvas.drawText(Utils.dataFormation(jo.getDouble("wb")*100, 1)+"%", x, y, paint);
            //            
            //            paint.setTextAlign(Paint.Align.LEFT);
            //            paint.setColor(GlobalColor.colorLabelName);
            //            canvas.drawText("", x+tips, y, paint);
            //
            //            paint.setTextAlign(Paint.Align.RIGHT);
            //            canvas.translate(width/2, 0);
            //            if(jo.getDouble("wc")<0) {
            //               paint.setColor(GlobalColor.colorPriceDown);
            //               canvas.drawText("-" + Utils.getAmountFormat(Math.abs(jo.getDouble("wc")), true), x-tips, y, paint);
            //            }
            //            else if(jo.getDouble("wc")>0) {
            //               paint.setColor(GlobalColor.colorpriceUp);
            //               canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), true), x-tips, y, paint);
            //            }
            //            else {
            //               paint.setColor(GlobalColor.colorPriceEqual);
            //               canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), true), x-tips, y, paint);
            //            }
            //            
            //            canvas.translate(-width, DY);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 5; i >= 1; i--) {
                double temp2 = jo.getDouble("sjw" + i);
                setColor(paint, temp2, zrsp);
                str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
                canvas.drawText(str, x, y, paint);
                if (i != 1)
                    canvas.translate(0, DY);
            }

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 5; i >= 1; i--) {
                paint.setTextAlign(Paint.Align.RIGHT);
                canvas.drawText(Utils.getAmountFormat(jo.getInt("ssl" + i), false), x - tips, y, paint);
                if (i != 1)
                    canvas.translate(0, DY);
            }

            canvas.translate(-width, DY);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 4);
            paint.setTextAlign(Paint.Align.RIGHT);
            for (int i = 1; i <= 5; i++) {
                double temp2 = jo.getDouble("bjw" + i);
                setColor(paint, temp2, zrsp);
                str = Utils.dataFormation(temp2, stockdigit, jo.getInt("tp"));
                canvas.drawText(str, x, y, paint);
                if (i != 5)
                    canvas.translate(0, DY);
            }

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(width / 2, -DY * 4);
            for (int i = 1; i <= 5; i++) {
                paint.setTextAlign(Paint.Align.RIGHT);
                canvas.drawText(Utils.getAmountFormat(jo.getInt("bsl" + i), false), x - tips, y, paint);
                if (i != 5)
                    canvas.translate(0, DY);
            }

            canvas.translate(-width, DY);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 6);

            paint.setTextAlign(Paint.Align.RIGHT);
            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit, jo.getInt("tp")), x, y, paint);

            canvas.translate(0, DY);
            double zhangd = jo.getDouble("zd");
            if (zhangd < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangd > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            String zhangdie = Utils.dataFormation(zhangd, stockdigit, jo.getInt("tp"));
            if (zhangdie.equals("-") || zhangdie.equals(""))
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(zhangdie, x, y, paint);

            double zhangf = jo.getDouble("zf");
            if (zhangf < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangf > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.translate(0, DY);
            String zhangfu = Utils.dataFormation(zhangf * 100, 1, jo.getInt("tp"));
            if (zhangfu.equals("-") || zhangfu.equals(""))
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(zhangfu + "%", x, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("cjsl"), false), x, y, paint);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), false), x, y, paint);
            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("msgs"), true), x, y, paint);

            canvas.translate(0, -DY * 5);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            //            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 5);

            paint.setTextAlign(Paint.Align.RIGHT);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            canvas.translate(0, DY);
            double zg = jo.getDouble("zgcj");
            setColor(paint, zg, zrsp);
            canvas.drawText(Utils.dataFormation(zg, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            canvas.translate(0, DY);
            double zd = jo.getDouble("zdcj");
            setColor(paint, zd, zrsp);
            canvas.drawText(Utils.dataFormation(zd, stockdigit, jo.getInt("tp")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            //            canvas.translate(0, DY);
            //            canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), false), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), false), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.cssweb.android.view.PriceView.java

public void drawHKIndex(Canvas canvas) {
    Paint paint = this.mPaint;
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    paint.setAntiAlias(true);/*from   ww w. ja  v  a  2  s  .  com*/
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);
    this.x = 0;
    this.y = 0;
    startX = x + tips / 2;
    endX = width - tips / 2;
    canvas.drawRect(startX, DY + DY / 4, endX, height - DY / 4, tPaint);
    canvas.drawLine(startX, DY * 5 + DY / 2, endX, DY * 5 + DY / 2, tPaint);
    canvas.drawLine(startX, DY * 11 + DY / 8, endX, DY * 11 + DY / 8, tPaint);
    //canvas.drawLine(startX, DY*16+DY/4, endX, DY*16+DY/4, tPaint);
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            double zrsp = jo.getDouble("zrsp");

            paint.setTextSize(mTextSize);
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(0, DY * 2);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            //            canvas.translate(0, DY);
            //            canvas.drawText("??", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("??", x + tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            //            canvas.drawText("?", x + tips, y, paint);
            //            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            canvas.translate(width, -DY * 13f);
            paint.setTextAlign(Paint.Align.RIGHT);

            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);

            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x - tips, y, paint);

            double zhangd = jo.getDouble("zd");
            if (zhangd < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangd > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.translate(0, DY);
            String zhangdie = Utils.dataFormation(zhangd, stockdigit);
            if (zhangdie.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangdie, x - tips, y, paint);

            double zhangf = jo.getDouble("zf");
            if (zhangf < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangf > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.translate(0, DY);
            String zhangfu = Utils.dataFormation(zhangf * 100, stockdigit);
            if (zhangfu.equals("-"))
                canvas.drawText("", x - tips, y, paint);
            else
                canvas.drawText(zhangfu + "%", x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("amp") * 100, 1) + "%", x - tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText(Utils.dataFormation(zrsp, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double zg = jo.getDouble("zgcj");
            setColor(paint, zg, zrsp);
            canvas.drawText(Utils.dataFormation(zg, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double zd = jo.getDouble("zdcj");
            setColor(paint, zd, zrsp);
            canvas.drawText(Utils.dataFormation(zd, stockdigit), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            //canvas.translate(0, DY);
            //canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjsl"), true), x - tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x - tips, y, paint);

            canvas.translate(0, DY * 1.5f);
            //canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1), x - tips, y, paint);

            paint.setColor(GlobalColor.colorpriceUp);
            //canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("zj")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceEqual);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("pj")), x - tips, y, paint);

            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(String.valueOf(jo.getInt("dj")), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.cssweb.android.view.PriceView.java

private void drawQihuo(Canvas canvas) {
    //stockdigit = 0;
    Paint paint = this.mPaint;
    tPaint.setColor(GlobalColor.clrLine);
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setStrokeWidth(1);/* w w w .  j a va  2  s .  c  om*/
    this.x = 0;
    this.y = 0;
    startX = x + tips / 2;
    endX = width - tips / 2;
    canvas.drawRect(startX, DY / 4, endX, height - DY / 4, tPaint);
    canvas.drawLine(startX, DY * 2 + DY / 4, endX, DY * 2 + DY / 4, tPaint);
    canvas.drawLine(startX, DY * 8 + DY / 4, endX, DY * 8 + DY / 4, tPaint);
    canvas.drawLine(startX, DY * 11 + DY / 4, endX, DY * 11 + DY / 4, tPaint);
    //canvas.drawLine(startX, DY*16+DY/4, endX, DY*16+DY/4, tPaint);
    if (quoteData != null) {
        try {
            JSONArray jArr = quoteData.getJSONArray("data");
            JSONObject jo = jArr.getJSONObject(0);
            String str = "";
            double zrsp = jo.getDouble("zrsp");

            canvas.translate(0, DY);

            paint.setTypeface(Typeface.DEFAULT_BOLD);
            paint.setAntiAlias(true);
            paint.setTextSize(mTextSize);
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);

            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, -DY);
            double temp2 = jo.getDouble("sjw1");
            setColor(paint, temp2, zrsp);
            str = Utils.dataFormation(temp2, stockdigit);
            canvas.drawText(str, x, y, paint);

            canvas.translate(0, DY);
            temp2 = jo.getDouble("bjw1");
            setColor(paint, temp2, zrsp);
            str = Utils.dataFormation(temp2, stockdigit);
            canvas.drawText(str, x, y, paint);

            canvas.translate(0, -DY);
            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.drawText("??", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            paint.setTextAlign(Paint.Align.RIGHT);
            canvas.translate(width / 2, -DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("ssl1"), true), x - tips, y, paint);

            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("bsl1"), true), x - tips, y, paint);

            canvas.translate(-width, DY);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 5);

            paint.setTextAlign(Paint.Align.RIGHT);
            double zjcj = jo.getDouble("zjcj");
            setColor(paint, zjcj, zrsp);
            canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x, y, paint);

            canvas.translate(0, DY);
            double zhangd = jo.getDouble("zd");
            if (zhangd < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangd > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            String zhangdie = Utils.dataFormation(zhangd, stockdigit);
            if (zhangdie.equals("-"))
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(zhangdie, x, y, paint);

            double zhangf = jo.getDouble("zf");
            if (zhangf < 0) {
                paint.setColor(GlobalColor.colorPriceDown);
            } else if (zhangf > 0) {
                paint.setColor(GlobalColor.colorpriceUp);
            } else {
                paint.setColor(GlobalColor.colorPriceEqual);
            }
            canvas.translate(0, DY);
            String zhangfu = Utils.dataFormation(zhangf * 100, 1);
            if (zhangfu.equals("-"))
                canvas.drawText("", x, y, paint);
            else
                canvas.drawText(zhangfu + "%", x, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jrjs"), stockdigit), x, y, paint);
            paint.setColor(GlobalColor.colorpriceUp);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), true), x, y, paint);
            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getInt("cjsl"), true), x, y, paint);

            canvas.translate(0, -DY * 5);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 5);

            paint.setTextAlign(Paint.Align.RIGHT);
            double jrkp = jo.getDouble("jrkp");
            setColor(paint, jrkp, zrsp);
            canvas.drawText(Utils.dataFormation(jrkp, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double zg = jo.getDouble("zgcj");
            setColor(paint, zg, zrsp);
            canvas.drawText(Utils.dataFormation(zg, stockdigit), x - tips, y, paint);

            canvas.translate(0, DY);
            double zd = jo.getDouble("zdcj");
            setColor(paint, zd, zrsp);
            canvas.drawText(Utils.dataFormation(zd, stockdigit), x - tips, y, paint);

            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("zrjs"), stockdigit), x - tips, y, paint);
            paint.setColor(GlobalColor.colorPriceDown);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), true), x - tips, y, paint);
            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x - tips, y, paint);

            canvas.translate(-width, DY);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);

            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(" ", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 2);

            paint.setTextAlign(Paint.Align.RIGHT);
            double zt = jo.getDouble("zt");
            setColor(paint, zt, zrsp);
            canvas.drawText(Utils.dataFormation(zt, stockdigit), x, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jrcc"), 0), x, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jrkc"), 0), x, y, paint);

            paint.setTextAlign(Paint.Align.LEFT);
            paint.setColor(GlobalColor.colorLabelName);
            canvas.translate(0, -DY * 2);

            canvas.drawText("?", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText("", x + tips, y, paint);
            canvas.translate(0, DY);
            canvas.drawText(" ", x + tips, y, paint);

            canvas.translate(width / 2, -DY * 2);

            paint.setTextAlign(Paint.Align.RIGHT);
            double dt = jo.getDouble("dt");
            setColor(paint, dt, zrsp);
            canvas.drawText(Utils.dataFormation(dt, stockdigit), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("zc"), 0), x - tips, y, paint);

            paint.setColor(GlobalColor.colorStockName);
            canvas.translate(0, DY);
            canvas.drawText(Utils.dataFormation(jo.getDouble("jrpc"), 0), x - tips, y, paint);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
}

From source file:com.piusvelte.sonet.core.SelectFriends.java

protected void loadFriends() {
    mFriends.clear();// w  w w.j a v a2  s  .co  m
    //      SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND, Entities.ESID}, new int[]{R.id.profile, R.id.name, R.id.selected});
    SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend,
            new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected });
    setListAdapter(sa);
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Long, String, Boolean> asyncTask = new AsyncTask<Long, String, Boolean>() {
        @Override
        protected Boolean doInBackground(Long... params) {
            boolean loadList = false;
            SonetCrypto sonetCrypto = SonetCrypto.getInstance(getApplicationContext());
            // load the session
            Cursor account = getContentResolver().query(Accounts.getContentUri(SelectFriends.this),
                    new String[] { Accounts.TOKEN, Accounts.SECRET, Accounts.SERVICE }, Accounts._ID + "=?",
                    new String[] { Long.toString(params[0]) }, null);
            if (account.moveToFirst()) {
                mToken = sonetCrypto.Decrypt(account.getString(0));
                mSecret = sonetCrypto.Decrypt(account.getString(1));
                mService = account.getInt(2);
            }
            account.close();
            String response;
            switch (mService) {
            case TWITTER:
                break;
            case FACEBOOK:
                if ((response = SonetHttpClient.httpResponse(mHttpClient, new HttpGet(
                        String.format(FACEBOOK_FRIENDS, FACEBOOK_BASE_URL, Saccess_token, mToken)))) != null) {
                    try {
                        JSONArray friends = new JSONObject(response).getJSONArray(Sdata);
                        for (int i = 0, l = friends.length(); i < l; i++) {
                            JSONObject f = friends.getJSONObject(i);
                            HashMap<String, String> newFriend = new HashMap<String, String>();
                            newFriend.put(Entities.ESID, f.getString(Sid));
                            newFriend.put(Entities.PROFILE, String.format(FACEBOOK_PICTURE, f.getString(Sid)));
                            newFriend.put(Entities.FRIEND, f.getString(Sname));
                            // need to alphabetize
                            if (mFriends.isEmpty())
                                mFriends.add(newFriend);
                            else {
                                String fullName = f.getString(Sname);
                                int spaceIdx = fullName.lastIndexOf(" ");
                                String newFirstName = null;
                                String newLastName = null;
                                if (spaceIdx == -1)
                                    newFirstName = fullName;
                                else {
                                    newFirstName = fullName.substring(0, spaceIdx++);
                                    newLastName = fullName.substring(spaceIdx);
                                }
                                List<HashMap<String, String>> newFriends = new ArrayList<HashMap<String, String>>();
                                for (int i2 = 0, l2 = mFriends.size(); i2 < l2; i2++) {
                                    HashMap<String, String> oldFriend = mFriends.get(i2);
                                    if (newFriend == null) {
                                        newFriends.add(oldFriend);
                                    } else {
                                        fullName = oldFriend.get(Entities.FRIEND);
                                        spaceIdx = fullName.lastIndexOf(" ");
                                        String oldFirstName = null;
                                        String oldLastName = null;
                                        if (spaceIdx == -1)
                                            oldFirstName = fullName;
                                        else {
                                            oldFirstName = fullName.substring(0, spaceIdx++);
                                            oldLastName = fullName.substring(spaceIdx);
                                        }
                                        if (newFirstName == null) {
                                            newFriends.add(newFriend);
                                            newFriend = null;
                                        } else {
                                            int comparison = oldFirstName.compareToIgnoreCase(newFirstName);
                                            if (comparison == 0) {
                                                // compare firstnames
                                                if (newLastName == null) {
                                                    newFriends.add(newFriend);
                                                    newFriend = null;
                                                } else if (oldLastName != null) {
                                                    comparison = oldLastName.compareToIgnoreCase(newLastName);
                                                    if (comparison == 0) {
                                                        newFriends.add(newFriend);
                                                        newFriend = null;
                                                    } else if (comparison > 0) {
                                                        newFriends.add(newFriend);
                                                        newFriend = null;
                                                    }
                                                }
                                            } else if (comparison > 0) {
                                                newFriends.add(newFriend);
                                                newFriend = null;
                                            }
                                        }
                                        newFriends.add(oldFriend);
                                    }
                                }
                                if (newFriend != null)
                                    newFriends.add(newFriend);
                                mFriends = newFriends;
                            }
                        }
                        loadList = true;
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                }
                break;
            case MYSPACE:
                break;
            case LINKEDIN:
                break;
            case FOURSQUARE:
                break;
            case IDENTICA:
                break;
            case GOOGLEPLUS:
                break;
            case CHATTER:
                break;
            }
            return loadList;
        }

        @Override
        protected void onPostExecute(Boolean loadList) {
            if (loadList) {
                //               SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND}, new int[]{R.id.profile, R.id.name});
                SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend,
                        new String[] { Entities.FRIEND, Entities.ESID },
                        new int[] { R.id.name, R.id.selected });
                sa.setViewBinder(mViewBinder);
                setListAdapter(sa);
            }
            if (loadingDialog.isShowing())
                loadingDialog.dismiss();
        }
    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute(mAccountId);
}

From source file:com.partytv.server.GeoCoderTask.java

private GeoResponse parse(JSONObject json) {
    GeoResponse geoResponse = null;//from   w w  w .j a  v a2  s .  c o m
    try {
        JSONArray array = json.getJSONArray("results");
        if (array.length() > 0) {

            JSONObject obj = array.getJSONObject(0);
            JSONObject viewport = obj.getJSONObject("geometry").getJSONObject("viewport");
            double minLat = viewport.getJSONObject("southwest").getDouble("lat");
            double minLng = viewport.getJSONObject("southwest").getDouble("lng");
            double maxLat = viewport.getJSONObject("northeast").getDouble("lat");
            double maxLng = viewport.getJSONObject("northeast").getDouble("lng");
            geoResponse = new GeoResponse(minLat, minLng, maxLat, maxLng);
        }
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
    return geoResponse;
}

From source file:net.freifunk.android.discover.model.NodesResponse.java

@Override
public void onResponse(JSONObject jsonObject) {
    try {/* w w  w.j  a  va 2 s .c o m*/
        JSONArray node_list = jsonObject.getJSONArray("nodes");
        for (int i = 0; i < node_list.length(); i++) {
            JSONObject node = node_list.getJSONObject(i);
            List<String> mac_list = new ArrayList<String>(1);
            // MAC
            if (node.has("macs")) {
                String[] macs = ((String) node.get("macs")).split(",");
                mac_list = new ArrayList<String>(macs.length);
                for (String mac : macs) {
                    mac_list.add(mac.trim());
                }
            } else {
                mac_list.add(" ");
            }
            // Name
            String name = ((String) node.get("name")).trim();

            // Firmware
            String firmware = String.valueOf(node.get("firmware")).trim();

            // Flags
            Map<String, String> flags = new HashMap<String, String>();
            JSONObject jflags = node.getJSONObject("flags");
            Iterator flag = jflags.keys();
            while (flag.hasNext()) {
                String key = (String) flag.next();
                String val = String.valueOf(jflags.get(key));
                flags.put(key, val);
            }

            // Geo
            LatLng pos = null;
            //               Log.d(TAG, String.valueOf(node.get("geo")));
            if (!String.valueOf(node.get("geo")).equals("null")) {
                JSONArray geo = node.getJSONArray("geo");
                Double lat = (Double) geo.get(0);
                Double lng = (Double) geo.get(1);
                pos = new LatLng(lat, lng);
            }

            // Id
            String id = ((String) node.get("id")).trim();

            Node n = new Node(mac_list, this.mCallingMap.getMapName(), name, firmware, flags, pos, id);
            Node.nodes.add(n);
            mCallback.onNodeAvailable(n);
        }
    } catch (JSONException e) {
        Log.e(TAG, "Seems something went wrong while loading Nodes for " + this.mCallingMap.getMapName() + ":"
                + e.toString());
    } finally {
        mCallback.onResponseFinished(this.mCallingMap);
    }
}

From source file:com.cssweb.android.view.TrendView.java

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (quoteData == null) {
        drawWin(canvas);//  ww  w .j a  v a 2  s . co m
        return;
    }
    try {
        drawChart(canvas);
    } catch (JSONException e) {
        e.printStackTrace();
        CssLog.e(TAG, e.toString());
    }
}

From source file:org.fabrican.extension.variable.provider.servlet.ManagementServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    try {//from   ww  w  .  j av  a 2 s . c  om
        resp.setHeader("Cache-Control", "no-cache");
        Pair<String, String> params = gePathParams(req);
        String cmd = params.left();
        String name = params.right();
        RuleSetDAO dao = RuleSetDAO.getInstance();
        switch (cmd) {
        case "config":
            JSONObject jo = new JSONObject();
            jo.put("connected", dao.connected());
            if (dao.getDriver() != null) {
                jo.put("driver", dao.getDriver());
            }
            if (dao.getUrl() != null) {
                jo.put("url", dao.getUrl());
            }
            if (dao.getUser() != null) {
                jo.put("user", dao.getUser());
            }
            if (dao.getPass() != null) {
                jo.put("pass", dao.getPass());
            }
            resp.setStatus(200);
            output(resp, jo.toString());
            return;
        case "providers":
            name = name.trim();
            if (name.equals("")) {
                resp.setStatus(200);
                output(resp, getListJSON(dao).toString());
            } else {
                RuleSet rs = dao.getRuleSetByName(name);
                if (rs == null) {
                    resp.setStatus(404);
                } else {
                    resp.setStatus(200);
                    output(resp, RuleSetJSONHelper.toJSON(rs).toString());
                }
            }
            return;
        }
    } catch (JSONException e) {
        resp.setStatus(500);
        output(resp, e.toString());
    } catch (SQLException e) {
        resp.setStatus(500);
        output(resp, e.toString());
    } catch (InterruptedException e) {
        resp.setStatus(500);
        output(resp, e.toString());
    } finally {

    }
    resp.setStatus(400);
    output(resp, "unrecognized request");
}

From source file:org.openmrs.mobile.listeners.visit.FindVisitByUUIDAfterOfflineCaptureVitalsListener.java

@Override
public void onResponse(JSONObject response) {
    mLogger.d(response.toString());/*from   www .ja v  a  2  s  .c  o  m*/
    boolean updateSuccessful = true;
    try {
        Visit visit = VisitMapper.map(response);
        long visitId = visitDAO.getVisitsIDByUUID(visit.getUuid());
        if (visitId > 0) {
            visitDAO.updateVisitAfterOfflineCaptureVitals(visit, visitId);
        } else {
            visitDAO.saveVisit(visit, mPatientID);
        }
    } catch (JSONException e) {
        mLogger.d(e.toString());
        updateSuccessful = false;
    }

    if (updateSuccessful) {
        mManagerCaller.removeFromQueue();
    }
}