コード例 #1
0
 public void setSetings(String key, String value) {
   ContentResolver cr = ctx.getContentResolver();
   String currentValue = DBUtils.getSettValue(cr, key);
   if (currentValue == null) {
     DBUtils.createSetValue(cr, key, value);
   } else {
     DBUtils.updateSetValue(cr, key, value);
   }
 }
コード例 #2
0
  public void invalidateDateFormat() {
    String value = DBUtils.getSettValue(ctx.getContentResolver(), SET_DATE_FORMAT);

    if (value == null) {
      value = "0";
    }

    DATATE_FORMAT = dataFormatArray[Integer.valueOf(value)];
  }
コード例 #3
0
  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();
  }
コード例 #4
0
  @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;
  }
コード例 #5
0
 public String getLogDefault(int type) {
   ContentResolver cr = ctx.getContentResolver();
   String value = DBUtils.getSettValue(cr, LOG_DEF + type);
   return value == null ? "" : value;
 }
コード例 #6
0
 public String getSetting(String key, String defaultValue) {
   ContentResolver cr = ctx.getContentResolver();
   String value = DBUtils.getSettValue(cr, key);
   return value == null ? defaultValue : value;
 }
コード例 #7
0
 public String getSetting(String key) {
   ContentResolver cr = ctx.getContentResolver();
   return DBUtils.getSettValue(cr, key);
 }