当前位置: 首页>>代码示例>>Java>>正文


Java Wire类代码示例

本文整理汇总了Java中com.squareup.wire.Wire的典型用法代码示例。如果您正苦于以下问题:Java Wire类的具体用法?Java Wire怎么用?Java Wire使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Wire类属于com.squareup.wire包,在下文中一共展示了Wire类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import com.squareup.wire.Wire; //导入依赖的package包/类
@Before
public void setup() throws IOException {
  wire = new Wire();
  outputStream = new PipedOutputStream();
  inputStream = new PipedInputStream();
  outputStream.connect(inputStream); 
  person = new Person.Builder()
                            .id(id)
                            .name(name)
                            .build();

  friends.add("foo");
  friends.add("bar");
  cleartextFriends = new CleartextFriends.Builder()
                                         .friends(friends)
                                         .build();
  nullFriends = new CleartextFriends.Builder()
                                         .friends(new ArrayList<String>())
                                         .build();
                                        
  messages.add(new RangzenMessage.Builder()
                                 .text("foo")
                                 .priority(0.25)
                                 .build());
  messages.add(new RangzenMessage.Builder()
                                 .text("bar")
                                 .priority(0.75325)
                                 .build());
  cleartextMessages = new CleartextMessages.Builder()
                                           .messages(messages)
                                           .build();
}
 
开发者ID:casific,项目名称:murmur,代码行数:33,代码来源:WireTest.java

示例2: 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");
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:31,代码来源:BgReading.java

示例3: 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");
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:36,代码来源:BloodTest.java

示例4: main

import com.squareup.wire.Wire; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {

	// ��������
	PhoneNumber pb = new PhoneNumber.Builder().number("123---adf")
			.type(PhoneType.HOME).build();
	PhoneNumber pb2 = new PhoneNumber.Builder().number("123---adf")
			.type(PhoneType.MOBILE).build();

	List<PhoneNumber> phones = new ArrayList<PhoneNumber>();
	phones.add(pb);
	phones.add(pb2);

	Person john = new Person.Builder().id(1234).name("John Doe")
			.email("[email protected]").phone(phones).build();

	System.out.println(john.toString());

	// ���л�
	byte[] johnbyte = john.toByteArray();

	// �����л�
	Wire wire = new Wire();
	try {
		Person john2 = wire.parseFrom(johnbyte, Person.class);
		System.out.println(john2.toString());
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:34,代码来源:Main.java

示例5: 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;
}
 
开发者ID:jpd236,项目名称:fantasywear,代码行数:33,代码来源:ScoreboardParser.java

示例6: readDataMap

import com.squareup.wire.Wire; //导入依赖的package包/类
public static DataMap readDataMap(byte[] bytes, List<Asset> assets) {
    try {
        return readDataMap(new Wire().parseFrom(bytes, DataBundle.class), assets);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:microg,项目名称:android_external_GmsLib,代码行数:8,代码来源:DataBundleUtil.java

示例7: read

import com.squareup.wire.Wire; //导入依赖的package包/类
private static Message read(int mcsTag, byte[] bytes, int len) throws IOException {
    Wire wire = new Wire();
    try {
        switch (mcsTag) {
            case MCS_HEARTBEAT_PING_TAG:
                return wire.parseFrom(bytes, 0, len, HeartbeatPing.class);
            case MCS_HEARTBEAT_ACK_TAG:
                return wire.parseFrom(bytes, 0, len, HeartbeatAck.class);
            case MCS_LOGIN_REQUEST_TAG:
                return wire.parseFrom(bytes, 0, len, LoginRequest.class);
            case MCS_LOGIN_RESPONSE_TAG:
                return wire.parseFrom(bytes, 0, len, LoginResponse.class);
            case MCS_CLOSE_TAG:
                return wire.parseFrom(bytes, 0, len, Close.class);
            case MCS_IQ_STANZA_TAG:
                return wire.parseFrom(bytes, 0, len, IqStanza.class);
            case MCS_DATA_MESSAGE_STANZA_TAG:
                return wire.parseFrom(bytes, 0, len, DataMessageStanza.class);
            default:
                Log.w(TAG, "Unknown tag: " + mcsTag);
                return null;
        }
    } catch (IllegalStateException e) {
        Log.w(TAG, "Error parsing tag: "+mcsTag, e);
        return null;
    }
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:28,代码来源:McsInputStream.java

示例8: refreshColonyDetails

import com.squareup.wire.Wire; //导入依赖的package包/类
private void refreshColonyDetails(Star star, Planet planet) {
  String pop = "Pop: "
      + Math.round(planet.colony.population)
      + " <small>"
      + String.format(Locale.US, "(%s%d / hr)",
      Wire.get(planet.colony.delta_population, 0.0f) < 0 ? "-" : "+",
      Math.abs(Math.round(Wire.get(planet.colony.delta_population, 0.0f))))
      + "</small> / "
      + ColonyHelper.getMaxPopulation(planet);
  populationCountTextView.setText(Html.fromHtml(pop));

  colonyFocusView.setVisibility(View.VISIBLE);
  colonyFocusView.refresh(star, planet.colony);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:15,代码来源:PlanetSummaryView.java

示例9: create

import com.squareup.wire.Wire; //导入依赖的package包/类
/**
 * Create an instance using a default {@link Wire} instance for conversion.
 */
public static WireConverterFactory create() {
    return create(new Wire());
}
 
开发者ID:ayvazj,项目名称:retrotooth,代码行数:7,代码来源:WireConverterFactory.java

示例10: WireConverterFactory

import com.squareup.wire.Wire; //导入依赖的package包/类
/**
 * Create a converter using the supplied {@link Wire} instance.
 */
private WireConverterFactory(Wire wire) {
    if (wire == null) throw new NullPointerException("wire == null");
    this.wire = wire;
}
 
开发者ID:ayvazj,项目名称:retrotooth,代码行数:8,代码来源:WireConverterFactory.java

示例11: WireResponseBodyConverter

import com.squareup.wire.Wire; //导入依赖的package包/类
WireResponseBodyConverter(Wire wire, Class<T> cls) {
    this.wire = wire;
    this.cls = cls;
}
 
开发者ID:ayvazj,项目名称:retrotooth,代码行数:5,代码来源:WireResponseBodyConverter.java

示例12: 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();
    }
}
 
开发者ID:TruckMuncher,项目名称:TruckMuncher-Android,代码行数:50,代码来源:GetTruckProfilesService.java

示例13: 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());
        }
    }
 
开发者ID:TruckMuncher,项目名称:TruckMuncher-Android,代码行数:60,代码来源:VendorTruckStateResolver.java

示例14: WireConverter

import com.squareup.wire.Wire; //导入依赖的package包/类
/**
 * Create a converter with a default {@link Wire} instance.
 */
public WireConverter()
{
  this(new Wire());
}
 
开发者ID:toadzky,项目名称:retrofit-jaxrs,代码行数:8,代码来源:WireConverter.java

示例15: 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))));
    }
  }
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:59,代码来源:StoreView.java


注:本文中的com.squareup.wire.Wire类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。