@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Long carId = DBUtils.getActiveCarId(getActivity().getContentResolver()); CursorLoader cursorLoader = new CursorLoader( getActivity(), ProviderDescriptor.FuelRateView.CONTENT_URI, null, DBUtils.CAR_SELECTION_RATE, new String[] {String.valueOf(carId)}, null); return cursorLoader; }
public void reload(long carId, boolean onlyLabels) { if (carId != -1) { Cursor c = ctx.getContentResolver() .query( ProviderDescriptor.Car.CONTENT_URI, null, BaseActivity.SELECTION_ID_FILTER, new String[] {String.valueOf(carId)}, null); if (c == null) { return; } boolean hasItem = c.moveToFirst(); if (hasItem) { fuelValue = c.getInt(c.getColumnIndex(ProviderDescriptor.Car.Cols.UNIT_FUEL)); distanceValue = c.getInt(c.getColumnIndex(ProviderDescriptor.Car.Cols.UNIT_DISTANCE)); consumptionValue = c.getInt(c.getColumnIndex(ProviderDescriptor.Car.Cols.UNIT_CONSUMPTION)); currency = c.getString(c.getColumnIndex(ProviderDescriptor.Car.Cols.UNIT_CURRENCY)); loadConsumptionArrayType(); } } else { loadDefault(ctx); } if (onlyLabels) { return; } carId = DBUtils.getActiveCarId(ctx.getContentResolver()); carName = DBUtils.getActiveCarName(ctx.getContentResolver(), carId); if (carName == null || carName.length() == 0) { carName = ctx.getString(R.string.no_car); } invalidateAll(); }