Example usage for android.database Cursor getDouble

List of usage examples for android.database Cursor getDouble

Introduction

In this page you can find the example usage for android.database Cursor getDouble.

Prototype

double getDouble(int columnIndex);

Source Link

Document

Returns the value of the requested column as a double.

Usage

From source file:org.jnegre.android.osmonthego.service.ExportService.java

/**
 * Handle export in the provided background thread
 *//*from w  w w. j  a  va 2  s .  c  o m*/
private void handleOsmExport(boolean includeAddress, boolean includeFixme) {
    //TODO handle empty survey
    //TODO handle bounds around +/-180

    if (!isExternalStorageWritable()) {
        notifyUserOfError();
        return;
    }

    int id = 0;
    double minLat = 200;
    double minLng = 200;
    double maxLat = -200;
    double maxLng = -200;
    StringBuilder builder = new StringBuilder();

    if (includeAddress) {
        Uri uri = AddressTableMetaData.CONTENT_URI;
        Cursor cursor = getContentResolver().query(uri, new String[] { //projection
                AddressTableMetaData.LATITUDE, AddressTableMetaData.LONGITUDE, AddressTableMetaData.NUMBER,
                AddressTableMetaData.STREET }, null, //selection string
                null, //selection args array of strings
                null); //sort order

        if (cursor == null) {
            notifyUserOfError();
            return;
        }

        try {
            int iLat = cursor.getColumnIndex(AddressTableMetaData.LATITUDE);
            int iLong = cursor.getColumnIndex(AddressTableMetaData.LONGITUDE);
            int iNumber = cursor.getColumnIndex(AddressTableMetaData.NUMBER);
            int iStreet = cursor.getColumnIndex(AddressTableMetaData.STREET);

            for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                //Gather values
                double lat = cursor.getDouble(iLat);
                double lng = cursor.getDouble(iLong);
                String number = cursor.getString(iNumber);
                String street = cursor.getString(iStreet);

                minLat = Math.min(minLat, lat);
                maxLat = Math.max(maxLat, lat);
                minLng = Math.min(minLng, lng);
                maxLng = Math.max(maxLng, lng);
                builder.append("<node id=\"-").append(++id).append("\" lat=\"").append(lat).append("\" lon=\"")
                        .append(lng).append("\" version=\"1\" action=\"modify\">\n");
                addOsmTag(builder, "addr:housenumber", number);
                addOsmTag(builder, "addr:street", street);
                builder.append("</node>\n");
            }
        } finally {
            cursor.close();
        }
    }

    if (includeFixme) {
        Uri uri = FixmeTableMetaData.CONTENT_URI;
        Cursor cursor = getContentResolver().query(uri, new String[] { //projection
                FixmeTableMetaData.LATITUDE, FixmeTableMetaData.LONGITUDE, FixmeTableMetaData.COMMENT }, null, //selection string
                null, //selection args array of strings
                null); //sort order

        if (cursor == null) {
            notifyUserOfError();
            return;
        }

        try {
            int iLat = cursor.getColumnIndex(FixmeTableMetaData.LATITUDE);
            int iLong = cursor.getColumnIndex(FixmeTableMetaData.LONGITUDE);
            int iComment = cursor.getColumnIndex(FixmeTableMetaData.COMMENT);

            for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
                //Gather values
                double lat = cursor.getDouble(iLat);
                double lng = cursor.getDouble(iLong);
                String comment = cursor.getString(iComment);

                minLat = Math.min(minLat, lat);
                maxLat = Math.max(maxLat, lat);
                minLng = Math.min(minLng, lng);
                maxLng = Math.max(maxLng, lng);
                builder.append("<node id=\"-").append(++id).append("\" lat=\"").append(lat).append("\" lon=\"")
                        .append(lng).append("\" version=\"1\" action=\"modify\">\n");
                addOsmTag(builder, "fixme", comment);
                builder.append("</node>\n");
            }
        } finally {
            cursor.close();
        }
    }

    try {
        File destinationFile = getDestinationFile();
        destinationFile.getParentFile().mkdirs();
        PrintWriter writer = new PrintWriter(destinationFile, "UTF-8");

        writer.println("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>");
        writer.println("<osm version=\"0.6\" generator=\"OsmOnTheGo\">");
        writer.print("<bounds minlat=\"");
        writer.print(minLat - MARGIN);
        writer.print("\" minlon=\"");
        writer.print(minLng - MARGIN);
        writer.print("\" maxlat=\"");
        writer.print(maxLat + MARGIN);
        writer.print("\" maxlon=\"");
        writer.print(maxLng + MARGIN);
        writer.println("\" />");

        writer.println(builder);

        writer.print("</osm>");
        writer.close();

        if (writer.checkError()) {
            notifyUserOfError();
        } else {
            //FIXME i18n the subject and content
            Intent emailIntent = new Intent(Intent.ACTION_SEND);
            emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            emailIntent.setType(HTTP.OCTET_STREAM_TYPE);
            //emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"johndoe@exemple.com"});
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "OSM On The Go");
            emailIntent.putExtra(Intent.EXTRA_TEXT, "Your last survey.");
            emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(destinationFile));
            startActivity(emailIntent);
        }
    } catch (IOException e) {
        Log.e(TAG, "Could not write to file", e);
        notifyUserOfError();
    }

}

From source file:com.enadein.carlogbook.ui.AddUpdateLogActivity.java

@Override
protected void populateEditEntity() {
    Cursor logCursor = getContentResolver().query(ProviderDescriptor.Log.CONTENT_URI, null, "_id = ?",
            new String[] { String.valueOf(id) }, null);
    if (logCursor != null && logCursor.moveToFirst()) {
        int odometerIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.ODOMETER);
        int priceIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.PRICE);
        int dateIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.DATE);
        int nameIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.NAME);
        int typeIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.TYPE_ID);
        int commentIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.CMMMENT);
        int otherTypeIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.OTHER_TYPE_ID);
        commentView.setText(logCursor.getString(commentIdx));

        odometerView.setText(String.valueOf(logCursor.getLong(odometerIdx)));
        priceView.setText(CommonUtils.formatPriceNew(logCursor.getDouble(priceIdx), unitFacade));
        date = new Date(logCursor.getLong(dateIdx));
        priceView.setText(CommonUtils.formatPriceNew(logCursor.getDouble(priceIdx), unitFacade));
        nameView.setText(logCursor.getString(nameIdx));
        int typePos = logCursor.getInt(typeIdx);
        typeSpinner.setSelection(typePos);

        otherTypeId = logCursor.getLong(otherTypeIdx);

        //            if (typePos != 0) {
        //                findViewById(R.id.otherGroup).setVisibility(View.GONE);
        //            }

    }//from   w w w  . j  a va 2  s .c  o m
}

From source file:com.uproot.trackme.LocationActivity.java

public void showData() throws IOException {

    SQLiteDatabase db = null;//from  w w  w .  j  a va 2s  . c  o  m
    Cursor cursor = null;
    db = openOrCreateDatabase(DATABASE_NAME, SQLiteDatabase.OPEN_READWRITE, null);
    cursor = db.rawQuery("SELECT * " + " FROM " + POINTS_TABLE_NAME + " ORDER BY GMTTIMESTAMP ASC", null);

    StringBuffer str = new StringBuffer(
            "<session id=\"chetan123\" userid=\"" + userid + "\" passkey=\"" + passkey + "\">");

    int latitudeColumnIndex = cursor.getColumnIndexOrThrow("LATITUDE");
    int longitudeColumnIndex = cursor.getColumnIndexOrThrow("LONGITUDE");
    int TSColumnIndex = cursor.getColumnIndexOrThrow("GMTTIMESTAMP");
    int ACCColumnIndex = cursor.getColumnIndexOrThrow("ACCURACY");
    if (cursor.moveToFirst()) {
        do {
            double latitude = cursor.getDouble(latitudeColumnIndex);
            double longitude = cursor.getDouble(longitudeColumnIndex);
            long timestamp = (long) cursor.getDouble(TSColumnIndex);
            long accuracy = (long) cursor.getDouble(ACCColumnIndex);
            str.append("<location latitude=\"");
            str.append(latitude);
            str.append("\" longitude=\"");
            str.append(longitude);
            str.append("\" accuracy=\"");
            str.append(accuracy);
            str.append("\" timestamp=\"");
            str.append(timestamp);
            str.append("\" />");
        } while (cursor.moveToNext());
        str.append("</session>");
        fileContents = str.toString();
    }
    db.close();
}

From source file:org.mitre.svmp.common.DatabaseHandler.java

private String makePerformanceData(Cursor cursor, MeasurementInfo measurementInfo,
        SimpleDateFormat dateFormat) {
    try {//from w w  w  .j  a  v  a2s .co m
        // get values from query
        long measureDate = cursor.getLong(0);
        //long startDate = cursor.getLong(1); // don't need this, it's just a foreign key
        int frameCount = cursor.getInt(2);
        int sensorUpdates = cursor.getInt(3);
        int touchUpdates = cursor.getInt(4);
        double cpuUsage = cursor.getDouble(5);
        int memoryUsage = cursor.getInt(6);
        double wifiStrength = cursor.getDouble(7);
        double batteryLevel = cursor.getDouble(8);
        int cellNetwork = cursor.getInt(9);
        String cellValues = cursor.getString(10);
        int ping = cursor.getInt(11);

        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(dateFormat.format(new Date(measureDate)));
        stringBuilder.append(",");
        stringBuilder.append(numberPerSecond(frameCount, measurementInfo.getMeasureInterval()));
        stringBuilder.append(",");
        stringBuilder.append(numberPerSecond(sensorUpdates, measurementInfo.getMeasureInterval()));
        stringBuilder.append(",");
        stringBuilder.append(numberPerSecond(touchUpdates, measurementInfo.getMeasureInterval()));
        stringBuilder.append(",");
        stringBuilder.append(cpuUsage);
        stringBuilder.append(",");
        stringBuilder.append(memoryUsage);
        stringBuilder.append(",");
        stringBuilder.append(wifiStrength);
        stringBuilder.append(",");
        stringBuilder.append(batteryLevel);
        stringBuilder.append(",");
        stringBuilder.append(Utility.cellNetwork(cellNetwork));
        stringBuilder.append(",");
        stringBuilder.append(cellValues);
        stringBuilder.append(",");
        stringBuilder.append(ping);

        return stringBuilder.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.udacity.sunshine.fragment.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    Log.v(TAG, "In onLoadFinished");
    if (data != null && data.moveToFirst()) {
        // Read weather condition ID from cursor
        int weatherId = data.getInt(COL_WEATHER_CONDITION_ID);
        // Use weather art Image
        mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

        // Read date from cursor and update views for day of week and date
        long date = data.getLong(COL_WEATHER_DATE);
        String friendlyDateText = Utility.getDayName(getActivity(), date);
        String dateText = Utility.getFormattedMonthDay(getActivity(), date);
        mFriendlyDateView.setText(friendlyDateText);
        mDateView.setText(dateText);/* ww w.j av  a  2s.  c  o  m*/

        // Read description from cursor and update view
        String description = data.getString(COL_WEATHER_DESC);
        mDescriptionView.setText(description);

        // For accessibility, add a content description to the icon field
        mIconView.setContentDescription(description);

        double high = data.getDouble(COL_WEATHER_MAX_TEMP);
        String highString = Utility.formatTemperature(getActivity(), high);
        mHighTempView.setText(highString);

        // Read low temperature from cursor and update view
        double low = data.getDouble(COL_WEATHER_MIN_TEMP);
        String lowString = Utility.formatTemperature(getActivity(), low);
        mLowTempView.setText(lowString);

        // Read humidity from cursor and update view
        float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
        mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

        // Read wind speed and direction from cursor and update view
        float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
        float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
        mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

        // Read pressure from cursor and update view
        float pressure = data.getFloat(COL_WEATHER_PRESSURE);
        mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

        // We still need this for the share intent
        mForecastStr = String.format("%s - %s - %s/%s", dateText, description, high, low);

        // If onCreateOptionsMenu has already happened, we need to update the share intent now.
        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(createShareForecastIntent());
        }
    }
}

From source file:com.jackie.sunshine.app.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    Log.d(TAG, "onLoadFinished: ");
    if (data == null || !data.moveToFirst())
        return;/*w  w w .  j  ava  2 s .  c  o m*/

    Context context = getContext();

    int weatherId = data.getInt(COL_WEATHER_CONDITION_ID);
    mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

    // Read date from cursor and update views for day of week and date
    long date = data.getLong(COL_WEATHER_DATE);
    String friendlyDateStr = Utility.getDayName(context, date);
    String dateStr = Utility.getFormattedMonthDay(context, date);
    mTvDate.setText(dateStr);
    mTvFriendlyDate.setText(friendlyDateStr);

    // Read description from cursor and update view
    String weatherDescription = data.getString(COL_WEATHER_DESC);
    mTvDescription.setText(weatherDescription);
    mIconView.setContentDescription(weatherDescription);

    boolean isMetric = Utility.isMetric(context);

    // Read high temperature from cursor and update view
    String high = Utility.formatTemperature(context, data.getDouble(COL_WEATHER_MAX_TEMP));
    mTvHighTemp.setText(high);

    // Read low temperature from cursor and update view
    String low = Utility.formatTemperature(context, data.getDouble(COL_WEATHER_MIN_TEMP));
    mTvLowTemp.setText(low);

    // Read humidity from cursor and update view
    float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
    mTvHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

    // Read wind speed and direction from cursor and update view
    float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
    float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
    mTvWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

    // Read pressure from cursor and update view
    float pressure = data.getFloat(COL_WEATHER_PRESSURE);
    mTvPressure.setText(getString(R.string.format_pressure, pressure));

    mForecastStr = String.format("%s - %s - %s/%s", dateStr, weatherDescription, high, low);

    if (mShareAction != null) {
        mShareAction.setShareIntent(createShareIntent());
    }
}

From source file:com.hichinaschool.flashcards.libanki.Stats.java

/**
 * Reps and time spent/* ww  w.  j  av a  2  s  .com*/
 * ***********************************************************************************************
 */

public boolean calculateDone(int type, boolean reps) {
    mType = type;
    mBackwards = true;
    if (reps) {
        mTitle = R.string.stats_review_count;
        mAxisTitles = new int[] { type, R.string.stats_answers };
    } else {
        mTitle = R.string.stats_review_time;
    }
    mValueLabels = new int[] { R.string.statistics_learn, R.string.statistics_relearn,
            R.string.statistics_young, R.string.statistics_mature, R.string.statistics_cram };
    mColors = new int[] { R.color.stats_learn, R.color.stats_relearn, R.color.stats_young, R.color.stats_mature,
            R.color.stats_cram };
    int num = 0;
    int chunk = 0;
    switch (type) {
    case TYPE_MONTH:
        num = 31;
        chunk = 1;
        break;
    case TYPE_YEAR:
        num = 52;
        chunk = 7;
        break;
    case TYPE_LIFE:
        num = -1;
        chunk = 30;
        break;
    }
    ArrayList<String> lims = new ArrayList<String>();
    if (num != -1) {
        lims.add("id > " + ((mCol.getSched().getDayCutoff() - ((num + 1) * chunk * 86400)) * 1000));
    }
    String lim = _revlogLimit().replaceAll("[\\[\\]]", "");
    if (lim.length() > 0) {
        lims.add(lim);
    }
    if (lims.size() > 0) {
        lim = "WHERE ";
        while (lims.size() > 1) {
            lim += lims.remove(0) + " AND ";
        }
        lim += lims.remove(0);
    } else {
        lim = "";
    }
    String ti;
    String tf;
    if (!reps) {
        ti = "time/1000";
        if (mType == 0) {
            tf = "/60.0"; // minutes
            mAxisTitles = new int[] { type, R.string.stats_minutes };
        } else {
            tf = "/3600.0"; // hours
            mAxisTitles = new int[] { type, R.string.stats_hours };
        }
    } else {
        ti = "1";
        tf = "";
    }
    ArrayList<double[]> list = new ArrayList<double[]>();
    Cursor cur = null;
    try {
        cur = mCol.getDb().getDatabase()
                .rawQuery("SELECT (cast((id/1000 - " + mCol.getSched().getDayCutoff() + ") / 86400.0 AS INT))/"
                        + chunk + " AS day, " + "sum(CASE WHEN type = 0 THEN " + ti + " ELSE 0 END)" + tf + ", " // lrn
                        + "sum(CASE WHEN type = 1 AND lastIvl < 21 THEN " + ti + " ELSE 0 END)" + tf + ", " // yng
                        + "sum(CASE WHEN type = 1 AND lastIvl >= 21 THEN " + ti + " ELSE 0 END)" + tf + ", " // mtr
                        + "sum(CASE WHEN type = 2 THEN " + ti + " ELSE 0 END)" + tf + ", " // lapse
                        + "sum(CASE WHEN type = 3 THEN " + ti + " ELSE 0 END)" + tf // cram
                        + " FROM revlog " + lim + " GROUP BY day ORDER BY day", null);
        while (cur.moveToNext()) {
            list.add(new double[] { cur.getDouble(0), cur.getDouble(1), cur.getDouble(4), cur.getDouble(2),
                    cur.getDouble(3), cur.getDouble(5) });
        }
    } finally {
        if (cur != null && !cur.isClosed()) {
            cur.close();
        }
    }

    // small adjustment for a proper chartbuilding with achartengine
    if (type != TYPE_LIFE && (list.size() == 0 || list.get(0)[0] > -num)) {
        list.add(0, new double[] { -num, 0, 0, 0, 0, 0 });
    } else if (type == TYPE_LIFE && list.size() == 0) {
        list.add(0, new double[] { -12, 0, 0, 0, 0, 0 });
    }
    if (list.get(list.size() - 1)[0] < 0) {
        list.add(new double[] { 0, 0, 0, 0, 0, 0 });
    }

    mSeriesList = new double[6][list.size()];
    for (int i = 0; i < list.size(); i++) {
        double[] data = list.get(i);
        mSeriesList[0][i] = data[0]; // day
        mSeriesList[1][i] = data[1] + data[2] + data[3] + data[4] + data[5]; // lrn
        mSeriesList[2][i] = data[2] + data[3] + data[4] + data[5]; // relearn
        mSeriesList[3][i] = data[3] + data[4] + data[5]; // young
        mSeriesList[4][i] = data[4] + data[5]; // mature
        mSeriesList[5][i] = data[5]; // cram
    }
    return list.size() > 0;
}

From source file:org.openbmap.soapclient.GpxSerializer.java

/**
 * Iterates on track points and write them.
 *
 * @param trackName//from  w w w .ja  va  2 s . co  m
 *         Name of the track (metadata).
 * @param bw
 *         Writer to the target file.
 */
private void writeTrackpoints(final String trackName, final BufferedWriter bw) throws IOException {
    Log.i(TAG, "Writing trackpoints");

    //@formatter:off
    Cursor c = mDbHelper.getReadableDatabase().rawQuery(TRACKPOINT_SQL_QUERY1,
            new String[] { String.valueOf(mSession), String.valueOf(0) });
    //@formatter:on

    final int colLatitude = c.getColumnIndex(Schema.COL_LATITUDE);
    final int colLongitude = c.getColumnIndex(Schema.COL_LONGITUDE);
    final int colAltitude = c.getColumnIndex(Schema.COL_ALTITUDE);
    final int colTimestamp = c.getColumnIndex(Schema.COL_TIMESTAMP);

    bw.write("<trk>");
    bw.write("<name>");
    bw.write(trackName);
    bw.write("</name>");
    bw.write("<trkseg>");

    long outer = 0;
    while (!c.isAfterLast()) {
        c.moveToFirst();
        while (!c.isAfterLast()) {
            StringBuffer out = new StringBuffer(32 * 1024);
            out.append("<trkpt lat=\"");
            out.append(String.valueOf(c.getDouble(colLatitude)));
            out.append("\" ");
            out.append("lon=\"");
            out.append(String.valueOf(c.getDouble(colLongitude)));
            out.append("\">");
            out.append("<ele>");
            out.append(String.valueOf(c.getDouble(colAltitude)));
            out.append("</ele>");
            out.append("<time>");
            // time stamp conversion to ISO 8601
            out.append(getGpxDate(c.getLong(colTimestamp)));
            out.append("</time>");
            out.append("</trkpt>");

            bw.write(out.toString());
            bw.flush();
            c.moveToNext();
        }

        // fetch next CURSOR_SIZE records
        outer += CURSOR_SIZE;
        c.close();
        //@formatter:off
        c = mDbHelper.getReadableDatabase().rawQuery(TRACKPOINT_SQL_QUERY1,
                new String[] { String.valueOf(mSession), String.valueOf(outer) });
        //@formatter:on
    }
    c.close();

    bw.write("</trkseg>");
    bw.write("</trk>");
    bw.flush();
}

From source file:gov.nasa.arc.geocam.geocam.GeoCamService.java

public boolean uploadImage(Uri uri, int downsampleFactor) {
    final String[] projection = new String[] { MediaStore.Images.ImageColumns._ID,
            MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.LATITUDE,
            MediaStore.Images.ImageColumns.LONGITUDE, MediaStore.Images.ImageColumns.DESCRIPTION,
            MediaStore.Images.ImageColumns.SIZE, };

    final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    boolean success = false;

    try {/*from   w w  w.  j  ava2  s.  c om*/
        Cursor cur = getContentResolver().query(uri, projection, null, null, null);
        cur.moveToFirst();

        long id = cur.getLong(cur.getColumnIndex(MediaStore.Images.ImageColumns._ID));
        long dateTakenMillis = cur.getLong(cur.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN));
        double latitude = cur.getDouble(cur.getColumnIndex(MediaStore.Images.ImageColumns.LATITUDE));
        double longitude = cur.getDouble(cur.getColumnIndex(MediaStore.Images.ImageColumns.LONGITUDE));
        String description = cur.getString(cur.getColumnIndex(MediaStore.Images.ImageColumns.DESCRIPTION));

        double[] angles = new double[3];
        String note;
        String tag;
        String uuid;
        String yawRef;
        try {
            JSONObject imageData = new JSONObject(description);
            angles = GeoCamMobile.rpyUnSerialize(imageData.getString("rpy"));
            note = imageData.getString("note");
            tag = imageData.getString("tag");
            uuid = imageData.getString("uuid");
            yawRef = imageData.getString("yawRef");
        } catch (JSONException e) {
            angles[0] = angles[1] = angles[2] = 0.0;
            note = "";
            tag = "";
            uuid = "";
            yawRef = GeoCamMobile.YAW_MAGNETIC;
        }

        String cameraTime = df.format(new Date(dateTakenMillis));

        Map<String, String> vars = new HashMap<String, String>();
        vars.put("cameraTime", cameraTime);
        vars.put("latitude", String.valueOf(latitude));
        vars.put("longitude", String.valueOf(longitude));
        vars.put("roll", String.valueOf(angles[0]));
        vars.put("pitch", String.valueOf(angles[1]));
        vars.put("yaw", String.valueOf(angles[2]));
        vars.put("notes", note);
        vars.put("tags", tag);
        vars.put("uuid", uuid);
        vars.put("yawRef", yawRef);

        Log.d(GeoCamMobile.DEBUG_ID, "Uploading with yawRef: " + yawRef);

        success = uploadImage(uri, id, vars, downsampleFactor);
        cur.close();
    } catch (CursorIndexOutOfBoundsException e) {
        // Bad db entry, remove from queue and report success so we can move on
        mUploadQueue.setAsUploaded(mUploadQueue.getNextFromQueue());
        Log.d(GeoCamMobile.DEBUG_ID, "Invalid entry in upload queue, removing: " + e);
        success = true;
    }
    return success;
}

From source file:com.money.manager.ex.home.DashboardFragment.java

private View showTableLayoutUpComingTransactions(Cursor cursor) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null);
    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());
    Core core = new Core(getActivity().getApplicationContext());

    // Textview Title
    TextView title = (TextView) layout.findViewById(R.id.textViewTitle);
    title.setText(R.string.upcoming_transactions);
    // Table// w  w w  . j av a  2  s .  c  o m
    TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary);
    // add rows
    while (cursor.moveToNext()) {
        // load values
        String payee = "<i>" + cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)) + "</i>";
        double total = cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT));
        int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT));
        int currencyId = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID));
        String daysLeftText = "";
        daysLeftText = Integer.toString(Math.abs(daysLeft)) + " "
                + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue);
        TableRow row = createTableRow(
                new String[] { "<small>" + payee + "</small>",
                        "<small>" + currencyService.getCurrencyFormatted(currencyId,
                                MoneyFactory.fromDouble(total)) + "</small>",
                        "<small>" + daysLeftText + "</small>" },
                new Float[] { 1f, null, 1f }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
                new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null });
        TextView txt = (TextView) row.getChildAt(2);
        UIHelper uiHelper = new UIHelper(getActivity());
        int color = daysLeft >= 0 ? uiHelper.resolveAttribute(R.attr.holo_green_color_theme)
                : uiHelper.resolveAttribute(R.attr.holo_red_color_theme);
        txt.setTextColor(ContextCompat.getColor(getActivity(), color));
        // Add Row
        tableLayout.addView(row);
    }
    // return Layout
    return layout;
}