Example usage for android.database Cursor getFloat

List of usage examples for android.database Cursor getFloat

Introduction

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

Prototype

float getFloat(int columnIndex);

Source Link

Document

Returns the value of the requested column as a float.

Usage

From source file:com.taxicop.sync.SyncAdapter.java

public ArrayList<Complaint> query(ContentProviderClient provider, int FROM) {
    ArrayList<Complaint> reports = new ArrayList<Complaint>();
    try {//from  w  ww.j  av a 2  s.com
        Cursor c = provider.query(PlateContentProvider.URI_REPORT, null, Fields.ID_KEY + " > " + FROM + "",
                null, null);
        if (c.moveToFirst()) {
            do {
                float rank = c.getFloat(c.getColumnIndex(Fields.RANKING));
                String plate = "" + (c.getString(c.getColumnIndex(Fields.CAR_PLATE)));
                String desc = "" + (c.getString(c.getColumnIndex(Fields.DESCRIPTION)));
                String date = "" + (c.getString(c.getColumnIndex(Fields.DATE_REPORT)));
                Log.d(TAG, "plate=" + plate);
                reports.add(new Complaint(rank, plate, desc, USER, date));
            } while (c.moveToNext());
        }
        c.close();
    } catch (Exception e) {
        Log.e(TAG, "query= " + e.getMessage());
    }

    return reports;
}

From source file:org.wheelmap.android.adapter.POIsListCursorAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    POIsListItemView pliv = (POIsListItemView) view;
    SupportManager manager = WheelmapApp.getSupportManager();

    String name = POIHelper.getName(cursor);
    WheelchairFilterState state = POIHelper.getWheelchair(cursor);
    int index = cursor.getColumnIndex(POIsCursorWrapper.LOCATION_COLUMN_NAME);
    float distance = cursor.getFloat(index);
    float direction = cursor.getFloat(cursor.getColumnIndex(DirectionCursorWrapper.SHOW_DIRECTION_COLUMN_NAME));
    int categoryId = POIHelper.getCategoryId(cursor);
    int nodeTypeId = POIHelper.getNodeTypeId(cursor);
    NodeType nodeType = manager.lookupNodeType(nodeTypeId);

    if (name != null && name.length() > 0) {
        pliv.setName(name);/*from w  w  w  .  j  a v  a  2s . c  o  m*/
    } else {
        pliv.setName(nodeType.localizedName);
    }

    pliv.setNodeType(nodeType.localizedName);

    pliv.setDistance(mDistanceFormatter.format(distance));
    Drawable marker = manager.lookupNodeTypeList(nodeTypeId).getStateDrawable(state);

    pliv.setIcon(marker);
}

From source file:org.fitchfamily.android.wifi_backend.ui.data.WifiDetailFragment.java

@AfterViews
protected void init() {
    container.setVisibility(View.INVISIBLE);

    getLoaderManager().initLoader(0, null, new LoaderManager.LoaderCallbacks<Cursor>() {
        @Override//from w ww  . j ava  2s .co  m
        public Loader<Cursor> onCreateLoader(int id, Bundle args) {
            return new CursorLoader(getContext()).table(Database.TABLE_SAMPLES)
                    .selection(Database.COL_RFID + " = ?").selectionArgs(new String[] { rfId })
                    .columns(new String[] { Database.COL_LATITUDE, Database.COL_LONGITUDE, Database.COL_RADIUS,
                            Database.COL_SSID, Database.COL_LAT1, Database.COL_LON1, Database.COL_LAT2,
                            Database.COL_LON2, Database.COL_LAT3, Database.COL_LON3 });
        }

        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
            if (cursor != null && cursor.moveToFirst()) {
                container.setVisibility(View.VISIBLE);

                lat = cursor.getDouble(0);
                lon = cursor.getDouble(1);
                acc = Math.max(Configuration.with(getContext()).accessPointAssumedAccuracy(),
                        cursor.getFloat(2));
                ssid = cursor.getString(3);
                smp = countSamples(cursor, 4);

                WifiDetailFragment.this.accuracy.setText(accuracy());
                WifiDetailFragment.this.samples.setText(samples());
            } else {
                container.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void onLoaderReset(Loader<Cursor> loader) {
            container.setVisibility(View.INVISIBLE);
        }
    });
}

From source file:com.xengar.android.stocktracker.ui.DetailFragment.java

private void fillViewData(Cursor data) {
    String symbol = data.getString(COL_QUOTE_SYMBOL);
    float price = data.getFloat(COL_QUOTE_PRICE);
    float absoluteChange = data.getFloat(COL_QUOTE_ABSOLUTE_CHANGE);
    float percentageChange = data.getFloat(COL_QUOTE_PERCENTAGE_CHANGE);

    // Display the data
    mSymbolView.setText(symbol);/* w  w  w.j a  v  a  2s  . c  o  m*/
    mPriceView.setText(Utility.getPriceInDisplayMode(price));
    mChangeView.setText(Utility.getChangeInDisplayMode(getContext(), absoluteChange, percentageChange));
}

From source file:com.rappsantiago.weighttracker.progress.StatisticsFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

    if (null != data && 0 < data.getCount()) {

        ArrayList<Entry> entries = new ArrayList<>();
        ArrayList<String> labels = new ArrayList<>();
        int dataIdx = 0;

        String weightUnit = PreferenceUtil.getWeightUnit(getActivity());

        while (data.moveToNext()) {

            float weight = data.getFloat(DbConstants.IDX_PROGRESS_WEIGHT);
            long dateInMillis = data.getLong(DbConstants.IDX_PROGRESS_TIMESTAMP);

            switch (weightUnit) {
            case WeightTrackerContract.Profile.WEIGHT_UNIT_KILOGRAMS:
                entries.add(new Entry(weight, dataIdx++));
                break;

            case WeightTrackerContract.Profile.WEIGHT_UNIT_POUNDS:
                entries.add(new Entry((float) Util.kilogramsToPounds(weight), dataIdx++));
                break;

            default:
                throw new IllegalArgumentException();
            }/*from   w w  w.j  a v  a  2 s.c  o  m*/

            labels.add(DisplayUtil.getReadableDate(dateInMillis));
        }

        String legend = "";

        switch (weightUnit) {
        case WeightTrackerContract.Profile.WEIGHT_UNIT_KILOGRAMS:
            legend = getString(R.string.weight_in_kilograms);
            break;

        case WeightTrackerContract.Profile.WEIGHT_UNIT_POUNDS:
            legend = getString(R.string.weight_in_pounds);
            break;

        default:
            throw new IllegalArgumentException();
        }

        LineDataSet weightDataSet = new LineDataSet(entries, legend);
        weightDataSet.setDrawCubic(true);

        LineData lineData = new LineData(labels, weightDataSet);

        mLineChart.setData(lineData);
        mLineChart.invalidate();
    }
}

From source file:com.julia.android.stockhawk.ui.StockDetailActivity.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    swipeRefreshLayout.setRefreshing(false);
    if (data.getCount() != 0) {
        data.moveToFirst();//from   w w w .j a  v a 2s .  c o m

        // Update an information of the selected stock in the app bar view
        updateStockInfo(data.getString(Contract.Quote.POSITION_NAME),
                data.getFloat(Contract.Quote.POSITION_PRICE),
                data.getFloat(Contract.Quote.POSITION_ABSOLUTE_CHANGE),
                data.getFloat(Contract.Quote.POSITION_PERCENTAGE_CHANGE));

        // Update graph view the stock's value over time
        updateStockGraph(data.getString(Contract.Quote.POSITION_HISTORY));
    }
}

From source file:com.ultramegasoft.flavordex2.widget.EntryListAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    final Holder holder = (Holder) view.getTag();

    final long id = cursor.getLong(cursor.getColumnIndex(Tables.Entries._ID));
    final String title = cursor.getString(cursor.getColumnIndex(Tables.Entries.TITLE));
    final String maker = cursor.getString(cursor.getColumnIndex(Tables.Entries.MAKER));
    final float rating = cursor.getFloat(cursor.getColumnIndex(Tables.Entries.RATING));
    final long date = cursor.getLong(cursor.getColumnIndex(Tables.Entries.DATE));

    if (!mMultiChoice) {
        sThumbLoader.load(holder.thumb, id);
    }//from w w  w .j a  v  a2 s.  c  o m
    holder.title.setText(title);
    holder.maker.setText(maker);
    holder.rating.setRating(rating);
    if (date > 0) {
        holder.date.setText(mDateFormat.format(new Date(date)));
    } else {
        holder.date.setText(null);
    }
}

From source file:th.in.ffc.person.visit.VisitDrugActivity.java

private void generateDrugFragment(Cursor c) {
    String action = Action.EDIT;
    do {/* w  w  w.  jav  a2  s  .c o m*/
        String code = c.getString(c.getColumnIndex(VisitDrug.CODE));
        String dose = c.getString(c.getColumnIndex(VisitDrug.DOSE));
        float cost = c.getFloat(c.getColumnIndex(VisitDrug.COST));
        float real = c.getFloat(c.getColumnIndex(VisitDrug.REAL));
        int unit = c.getInt(c.getColumnIndex(VisitDrug.UNIT));

        DrugFragment f = DrugFragment.getNewInstance(action, code, dose, cost, real, unit, code);
        // addDrugFragment(f, code);
        addEditFragment(f, code);
    } while (c.moveToNext());
}

From source file:com.alley.android.ppi.app.DetailFragment.java

public void onLoadFinishedDetail(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        int propertyId = data.getInt(COL_PROPERTY_CONDITION_ID);
        int numberOfBeds = data.getInt(COL_NUM_BEDS);
        float squareArea = data.getFloat(COL_SQUARE_AREA);
        int aptHouse = data.getInt(COLUMN_APARTMENT_HOUSE);

        //            mIconView.setImageResource(Utility.getArtResourceForPropType(propertyId, numberOfBeds));

        int artWork = Utility.getArtResourceForPropType(propertyId, numberOfBeds, aptHouse);
        mIconView.setImageResource(artWork);

        long date = data.getLong(COL_PROPERTY_DATE);
        String dateText = Utility.getFormattedMonthDay(getActivity(), date);

        if (R.drawable.art_spinner == artWork) {
            dateText = dateText + " - " + getActivity().getString(R.string.come_back_later);
            recList.setVisibility(View.GONE);
        } else if (artWork == R.drawable.art_second_hand || artWork == R.drawable.art_no_vat) {
            dateText = dateText + " - " + getActivity().getString(R.string.could_not_find_full_brochure);
            recList.setVisibility(View.GONE);
        } else {/* w  w w . j  a va  2 s . c  om*/
            dateText = dateText + " - " + numberOfBeds + " bed, " + squareArea + "m";
            recList.setVisibility(View.VISIBLE);
        }

        mDateView.setText(dateText);

        String description = data.getString(COL_PROPERTY_DESC);
        mDescriptionView.setText(description);

        mIconView.setContentDescription(description);

        String price = data.getString(COL_PRICE);
        String priceString = Utility.formatPrice(getActivity(), price);
        mPriceView.setText(priceString);

        String contentDescription = data.getString(COL_CONTENT_DESCRIPTION);
        mContentDescription.setText(contentDescription);

        String featuresDescription = data.getString(COL_HEADER_FEATURES);
        mFeaturesDescription.setText(featuresDescription);

        String accommodation = data.getString(COLUMN_ACCOMMODATION);
        mAccommodation.setText(accommodation);

        String ber = data.getString(COLUMN_BER);
        mBer.setText(ber);

        mPropertyDescription = String.format("%s - %s - %s", dateText, description, price);

        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(createSharePropertyIntent());
        }
        String brochureSuccess = data.getString(COLUMN_BROCHURE_SUCCESS);
        if (brochureSuccess != null && brochureSuccess.equalsIgnoreCase("1")) {
            hideShowBrochureFields(View.VISIBLE);
        } else {
            hideShowBrochureFields(View.INVISIBLE);
        }
    }
    // temporarily
    //delete();
}

From source file:org.ohmage.reminders.types.location.LocationTrigger.java

private JSONArray getLocations(Context context, int categId) {

    JSONArray jLocs = new JSONArray();

    LocTrigDB db = new LocTrigDB(context);
    db.open();/*  w w w .ja v  a2  s . c  om*/

    Cursor cLocs = db.getLocations(categId);
    if (cLocs.moveToFirst()) {
        do {
            int lat = cLocs.getInt(cLocs.getColumnIndexOrThrow(LocTrigDB.KEY_LAT));
            int lng = cLocs.getInt(cLocs.getColumnIndexOrThrow(LocTrigDB.KEY_LONG));
            float radius = cLocs.getFloat(cLocs.getColumnIndexOrThrow(LocTrigDB.KEY_RADIUS));

            JSONObject jLoc = new JSONObject();
            try {
                jLoc.put(KEY_LATITUDE, (lat / 1E6));
                jLoc.put(KEY_LONGITUDE, (lng / 1E6));
                jLoc.put(KEY_RADIUS, radius);

                jLocs.put(jLoc);
            } catch (JSONException e) {
                Log.e(TAG, "LocationTrigger: Error adding locations to " + "preference JSON", e);
            }

        } while (cLocs.moveToNext());
    }

    cLocs.close();
    db.close();

    return jLocs;
}