项目:xDrip
文件:AlertType.java
public static boolean toSettings(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<AlertType> alerts = new Select()
.from(AlertType.class)
.execute();
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
String output = gson.toJson(alerts);
Log.e(TAG,"Created the string " + output);
prefs.edit().putString("saved_alerts",output).commit();
return true;
}
项目:xDrip
文件:AlertType.java
public static boolean toSettings(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<AlertType> alerts = new Select()
.from(AlertType.class)
.execute();
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,output).commit(); // always leave this as commit
return true;
}
项目:xDrip
文件:GcmActivity.java
private static String sensorAndCalibrationsToJson(Sensor sensor,int limit) {
SensorCalibrations[] sensorCalibrations = new SensorCalibrations[1];
sensorCalibrations[0] = new SensorCalibrations();
sensorCalibrations[0].sensor = sensor;
sensorCalibrations[0].calibrations = Calibration.getCalibrationsForSensor(sensor,limit);
if (d) Log.d(TAG,"calibrations size " + sensorCalibrations[0].calibrations.size());
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
String output = gson.toJson(sensorCalibrations);
if (d) Log.d(TAG,"sensorAndCalibrationsToJson created the string " + output);
return output;
}
项目:xDrip
文件:GcmActivity.java
private static String newCalibrationToJson(double bgValue,String uuid,long offset) {
NewCalibration newCalibrationArray[] = new NewCalibration[1];
NewCalibration newCalibration = new NewCalibration();
newCalibration.bgValue = bgValue;
newCalibration.uuid = uuid;
newCalibration.timestamp = JoH.tsl();
newCalibration.offset = offset;
newCalibrationArray[0] = newCalibration;
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
String output = gson.toJson(newCalibrationArray);
Log.d(TAG,"newCalibrationToJson Created the string " + output);
return output;
}
项目:xDrip-plus
文件:AlertType.java
public static boolean toSettings(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<AlertType> alerts = new Select()
.from(AlertType.class)
.execute();
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,output).commit();
return true;
}
项目:xDrip-plus
文件:AlertType.java
public static boolean toSettings(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<AlertType> alerts = new Select()
.from(AlertType.class)
.execute();
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,output).commit(); // always leave this as commit
return true;
}
项目:xDrip-plus
文件:GcmActivity.java
private static String sensorAndCalibrationsToJson(Sensor sensor,"sensorAndCalibrationsToJson created the string " + output);
return output;
}
项目:xDrip-plus
文件:GcmActivity.java
private static String newCalibrationToJson(double bgValue,"newCalibrationToJson Created the string " + output);
return output;
}
项目:tipz-android
文件:TipzService.java
/***
* Note: This method runs on the UI Thread
*/
@Override
public void onCreate() {
super.onCreate();
// The following code creates a new Gson instance that will convert all fields from lower
// case with underscores to camel case and vice versa. It also registers a type adapter for
// the Date class. This DateTypeAdapter will be used anytime Gson encounters a Date field.
// The gson instance is passed as a parameter to GsonConverter,which is a wrapper
// class for converting types.
// (Source: http://square.github.io/retrofit/)
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERscoreS)
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.create();
// Creating the rest adapter (Retrofit)
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(getString(R.string.tipz_api_base_url))
.setConverter(new GsonConverter(gson))
.build();
mTipzApi = restAdapter.create(TipzApi.class);
}
项目:xDrip-Experimental
文件:AlertType.java
public static boolean toSettings(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<AlertType> alerts = new Select()
.from(AlertType.class)
.execute();
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,output).commit();
return true;
}
项目:soundcloud-web-api-android
文件:SoundCloudAPI.java
/**
* Creates a {@link SoundCloudService}. Serializes with JSON.
*
* @param clientId Client ID provided by SoundCloud.
*/
public SoundCloudAPI(String clientId) {
this.clientId = clientId;
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERscoreS)
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.create();
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new SoundCloudInterceptor())
.build();
Retrofit adapter = new Retrofit.Builder()
.client(client)
.baseUrl(SOUNDCLOUD_API_ENDPOINT)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
service = adapter.create(SoundCloudService.class);
}
项目:GitHub
文件:SupportTest.java
@Test
public void unwrapObject() throws Exception {
Date date = new Date();
Support.Adapted<Date> adapted = new Support.Adapted<>(new DateTypeAdapter(),date);
Object result = Support.unwrapBsonable(adapted);
check(result.toString()).isNonEmpty();
}
项目:chuck
文件:JsonConvertor.java
public static Gson getInstance() {
if (gson == null) {
gson = new GsonBuilder()
.setPrettyPrinting()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERscoreS)
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.create();
}
return gson;
}
项目:wearDrip
文件:Calibration.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:wearDrip
文件:BgReading.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:UserError.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:Calibration.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:Sensor.java
public String toS() {//KS
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
Log.d("SENSOR","Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at);
return gson.toJson(this);
}
项目:xDrip
文件:AlertType.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:TransmitterData.java
public String toS() {//KS
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:BgReading.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:Treatments.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip
文件:WatchUpdaterService.java
private synchronized void syncStepSensorData(DataMap dataMap,boolean bBenchmark) {
Log.d(TAG,"syncStepSensorData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
Log.d(TAG,"syncStepSensorData add to Table" );
if (entries != null) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
StepCounter pm = StepCounter.last();
Log.d(TAG,"syncStepSensorData add Table entries count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG,"syncStepSensorData add Table entry=" + entry);
String record = entry.getString("entry");
if (record != null) {
Log.d(TAG,"syncStepSensorData add Table record=" + record);
StepCounter data = gson.fromJson(record,StepCounter.class);
if (data != null) {
timeOfLastEntry = (long) data.timestamp + 1;
Log.d(TAG,"syncStepSensorData add Entry Wear=" + data.toString());
Log.d(TAG,"syncStepSensorData WATCH data.metric=" + data.metric + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
if (!bBenchmark)
data.saveit();
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(),timeOfLastEntry,bBenchmark?"BM":"STEP",-1);
}
}
项目:xDrip-plus
文件:UserError.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip-plus
文件:Calibration.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip-plus
文件:Sensor.java
public String toS() {//KS
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,"Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at);
return gson.toJson(this);
}
项目:xDrip-plus
文件:AlertType.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip-plus
文件:TransmitterData.java
public String toS() {//KS
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip-plus
文件:BgReading.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip-plus
文件:Treatments.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
项目:xDrip-plus
文件:WatchUpdaterService.java
private synchronized void syncStepSensorData(DataMap dataMap,-1);
}
}
项目:xDrip-Experimental
文件:Calibration.java
public String toS() {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class,new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
return gson.toJson(this);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。