Java Code Examples for com.nextgis.maplib.util.GeoConstants#FTTime
The following examples show how to use
com.nextgis.maplib.util.GeoConstants#FTTime .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTime.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
protected View.OnClickListener getDateUpdateWatcher(final int pickerType) { return new View.OnClickListener() { protected void setValue() { DateTime.this.setText(mDateFormat.format(mCalendar.getTime())); } @Override public void onClick(View view) { Context context = DateTime.this.getContext(); String title = null; Type type = Type.ALL; switch (pickerType) { case GeoConstants.FTDate: title = context.getString(R.string.field_type_date); type = Type.YEAR_MONTH_DAY; break; case GeoConstants.FTTime: title = context.getString(R.string.field_type_time); type = Type.HOURS_MINS; break; case GeoConstants.FTDateTime: title = context.getString(R.string.field_type_datetime); type = Type.ALL; break; } OnDateSetListener onDateSetListener = new OnDateSetListener() { @Override public void onDateSet(TimePickerDialog timePickerView, long milliseconds) { mCalendar.setTimeInMillis(milliseconds); setValue(); } }; mTimeDialog = new TimePickerDialog.Builder() .setCallBack(onDateSetListener) .setTitleStringId(title) .setSureStringId(context.getString(android.R.string.ok)) .setCancelStringId(context.getString(android.R.string.cancel)) .setYearText(" " + context.getString(R.string.unit_year)) .setMonthText(" " + context.getString(R.string.unit_month)) .setDayText(" " + context.getString(R.string.unit_day)) .setHourText(" " + context.getString(R.string.unit_hour)) .setMinuteText(" " + context.getString(R.string.unit_min)) .setType(type) .setCyclic(false) .setMinMillseconds(1) .setMaxMillseconds(Long.MAX_VALUE) .setCurrentMillseconds(mCalendar.getTimeInMillis()) .setWheelItemTextSize(12) .setWheelItemTextNormalColor(ContextCompat.getColor(getContext(), R.color.timetimepicker_default_text_color)) .setWheelItemTextSelectorColor(ContextCompat.getColor(getContext(), R.color.accent)) .setThemeColor(ContextCompat.getColor(getContext(), R.color.primary_dark)) .build(); AppCompatActivity activity = ControlHelper.getActivity(getContext()); if (activity != null) mTimeDialog.show(activity.getSupportFragmentManager(), "TimePickerDialog"); } }; }
Example 2
Source File: DateTime.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
protected View.OnClickListener getDateUpdateWatcher(final int pickerType) { return new View.OnClickListener() { protected Calendar mCalendar = Calendar.getInstance(); protected void setValue() { mValue = mCalendar.getTimeInMillis(); DateTime.this.setText(getText()); } @Override public void onClick(View view) { Context context = DateTime.this.getContext(); if (null != mValue) { mCalendar.setTimeInMillis(mValue); } else { mCalendar.setTime(new Date()); } String title = null; Type type = Type.ALL; switch (pickerType) { case GeoConstants.FTDate: title = context.getString(R.string.field_type_date); type = Type.YEAR_MONTH_DAY; break; case GeoConstants.FTTime: title = context.getString(R.string.field_type_time); type = Type.HOURS_MINS; break; case GeoConstants.FTDateTime: title = context.getString(R.string.field_type_datetime); type = Type.ALL; break; } OnDateSetListener onDateSetListener = new OnDateSetListener() { @Override public void onDateSet(TimePickerDialog timePickerView, long milliseconds) { mCalendar.setTimeInMillis(milliseconds); setValue(); } }; mTimeDialog = new TimePickerDialog.Builder() .setCallBack(onDateSetListener) .setTitleStringId(title) .setSureStringId(context.getString(android.R.string.ok)) .setCancelStringId(context.getString(android.R.string.cancel)) .setYearText(" " + context.getString(R.string.unit_year)) .setMonthText(" " + context.getString(R.string.unit_month)) .setDayText(" " + context.getString(R.string.unit_day)) .setHourText(" " + context.getString(R.string.unit_hour)) .setMinuteText(" " + context.getString(R.string.unit_min)) .setType(type) .setCyclic(false) .setMinMillseconds(1) .setMaxMillseconds(Long.MAX_VALUE) .setCurrentMillseconds(mCalendar.getTimeInMillis()) .setWheelItemTextSize(12) .setWheelItemTextNormalColor(ContextCompat.getColor(getContext(), R.color.timetimepicker_default_text_color)) .setWheelItemTextSelectorColor(ContextCompat.getColor(getContext(), R.color.accent)) .setThemeColor(ContextCompat.getColor(getContext(), R.color.primary_dark)) .build(); AppCompatActivity activity = ControlHelper.getActivity(getContext()); if (activity != null) mTimeDialog.show(activity.getSupportFragmentManager(), "TimePickerDialog"); } }; }
Example 3
Source File: Feature.java From android_maplib with GNU Lesser General Public License v3.0 | 4 votes |
public boolean equalsData(Feature f) { if (null == f) { return false; } //compare attributes Log.d(TAG, "Feature id:" + mId + " compare attributes"); for (int i = 0; i < mFields.size(); i++) { Field field = mFields.get(i); Object value = getFieldValue(i); Object valueOther = f.getFieldValue(field.getName()); //Log.d(TAG, value + "<->" + valueOther); if (null == value) { if (null != valueOther) { if (field.getType() == FTDateTime) { long lValue = dateObjectToLong(valueOther); if (lValue > 0) { Log.d(TAG, value + "<->" + valueOther); return false; } } else { Log.d(TAG, value + "<->" + valueOther); return false; } } } else if (null == valueOther) { Log.d(TAG, value + "<->" + valueOther); return false; } else { if (field.getType() == GeoConstants.FTInteger) { if (!checkIntegerEqual(value, valueOther)) { Log.d(TAG, value + "<->" + valueOther); return false; } } else if (field.getType() == GeoConstants.FTReal) { if (!checkRealEqual(value, valueOther)) { Log.d(TAG, value + "<->" + valueOther); return false; } } else if (field.getType() == GeoConstants.FTDate || field.getType() == GeoConstants.FTTime || field.getType() == GeoConstants.FTDateTime) { if (!checkDateEqual(value, valueOther)) { Log.d(TAG, value + "<->" + valueOther); return false; } } else if (!value.equals(valueOther)) { // any other cases Log.d(TAG, value + "<->" + valueOther); return false; } } } //compare geometry Log.d(TAG, "Feature id:" + mId + " compare geometry"); if (null == mGeometry) { return null == f.getGeometry(); } return mGeometry.equals(f.getGeometry()); }
Example 4
Source File: NGWVectorLayer.java From android_maplib with GNU Lesser General Public License v3.0 | 4 votes |
protected String cursorToJson(Cursor cursor) throws JSONException, IOException { JSONObject rootObject = new JSONObject(); if (0 != (mSyncType & Constants.SYNC_ATTRIBUTES)) { JSONObject valueObject = new JSONObject(); for (int i = 0; i < cursor.getColumnCount(); i++) { String name = cursor.getColumnName(i); if (name.equals(Constants.FIELD_ID) || name.equals(Constants.FIELD_GEOM)) { continue; } Field field = mFields.get(cursor.getColumnName(i)); if (null == field) { continue; } switch (field.getType()) { case GeoConstants.FTReal: valueObject.put(name, cursor.getFloat(i)); break; case GeoConstants.FTInteger: valueObject.put(name, cursor.getInt(i)); break; case GeoConstants.FTString: String stringVal = cursor.getString(i); if (null != stringVal && !stringVal.equals("null")) { valueObject.put(name, stringVal); } break; case GeoConstants.FTDateTime: TimeZone timeZoneDT = TimeZone.getDefault(); timeZoneDT.setRawOffset(0); // set to UTC Calendar calendarDT = Calendar.getInstance(timeZoneDT); calendarDT.setTimeInMillis(cursor.getLong(i)); JSONObject jsonDateTime = new JSONObject(); jsonDateTime.put("year", calendarDT.get(Calendar.YEAR)); jsonDateTime.put("month", calendarDT.get(Calendar.MONTH) + 1); jsonDateTime.put("day", calendarDT.get(Calendar.DAY_OF_MONTH)); jsonDateTime.put("hour", calendarDT.get(Calendar.HOUR_OF_DAY)); jsonDateTime.put("minute", calendarDT.get(Calendar.MINUTE)); jsonDateTime.put("second", calendarDT.get(Calendar.SECOND)); valueObject.put(name, jsonDateTime); break; case GeoConstants.FTDate: TimeZone timeZoneD = TimeZone.getDefault(); timeZoneD.setRawOffset(0); // set to UTC Calendar calendarD = Calendar.getInstance(timeZoneD); calendarD.setTimeInMillis(cursor.getLong(i)); JSONObject jsonDate = new JSONObject(); jsonDate.put("year", calendarD.get(Calendar.YEAR)); jsonDate.put("month", calendarD.get(Calendar.MONTH) + 1); jsonDate.put("day", calendarD.get(Calendar.DAY_OF_MONTH)); valueObject.put(name, jsonDate); break; case GeoConstants.FTTime: TimeZone timeZoneT = TimeZone.getDefault(); timeZoneT.setRawOffset(0); // set to UTC Calendar calendarT = Calendar.getInstance(timeZoneT); calendarT.setTimeInMillis(cursor.getLong(i)); JSONObject jsonTime = new JSONObject(); jsonTime.put("hour", calendarT.get(Calendar.HOUR_OF_DAY)); jsonTime.put("minute", calendarT.get(Calendar.MINUTE)); jsonTime.put("second", calendarT.get(Calendar.SECOND)); valueObject.put(name, jsonTime); break; default: break; } } rootObject.put(NGWUtil.NGWKEY_FIELDS, valueObject); } if (0 != (mSyncType & Constants.SYNC_GEOMETRY)) { //may be found geometry in cache by id is faster GeoGeometry geometry = GeoGeometryFactory.fromBlob( cursor.getBlob(cursor.getColumnIndex(Constants.FIELD_GEOM))); geometry.setCRS(GeoConstants.CRS_WEB_MERCATOR); if (mCRS != GeoConstants.CRS_WEB_MERCATOR) geometry.project(mCRS); rootObject.put(NGWUtil.NGWKEY_GEOM, geometry.toWKT(true)); //rootObject.put("id", cursor.getLong(cursor.getColumnIndex(FIELD_ID))); } return rootObject.toString(); }