Skip to content

Instantly share code, notes, and snippets.

@MaciejCiemiega
Last active August 29, 2015 14:06
Show Gist options
  • Save MaciejCiemiega/a8dc9714594dba1d7497 to your computer and use it in GitHub Desktop.
Save MaciejCiemiega/a8dc9714594dba1d7497 to your computer and use it in GitHub Desktop.
Sending class with DataApi using DataMap
import java.util.ArrayList;
import java.util.List;
import com.google.android.gms.wearable.DataMap;
public class MyObject {
public final long itemId;
public final long sortOrder;
public final String priceString;
public MyObject(long itemId, long sortOrder, String priceString) {
this.itemId = itemId;
this.sortOrder = sortOrder;
this.priceString = priceString;
}
public MyObject(DataMap map) {
this(
map.getLong("itemId"),
map.getLong("sortOrder"),
map.getString("priceString")
);
}
public DataMap putToDataMap(DataMap map) {
map.putLong("itemId", itemId);
map.putLong("sortOrder", sortOrder);
map.putString("priceString", priceString);
return map;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment