Last active
August 29, 2015 14:06
-
-
Save MaciejCiemiega/a8dc9714594dba1d7497 to your computer and use it in GitHub Desktop.
Sending class with DataApi using DataMap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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