Java Code Examples for android.database.Cursor.getDouble()

The following are Jave code examples for showing how to use getDouble() of the android.database.Cursor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: techstar-shop   File: CartTable.java   Source Code and License Vote up 6 votes
public CartProducts findByTitle(String title){
    String query = "Select * FROM " + TABLE_PRODUCT + " WHERE " + PRODUCT_TITLE + " =  \"" + title + "\"";
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor c = db.rawQuery(query, null);
    CartProducts product ;

    if (c.moveToFirst()) {
        c.moveToFirst();
        product = new CartProducts(c.getString(1),c.getString(2),c.getDouble(4),c.getString(5),c.getDouble(6),c.getInt(7));
      c.close();
    } else {
        product = null;
    }
    db.close();
    return product;
}
 
Example 2
Project: medialibrary   File: LocalImage.java   Source Code and License Vote up 6 votes
private void loadFromCursor(Cursor cursor) {
    id = cursor.getInt(INDEX_ID);
    caption = cursor.getString(INDEX_CAPTION);
    mimeType = cursor.getString(INDEX_MIME_TYPE);
    latitude = cursor.getDouble(INDEX_LATITUDE);
    longitude = cursor.getDouble(INDEX_LONGITUDE);
    dateTakenInMs = cursor.getLong(INDEX_DATE_TAKEN);
    dateAddedInSec = cursor.getLong(INDEX_DATE_ADDED);
    dateModifiedInSec = cursor.getLong(INDEX_DATE_MODIFIED);
    filePath = cursor.getString(INDEX_DATA);
    rotation = cursor.getInt(INDEX_ORIENTATION);
    bucketId = cursor.getInt(INDEX_BUCKET_ID);
    fileSize = cursor.getLong(INDEX_SIZE);
    width = cursor.getInt(INDEX_WIDTH);
    height = cursor.getInt(INDEX_HEIGHT);
}
 
Example 3
Project: Runnest   File: DBHelper.java   Source Code and License Vote up 6 votes
/**
 * Retrieve a track from the database given its starting and ending index.
 *
 * @param fromId the id of the first checkpoint
 * @param toId the id of the last checkpoint
 * @return the track
 */
private Track fetchTrack(long fromId, long toId) {
    String selection = CHECKPOINTS_COLS[0] + " >= " + fromId + " AND " + CHECKPOINTS_COLS[0] + " <= " + toId;
    Cursor result = db.query(CHECKPOINTS_TABLE_NAME, CHECKPOINTS_COLS, selection, null, null, null, null);
    Track track = new Track();
    if (result.getCount() > 0) {
        while (result.moveToNext()) {
            Double latitude = result.getDouble(1);
            Double longitude = result.getDouble(2);

            CheckPoint checkpoint = new CheckPoint(latitude, longitude);
            track.add(checkpoint);
        }
    }
    result.close();
    return track;
}
 
Example 4
Project: AndiCar   File: DBAdapter.java   Source Code and License Vote up 6 votes
@Nullable
public Double getFuelQtyForCons(long carID, BigDecimal prevIndex, Double currIndex) {
    Double retVal = null;
    String selectSql;
    Cursor selectCursor;
    selectSql = " SELECT SUM( " + COL_NAME_REFUEL__QUANTITY + ") " + " FROM " + TABLE_NAME_REFUEL + " WHERE 1 = 1 " + WHERE_CONDITION_ISACTIVE + " AND "
            + COL_NAME_REFUEL__INDEX + " > " + prevIndex + " AND " + COL_NAME_REFUEL__INDEX + " <= " + currIndex + " AND " + COL_NAME_REFUEL__CAR_ID
            + " = " + carID;

    selectCursor = execSelectSql(selectSql, null);
    if (selectCursor.moveToFirst()) {
        retVal = selectCursor.getDouble(0);
    }
    selectCursor.close();
    return retVal;
}
 
Example 5
Project: Remindy   File: RemindyDAO.java   Source Code and License Vote up 5 votes
private Place getPlaceFromCursor(Cursor cursor) {
    int id = cursor.getInt(cursor.getColumnIndex(RemindyContract.PlaceTable._ID));
    String alias = cursor.getString(cursor.getColumnIndex(RemindyContract.PlaceTable.COLUMN_NAME_ALIAS.getName()));
    String address = cursor.getString(cursor.getColumnIndex(RemindyContract.PlaceTable.COLUMN_NAME_ADDRESS.getName()));
    double latitude = cursor.getDouble(cursor.getColumnIndex(RemindyContract.PlaceTable.COLUMN_NAME_LATITUDE.getName()));
    double longitude = cursor.getDouble(cursor.getColumnIndex(RemindyContract.PlaceTable.COLUMN_NAME_LONGITUDE.getName()));
    int radius = cursor.getInt(cursor.getColumnIndex(RemindyContract.PlaceTable.COLUMN_NAME_RADIUS.getName()));
    boolean isOneOff = Boolean.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.PlaceTable.COLUMN_NAME_IS_ONE_OFF.getName())));

    return new Place(id, alias, address, latitude, longitude, radius, isOneOff);
}
 
Example 6
Project: techstar-shop   File: CartTable.java   Source Code and License Vote up 5 votes
public ArrayList<CartProducts> readData(){

        SQLiteDatabase db = this.getReadableDatabase();
        ArrayList<CartProducts> data = new ArrayList<CartProducts>();

        String[] projection = {
                PRODUCT_ID,
                PRODUCT_TITLE,
                PRODUCT_DESCRIPTION,
                PRODUCT_COST,
                PRODUCT_IMAGE,
                PRODUCT_TOTAL_COST,
                PRODUCT_TOTAL_ORDER
        };

        String sortOrder =
                PRODUCT_TITLE + " ASC";

        Cursor c = db.query(
                TABLE_PRODUCT,
                projection,
                null,
                null,
                null,
                null,
                sortOrder
        );

        while(c.moveToNext()){
            CartProducts product = new CartProducts(c.getString(1),c.getString(2),c.getDouble(3),c.getString(4),c.getDouble(5),c.getInt(6));
          data.add(product);
        };
        c.close();
        db.close();
        return data;
    }
 
Example 7
Project: Android-Wear-Projects   File: MemoriesDataSource.java   Source Code and License Vote up 5 votes
private Memory cursorToMemory(Cursor cursor){
    Memory memory = new Memory();
    memory.id = cursor.getLong(0);
    memory.city = cursor.getString(1);
    memory.country = cursor.getString(2);
    memory.latitude = cursor.getDouble(3);
    memory.longitude = cursor.getDouble(4);
    memory.notes = cursor.getString(5);
    return memory;
}
 
Example 8
Project: GitHub   File: LitePalTestCase.java   Source Code and License Vote up 5 votes
protected List<Book> getBooks(String[] columns, String selection, String[] selectionArgs,
		String groupBy, String having, String orderBy, String limit) {
	List<Book> books = new ArrayList<Book>();
	Cursor cursor = Connector.getDatabase().query(getTableName(Book.class), columns, selection, selectionArgs,
			groupBy, having, orderBy, limit);
	if (cursor.moveToFirst()) {
		do {
			long id = cursor.getLong(cursor.getColumnIndexOrThrow("id"));
			String bookName = cursor.getString(cursor.getColumnIndexOrThrow("bookname"));
			int pages = cursor.getInt(cursor.getColumnIndexOrThrow("pages"));
			double price = cursor.getDouble(cursor.getColumnIndexOrThrow("price"));
			char level = cursor.getString(cursor.getColumnIndexOrThrow("level")).charAt(0);
			short isbn = cursor.getShort(cursor.getColumnIndexOrThrow("isbn"));
			float area = cursor.getFloat(cursor.getColumnIndexOrThrow("area"));
			boolean isPublished = cursor.getInt(cursor.getColumnIndexOrThrow("ispublished")) == 1;
			Book book = new Book();
			book.setId(id);
			book.setBookName(bookName);
			book.setPages(pages);
			book.setPrice(price);
			book.setLevel(level);
			book.setIsbn(isbn);
			book.setArea(area);
			book.setPublished(isPublished);
			books.add(book);
		} while (cursor.moveToNext());
	}
	cursor.close();
	return books;
}
 
Example 9
Project: Shopping_List   File: UsedProductDao.java   Source Code and License Vote up 5 votes
@Override
public UsedProduct readEntity(Cursor cursor, int offset) {
    UsedProduct entity = new UsedProduct( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.getDouble(offset + 1), // quantity
        cursor.getShort(offset + 2) != 0, // unit
        cursor.getShort(offset + 3) != 0, // isPurchased
        cursor.getLong(offset + 4), // date
        cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // productId
        cursor.getLong(offset + 6) // shoppingListId
    );
    return entity;
}
 
Example 10
Project: VennTracker   File: DatabaseHelper.java   Source Code and License Vote up 5 votes
public ArrayList<LatLng> getAllRedPolygons(String type) {
    ArrayList<LatLng> redPolygons = new ArrayList<>();

    Cursor res = getAllLocations("Temp Polygon Red");
    while(res.moveToNext()) {
        LatLng latLng = new LatLng(res.getDouble(2), res.getDouble(3));
        redPolygons.add(latLng);
    }
    return redPolygons;
}
 
Example 11
Project: Simpler   File: DraftServices.java   Source Code and License Vote up 5 votes
/**
 * 根据用户Id(uid)获取草稿
 *
 * @param uid 用户Id
 * @return 该用户的所有草稿,没有找到返回null
 */
public List<Draft> getDraftsByUid(String uid) {
    SQLiteDatabase db = this.dbHelper.getReadableDatabase();
    Cursor cursor = db.query(DBInfo.Table.DRAFT_TB_NAME, columns,
            Draft.UID + "=?", new String[]{uid}, null, null, null);

    List<Draft> draftList = null;
    if (cursor != null) {
        int count = cursor.getCount();
        if (count > 0) {
            draftList = new ArrayList<>(count);
            Draft draft = null;
            while (cursor.moveToNext()) {
                int id = cursor.getInt(cursor.getColumnIndex(Draft.ID));
                String content = cursor.getString(cursor.getColumnIndex(Draft.CONTENT));
                List<Photo> photoList = Draft.string2PhotoList(cursor.getString(cursor.getColumnIndex(Draft.PHOTO_LIST)));
                double latitude = cursor.getDouble(cursor.getColumnIndex(Draft.LATITUDE));
                double longitude = cursor.getDouble(cursor.getColumnIndex(Draft.LONGITUDE));
                boolean isEnableGeo = cursor.getInt(cursor.getColumnIndex(Draft.IS_ENABLE_GEO)) == 1;
                boolean isLocation = cursor.getInt(cursor.getColumnIndex(Draft.IS_LOCATION)) == 1;
                String addrStr = cursor.getString(cursor.getColumnIndex(Draft.ADDR_STR));
                int menuId = cursor.getInt(cursor.getColumnIndex(Draft.MENU_ID));
                String groupId = cursor.getString(cursor.getColumnIndex(Draft.GROUP_ID));
                String groupName = cursor.getString(cursor.getColumnIndex(Draft.GROUP_NAME));

                draft = new Draft(id, uid, content, photoList, latitude, longitude, isEnableGeo,
                        isLocation, addrStr, menuId, groupId, groupName);
                draftList.add(draft);
            }
        }
        cursor.close();
    }
    db.close();
    return draftList;
}
 
Example 12
Project: MyFlightbookAndroid   File: LocSample.java   Source Code and License Vote up 5 votes
private void FromCursor(Cursor c) {
    id = c.getLong(c.getColumnIndex("_id"));
    Latitude = c.getDouble(c.getColumnIndex("Lat"));
    Longitude = c.getDouble(c.getColumnIndex("Lon"));
    Alt = c.getInt(c.getColumnIndex("Alt"));
    Speed = c.getDouble(c.getColumnIndex("Speed"));
    HError = c.getDouble(c.getColumnIndex("Error"));
    try {
        TimeStamp = getUTCFormatter().parse(c.getString(c.getColumnIndex("TimeStamp")));
    } catch (ParseException ignored) {
    }
    TZOffset = c.getInt(c.getColumnIndex("TZOffset"));
    Comment = c.getString(c.getColumnIndex("Comment"));
}
 
Example 13
Project: MovieGuide   File: MovieActivity.java   Source Code and License Vote up 4 votes
/**
 * Process the Movie Details data.
 * @param jObj object
 */
private void processMovieDetails(JSONObject jObj) {
    if (jObj != null) {
        try {
            detailsData = new MovieData(getStringValue(jObj, "poster_path"),
                    movieID, getStringValue(jObj, "title"),
                    getStringValue(jObj, "overview"),
                    getStringValue(jObj, "release_date"),
                    getIntValue(jObj, "runtime", 0),
                    getDoubleValue(jObj, "vote_average", 0.0),
                    getIntValue(jObj, "vote_count", 0),
                    getStringValue(jObj, "backdrop_path"),
                    getStringValue(jObj, "original_language"),
                    getListValue(jObj, "production_countries", "name"),
                    getListValue(jObj, "genres", "name"),
                    getStringValue(jObj, "status"),
                    getUriValue(jObj, "imdb_uri" + IMDB_URI),
                    getListValue(jObj, "production_companies", "name"),
                    getLongValue(jObj, "budget", 0L),
                    getLongValue(jObj, "revenue", 0L),
                    getStringValue(jObj, "homepage"), getStringValue(jObj, "tagline"));
            populateDetails(detailsData);
        } catch (JSONException e) {
            if (LOG) {
                Log.e(TAG, "", e);
            }
        }

    } else {
        final Cursor cursor = getContentResolver().query(
                ContentUris.withAppendedId(URI, movieID),
                new String[]{ COLUMN_POSTER_PATH, COLUMN_TITLE, COLUMN_PLOT,
                        COLUMN_YEAR, COLUMN_DURATION, COLUMN_VOTE_AVERAGE, COLUMN_VOTE_COUNT,
                        COLUMN_BACKGROUND_PATH, COLUMN_ORIGINAL_LANGUAGE,
                        /*COLUMN_ORIGINAL_COUNTRIES, COLUMN_GENRES,*/ COLUMN_STATUS,
                        COLUMN_IMDB_ID/*, COLUMN_PROD_COMPANIES */, COLUMN_BUDGET,
                        COLUMN_REVENUE, COLUMN_HOMEPAGE, COLUMN_TAGLINE},
                null, null, null);

        if (cursor.getCount() != 0) {
            if (LOG) {
                Log.d(TAG, "Cursor = " + cursor.getCount());
            }
            cursor.moveToFirst();
            // Note: Better if it matches the query order
            detailsData = new MovieData(cursor.getString(0), movieID,
                    cursor.getString(1), cursor.getString(2), cursor.getString(3),
                    cursor.getInt(4), cursor.getDouble(5), cursor.getInt(6),
                    cursor.getString(7), cursor.getString(8), Collections.<String>emptyList(),
                    Collections.<String>emptyList(), cursor.getString(9),
                    cursor.getString(10), Collections.<String>emptyList(),
                    (long)cursor.getInt(11), (long)cursor.getInt(12), cursor.getString(13),
                    cursor.getString(14));
            populateDetails(detailsData);
        }
        cursor.close();
    }
}
 
Example 14
Project: Farmacias   File: FavoritePresenter.java   Source Code and License Vote up 4 votes
private List<Pharmacy> transformSearchCursor(Cursor data){
    List<Pharmacy> list = new ArrayList<Pharmacy>(data.getCount());
    if(data.moveToFirst()) {
        do {
            Pharmacy farmacia = new Pharmacy();
            farmacia.setName(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.NAME)));
            farmacia.setAddress(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.ADDRESS)));
            farmacia.setLocality(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.LOCALITY)));
            farmacia.setProvince(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.PROVINCE)));
            farmacia.setPostal_code(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.POSTAL_CODE)));
            String phone = data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.PHONE));
            farmacia.setPhone(phone);
            farmacia.setPhoneFormatted(Utils.formatPhoneNumber(phone));
            double latDest = data.getDouble(data.getColumnIndex(DbContract.FarmaciasEntity.LAT));
            double lonDest = data.getDouble(data.getColumnIndex(DbContract.FarmaciasEntity.LON));
            double distance = SphericalUtil.computeDistanceBetween(new LatLng(latDest,lonDest),
                    new LatLng(mLocation.getLatitude(),mLocation.getLongitude()));
            //double distance = Utils.meterDistanceBetweenPoints(latDest, lonDest, mLocation.getLatitude(), mLocation.getLongitude());
            farmacia.setLat(latDest);
            farmacia.setLon(lonDest);
            farmacia.setDistance(distance / 1000);

            String hours = data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.HOURS));
            farmacia.setHours(hours);
            farmacia.setOpen(Utils.isPharmacyOpen(hours));
            String addressFormatted = Utils.formatAddress(farmacia.getAddress(),
                    farmacia.getPostal_code(),
                    farmacia.getLocality(),
                    farmacia.getProvince());
            farmacia.setAddressFormatted(addressFormatted);


            boolean favorite;
            int j = data.getInt(data.getColumnIndex(DbContract.FarmaciasEntity.FAVORITE));
            if (j == 0) {
                favorite = false;
            } else {
                favorite = true;
            }

            farmacia.setFavorite(favorite);
            list.add(farmacia);
        } while (data.moveToNext());
    }
    return list;

}
 
Example 15
Project: Farmacias   File: FindPresenter.java   Source Code and License Vote up 4 votes
private List<Pharmacy> transformSearchCursor(Cursor data){
    List<Pharmacy> list = new ArrayList<Pharmacy>(data.getCount());
    if(data.moveToFirst()) {
        do {
            Pharmacy farmacia = new Pharmacy();
            farmacia.setName(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.NAME)));
            farmacia.setAddress(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.ADDRESS)));
            farmacia.setLocality(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.LOCALITY)));
            farmacia.setProvince(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.PROVINCE)));
            farmacia.setPostal_code(data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.POSTAL_CODE)));
            String phone = data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.PHONE));
            farmacia.setPhone(phone);
            farmacia.setPhoneFormatted(Utils.formatPhoneNumber(phone));
            double latDest = data.getDouble(data.getColumnIndex(DbContract.FarmaciasEntity.LAT));
            double lonDest = data.getDouble(data.getColumnIndex(DbContract.FarmaciasEntity.LON));
            double distance = SphericalUtil.computeDistanceBetween(new LatLng(latDest,lonDest),
                    new LatLng(mLocation.getLatitude(),mLocation.getLongitude()));
            //double distance = Utils.meterDistanceBetweenPoints(latDest, lonDest, mLocation.getLatitude(), mLocation.getLongitude());
            farmacia.setLat(latDest);
            farmacia.setLon(lonDest);
            farmacia.setDistance(distance / 1000);

            String hours = data.getString(data.getColumnIndex(DbContract.FarmaciasEntity.HOURS));
            farmacia.setHours(hours);
            farmacia.setOpen(Utils.isPharmacyOpen(hours));
            String addressFormatted = Utils.formatAddress(farmacia.getAddress(),
                    farmacia.getPostal_code(),
                    farmacia.getLocality(),
                    farmacia.getProvince());
            farmacia.setAddressFormatted(addressFormatted);


            boolean favorite;
            int j = data.getInt(data.getColumnIndex(DbContract.FarmaciasEntity.FAVORITE));
            if (j == 0) {
                favorite = false;
            } else {
                favorite = true;
            }

            farmacia.setFavorite(favorite);
            list.add(farmacia);
        } while (data.moveToNext());
    }
    return list;

}
 
Example 16
Project: react-native-cameraroll   File: RNCameraRollModule.java   Source Code and License Vote up 4 votes
private static WritableArray buildAssets(Cursor assetsCursor, WritableMap response,
    int limit) {
    assetsCursor.moveToFirst();
    int idIndex = assetsCursor.getColumnIndex(Images.Media._ID);
    int mimeTypeIndex = assetsCursor.getColumnIndex(Images.Media.MIME_TYPE);
    int dateTakenIndex = assetsCursor.getColumnIndex(Images.Media.DATE_TAKEN);
    int widthIndex = assetsCursor.getColumnIndex(Images.Media.WIDTH);
    int heightIndex = assetsCursor.getColumnIndex(Images.Media.HEIGHT);
    int longitudeIndex = assetsCursor.getColumnIndex(Images.Media.LONGITUDE);
    int latitudeIndex = assetsCursor.getColumnIndex(Images.Media.LATITUDE);
    int filenameIndex = assetsCursor.getColumnIndex(Images.Media.DISPLAY_NAME);

    WritableArray assets = new WritableNativeArray();
    for (int i = 0; i < limit && !assetsCursor.isAfterLast(); i++) {
        WritableMap asset = new WritableNativeMap();
        asset.putDouble("width", assetsCursor.getInt(widthIndex));
        asset.putDouble("height", assetsCursor.getInt(heightIndex));
        asset.putString("filename", assetsCursor.getString(filenameIndex));
        asset.putDouble("timestamp", assetsCursor.getLong(dateTakenIndex) / 1000d);

        String mimeType = assetsCursor.getString(mimeTypeIndex);
        if (mimeType.startsWith("image/")) {
            Uri photoUri = Uri.withAppendedPath(Images.Media.EXTERNAL_CONTENT_URI,
                    assetsCursor.getString(idIndex));
            asset.putString("uri", photoUri.toString());
            asset.putString("type", "image");
        } else {
            Uri videoUri = Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                    assetsCursor.getString(idIndex));
            asset.putString("uri", videoUri.toString());
            asset.putString("type", "video");
        }

        double longitude = assetsCursor.getDouble(longitudeIndex);
        double latitude = assetsCursor.getDouble(latitudeIndex);
        if (longitude > 0 || latitude > 0) {
            WritableMap location = new WritableNativeMap();
            location.putDouble("longitude", longitude);
            location.putDouble("latitude", latitude);
            asset.putMap("location", location);
        }

        assets.pushMap(asset);
        assetsCursor.moveToNext();
    }
    return assets;
}
 
Example 17
Project: ifcalc   File: DataSource.java   Source Code and License Vote up 4 votes
/** Method to create a Disciplina
 *   @param cursor
 *   @return Disciplina
 */
private Disciplina createDisciplina(Cursor cursor) {
    Disciplina model = null;
    Double nb1, nb2, nb3, nb4, npf;

    if (cursor.getString(cursor.getColumnIndex(dbHelper.NOTAB1)).trim().isEmpty())
        nb1 = null;
    else
        nb1 = cursor.getDouble(cursor.getColumnIndex(dbHelper.NOTAB1));

    if (cursor.getString(cursor.getColumnIndex(dbHelper.NOTAB2)).trim().isEmpty())
        nb2 = null;
    else
        nb2 = cursor.getDouble(cursor.getColumnIndex(dbHelper.NOTAB2));

    if (cursor.getString(cursor.getColumnIndex(dbHelper.NOTAB3)).trim().isEmpty())
        nb3 = null;
    else
        nb3 = cursor.getDouble(cursor.getColumnIndex(dbHelper.NOTAB3));

    if (cursor.getString(cursor.getColumnIndex(dbHelper.NOTAB4)).trim().isEmpty())
        nb4 = null;
    else
        nb4 = cursor.getDouble(cursor.getColumnIndex(dbHelper.NOTAB4));

    if (cursor.getString(cursor.getColumnIndex(dbHelper.PROVA_FINAL)).trim().isEmpty())
        npf = null;
    else
        npf = cursor.getDouble(cursor.getColumnIndex(dbHelper.PROVA_FINAL));


    if (cursor.getInt(cursor.getColumnIndex(dbHelper.TIPO_DISCI)) == 1) {
        model = new Disciplina(cursor.getInt(cursor.getColumnIndex(dbHelper.ID)),
                cursor.getString(cursor.getColumnIndex(dbHelper.TITULO)),
                nb1, nb2, nb3, nb4, npf,
                cursor.getDouble(cursor.getColumnIndex(dbHelper.MEDIA)),
                cursor.getString(cursor.getColumnIndex(dbHelper.SITUACAO)));
    } else if (cursor.getInt(cursor.getColumnIndex(dbHelper.TIPO_DISCI)) == 2){
        model = new Disciplina(cursor.getInt(cursor.getColumnIndex(dbHelper.ID)),
                cursor.getString(cursor.getColumnIndex(dbHelper.TITULO)),
                nb1, nb2, npf,
                cursor.getDouble(cursor.getColumnIndex(dbHelper.MEDIA)),
                cursor.getString(cursor.getColumnIndex(dbHelper.SITUACAO)));
    }

    model.setIdWeb(cursor.getString(cursor.getColumnIndex(dbHelper.ID_SUAP)));

    return model;
}
 
Example 18
Project: AndiCar   File: GPSTrackMap.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gpstrack_map);

    Bundle mExtras = getIntent().getExtras();
    if (mExtras != null) {
        mResource = getResources();
        mErrMsg = mResource.getString(R.string.error_056);
        //get the the track id
        mTrackId = mExtras.getLong(GPS_TRACK_ID);

        DBAdapter dbAdapter = new DBAdapter(this);
        Cursor c = dbAdapter.fetchRecord(DBAdapter.TABLE_NAME_GPSTRACK, DBAdapter.COL_LIST_GPSTRACK_TABLE, mTrackId);
        mInfoName = c != null ? c.getString(DBAdapter.COL_POS_GEN_NAME) : "";
        mInfoDateTimeStart = Utils.getFormattedDateTime((c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__DATE) : 0) * 1000, false); //format[0].format(new Date(c.getLong(DBAdapter.COL_POS_GPSTRACK__DATE) * 1000));
        mInfoDateTimeEnd = Utils.getFormattedDateTime(((c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__DATE) : 0) * 1000) + ((c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__TOTALTIME) : 0) * 1000), false);

        mInfoTotalTime = c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__TOTALTIME) : 0;
        mInfoMovingTime = c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__MOVINGTIME) : 0;
        mInfoTotalPauseTime = c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__TOTALPAUSETIME) : 0;
        mInfoNonMovingTime = mInfoTotalTime - mInfoTotalPauseTime - mInfoMovingTime;
        mInfoDistance = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__DISTANCE) : 0;
        mInfoMaxSpeed = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__MAXSPEED) : 0;
        mInfoAvgSpeed = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__AVGSPEED) : 0;
        mInfoAvgMovingSpeed = c != null ? c.getDouble(DBAdapter.COL_POS_GPSTRACK__AVGMOVINGSPEED) : 0;
        mCarUOMLengthCode = dbAdapter.getUOMCode(dbAdapter.getCarUOMLengthID(c != null ? c.getLong(DBAdapter.COL_POS_GPSTRACK__CAR_ID) : -1));
        if (c != null) {
            c.close();
        }

        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        if (metrics.densityDpi <= DisplayMetrics.DENSITY_HIGH) {
            trackLineWidth = 3;
        }

        loadTrackFiles = true;
        setUpMapIfNeeded();
    }
}
 
Example 19
Project: TaBeTa   File: InternalDB.java   Source Code and License Vote up 3 votes
public double GetCurlDirX(int level, int n){

		Cursor cu = mydb.query("CurlDirx", null, "ID="+level, null, null, null, null);
		cu.moveToPosition(0);
		double point = cu.getDouble(n+1);
		
		return point;
		
	}
 
Example 20
Project: OpenHomeAnalysis   File: OhaEnergyUseLogHelper.java   Source Code and License Vote up 2 votes
/**
 * Obter o total por Watts hora para um log de utilização de energia.
 * @param cursor informar o cursor posicionado no log onde deve ser calculado o Wh.
 * @param indexWatts informar o índice coluna, {@see LOG_COLUMNS}
 * @return watts por hora.
 */
private double getWh(Cursor cursor, int indexWatts) {
    return (cursor.getDouble(indexWatts) * cursor.getDouble(INDEX_DURATION)) / 3600.00;
}