本文整理汇总了Java中com.squareup.wire.Wire.get方法的典型用法代码示例。如果您正苦于以下问题:Java Wire.get方法的具体用法?Java Wire.get怎么用?Java Wire.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.wire.Wire
的用法示例。
在下文中一共展示了Wire.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFromMessage
import com.squareup.wire.Wire; //导入方法依赖的package包/类
private static void processFromMessage(BgReadingMessage btm) {
if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) {
BgReading bg = byUUID(btm.uuid);
if (bg != null) {
// we already have this uuid and we don't have a circumstance to update the record, so quick return here
return;
}
if (bg == null) {
bg = getForPreciseTimestamp(Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS, false);
if (bg != null) {
UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bg.uuid + " vs " + btm.uuid + " skipping!");
return;
}
bg = new BgReading();
}
bg.timestamp = Wire.get(btm.timestamp, BgReadingMessage.DEFAULT_TIMESTAMP);
bg.calculated_value = Wire.get(btm.calculated_value, BgReadingMessage.DEFAULT_CALCULATED_VALUE);
bg.filtered_calculated_value = Wire.get(btm.filtered_calculated_value, BgReadingMessage.DEFAULT_FILTERED_CALCULATED_VALUE);
bg.calibration_flag = Wire.get(btm.calibration_flag, BgReadingMessage.DEFAULT_CALIBRATION_FLAG);
bg.raw_calculated = Wire.get(btm.raw_calculated, BgReadingMessage.DEFAULT_RAW_CALCULATED);
bg.raw_data = Wire.get(btm.raw_data, BgReadingMessage.DEFAULT_RAW_DATA);
bg.calculated_value_slope = Wire.get(btm.calculated_value_slope, BgReadingMessage.DEFAULT_CALCULATED_VALUE_SLOPE);
bg.calibration_uuid = btm.calibration_uuid;
bg.uuid = btm.uuid;
bg.save();
} else {
UserError.Log.wtf(TAG, "processFromMessage uuid is null or invalid");
}
}
示例2: processFromMessage
import com.squareup.wire.Wire; //导入方法依赖的package包/类
private static void processFromMessage(BloodTestMessage btm) {
if ((btm != null) && (btm.uuid != null) && (btm.uuid.length() == 36)) {
boolean is_new = false;
BloodTest bt = byUUID(btm.uuid);
if (bt == null) {
bt = getForPreciseTimestamp(Wire.get(btm.timestamp, BloodTestMessage.DEFAULT_TIMESTAMP), CLOSEST_READING_MS);
if (bt != null) {
UserError.Log.wtf(TAG, "Error matches a different uuid with the same timestamp: " + bt.uuid + " vs " + btm.uuid + " skipping!");
return;
}
bt = new BloodTest();
is_new = true;
} else {
if (bt.state != Wire.get(btm.state, BloodTestMessage.DEFAULT_STATE)) {
is_new = true;
}
}
bt.timestamp = Wire.get(btm.timestamp, BloodTestMessage.DEFAULT_TIMESTAMP);
bt.mgdl = Wire.get(btm.mgdl, BloodTestMessage.DEFAULT_MGDL);
bt.created_timestamp = Wire.get(btm.created_timestamp, BloodTestMessage.DEFAULT_CREATED_TIMESTAMP);
bt.state = Wire.get(btm.state, BloodTestMessage.DEFAULT_STATE);
bt.source = Wire.get(btm.source, BloodTestMessage.DEFAULT_SOURCE);
bt.uuid = btm.uuid;
bt.saveit(); // de-dupe by uuid
if (is_new) { // cannot handle updates yet
if (UploaderQueue.newEntry(is_new ? "insert" : "update", bt) != null) {
if (JoH.quietratelimit("start-sync-service", 5)) {
SyncService.startSyncService(3000); // sync in 3 seconds
}
}
}
} else {
UserError.Log.wtf(TAG, "processFromMessage uuid is null or invalid");
}
}
示例3: parseMatchup
import com.squareup.wire.Wire; //导入方法依赖的package包/类
@Nullable
private static Matchup parseMatchup(XmlPullParser parser)
throws XmlPullParserException, IOException {
parser.require(XmlPullParser.START_TAG, null, "matchup");
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
if ("teams".equals(parser.getName())) {
if (!"2".equals(parser.getAttributeValue(null, "count"))) {
// TODO: Support other fantasy league formats (points, roto, others?).
throw new UnsupportedOperationException(
"Only head-to-head leagues are supported");
}
Team[] teams = parseTeams(parser);
if (Wire.get(teams[0].is_owned_by_current_login, false)) {
return new Matchup.Builder()
.my_team(teams[0])
.opponent_team(teams[1])
.build();
} else if (Wire.get(teams[1].is_owned_by_current_login, false)) {
return new Matchup.Builder()
.my_team(teams[1])
.opponent_team(teams[0])
.build();
}
} else {
Util.skipCurrentTag(parser);
}
}
}
// If the user's team wasn't found, we'll try the next matchup.
return null;
}
示例4: onHandleIntent
import com.squareup.wire.Wire; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
TruckProfilesRequest request = new TruckProfilesRequest.Builder()
.latitude(intent.getDoubleExtra(ARG_LATITUDE, 0.0))
.longitude(intent.getDoubleExtra(ARG_LONGITUDE, 0.0))
.build();
TruckProfilesResponse truckProfilesResponse = truckService.getTruckProfiles(request);
List<Truck> trucks = truckProfilesResponse.trucks;
SQLiteDatabase db = openHelper.getWritableDatabase();
try {
db.beginTransaction();
ContentValues values = new ContentValues();
values.put(Contract.TruckProperties.IS_DIRTY, 1);
// Mark all trucks in the database as dirty so we can remove "dead" trucks
db.update(Tables.TRUCK_PROPERTIES, values, null, null);
// Add new trucks. Set dirty to false
for (Truck truck : trucks) {
if (Wire.get(truck.approved, Truck.DEFAULT_APPROVED)) {
values.put(PublicContract.Truck.ID, truck.id);
values.put(PublicContract.Truck.NAME, truck.name);
values.put(PublicContract.Truck.IMAGE_URL, truck.imageUrl);
values.put(PublicContract.Truck.KEYWORDS, convertListToString(truck.keywords));
values.put(PublicContract.Truck.COLOR_PRIMARY, truck.primaryColor);
values.put(PublicContract.Truck.COLOR_SECONDARY, truck.secondaryColor);
values.put(PublicContract.Truck.DESCRIPTION, truck.description);
values.put(PublicContract.Truck.PHONE_NUMBER, truck.phoneNumber);
values.put(PublicContract.Truck.WEBSITE, truck.website);
values.put(Contract.TruckProperties.IS_DIRTY, 0);
db.replace(Tables.TRUCK_PROPERTIES, null, values);
}
}
// Remove remaining dirty trucks
WhereClause where = new WhereClause.Builder()
.where(Contract.TruckProperties.IS_DIRTY, EQUALS, true)
.build();
db.delete(Tables.TRUCK_PROPERTIES, where.selection, where.selectionArgs);
db.setTransactionSuccessful();
getContentResolver().notifyChange(PublicContract.TRUCK_URI, null);
} finally {
db.endTransaction();
}
}
示例5: resolveState
import com.squareup.wire.Wire; //导入方法依赖的package包/类
public void resolveState() {
TrucksForVendorResponse response;
try {
response = truckService.getTrucksForVendor(new TrucksForVendorRequest());
} catch (ApiException e) {
ApiResult result = exceptionResolver.resolve(e);
switch (result) {
case SHOULD_RETRY: // Fall through
case TEMPORARY_ERROR:
resolveState(); // Retry
return;
case PERMANENT_ERROR: // Fall through
case NEEDS_USER_INPUT:
Timber.e(e, "Got an error while getting trucks for vendor.");
// TODO need to communicate this to the UI somehow
return;
default:
throw new IllegalStateException("Not expecting this result", e);
}
}
if (Wire.get(response.isNew, TrucksForVendorResponse.DEFAULT_ISNEW)) {
// A new truck is the equivalent of not having one. Let the logic where we fetch all trucks handle this case.
return;
}
boolean wasSuccessful = false;
try {
database.beginTransaction();
// We need to clear the owner of all trucks since the owner might have changed.
// Only then can we assign the current user as the owner.
ContentValues ownerColumn = new ContentValues(1);
ownerColumn.put(PublicContract.Truck.OWNER_ID, (String) null);
database.update(Tables.TRUCK_PROPERTIES, ownerColumn, null, null);
// Now that we have valid trucks that belong to the current user, assign them to the user. Other parts of the system
// already take care of keep truck data fresh. It's sent in the response only because the web needs it.
ownerColumn = new ContentValues(1);
ownerColumn.put(PublicContract.Truck.OWNER_ID, userAccount.getUserId());
for (Truck truck : response.trucks) {
WhereClause where = new WhereClause.Builder()
.where(PublicContract.Truck.ID, EQUALS, truck.id)
.build();
database.update(Tables.TRUCK_PROPERTIES, ownerColumn, where.selection, where.selectionArgs);
}
database.setTransactionSuccessful();
wasSuccessful = true;
} finally {
database.endTransaction();
}
if (wasSuccessful) {
bus.post(new CompletedEvent());
}
}
示例6: setStar
import com.squareup.wire.Wire; //导入方法依赖的package包/类
public void setStar(Star star) {
Empire myEmpire = Preconditions.checkNotNull(EmpireManager.i.getMyEmpire());
EmpireStorage storage = null;
for (EmpireStorage s : star.empire_stores) {
if (s.empire_id != null && s.empire_id.equals(myEmpire.id)) {
storage = s;
break;
}
}
if (storage == null) {
log.debug("storage is null");
setVisibility(View.GONE);
} else {
log.debug("storage is not null");
setVisibility(View.VISIBLE);
storedGoods.setText(NumberFormatter.format(Math.round(storage.total_goods)));
totalGoods.setText(String.format(Locale.ENGLISH, "/ %s",
NumberFormatter.format(Math.round(storage.max_goods))));
storedMinerals.setText(NumberFormatter.format(Math.round(storage.total_minerals)));
totalMinerals.setText(String.format(Locale.ENGLISH, "/ %s",
NumberFormatter.format(Math.round(storage.max_minerals))));
storedEnergy.setText(NumberFormatter.format(Math.round(storage.total_energy)));
totalEnergy.setText(String.format(Locale.ENGLISH, "/ %s",
NumberFormatter.format(Math.round(storage.max_energy))));
if (Wire.get(storage.goods_delta_per_hour, 0.0f) >= 0) {
deltaGoods.setTextColor(Color.GREEN);
deltaGoods.setText(String.format(Locale.ENGLISH, "+%d/hr",
Math.round(Wire.get(storage.goods_delta_per_hour, 0.0f))));
} else {
deltaGoods.setTextColor(Color.RED);
deltaGoods.setText(String.format(Locale.ENGLISH, "%d/hr",
Math.round(Wire.get(storage.goods_delta_per_hour, 0.0f))));
}
if (Wire.get(storage.minerals_delta_per_hour, 0.0f) >= 0) {
deltaMinerals.setTextColor(Color.GREEN);
deltaMinerals.setText(String.format(Locale.ENGLISH, "+%d/hr",
Math.round(
StarHelper.getDeltaMineralsPerHour(
star, myEmpire.id, System.currentTimeMillis()))));
} else {
deltaMinerals.setTextColor(Color.RED);
deltaMinerals.setText(String.format(Locale.ENGLISH, "%d/hr",
Math.round(Wire.get(storage.minerals_delta_per_hour, 0.0f))));
}
if (Wire.get(storage.energy_delta_per_hour, 0.0f) >= 0) {
deltaEnergy.setTextColor(Color.GREEN);
deltaEnergy.setText(String.format(Locale.ENGLISH, "+%d/hr",
Math.round(Wire.get(storage.energy_delta_per_hour, 0.0f))));
} else {
deltaEnergy.setTextColor(Color.RED);
deltaEnergy.setText(String.format(Locale.ENGLISH, "%d/hr",
Math.round(Wire.get(storage.energy_delta_per_hour, 0.0f))));
}
}
}
示例7: refresh
import com.squareup.wire.Wire; //导入方法依赖的package包/类
public void refresh(Star star, Colony colony) {
int defence = (int) (0.25 * colony.population * Wire.get(colony.defence_bonus, 1.0f));
if (defence < 1) {
defence = 1;
}
TextView defenceTextView = (TextView) findViewById(R.id.colony_defence);
defenceTextView.setText(String.format(Locale.US, "Defence: %d", defence));
/*
ProgressBar populationFocus =
(ProgressBar) findViewById(R.id.solarsystem_colony_population_focus);
populationFocus.setProgress((int) (100.0f * colony.focus.population));
TextView populationValue = (TextView) findViewById(R.id.solarsystem_colony_population_value);
String deltaPopulation = String.format(Locale.US, "%s%d / hr",
(Wire.get(colony.delta_population, 0.0f) > 0 ? "+" : "-"),
Math.abs(Math.round(Wire.get(colony.delta_population, 0.0f))));
boolean isInCooldown = (colony.cooldown_end_time < new Date().getTime());
if (Wire.get(colony.delta_population, 0.0f) < 0 && colony.population < 110.0 && isInCooldown) {
deltaPopulation = "<font color=\"#ffff00\">" + deltaPopulation + "</font>";
}
populationValue.setText(Html.fromHtml(deltaPopulation));
*/
ProgressBar farmingFocus = (ProgressBar) findViewById(R.id.solarsystem_colony_farming_focus);
farmingFocus.setProgress((int) (100.0f * colony.focus.farming));
TextView farmingValue = (TextView) findViewById(R.id.solarsystem_colony_farming_value);
farmingValue.setText(String.format(Locale.US, "%s%d / hr",
Wire.get(colony.delta_goods, 0.0f) < 0 ? "-" : "+",
Math.abs(Math.round(Wire.get(colony.delta_goods, 0.0f)))));
ProgressBar miningFocus = (ProgressBar) findViewById(R.id.solarsystem_colony_mining_focus);
miningFocus.setProgress((int) (100.0f * colony.focus.mining));
TextView miningValue = (TextView) findViewById(R.id.solarsystem_colony_mining_value);
miningValue.setText(String.format(Locale.US, "%s%d / hr",
Wire.get(colony.delta_minerals, 0.0f) < 0 ? "-" : "+",
Math.abs(Math.round(Wire.get(colony.delta_minerals, 0.0f)))));
ProgressBar constructionFocus =
(ProgressBar) findViewById(R.id.solarsystem_colony_construction_focus);
constructionFocus.setProgress((int) (100.0f * colony.focus.construction));
TextView constructionValue =
(TextView) findViewById(R.id.solarsystem_colony_construction_value);
int numBuildRequests = colony.build_requests == null ? 0 : colony.build_requests.size();
if (numBuildRequests == 0) {
constructionValue.setText(getContext().getString(R.string.idle));
} else {
constructionValue.setText(String.format(Locale.US, "Q: %d", numBuildRequests));
}
}